Shuxia Ning
2024-09-11 5dbe0ca9fe177aa83779ebad921b5d1d2cae6278
WinFrmUI/HStation.WinFrmUI.Assets.Core/05-ValveManage/ValveManageMainPanel.cs
ÎļþÃû´Ó WinFrmUI/HStation.WinFrmUI.Assets.Core/01-ValveManage/ValveManageMainPanel.cs ÐÞ¸Ä
@@ -6,26 +6,28 @@
        {
            InitializeComponent();
            this.PageTitle.Caption = "阀门管理";
            this.gridView1.SetNormalView();
            this.gridView1.RegistCustomDrawRowIndicator();
            this.PageTitle.HeaderSvgImage = this.svgImageCollection1[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.valveTypeTreeListCtrl1.RloadEvent += ValveTypeTreeListCtrl1_RloadEvent;
        }
        private BLL.ValveMain _Bll = null;
        private BLL.ValveMain _bll = null;
        private List<ValveMainViewModel> _allBindingList = new List<ValveMainViewModel>();
        //初始化数据
        public override void InitialDataSource()
        {
            _Bll = new BLL.ValveMain();
            _bll = new BLL.ValveMain();
            this.valveTypeTreeListCtrl1.SetBindingData();
            this.valveMainViewModelBindingSource.DataSource = _allBindingList;
        }
        private async void ValveTypeTreeListCtrl1_RloadEvent(long SeriesID)
        {
            var alllist = await _Bll.GetBySeriesID(SeriesID);
            var alllist = await _bll.GetBySeriesID(SeriesID);
            _allBindingList.Clear();
            foreach (var item in alllist)
            {
@@ -47,7 +49,7 @@
            dlg.SetBindingData(seriesid);
            dlg.ReloadDataEvent += async (rhs) =>
            {
                var id = await _Bll.Insert(rhs);
                var id = await _bll.Insert(rhs);
                if (id > 0)
                {
                    rhs.ID = id;
@@ -73,7 +75,7 @@
            dlg.SetBindingData(vm.ID);
            dlg.ReloadDataEvent += async (rhs) =>
            {
                if (await _Bll.Update(rhs))
                if (await _bll.Update(rhs))
                {
                    vm.Reset(rhs);
                    this.valveMainViewModelBindingSource.ResetBindings(false);
@@ -83,5 +85,30 @@
            };
            dlg.ShowDialog();
        }
        //删除阀门
        private async void BtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var currentVm = this.gridView1.GetCurrentViewModel(_allBindingList);
            if (currentVm == null)
            {
                MessageBoxHelper.ShowWarning("请选择数据行!");
                return;
            }
            if (MessageBoxHelper.IsClickOk($"确认删除数据行?", "提示"))
                return;
            var groupresult = await _bll.DeleteByID(currentVm.ID);
            if (groupresult)
            {
                _allBindingList.Remove(currentVm);
                this.valveMainViewModelBindingSource.ResetBindings(false);
                TipFormHelper.ShowSucceed("删除成功!");
            }
            else
            {
                TipFormHelper.ShowSucceed("删除失败!");
                return;
            }
        }
    }
}