duheng
2024-07-23 3fec42c6383aa3b8d65f744a93b8a918d7cc6e02
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
using Mapster;
using Yw.Dto;
 
namespace HStation.WinFrmUI.Basic
{
    public partial class EditSysPropGrouoDlg : DevExpress.XtraEditors.XtraForm
    {
        public EditSysPropGrouoDlg()
        {
            InitializeComponent();
        }
 
        public event Func<Yw.Dto.UpdateSysPropGroupInput, Task<bool>> ReloadDataEvent = null;
 
        private UpdateSysPropGroupInput _UpdatePropGroupDto { get; set; }
 
        public async void SetBindingData(long ID)
        {
            var model = await new Yw.BLL.SysPropGroup().GetByID(ID);
            _UpdatePropGroupDto = model.Adapt<UpdateSysPropGroupInput>();
            this.TextEditName.Text = model.Name;
            this.TextEditDescription.Text = model.Description;
            this.TextEditCode.Text = model.Code;
        }
 
        //数据验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(TextEditName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextEditName, "必填项");
                return false;
            }
            return true;
        }
 
        //完成
        private async void BtnOk_ClickAsync(object sender, EventArgs e)
        {
            _UpdatePropGroupDto.Name = TextEditName.Text.Trim();
            _UpdatePropGroupDto.Description = TextEditDescription.Text.Trim();
            _UpdatePropGroupDto.Code = TextEditCode.Text.Trim();
            if (await this.ReloadDataEvent.Invoke(_UpdatePropGroupDto))
            {
                MessageBoxHelper.ShowSuccess("修改成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("修改失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}