Shuxia Ning
2024-07-22 952cb084d1f31a1c2634b91d4d03374c359b52da
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
namespace HStation.WinFrmUI.Xhs.PumpProduct
{
    public partial class AddPumpProductGroupDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddPumpProductGroupDlg()
        {
            InitializeComponent();
        }
 
        public event Func<AddPumpGroupDto, Task<bool>> ReloadDataEvent = null;
 
        private AddPumpGroupDto _AddPumpGroupDto { get; set; }
 
        public void SetBindingData(long ID)
        {
            _AddPumpGroupDto = new AddPumpGroupDto();
            _AddPumpGroupDto.PumpSeriesID = ID;
        }
 
        //数据验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(NameTextEdit.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
                return false;
            }
            return true;
        }
 
        //完成
        private async void BtnOk_ClickAsync(object sender, EventArgs e)
        {
            _AddPumpGroupDto.TagName = TagNameTextEdit.Text.Trim();
            _AddPumpGroupDto.Name = NameTextEdit.Text.Trim();
            _AddPumpGroupDto.Description = DescriptionTextEdit.Text.Trim();
            if (await this.ReloadDataEvent.Invoke(_AddPumpGroupDto))
            {
                MessageBoxHelper.ShowSuccess("添加成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("添加失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}