From 278e94cb1b045288d1205f36b67f60cb5224754c Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期三, 06 十一月 2024 11:50:19 +0800
Subject: [PATCH] 属性调整

---
 WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/19-compressor/HydroCompressorListCtrl.cs |  331 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 255 insertions(+), 76 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/19-compressor/HydroCompressorListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/19-compressor/HydroCompressorListCtrl.cs
index 21dfb6e..00c6231 100644
--- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/19-compressor/HydroCompressorListCtrl.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-parter/19-compressor/HydroCompressorListCtrl.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,192 @@
         /// </summary>
         public bool HasHydroList
         {
-            get { return _allBindingList != null && _allBindingList.Count > 0; }
+            get { return _allList != null && _allList.Count > 0; }
         }
 
-
-        private List<HydroCompressorViewModel> _allBindingList = null;//鎵�鏈夌粦瀹氬垪琛�
+        //鎵�鏈夊垪琛�
+        private List<HydroCompressorViewModel> _allList = null;
+        //鎵�鏈夌粦瀹氬垪琛�
+        private List<HydroCompressorViewModel> _allBindingList = null;
 
         /// <summary>
         /// 缁戝畾鏁版嵁
         /// </summary>
-        /// <param name="allExchangerList"></param>
-        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        public void SetBindingData(HydroModelInfo hydroInfo)
         {
-            _allBindingList = new List<HydroCompressorViewModel>();
+            _allList = new List<HydroCompressorViewModel>();
             if (hydroInfo != null && hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0)
             {
-                foreach (var compressor in hydroInfo.Compressors)
+                foreach (var valve in hydroInfo.Compressors)
                 {
-                    var calcuLinkResult = allCalcuResultList?.Find(x => x.Code == compressor.Code) as HydroCalcuLinkResult;
-                    var vm = new HydroCompressorViewModel(compressor, hydroInfo);
-                    _allBindingList.Add(vm);
+                    var vm = new HydroCompressorViewModel(valve, hydroInfo);
+                    _allList.Add(vm);
                 }
+            }
+            Search();
+        }
+
+        /// <summary>
+        /// 缁戝畾鏁版嵁
+        /// </summary>
+        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
+        {
+            _allList = new List<HydroCompressorViewModel>();
+            if (hydroInfo != null && hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0)
+            {
+                foreach (var valve in hydroInfo.Compressors)
+                {
+                    var vm = new HydroCompressorViewModel(valve, hydroInfo);
+                    var calcuResult = allCalcuResultList?.Find(x => x.Code == valve.Code);
+                    if (calcuResult != null)
+                    {
+                        vm.UpdateCalcuProperty(calcuResult);
+                    }
+                    _allList.Add(vm);
+                }
+            }
+            Search();
+        }
+
+        /// <summary>
+        /// 鏇存柊灞炴��
+        /// </summary>
+        public void UpdateProperty()
+        {
+            if (_allList == null || _allList.Count < 1)
+            {
+                return;
+            }
+            _allList.ForEach(x => x.UpdateProperty());
+            this.hydroCompressorViewModelBindingSource.ResetBindings(false);
+        }
+
+        /// <summary>
+        /// 鏇存柊灞炴��
+        /// </summary>
+        public void UpdateProperty(Yw.Model.HydroParterInfo parter)
+        {
+            if (_allList == null || _allList.Count < 1)
+            {
+                return;
+            }
+            if (parter == null)
+            {
+                return;
+            }
+            var vm = _allList.Find(x => x.Code == parter.Code);
+            if (vm == null)
+            {
+                return;
+            }
+            vm.UpdateProperty();
+            this.hydroCompressorViewModelBindingSource.ResetBindings(false);
+        }
+
+        /// <summary>
+        /// 鏇存柊灞炴��
+        /// </summary>
+        public void UpdateProperty(List<Yw.Model.HydroParterInfo> parterList)
+        {
+            if (_allList == null || _allList.Count < 1)
+            {
+                return;
+            }
+            if (parterList == null || parterList.Count < 1)
+            {
+                return;
+            }
+            parterList.ForEach(x =>
+            {
+                var vm = _allList.Find(t => x.Code == x.Code);
+                if (vm != null)
+                {
+                    vm.UpdateProperty();
+                }
+            });
+            this.hydroCompressorViewModelBindingSource.ResetBindings(false);
+        }
+
+        /// <summary>
+        /// 鏇存柊璁$畻灞炴��
+        /// </summary>
+        public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList)
+        {
+            if (allCalcuResultList != null && allCalcuResultList.Count > 0)
+            {
+                if (_allList != null && _allList.Count > 0)
+                {
+                    foreach (var parter in _allList)
+                    {
+                        var calcuResult = allCalcuResultList.Find(x => x.Code == parter.Code);
+                        if (calcuResult != null)
+                        {
+                            parter.UpdateCalcuProperty(calcuResult);
+                        }
+                    }
+                    this.hydroCompressorViewModelBindingSource.ResetBindings(false);
+                }
+            }
+        }
+
+        //鏌ヨ
+        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.hydroCompressorViewModelBindingSource.DataSource = _allBindingList;
             this.hydroCompressorViewModelBindingSource.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 SetHydroCompressorDlg();
+            dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList());
+            dlg.ReloadDataEvent += (list) =>
             {
-                SetCalcuView();
-            }
+                _allBindingList.ForEach(x =>
+                {
+                    x.UpdateProperty();
+                });
+                this.hydroCompressorViewModelBindingSource.ResetBindings(false);
+                var allParterList = _allBindingList.Select(x => x.Vmo as Yw.Model.HydroParterInfo).ToList();
+                this.HydroChangedEvent?.Invoke(allParterList);
+            };
+            dlg.ShowDialog();
         }
 
         /// <summary>
@@ -73,25 +232,22 @@
         /// </summary>
         public void SetSimpleView()
         {
-            this.colDbLocked.Visible = true;
-            this.colCode.Visible = true;
+            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.colHasDb.Visible = true;
-            this.colStartCode.Visible = false;
-            this.colEndCode.Visible = false;
             this.colLinkStatus.Visible = true;
-            this.colDiameter.Visible = false;
-            this.colLength.Visible = false;
             this.colMaterial.Visible = false;
-            this.colRoughness.Visible = true;
-            this.colMinorLoss.Visible = true;
-            this.colMinorLossK.Visible = true;
+            this.colDiameter.Visible = false;
+            this.colMinorLoss.Visible = false;
             this.colCalcuFlow.Visible = false;
             this.colCalcuVelocity.Visible = false;
             this.colCalcuHeadLoss.Visible = false;
-            this.colFlagsString.Visible = true;
+            this.colHasDb.Visible = false;
+            this.colFlags.Visible = true;
             this.colDescription.Visible = true;
+            this.colSet.Visible = false;
         }
 
         /// <summary>
@@ -99,25 +255,22 @@
         /// </summary>
         public void SetNormalView()
         {
+            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
             this.colDbLocked.Visible = true;
-            this.colCode.Visible = true;
             this.colName.Visible = true;
+            this.colCode.Visible = true;
             this.colModelType.Visible = true;
-            this.colHasDb.Visible = true;
-            this.colStartCode.Visible = false;
-            this.colEndCode.Visible = false;
             this.colLinkStatus.Visible = true;
-            this.colDiameter.Visible = true;
-            this.colLength.Visible = true;
             this.colMaterial.Visible = true;
-            this.colRoughness.Visible = true;
+            this.colDiameter.Visible = true;
             this.colMinorLoss.Visible = true;
-            this.colMinorLossK.Visible = true;
             this.colCalcuFlow.Visible = false;
             this.colCalcuVelocity.Visible = false;
             this.colCalcuHeadLoss.Visible = false;
-            this.colFlagsString.Visible = true;
+            this.colHasDb.Visible = true;
+            this.colFlags.Visible = true;
             this.colDescription.Visible = true;
+            this.colSet.Visible = true;
         }
 
         /// <summary>
@@ -125,66 +278,92 @@
         /// </summary>
         public void SetCalcuView()
         {
+            this.groupForHead.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
             this.colDbLocked.Visible = true;
-            this.colCode.Visible = true;
             this.colName.Visible = true;
+            this.colCode.Visible = true;
             this.colModelType.Visible = true;
-            this.colHasDb.Visible = true;
-            this.colStartCode.Visible = false;
-            this.colEndCode.Visible = false;
             this.colLinkStatus.Visible = true;
-            this.colDiameter.Visible = true;
-            this.colLength.Visible = true;
             this.colMaterial.Visible = true;
-            this.colRoughness.Visible = true;
+            this.colDiameter.Visible = true;
             this.colMinorLoss.Visible = true;
-            this.colMinorLossK.Visible = true;
             this.colCalcuFlow.Visible = true;
             this.colCalcuVelocity.Visible = true;
             this.colCalcuHeadLoss.Visible = true;
-            this.colFlagsString.Visible = true;
+            this.colHasDb.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.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 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)
         {
             var row = this.gridView1.GetRow(e.RowHandle) as HydroCompressorViewModel;
             if (row == null)
             {
                 return;
             }
-            this.HydroClickEvent?.Invoke(row.Vmo);
+
+            if (e.Column == this.colSet)
+            {
+                var dlg = new SetHydroCompressorDlg();
+                dlg.SetBindingData(row.Vmo);
+                dlg.ReloadDataEvent += (list) =>
+                {
+                    row.UpdateProperty();
+                    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();
-        }
-
-        public void UpdateProperty()
-        {
-            throw new NotImplementedException();
-        }
-
-        public void UpdateProperty(HydroParterInfo parter)
-        {
-            throw new NotImplementedException();
-        }
-
-        public void UpdateProperty(List<HydroParterInfo> parterList)
-        {
-            throw new NotImplementedException();
-        }
-
-        public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList)
-        {
-            throw new NotImplementedException();
-        }
     }
 }

--
Gitblit v1.9.3