From 4979ba269bd93763daad758f0d5a1bc58c4f57c6 Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期一, 19 八月 2024 17:55:20 +0800
Subject: [PATCH] 型号选择添加步骤界面

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-scheme/02-asset-mgr/PumpMain/ChoicePumpMainDlg.cs |  134 +++++++++++++++++++-------------------------
 1 files changed, 57 insertions(+), 77 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-scheme/02-asset-mgr/PumpMain/ChoicePumpMainDlg.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-scheme/02-asset-mgr/PumpMain/ChoicePumpMainDlg.cs
index a283be9..db28eae 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-scheme/02-asset-mgr/PumpMain/ChoicePumpMainDlg.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-scheme/02-asset-mgr/PumpMain/ChoicePumpMainDlg.cs
@@ -1,4 +1,4 @@
-锘縰sing DevExpress.XtraEditors;
+锘縰sing DevExpress.XtraLayout.Utils;
 
 namespace HStation.WinFrmUI.Xhs
 {
@@ -9,101 +9,81 @@
             InitializeComponent();
         }
 
-        private List<PumpMainChoieViewModel> _allBindingList = null;
+        private readonly PumpMainChoiceViewModel _vm = new();
 
-        private BLL.PumpSeries _seriesBll = new BLL.PumpSeries();
+        private PumpMainChoiceManager _wizard;
 
-        private BLL.PumpGroup _groupBll = new BLL.PumpGroup();
-
-        private BLL.PumpMain _pumpBll = new BLL.PumpMain();
-
-        private BLL.PumpGroupAndMainMap _groupMapBll = new BLL.PumpGroupAndMainMap();
-
-        //妯$硦鏌ヨ鏂囧瓧杈撳叆
-        private async void TextPopupPumpChoice_EditValueChanged(object sender, EventArgs e)
+        public void SetBindingData()
         {
+            _wizard = new PumpMainChoiceManager(_vm);
+            _wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent;
+            _wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent; ;
+            _wizard.InitialManager(new IWizardPage<PumpMainChoiceViewModel>[] {
+                this.pumpMainChoicePage,
+                this.ValveChoicePage
+             });
         }
 
-        //鏍规嵁娉靛瀷鍙锋ā绯婃煡璇�
-        private async void simpleLabelSearch_Click(object sender, EventArgs e)
+        //閫夋嫨椤甸潰鏀瑰彉
+        private void _wizard_SelectedPageChangedEvent(IWizardPage<PumpMainChoiceViewModel> page, int index)
         {
-            _allBindingList = new List<PumpMainChoieViewModel>();
-            var allSeries = await _seriesBll.GetAll();
-            var allGroup = await _groupBll.GetAll();
-            var allPumpMain = await _pumpBll.GetAll();
-            var allGroupMap = await _groupMapBll.GetAll();
-            if (TextPopupPumpChoice.EditValue == null)
+            this.navigationFrame1.SelectedPageIndex = index;
+            this.stepProgressBar1.SelectedItemIndex = index;
+        }
+
+        //閫夋嫨椤甸潰鐘舵�佹敼鍙�
+        private void _wizard_SelectedPageStateChangedEvent(IWizardPage<PumpMainChoiceViewModel> page, int index)
+        {
+            this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never;
+            this.itemForComplete.Visibility = page.AllowComplete ? LayoutVisibility.Always : LayoutVisibility.Never;
+        }
+
+        //涓婁竴姝�
+        private void btnPrev_Click(object sender, EventArgs e)
+        {
+            if (_wizard != null)
             {
-                return;
+                _wizard.Prev();
             }
-            //娉靛瀷鍙�
-            foreach (var item in allPumpMain)
+        }
+
+        //涓嬩竴姝�
+        private void btnNext_Click(object sender, EventArgs e)
+        {
+            if (_wizard != null)
             {
-                if (item.Name.Contains(this.TextPopupPumpChoice.Text.Trim()))
+                _wizard.Next();
+            }
+        }
+
+        //鍙栨秷
+        private void btnCancel_Click(object sender, EventArgs e)
+        {
+            if (_wizard != null)
+            {
+                var bol = _wizard.Cancel();
+                if (bol)
                 {
-                    var groupMap = allGroupMap.Find(x => x.PumpMainID == item.ID);
-                    if (groupMap != null)
-                    {
-                        var group = allGroup.Find(x => x.ID == groupMap.PumpGroupID);
-                        if (group != null)
-                        {
-                            var series = allSeries.Find(x => x.ID == group.PumpSeriesID);
-                            if (series != null)
-                            {
-                                if (_allBindingList.Find(x => x.ID == series.ID) == null)
-                                {
-                                    _allBindingList.Add(new PumpMainChoieViewModel(series));
-                                }
-                                if (_allBindingList.Find(x => x.ID == group.ID) == null)
-                                {
-                                    _allBindingList.Add(new PumpMainChoieViewModel(item, group.ID));
-                                }
-                                _allBindingList.Add(new PumpMainChoieViewModel(group));
-                            }
-                        }
-                    }
-                    else
-                    {
-                        var series = allSeries.Find(x => x.ID == item.PumpSeriesID);
-                        if (series != null)
-                        {
-                            if (_allBindingList.Find(x => x.ID == series.ID) == null)
-                            {
-                                _allBindingList.Add(new PumpMainChoieViewModel(series));
-                            }
-                            _allBindingList.Add(new PumpMainChoieViewModel(item));
-                        }
-                    }
+                    this.DialogResult = DialogResult.Cancel;
+                    this.Close();
                 }
             }
-            this.treeList1.DataSource = _allBindingList;
-            TextPopupPumpChoice.ShowPopup();
-            //  TextPopupPumpChoice.Focus();
         }
 
-        //閫夋嫨椤瑰彉鎹�
-        private async void treeList1_SelectionChanged(object sender, EventArgs e)
+        //瀹屾垚
+        private void btnComplete_Click(object sender, EventArgs e)
         {
-            var vm = this.treeList1.GetCurrentViewModel(_allBindingList);
-            if (vm != null)
+            if (_wizard != null)
             {
-                if (!vm.IsPump)
+                var bol = _wizard.Complete();
+                if (bol)
                 {
-                    return;
+                    this.DialogResult = DialogResult.OK;
+                    this.Close();
                 }
-                var model = await _pumpBll.GetByID(vm.ID);
-                if (model == null)
-                    return;
-
-                pumpMainForm1.SetBindingData(model);
             }
-            //treeList1.CloseEditForm();
-        }
-
-        private void BtnAddPumpMain_Click(object sender, EventArgs e)
-        {
-            var dlg = new AddPumpMainDlg();
-            dlg.ShowDialog();
         }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3