From f373ad1f566c9c8679547f4205d86eb6e0836d59 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期一, 06 一月 2025 17:22:13 +0800 Subject: [PATCH] 修改保存逻辑 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/02-tank/HydroTankListCtrl.cs | 121 ++++++++++++++++++++++----------------- 1 files changed, 68 insertions(+), 53 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/02-tank/HydroTankListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/02-tank/HydroTankListCtrl.cs index c3e82c9..e4a63b3 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/02-tank/HydroTankListCtrl.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/02-tank/HydroTankListCtrl.cs @@ -7,9 +7,12 @@ public HydroTankListCtrl() { InitializeComponent(); + this.layoutControl1.SetupLayoutControl(); this.gridView1.SetNormalView(30); this.gridView1.RegistCustomDrawRowIndicator(40); - this.layoutControl1.SetupLayoutControl(); + this.generalSearchAndSetCtrl1.SearchEvent += Search; + this.generalSearchAndSetCtrl1.ClearEvent += Reset; + this.generalSearchAndSetCtrl1.SetEvent += Set; } /// <summary> @@ -28,18 +31,10 @@ /// 姘村姏鏀瑰彉瑙嗗浘浜嬩欢 /// </summary> public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent; - /// <summary> - /// 鏄剧ず鏌ヨ闈㈡澘 + /// 鏋勪欢鏀瑰彉浜嬩欢 /// </summary> - [Browsable(true)] - [Description("鏄剧ず鏌ヨ闈㈡澘")] - [DefaultValue(true)] - public bool ShowFindPanel - { - get { return this.gridView1.OptionsFind.AlwaysVisible; } - set { this.gridView1.OptionsFind.AlwaysVisible = value; } - } + public event Action<HydroParterInfo, eChangeType> ParterChangedEvent; /// <summary> /// 鏄惁鎷ユ湁姘村姏鍒楄〃 @@ -59,22 +54,22 @@ /// </summary> public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo) { - _allList = new List<HydroTankViewModel>(); - if (hydroInfo != null && hydroInfo.Tanks != null && hydroInfo.Tanks.Count > 0) - { - foreach (var visual in hydroInfo.Tanks) - { - var vm = new HydroTankViewModel(visual, hydroInfo); - _allList.Add(vm); - } - } - Search(); + SetBindingData(hydroInfo, allCalcuResultVisualDict: null); } /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList) + public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList) + { + var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code); + SetBindingData(hydroInfo, allCalcuResultVisualDict); + } + + /// <summary> + /// 缁戝畾鏁版嵁 + /// </summary> + public void SetBindingData(HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict) { _allList = new List<HydroTankViewModel>(); if (hydroInfo != null && hydroInfo.Tanks != null && hydroInfo.Tanks.Count > 0) @@ -82,7 +77,7 @@ foreach (var visual in hydroInfo.Tanks) { var vm = new HydroTankViewModel(visual, hydroInfo); - var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code); + var calcuResult = allCalcuResultVisualDict?.GetValue(visual.Code); if (calcuResult != null) { vm.UpdateCalcuProperty(calcuResult); @@ -101,7 +96,7 @@ _allList = new List<HydroTankViewModel>(); allVisualViewModelList?.ForEach(x => { - if (x.Catalog == HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Tank)) + if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Tank) { _allList.Add(x as HydroTankViewModel); } @@ -179,15 +174,24 @@ /// <summary> /// 鏇存柊璁$畻灞炴�� /// </summary> - public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList) + public void UpdateCalcuProperty(List<HydroCalcuVisualResult> allCalcuResultList) { - if (allCalcuResultList != null && allCalcuResultList.Count > 0) + var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code); + UpdateCalcuProperty(allCalcuResultVisualDict); + } + + /// <summary> + /// 鏇存柊璁$畻灞炴�� + /// </summary> + public void UpdateCalcuProperty(Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict) + { + if (allCalcuResultVisualDict != null && allCalcuResultVisualDict.Count > 0) { if (_allList != null && _allList.Count > 0) { foreach (var visual in _allList) { - var calcuResult = allCalcuResultList.Find(x => x.Code == visual.Code); + var calcuResult = allCalcuResultVisualDict.GetValue(visual.Code); if (calcuResult != null) { visual.UpdateCalcuProperty(calcuResult); @@ -247,33 +251,21 @@ dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList()); dlg.ReloadDataEvent += (list) => { + if (list == null || list.Count < 1) + { + return; + } _allBindingList.ForEach(x => x.UpdateProperty()); this.hydroTankViewModelBindingSource.ResetBindings(false); var allVisualViewModelList = _allBindingList.Select(x => x as HydroVisualViewModel).ToList(); this.HydroChangedViewEvent?.Invoke(allVisualViewModelList); var allVisualInfoList = allVisualViewModelList.Select(x => x.Vmo).ToList(); this.HydroChangedInfoEvent?.Invoke(allVisualInfoList); + list.ForEach(x => this.ParterChangedEvent?.Invoke(x, eChangeType.Update)); }; dlg.ShowDialog(); } - //鏌ヨ - private void btnSearch_Click(object sender, EventArgs e) - { - Search(); - } - - //閲嶇疆 - private void btnReset_Click(object sender, EventArgs e) - { - Reset(); - } - - //璁剧疆 - private void btnSet_Click(object sender, EventArgs e) - { - Set(); - } private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { @@ -289,10 +281,15 @@ dlg.SetBindingData(row.Vmo); dlg.ReloadDataEvent += (list) => { + if (list == null || list.Count < 1) + { + return; + } row.UpdateProperty(); this.gridView1.RefreshRow(e.RowHandle); this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row }); this.HydroChangedInfoEvent?.Invoke(new List<HydroVisualInfo>() { row.Vmo }); + this.ParterChangedEvent?.Invoke(row.Vmo, eChangeType.Update); }; dlg.ShowDialog(); } @@ -319,7 +316,6 @@ this.colMaxLevel.Visible = false; this.colDN.Visible = false; this.colMinVol.Visible = false; - this.colCurve.Visible = false; this.colOverFlow.Visible = false; this.colCalcuPress.Visible = false; this.colCalcuHead.Visible = false; @@ -346,7 +342,6 @@ this.colMaxLevel.Visible = true; this.colDN.Visible = true; this.colMinVol.Visible = true; - this.colCurve.Visible = true; this.colOverFlow.Visible = true; this.colCalcuPress.Visible = false; this.colCalcuHead.Visible = false; @@ -373,7 +368,6 @@ this.colMaxLevel.Visible = true; this.colDN.Visible = true; this.colMinVol.Visible = true; - this.colCurve.Visible = true; this.colOverFlow.Visible = true; this.colCalcuPress.Visible = true; this.colCalcuHead.Visible = true; @@ -385,9 +379,9 @@ } /// <summary> - /// 璁剧疆鎵归噺璁剧疆妯″紡 + /// 璁剧疆鎵归噺妯″紡 /// </summary> - public void SetBulkSetView() + public void SetBulkView() { this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; this.colDbLocked.Visible = true; @@ -400,7 +394,6 @@ this.colMaxLevel.Visible = true; this.colDN.Visible = true; this.colMinVol.Visible = true; - this.colCurve.Visible = true; this.colOverFlow.Visible = true; this.colCalcuPress.Visible = false; this.colCalcuHead.Visible = false; @@ -411,8 +404,30 @@ this.colSet.Visible = true; } - - - + /// <summary> + /// 璁剧疆缁撴灉妯″紡 + /// </summary> + public void SetResultView() + { + this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; + this.colDbLocked.Visible = true; + this.colName.Visible = true; + this.colCode.Visible = true; + this.colModelType.Visible = true; + this.colPoolElev.Visible = true; + this.colInitLevel.Visible = true; + this.colMinLevel.Visible = true; + this.colMaxLevel.Visible = true; + this.colDN.Visible = true; + this.colMinVol.Visible = true; + this.colOverFlow.Visible = true; + this.colCalcuPress.Visible = true; + this.colCalcuHead.Visible = true; + this.colCalcuDemand.Visible = true; + this.colHasDb.Visible = true; + this.colFlags.Visible = true; + this.colDescription.Visible = true; + this.colSet.Visible = false; + } } } -- Gitblit v1.9.3