From a01861a95ede48fa4979a47b24f21616e362e534 Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期二, 19 十一月 2024 16:29:46 +0800
Subject: [PATCH] 用水当量模块

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/01-set/02-valve/SetSchemeValveListCtrl.cs |  239 +++++++++++++++++------------------------------------------
 1 files changed, 68 insertions(+), 171 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/01-set/02-valve/SetSchemeValveListCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/01-set/02-valve/SetSchemeValveListCtrl.cs
index 680cb6e..f7704a7 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/01-set/02-valve/SetSchemeValveListCtrl.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/01-add/01-set/02-valve/SetSchemeValveListCtrl.cs
@@ -2,15 +2,27 @@
 
 namespace HStation.WinFrmUI
 {
-    public partial class SetSchemeValveListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroParterList
+    public partial class SetSchemeValveListCtrl : DevExpress.XtraEditors.XtraUserControl, ISetSchemeParterList
     {
         public SetSchemeValveListCtrl()
         {
             InitializeComponent();
+            this.layoutControl1.SetupLayoutControl();
             this.gridView1.SetNormalView(30);
             this.gridView1.RegistCustomDrawRowIndicator(40);
             this.gridView1.BorderStyle = BorderStyles.NoBorder;
-            this.layoutControl1.SetupLayoutControl();
+            this.generalSearchAndSelectCtrl1.SearchEvent += () =>
+            {
+                Search();
+            };
+            this.generalSearchAndSelectCtrl1.ClearEvent += () =>
+            {
+                Clear();
+            };
+            this.generalSearchAndSelectCtrl1.SelectEvent += () =>
+            {
+                TipFormHelper.Show(eTipStatus.Info, "鎵归噺閫夋嫨寰呮洿鏂�");
+            };
         }
 
         /// <summary>
@@ -21,6 +33,11 @@
         /// 姘村姏鏀瑰彉浜嬩欢
         /// </summary>
         public event Action<List<HydroParterInfo>> HydroChangedEvent;
+
+        /// <summary>
+        /// 姘村姏璁板綍鏀瑰彉浜嬩欢
+        /// </summary>
+        public event Action<SetSchemeParterRecord> HydroRecordChangedEvent;
 
         /// <summary>
         /// 鏄剧ず鏌ヨ闈㈡澘
@@ -42,6 +59,8 @@
             get { return _allList != null && _allList.Count > 0; }
         }
 
+        //姘村姏淇℃伅
+        private Yw.Model.HydroModelInfo _hydroInfo = null;
         //鎵�鏈夊垪琛�
         private List<HydroValveViewModel> _allList = null;
         //鎵�鏈夌粦瀹氬垪琛�
@@ -52,6 +71,7 @@
         /// </summary>
         public void SetBindingData(HydroModelInfo hydroInfo)
         {
+            _hydroInfo = hydroInfo;
             _allList = new List<HydroValveViewModel>();
             if (hydroInfo != null && hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
             {
@@ -67,7 +87,7 @@
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList)
         {
             _allList = new List<HydroValveViewModel>();
             if (hydroInfo != null && hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
@@ -148,7 +168,7 @@
         /// <summary>
         /// 鏇存柊璁$畻灞炴��
         /// </summary>
-        public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList)
+        public void UpdateCalcuProperty(List<HydroCalcuVisualResult> allCalcuResultList)
         {
             if (allCalcuResultList != null && allCalcuResultList.Count > 0)
             {
@@ -204,127 +224,35 @@
         }
 
         //璁剧疆
-        private void Set()
+        private void SelectChange()
         {
+            if (_hydroInfo == null)
+            {
+                XtraMessageBox.Show("鏃犳按鍔涗俊鎭�");
+                return;
+            }
             Search();
-            if (_allBindingList == null || _allBindingList.Count < 1)
+            var row = this.gridView1.GetFocusedRow() as HydroValveViewModel;
+            if (row == null)
             {
                 XtraMessageBox.Show("鏃犲彲璁剧疆闃�闂ㄦ暟鎹�");
                 return;
             }
-            var dlg = new SetHydroValveDlg();
-            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
-            dlg.ReloadDataEvent += (list) =>
+
+            var input = AssetsMatchingParasHelper.Create(_hydroInfo, row.Vmo, null);
+            var dlg = new ValveSingleMatchingDlg();
+            dlg.SetBindingData(input);
+            dlg.ReloadDataEvent += (output) =>
             {
-                _allBindingList.ForEach(x =>
+                var bol = AssetsMatchingParasHelper.Apply(_hydroInfo, output);
+                if (bol)
                 {
-                    x.UpdateProperty();
-                });
-                this.hydroValveViewModelBindingSource.ResetBindings(false);
-                var allParterList = _allBindingList.Select(x => x.Vmo as Yw.Model.HydroParterInfo).ToList();
-                this.HydroChangedEvent?.Invoke(allParterList);
+                    UpdateProperty();
+                }
             };
             dlg.ShowDialog();
         }
 
-
-        /// <summary>
-        /// 璁剧疆绠�鍗曟樉绀烘ā寮�
-        /// </summary>
-        public void SetSimpleView()
-        {
-            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
-            this.colDbLocked.Visible = false;
-            this.colName.Visible = true;
-            this.colCode.Visible = true;
-            this.colModelType.Visible = true;
-            this.colValveType.Visible = false;
-            this.colLinkStatus.Visible = true;
-            this.colMaterial.Visible = false;
-            this.colDiameter.Visible = false;
-            this.colMinorLoss.Visible = false;
-            this.colCalcuFlow.Visible = false;
-            this.colCalcuVelocity.Visible = false;
-            this.colCalcuHeadLoss.Visible = false;
-            this.colHasDb.Visible = false;
-            this.colFlags.Visible = true;
-            this.colDescription.Visible = true;
-            this.colSet.Visible = false;
-        }
-
-        /// <summary>
-        /// 璁剧疆姝e父鏄剧ず妯″紡
-        /// </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.colModelType.Visible = true;
-            this.colValveType.Visible = true;
-            this.colLinkStatus.Visible = true;
-            this.colMaterial.Visible = true;
-            this.colDiameter.Visible = true;
-            this.colMinorLoss.Visible = true;
-            this.colCalcuFlow.Visible = false;
-            this.colCalcuVelocity.Visible = false;
-            this.colCalcuHeadLoss.Visible = false;
-            this.colHasDb.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.colModelType.Visible = true;
-            this.colValveType.Visible = true;
-            this.colLinkStatus.Visible = true;
-            this.colMaterial.Visible = true;
-            this.colDiameter.Visible = true;
-            this.colMinorLoss.Visible = true;
-            this.colCalcuFlow.Visible = true;
-            this.colCalcuVelocity.Visible = true;
-            this.colCalcuHeadLoss.Visible = true;
-            this.colHasDb.Visible = true;
-            this.colFlags.Visible = true;
-            this.colDescription.Visible = true;
-            this.colSet.Visible = true;
-        }
-
-        /// <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.colValveType.Visible = true;
-            this.colLinkStatus.Visible = true;
-            this.colMaterial.Visible = true;
-            this.colDiameter.Visible = true;
-            this.colMinorLoss.Visible = true;
-            this.colCalcuFlow.Visible = false;
-            this.colCalcuVelocity.Visible = false;
-            this.colCalcuHeadLoss.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)
@@ -335,15 +263,35 @@
                 return;
             }
 
-            if (e.Column == this.colSet)
+            if (e.Column == this.colSelect)
             {
-                var dlg = new SetHydroValveDlg();
-                dlg.SetBindingData(row.Vmo);
-                dlg.ReloadDataEvent += (list) =>
+                var input = AssetsMatchingParasHelper.Create(_hydroInfo, row.Vmo, null);
+                var dlg = new ValveSingleMatchingDlg();
+                dlg.SetBindingData(input);
+                dlg.ReloadDataEvent += (output) =>
                 {
-                    row.UpdateProperty();
-                    this.gridView1.RefreshRow(e.RowHandle);
-                    this.HydroChangedEvent?.Invoke(new List<Yw.Model.HydroParterInfo>() { row.Vmo });
+                    var bol = AssetsMatchingParasHelper.Apply(_hydroInfo, output);
+                    if (bol)
+                    {
+                        row.UpdateProperty();
+                        this.gridView1.RefreshRow(e.RowHandle);
+                        this.HydroChangedEvent?.Invoke(new List<Yw.Model.HydroParterInfo>() { row.Vmo });
+
+
+                        var record = new SetSchemeParterRecord();
+                        record.Name = row.Vmo.Name;
+                        record.Code = row.Vmo.Code;
+                        record.Catalog = Yw.Hydro.ParterCatalog.Valve;
+                        record.MatchingModel = output;
+                        record.Items = new List<SetSchemeParterRecordItem>() {
+                        new() {Name="鍨嬪彿",BeforeValue=$"{output.ModelType}",AfterValue=$"{output.MatchingModelType}"},
+                        new() {Name="鏉愭枡",BeforeValue=$"{output.Material}",AfterValue=$"{output.MatchingMaterial}"},
+                        new() {Name="鐩村緞锛坢m锛�",BeforeValue=$"{output.Diameter}",AfterValue=$"{output.MatchingDiameter}"},
+                        new() {Name="灞�闃荤郴鏁�",BeforeValue=$"{output.MinorLoss}",AfterValue=$"{output.MatchingMinorLoss}"},
+                        new() {Name="闃�闂ㄧ被鍨�",BeforeValue=$"{output.ValveType}",AfterValue=$"{output.MatchingValveType}"},
+                        };
+                        this.HydroRecordChangedEvent?.Invoke(record);
+                    }
                 };
                 dlg.ShowDialog();
             }
@@ -352,57 +300,6 @@
                 this.HydroClickEvent?.Invoke(row.Vmo);
             }
         }
-
-
-        #region BtnClick
-
-        private void buttonEditSearch_ButtonClick(object sender, ButtonPressedEventArgs e)
-        {
-            var obj = e.Button.Tag;
-            if (obj is string tag)
-            {
-                BtnClick(tag);
-            }
-        }
-
-        private void buttonEditSet_ButtonClick(object sender, ButtonPressedEventArgs e)
-        {
-            var obj = e.Button.Tag;
-            if (obj is string tag)
-            {
-                BtnClick(tag);
-            }
-        }
-
-        private void BtnClick(string tag)
-        {
-            switch (tag)
-            {
-                case "Search":
-                    {
-                        Search();
-                    }
-                    break;
-                case "Clear":
-                    {
-                        Clear();
-                    }
-                    break;
-                case "Set":
-                    {
-                        Set();
-                    }
-                    break;
-                default:
-                    {
-
-                    }
-                    break;
-            }
-        }
-
-        #endregion
-
 
     }
 }

--
Gitblit v1.9.3