duheng
2024-09-27 0e54c48e8190937f5b483c79e3cc9d17ec7c9af0
WinFrmUI/HStation.WinFrmUI.Basic/01-SysCatalogManage/SysCatalogManageMainPanel.cs
@@ -6,10 +6,10 @@
        {
            InitializeComponent();
            this.PageTitle.Caption = "分类管理";
            this.PageTitle.HeaderSvgImage = this.svgImage32[1];
            this.treeList1.InitialMultiColSettings();
            this.PageTitle.HeaderSvgImage = this.svgImage32[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.typeTreeListCtrl2.FocusedChangedEvent += TypeTreeListCtrl2_FocusedChangedEvent;
        }
        private List<SysCatalogViewModel> _allBindingList = null;
@@ -33,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);
        }
        //添加
@@ -42,6 +42,8 @@
        {
            var dlg = new AddSysCatalogDlg();
            var typeID = this.typeTreeListCtrl2.GetCurrentID();
            if (typeID == 0)
                return;
            dlg.SetBindingData(typeID);
            dlg.ReloadDataEvent += async (rhs) =>
           {
@@ -50,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;
@@ -77,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;
@@ -88,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)
            {
@@ -101,7 +103,7 @@
                if (await _bll.Update(rhs))
                {
                    vm.Reset(rhs);
                    this.catlogViewModelBindingSource.ResetBindings(false);
                    this.catalogViewModelBindingSource.ResetBindings(false);
                    return true;
                }
                return false;
@@ -120,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);
            }
        }