From f04e6ed843d66c22e08132ca23d2193d6800905c Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期四, 26 九月 2024 11:51:19 +0800
Subject: [PATCH] 增加窗体图标

---
 WinFrmUI/HStation.WinFrmUI.Basic/01-SysCatalogManage/SysCatalogManageMainPanel.cs |   43 ++++++++++++++++++++++++++++---------------
 1 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Basic/01-SysCatalogManage/SysCatalogManageMainPanel.cs b/WinFrmUI/HStation.WinFrmUI.Basic/01-SysCatalogManage/SysCatalogManageMainPanel.cs
index 3de1cac..33c0607 100644
--- a/WinFrmUI/HStation.WinFrmUI.Basic/01-SysCatalogManage/SysCatalogManageMainPanel.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Basic/01-SysCatalogManage/SysCatalogManageMainPanel.cs
@@ -5,6 +5,10 @@
         public SysCatalogManageMainPanel()
         {
             InitializeComponent();
+            this.PageTitle.Caption = "鍒嗙被绠$悊";
+            this.treeList1.InitialMultiColSettings();
+            this.PageTitle.HeaderSvgImage = this.svgImage32[0];
+            this.PageTitle.SvgImageSize = new Size(24, 24);
             this.typeTreeListCtrl2.FocusedChangedEvent += TypeTreeListCtrl2_FocusedChangedEvent;
         }
 
@@ -15,13 +19,13 @@
         public override void InitialDataSource()
         {
             this.typeTreeListCtrl2.SetBindingData();
+            _bll = new Yw.BLL.SysCatalog();
         }
 
         //鑱氱劍鍒囨崲
         private async void TypeTreeListCtrl2_FocusedChangedEvent(long typeID)
         {
             _allBindingList = new List<SysCatalogViewModel>();
-            _bll = new Yw.BLL.SysCatalog();
             var alllist = await _bll.GetByTypeID(typeID);
             _allBindingList.Clear();
             foreach (var item in alllist)
@@ -29,8 +33,8 @@
                 _allBindingList.Add(new SysCatalogViewModel(item));
             }
             _allBindingList = _allBindingList.OrderBy(x => x.SortCode).ToList();
-            this.catlogViewModelBindingSource.DataSource = _allBindingList;
-            this.catlogViewModelBindingSource.ResetBindings(false);
+            this.catalogViewModelBindingSource.DataSource = _allBindingList;
+            this.catalogViewModelBindingSource.ResetBindings(false);
         }
 
         //娣诲姞
@@ -38,6 +42,8 @@
         {
             var dlg = new AddSysCatalogDlg();
             var typeID = this.typeTreeListCtrl2.GetCurrentID();
+            if (typeID == 0)
+                return;
             dlg.SetBindingData(typeID);
             dlg.ReloadDataEvent += async (rhs) =>
            {
@@ -46,7 +52,7 @@
                {
                    var model = await _bll.GetByID(id);
                    _allBindingList.Add(new SysCatalogViewModel(model));
-                   this.catlogViewModelBindingSource.ResetBindings(false);
+                   this.catalogViewModelBindingSource.ResetBindings(false);
                    return true;
                }
                return false;
@@ -73,7 +79,7 @@
                 {
                     var model = await _bll.GetByID(id);
                     _allBindingList.Add(new SysCatalogViewModel(model));
-                    this.catlogViewModelBindingSource.ResetBindings(false);
+                    this.catalogViewModelBindingSource.ResetBindings(false);
                     return true;
                 }
                 return false;
@@ -84,7 +90,7 @@
         //缂栬緫
         private void barBtnEditPumpCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            var dlg = new EditSysCatlaogDlg();
+            var dlg = new EditSysCatalogDlg();
             var vm = this.treeList1.GetCurrentViewModel(_allBindingList);
             if (vm == null)
             {
@@ -97,7 +103,7 @@
                 if (await _bll.Update(rhs))
                 {
                     vm.Reset(rhs);
-                    this.catlogViewModelBindingSource.ResetBindings(false);
+                    this.catalogViewModelBindingSource.ResetBindings(false);
                     return true;
                 }
                 return false;
@@ -116,17 +122,24 @@
             }
             if (MessageBoxHelper.IsClickOk($"纭鍒犻櫎鏁版嵁琛�?", "鎻愮ず"))
                 return;
-            var result = await _bll.DeleteByID(currentVm.ID);
-            if (result)
+            try
             {
-                _allBindingList.Remove(currentVm);
-                this.catlogViewModelBindingSource.ResetBindings(false);
-                MessageBoxHelper.ShowSuccess($"鍒犻櫎鎴愬姛!");
+                var result = await _bll.DeleteByID(currentVm.ID);
+                if (result)
+                {
+                    _allBindingList.Remove(currentVm);
+                    this.catalogViewModelBindingSource.ResetBindings(false);
+                    MessageBoxHelper.ShowSuccess($"鍒犻櫎鎴愬姛!");
+                }
+                else
+                {
+                    MessageBoxHelper.ShowError($"鍒犻櫎澶辫触!");
+                    return;
+                }
             }
-            else
+            catch (Yw.Dto.InternalException ex)
             {
-                MessageBoxHelper.ShowError($"鍒犻櫎澶辫触!");
-                return;
+                MessageBoxHelper.ShowError(ex.ErrorMsg);
             }
         }
 

--
Gitblit v1.9.3