| | |
| | | using Yw.Model; |
| | | using DevExpress.XtraEditors; |
| | | using Yw.Model; |
| | | |
| | | namespace Yw.WinFrmUI |
| | | { |
| | |
| | | InitializeComponent(); |
| | | this.gridView1.SetNormalView(30); |
| | | this.gridView1.RegistCustomDrawRowIndicator(40); |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 水力点击事件 |
| | | /// </summary> |
| | | public event Action<Yw.Model.HydroParterInfo> HydroClickEvent; |
| | | /// <summary> |
| | | /// 水力改变事件 |
| | | /// </summary> |
| | | public event Action<List<HydroParterInfo>> HydroChangedEvent; |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool HasHydroList |
| | | { |
| | | get { return _allBindingList != null && _allBindingList.Count > 0; } |
| | | get { return _allList != null && _allList.Count > 0; } |
| | | } |
| | | |
| | | |
| | | //所有列表 |
| | | private List<HydroPressmeterViewModel> _allList = null; |
| | | //所有绑定列表 |
| | | private List<HydroPressmeterViewModel> _allBindingList = null; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | /// <param name="allPressmeterList"></param> |
| | | public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList) |
| | | public void SetBindingData(HydroModelInfo hydroInfo) |
| | | { |
| | | _allBindingList = new List<HydroPressmeterViewModel>(); |
| | | _allList = new List<HydroPressmeterViewModel>(); |
| | | if (hydroInfo != null && hydroInfo.Pressmeters != null && hydroInfo.Pressmeters.Count > 0) |
| | | { |
| | | foreach (var pressmeter in hydroInfo.Pressmeters) |
| | | { |
| | | var calcuResult = allCalcuResultList?.Find(x => x.Code == pressmeter.Code) as HydroCalcuPressmeterResult; |
| | | var vm = new HydroPressmeterViewModel(pressmeter, hydroInfo); |
| | | _allBindingList.Add(vm); |
| | | _allList.Add(vm); |
| | | } |
| | | } |
| | | Search(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList) |
| | | { |
| | | _allList = new List<HydroPressmeterViewModel>(); |
| | | if (hydroInfo != null && hydroInfo.Pressmeters != null && hydroInfo.Pressmeters.Count > 0) |
| | | { |
| | | foreach (var pressmeter in hydroInfo.Pressmeters) |
| | | { |
| | | var vm = new HydroPressmeterViewModel(pressmeter, hydroInfo); |
| | | var calcuResult = allCalcuResultList?.Find(x => x.Code == pressmeter.Code); |
| | | if (calcuResult != null) |
| | | { |
| | | vm.UpdateCalcuProperty(calcuResult); |
| | | } |
| | | _allList.Add(vm); |
| | | } |
| | | } |
| | | Search(); |
| | | } |
| | | |
| | | //查询 |
| | | private void Search() |
| | | { |
| | | if (_allList == null || _allList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var name = this.txtName.Text.Trim(); |
| | | var code = this.txtCode.Text.Trim(); |
| | | var modelType = this.txtModelType.Text.Trim(); |
| | | _allBindingList = _allList; |
| | | if (!string.IsNullOrEmpty(name)) |
| | | { |
| | | _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains(name)).ToList(); |
| | | } |
| | | if (!string.IsNullOrEmpty(code)) |
| | | { |
| | | _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Code) && x.Code.Contains(code)).ToList(); |
| | | } |
| | | if (!string.IsNullOrEmpty(modelType)) |
| | | { |
| | | _allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.ModelType) && x.ModelType.Contains(modelType)).ToList(); |
| | | } |
| | | this.hydroPressmeterViewModelBindingSource.DataSource = _allBindingList; |
| | | this.hydroPressmeterViewModelBindingSource.ResetBindings(false); |
| | | if (allCalcuResultList == null || allCalcuResultList.Count < 1) |
| | | { |
| | | SetNormalView(); |
| | | } |
| | | else |
| | | |
| | | //重置 |
| | | private void Reset() |
| | | { |
| | | SetCalcuView(); |
| | | this.txtName.EditValue = null; |
| | | this.txtCode.EditValue = null; |
| | | this.txtModelType.EditValue = null; |
| | | Search(); |
| | | } |
| | | |
| | | //设置 |
| | | private void Set() |
| | | { |
| | | Search(); |
| | | if (_allBindingList == null || _allBindingList.Count < 1) |
| | | { |
| | | XtraMessageBox.Show("无可设置流量计数据"); |
| | | return; |
| | | } |
| | | var dlg = new SetHydroPressmeterDlg(); |
| | | dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList()); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | _allBindingList.ForEach(x => |
| | | { |
| | | x.Update(); |
| | | }); |
| | | this.hydroPressmeterViewModelBindingSource.ResetBindings(false); |
| | | var allParterList = _allBindingList.Select(x => x.Vmo as HydroParterInfo).ToList(); |
| | | this.HydroChangedEvent?.Invoke(allParterList); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void SetSimpleView() |
| | | { |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.colDbLocked.Visible = true; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | |
| | | this.colMinorLoss.Visible = false; |
| | | this.colCalcuPr.Visible = false; |
| | | this.colHasDb.Visible = true; |
| | | this.colFlagsString.Visible = true; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = false; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void SetNormalView() |
| | | { |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.colDbLocked.Visible = true; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | |
| | | this.colMinorLoss.Visible = true; |
| | | this.colCalcuPr.Visible = false; |
| | | this.colHasDb.Visible = true; |
| | | this.colFlagsString.Visible = true; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = true; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void SetCalcuView() |
| | | { |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.colDbLocked.Visible = true; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | |
| | | this.colMinorLoss.Visible = true; |
| | | this.colCalcuPr.Visible = true; |
| | | this.colHasDb.Visible = true; |
| | | this.colFlagsString.Visible = true; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = true; |
| | | } |
| | | |
| | | //行点击事件 |
| | | private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) |
| | | /// <summary> |
| | | /// 设置批量设置模式 |
| | | /// </summary> |
| | | public void SetBulkSetView() |
| | | { |
| | | this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
| | | this.colDbLocked.Visible = true; |
| | | this.colName.Visible = true; |
| | | this.colCode.Visible = true; |
| | | this.colModelType.Visible = true; |
| | | this.colElev.Visible = true; |
| | | this.colMinorLoss.Visible = true; |
| | | this.colCalcuPr.Visible = false; |
| | | this.colHasDb.Visible = true; |
| | | this.colFlags.Visible = true; |
| | | this.colDescription.Visible = true; |
| | | this.colSet.Visible = true; |
| | | } |
| | | |
| | | private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
| | | { |
| | | var row = this.gridView1.GetRow(e.RowHandle) as HydroPressmeterViewModel; |
| | | if (row == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (e.Column == this.colSet) |
| | | { |
| | | var dlg = new SetHydroPressmeterDlg(); |
| | | dlg.SetBindingData(row.Vmo); |
| | | dlg.ReloadDataEvent += (list) => |
| | | { |
| | | row.Update(); |
| | | this.gridView1.RefreshRow(e.RowHandle); |
| | | this.HydroChangedEvent?.Invoke(new List<Model.HydroParterInfo>() { row.Vmo }); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | else |
| | | { |
| | | this.HydroClickEvent?.Invoke(row.Vmo); |
| | | } |
| | | |
| | | public void SetBindingData(HydroModelInfo hydroInfo) |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | |
| | | public void SetBulkSetView() |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | } |
| | | } |