duheng
2024-09-26 f04e6ed843d66c22e08132ca23d2193d6800905c
WinFrmUI/HStation.WinFrmUI.Basic/02-SysPropManage/SetSysPropChoiceDlg.cs
@@ -1,4 +1,5 @@
using Mapster;
using Yw.DAL.Basic;
using Yw.Dto;
namespace HStation.WinFrmUI.Basic
@@ -8,14 +9,18 @@
        public SetSysPropChoiceDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
        }
        private Yw.BLL.SysPropChoice _bll = null;
        private List<SysPropChoiceViewModel> _allBindingList = null;
        private long _PropID;
        public async void SetBindingData(long PropID)
        {
            _PropID = PropID;
            _bll = new Yw.BLL.SysPropChoice();
            var alllist = await _bll.GetByPropID(PropID);
            _allBindingList = new List<SysPropChoiceViewModel>();
@@ -30,12 +35,24 @@
        //完成
        private async void BtnOk_Click(object sender, EventArgs e)
        {
            var AddSysPropChoices = new List<AddSysPropChoiceInput>();
            var AddSysPropChoices = new List<Yw.Vmo.SysPropChoiceVmo>();
            foreach (var item in _allBindingList)
            {
                AddSysPropChoices.Add(item.Adapt<SysPropChoiceViewModel, AddSysPropChoiceInput>());
                var choiceitem = item.Adapt<SysPropChoiceViewModel, Yw.Vmo.SysPropChoiceVmo>();
                choiceitem.PropID = _PropID;
                AddSysPropChoices.Add(choiceitem);
            }
            if (await _bll.Inserts(AddSysPropChoices))
            var alllist = await _bll.GetByPropID(_PropID);
            foreach (var item in alllist)
            {
                await _bll.DeleteByID(item.ID);
            }
            if (AddSysPropChoices.Count == 0)
            {
                MessageBoxHelper.ShowSuccess("设置成功!");
            }
            else if (await _bll.Inserts(AddSysPropChoices))
            {
                MessageBoxHelper.ShowSuccess("设置成功!");
            }
@@ -43,6 +60,8 @@
            {
                MessageBoxHelper.ShowError("设置失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        //删除