duheng
2024-07-12 09f8dfa6d6b382ed21e262e0a34704f61dab5e82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Mapster;
using System.ComponentModel;
using Yw.Dto;
 
namespace HStation.WinFrmUI.Basic
{
    public partial class SetSysPropChoiceDlg : DevExpress.XtraEditors.XtraForm
    {
        public SetSysPropChoiceDlg()
        {
            InitializeComponent();
        }
 
        private Yw.BLL.SysPropChoice _bll = null;
 
        private List<SysPropChoiceViewModel> _allBindingList = null;
 
        public async void SetBindingData(long PropID)
        {
            _bll = new Yw.BLL.SysPropChoice();
            var alllist = await _bll.GetByPropID(PropID);
            _allBindingList = new List<SysPropChoiceViewModel>();
            foreach (var item in alllist)
            {
                _allBindingList.Add(new SysPropChoiceViewModel(item));
            }
            this.sysPropChoiceViewModelBindingSource.DataSource = _allBindingList;
            this.sysPropChoiceViewModelBindingSource.ResetBindings(false);
        }
 
        //完成
        private async void BtnOk_Click(object sender, EventArgs e)
        {
            var AddSysPropChoices = new List<AddSysPropChoiceInput>();
            foreach (var item in _allBindingList)
            {
                AddSysPropChoices.Add(item.Adapt<SysPropChoiceViewModel, AddSysPropChoiceInput>());
            }
            if (await _bll.Inserts(AddSysPropChoices))
            {
                MessageBoxHelper.ShowSuccess("设置成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("设置失败!");
            }
        }
 
        //删除
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (_allBindingList == null || _allBindingList.Count < 1)
                return;
            var row = this.gridView1.GetCurrentViewModel(_allBindingList);
            if (row == null)
                return;
            if (e.Column == this.ColDelete)
                _allBindingList.Remove(row);
            this.sysPropChoiceViewModelBindingSource.DataSource = _allBindingList;
            this.sysPropChoiceViewModelBindingSource.ResetBindings(false);
        }
    }
}