From e6880d3fcc4b83c5c53166d1404e24b7513b7f9a Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期二, 05 十一月 2024 00:33:23 +0800
Subject: [PATCH] 部分水力属性修改

---
 WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/10-nozzle/HydroNozzleListCtrl.cs |  178 +++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 135 insertions(+), 43 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/10-nozzle/HydroNozzleListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/10-nozzle/HydroNozzleListCtrl.cs
index 723688c..6894c34 100644
--- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/10-nozzle/HydroNozzleListCtrl.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/10-nozzle/HydroNozzleListCtrl.cs
@@ -1,4 +1,5 @@
-锘縰sing Yw.Model;
+锘縰sing DevExpress.XtraEditors;
+using Yw.Model;
 
 namespace Yw.WinFrmUI
 {
@@ -9,12 +10,16 @@
             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>
@@ -34,38 +39,111 @@
         /// </summary>
         public bool HasHydroList
         {
-            get { return _allBindingList != null && _allBindingList.Count > 0; }
+            get { return _allList != null && _allList.Count > 0; }
         }
 
-
+        //鎵�鏈夊垪琛�
+        private List<HydroNozzleViewModel> _allList = null;
         //鎵�鏈夌粦瀹氬垪琛�
         private List<HydroNozzleViewModel> _allBindingList = null;
 
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        public void SetBindingData(HydroModelInfo hydroInfo)
         {
-            _allBindingList = new List<HydroNozzleViewModel>();
+            _allList = new List<HydroNozzleViewModel>();
             if (hydroInfo != null && hydroInfo.Nozzles != null && hydroInfo.Nozzles.Count > 0)
             {
                 foreach (var nozzle in hydroInfo.Nozzles)
                 {
-                    var calcuResult = allCalcuResultList?.Find(x => x.Code == nozzle.Code) as HydroCalcuNodeResult;
                     var vm = new HydroNozzleViewModel(nozzle, hydroInfo);
-                    _allBindingList.Add(vm);
+                    _allList.Add(vm);
                 }
+            }
+            Search();
+        }
+
+        /// <summary>
+        /// 缁戝畾鏁版嵁
+        /// </summary>
+        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        {
+            _allList = new List<HydroNozzleViewModel>();
+            if (hydroInfo != null && hydroInfo.Nozzles != null && hydroInfo.Nozzles.Count > 0)
+            {
+                foreach (var nozzle in hydroInfo.Nozzles)
+                {
+                    var vm = new HydroNozzleViewModel(nozzle, hydroInfo);
+                    var calcuResult = allCalcuResultList?.Find(x => x.Code == nozzle.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.hydroNozzleViewModelBindingSource.DataSource = _allBindingList;
             this.hydroNozzleViewModelBindingSource.ResetBindings(false);
-            if (allCalcuResultList == null || allCalcuResultList.Count < 1)
+        }
+
+        //閲嶇疆
+        private void Reset()
+        {
+            this.txtName.EditValue = null;
+            this.txtCode.EditValue = null;
+            this.txtModelType.EditValue = null;
+            Search();
+        }
+
+        //璁剧疆
+        private void Set()
+        {
+            Search();
+            if (_allBindingList == null || _allBindingList.Count < 1)
             {
-                SetNormalView();
+                XtraMessageBox.Show("鏃犲彲璁剧疆鍠峰槾鏁版嵁");
+                return;
             }
-            else
+            var dlg = new SetHydroNozzleDlg();
+            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
+            dlg.ReloadDataEvent += (list) =>
             {
-                SetCalcuView();
-            }
+                _allBindingList.ForEach(x =>
+                {
+                    x.Update();
+                });
+                this.hydroNozzleViewModelBindingSource.ResetBindings(false);
+                var allParterList = _allBindingList.Select(x => x.Vmo as Yw.Model.HydroParterInfo).ToList();
+                this.HydroChangedEvent?.Invoke(allParterList);
+            };
+            dlg.ShowDialog();
         }
 
         /// <summary>
@@ -79,15 +157,12 @@
             this.colModelType.Visible = true;
             this.colHasDb.Visible = true;
             this.colCoefficient.Visible = true;
-            this.colQuality.Visible = false;
             this.colElev.Visible = false;
             this.colMinorLoss.Visible = false;
-            this.colDemand.Visible = false;
-            this.colDemandPattern.Visible = false;
             this.colCalcuPress.Visible = false;
             this.colCalcuHead.Visible = false;
             this.colCalcuDemand.Visible = false;
-            this.colFlagsString.Visible = true;
+            this.colFlags.Visible = true;
             this.colDescription.Visible = true;
         }
 
@@ -102,15 +177,12 @@
             this.colModelType.Visible = true;
             this.colHasDb.Visible = true;
             this.colCoefficient.Visible = true;
-            this.colQuality.Visible = false;
-            this.colElev.Visible = true;
-            this.colMinorLoss.Visible = true;
-            this.colDemand.Visible = true;
-            this.colDemandPattern.Visible = false;
+            this.colElev.Visible = false;
+            this.colMinorLoss.Visible = false;
             this.colCalcuPress.Visible = false;
             this.colCalcuHead.Visible = false;
             this.colCalcuDemand.Visible = false;
-            this.colFlagsString.Visible = true;
+            this.colFlags.Visible = true;
             this.colDescription.Visible = true;
         }
 
@@ -125,37 +197,57 @@
             this.colModelType.Visible = true;
             this.colHasDb.Visible = true;
             this.colCoefficient.Visible = true;
-            this.colQuality.Visible = false;
-            this.colElev.Visible = true;
-            this.colMinorLoss.Visible = true;
-            this.colDemand.Visible = true;
-            this.colDemandPattern.Visible = false;
-            this.colCalcuPress.Visible = true;
-            this.colCalcuHead.Visible = true;
-            this.colCalcuDemand.Visible = true;
-            this.colFlagsString.Visible = true;
+            this.colElev.Visible = false;
+            this.colMinorLoss.Visible = false;
+            this.colCalcuPress.Visible = false;
+            this.colCalcuHead.Visible = false;
+            this.colCalcuDemand.Visible = false;
+            this.colFlags.Visible = true;
             this.colDescription.Visible = true;
         }
 
-        //琛岀偣鍑讳簨浠�
-        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
+        public void SetBulkSetView()
+        {
+            this.colDbLocked.Visible = true;
+            this.colCode.Visible = true;
+            this.colName.Visible = true;
+            this.colModelType.Visible = true;
+            this.colHasDb.Visible = true;
+            this.colCoefficient.Visible = true;
+            this.colElev.Visible = false;
+            this.colMinorLoss.Visible = false;
+            this.colCalcuPress.Visible = false;
+            this.colCalcuHead.Visible = false;
+            this.colCalcuDemand.Visible = false;
+            this.colFlags.Visible = true;
+            this.colDescription.Visible = true;
+        }
+
+
+        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
         {
             var row = this.gridView1.GetRow(e.RowHandle) as HydroNozzleViewModel;
             if (row == null)
             {
                 return;
             }
-            this.HydroClickEvent?.Invoke(row.Vmo);
-        }
 
-        public void SetBindingData(HydroModelInfo hydroInfo)
-        {
-            throw new NotImplementedException();
-        }
-
-        public void SetBulkSetView()
-        {
-            throw new NotImplementedException();
+            if (e.Column == this.colSet)
+            {
+                var dlg = new SetHydroNozzleDlg();
+                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);
+            }
         }
     }
 }

--
Gitblit v1.9.3