lixiaojun
2024-10-17 4cb1f00f84d160f97afd0fb86cf600e1be667dd5
WinFrmUI/HStation.WinFrmUI.Assets.Core/01-pump/01-EditPumpPartProp/PumpProductListBox.cs
@@ -1,4 +1,6 @@
namespace HStation.WinFrmUI.Assets
using DevExpress.XtraEditors;
namespace HStation.WinFrmUI.Assets
{
    public partial class PumpProductListBox : DevExpress.XtraEditors.XtraUserControl
    {
@@ -11,11 +13,15 @@
        public List<CurrentPartMainViewModel> _allBindingList = null;
        public BLL.AssetsPumpPartMain _Bll;
        public event Action<object, MouseEventArgs> MouseUp;
        public async void SetBindingData(Vmo.AssetsPumpMainVmo AssetsPumpMain)
        {
            _allBindingList = new List<CurrentPartMainViewModel>();
            var _bll = new BLL.AssetsPumpPartMain();
            var allpartlist = await _bll.GetByPumpMainID(AssetsPumpMain.ID);   //获取所有产品
            _Bll = new BLL.AssetsPumpPartMain();
            var allpartlist = await _Bll.GetByPumpMainID(AssetsPumpMain.ID);   //获取所有产品
            var series = await new BLL.AssetsPumpSeries().GetByID(AssetsPumpMain.PumpSeriesID);  //获取系列
            if (allpartlist != null)
            {
@@ -47,5 +53,33 @@
        {
            SelectReloadEvent.Invoke();
        }
        private void listBoxControl1_MouseUp(object sender, MouseEventArgs e)
        {
            MouseUp.Invoke(sender, e);
        }
        //删除属性
        private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var vm = this.listBoxControl1.GetCurrentViewModel(_allBindingList);
            if (vm == null)
            {
                TipFormHelper.ShowWarn("请选择数据行!");
                return;
            }
            if (MessageBoxHelper.IsClickOk($"确认删除数据行?", "提示"))
                return;
            if (await _Bll.DeleteEx(vm.ID))
            {
                _allBindingList.Remove(vm);
                this.listBoxControl1.Refresh();
                TipFormHelper.ShowSucceed("删除成功!");
            }
            else
            {
                TipFormHelper.ShowError("删除失败!");
            }
        }
    }
}