From fa3b4f4b277a72f51f66bf918e850d88aff7baf9 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期五, 20 十二月 2024 09:00:04 +0800
Subject: [PATCH] 换热器曲线

---
 WinFrmUI/HStation.WinFrmUI.Assets.Core/20-exchanger/04-curveql/AssetsExchangerCurveQLMgrPage.cs |  123 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 110 insertions(+), 13 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Assets.Core/20-exchanger/04-curveql/AssetsExchangerCurveQLMgrPage.cs b/WinFrmUI/HStation.WinFrmUI.Assets.Core/20-exchanger/04-curveql/AssetsExchangerCurveQLMgrPage.cs
index 62277a9..a5b51ef 100644
--- a/WinFrmUI/HStation.WinFrmUI.Assets.Core/20-exchanger/04-curveql/AssetsExchangerCurveQLMgrPage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Assets.Core/20-exchanger/04-curveql/AssetsExchangerCurveQLMgrPage.cs
@@ -24,9 +24,8 @@
             this.phartDiagramRelationListCtrl1.SelectedChangedEvent += PhartDiagramRelationListCtrl1_SelectedChangedEvent;
         }
 
-
-
         private AssetsExchangerMainVmo _vmo = null;
+        private List<PhartDiagramRelationVmo> _allBindingList = null;
         private PhartDiagramRelationVmo _relation = null;
 
         /// <summary>
@@ -40,46 +39,142 @@
             }
             _vmo = vmo;
             this.PageTitle.Caption = $"{vmo.Name}\r\n姘村ご鎹熷け鏇茬嚎";
-            var allRelationList = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance
-                .GetByObjectTypeAndObjectID(HStation.Assets.DataType.ExchangerMain, vmo.ID);
-            this.phartDiagramRelationListCtrl1.SetBindingData(allRelationList);
+            _allBindingList = new List<PhartDiagramRelationVmo>();
+            var allList = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance
+               .GetByObjectTypeAndObjectID(HStation.Assets.DataType.ExchangerMain, vmo.ID);
+            allList?.ForEach(x => _allBindingList.Add(x));
+            this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList);
         }
 
         //excel
         private void Excel()
         {
+            if (_vmo == null)
+            {
+                return;
+            }
             var dlg = new ImportAssetsExchangerCurveQLByExcelDlg();
-            dlg.SetBindingData();
+            dlg.ReloadDataEvent += (rhs) =>
+            {
+                _allBindingList.Add(rhs);
+                this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList);
+            };
+            dlg.SetBindingData(_vmo);
             dlg.ShowDialog();
         }
 
         //鍥剧墖
         private void Picture()
         {
+            if (_vmo == null)
+            {
+                return;
+            }
+            var vm = GetCurrentViewModel();
+            if (vm == null)
+            {
+                return;
+            }
             var dlg = new ImportAssetsExchangerCurveQLByPictureDlg();
-            dlg.SetBindingData();
+            dlg.ReloadDataEvent += (rhs) =>
+            {
+                _allBindingList.Add(rhs);
+                this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList);
+            };
+            dlg.SetBindingData(_vmo);
             dlg.ShowDialog();
         }
 
         //鍩烘湰淇℃伅
         private void Info()
         {
-
+            var vm = GetCurrentViewModel();
+            if (vm == null)
+            {
+                return;
+            }
+            var dlg = new EditPhartDiagramRelationDlg();
+            dlg.ReloadDataEvent += (rhs) =>
+            {
+                var item = _allBindingList?.Find(x => x.ID == rhs.ID);
+                if (item == null)
+                {
+                    return;
+                }
+                item.Reset(rhs);
+                this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList);
+            };
+            dlg.SetBindingData(vm);
+            dlg.ShowDialog();
         }
 
         //鏇茬嚎
-        private void Curve()
+        private async void Curve()
         {
+            var vm = GetCurrentViewModel();
+            if (vm == null)
+            {
+                return;
+            }
+            var vmo = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.GetByID(vm.DiagramID);
             var dlg = new EditAssetsExchangerCurveQLDlg();
-            dlg.SetBindingData(null);
+            dlg.ReloadDataEvent += (rhs) =>
+            {
+                this.universalChartViewCtrl1.SetBindingData(rhs);
+            };
+            dlg.SetBindingData(vmo);
             dlg.ShowDialog();
         }
 
         //鍒犻櫎
-        private void Delete()
+        private async void Delete()
         {
-
+            var vm = GetCurrentViewModel();
+            if (vm == null)
+            {
+                return;
+            }
+            var result = XtraMessageBox.Show("璇烽棶纭鍒犻櫎褰撳墠鏁版嵁鍚楋紵", "璇㈤棶", MessageBoxButtons.YesNo) == DialogResult.Yes;
+            if (!result)
+            {
+                return;
+            }
+            var bol = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance.DeleteByID(vm.ID);
+            if (!bol)
+            {
+                TipFormHelper.ShowError("鍒犻櫎澶辫触锛�");
+                return;
+            }
+            _allBindingList.Remove(vm);
+            this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList);
+            TipFormHelper.ShowSucceed("鍒犻櫎鎴愬姛锛�");
         }
+
+
+        #region 褰撳墠
+
+        //鑾峰彇褰撳墠
+        private PhartDiagramRelationVmo GetCurrentViewModel()
+        {
+            if (_allBindingList == null)
+            {
+                TipFormHelper.ShowError("鏁版嵁鍒濆鍖栭敊璇紒");
+                return null;
+            }
+            if (_allBindingList.Count < 1)
+            {
+                TipFormHelper.ShowInfo("鏃犳暟鎹紒");
+                return null;
+            }
+            if (_relation == null)
+            {
+                TipFormHelper.ShowWarn("璇烽�夋嫨鏁版嵁琛岋紒");
+                return null;
+            }
+            return _relation;
+        }
+
+        #endregion
 
         //Excel瀵煎叆
         private void barBtnImportByExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
@@ -115,8 +210,10 @@
         private void PhartDiagramRelationListCtrl1_SelectedChangedEvent(PhartDiagramRelationVmo obj)
         {
             _relation = obj;
+            LoadPhart(_relation);
         }
 
+        //鍔犺浇鍥捐〃
         private async void LoadPhart(PhartDiagramRelationVmo relation)
         {
             if (relation == null)
@@ -125,7 +222,7 @@
                 return;
             }
             var vmo = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.GetByID(relation.DiagramID);
-            //this.universalChartViewCtrl1.SetBindingData(vmo);
+            this.universalChartViewCtrl1.SetBindingData(vmo);
         }
 
     }

--
Gitblit v1.9.3