duheng
2024-07-05 5aba1bf12cd27faa797e7f3d15e0f960bdc2a4b2
WinFrmUI/HStation.WinFrmUI.Xhs.Project/05-CatlogManage/TypeTreeListCtrl.cs
@@ -1,6 +1,8 @@
using DevExpress.XtraEditors;
using DevExpress.XtraBars.Docking2010.DragEngine;
using DevExpress.XtraEditors;
using HStation.WinFrmUI.Xhs.Project;
using ISupply.WinFrmUI;
using Yw.Basic;
namespace HStation.WinFrmUI.Xhs
{
@@ -12,6 +14,7 @@
        public TypeTreeListCtrl()
        {
            InitializeComponent();
            this.treeList1.InitialDefaultSettings();
        }
        /// <summary>
@@ -19,9 +22,11 @@
        /// </summary>
        public event Action<long> FocusedChangedEvent;
        private List<TypeViewModel> _allBindingList = null;
        private List<TypeTreeListViewModel> _allBindingList = null;
        private Yw.BLL.SysModule _bll = null;
        private Yw.BLL.SysTypeStd _bll = null;
        private Yw.BLL.SysModule _Modulebll = null;
        /// <summary>
        /// 绑定数据
@@ -36,8 +41,19 @@
        /// </summary>
        public async void SetBindingData()
        {
            _allBindingList = new List<TypeViewModel>();
            _allBindingList = new List<TypeTreeListViewModel>();
            _bll = new Yw.BLL.SysTypeStd();
            var alllist = await _bll.GetLogicalTreeListByExtendType(eExtendType.Catalog);
            foreach (var item in alllist)
            {
                var module = new TypeTreeListViewModel(item);
                _allBindingList.Add(module);
                foreach (var child in item.Children)
                {
                    var children = new TypeTreeListViewModel(child);
                    _allBindingList.Add(children);
                }
            }
            this.moduleViewModelBindingSource.DataSource = _allBindingList;
            this.moduleViewModelBindingSource.ResetBindings(false);
        }
@@ -85,11 +101,11 @@
            var dlg = new AddMoudleDlg();
            dlg.ReloadDataEvent += async (rhs) =>
            {
                var id = await _bll.Insert(rhs);
                var id = await _Modulebll.Insert(rhs);
                if (id > 0)
                {
                    var model = await _bll.GetByID(id);
                    //   _allBindingList.Add(new ModuleViewModel(model));
                    var model = await _Modulebll.GetByID(id);
                    //  _allBindingList.Add(new ModuleViewModel(model));
                    this.moduleViewModelBindingSource.ResetBindings(false);
                    return true;
                }
@@ -118,7 +134,7 @@
            dlg.SetBindingData(vm.ID);
            dlg.ReloadDataEvent += async (rhs) =>
            {
                if (await _bll.Update(rhs))
                if (await _Modulebll.Update(rhs))
                {
                    //vm.Reset(rhs);
                    this.moduleViewModelBindingSource.ResetBindings(false);
@@ -140,12 +156,12 @@
            }
            if (MessageBoxHelper.IsClickOk("确认删除数据行?", "提示"))
                return;
            if (await _bll.IsExistByModuleID(currentVm.ID))
            if (await _Modulebll.IsExistByModuleID(currentVm.ID))
            {
                MessageBoxHelper.ShowWarning("存在系统类型,不可删除!");
                return;
            }
            var result = await _bll.DeleteByID(currentVm.ID);
            var result = await _Modulebll.DeleteByID(currentVm.ID);
            if (result)
            {
                _allBindingList.Remove(currentVm);