duheng
2024-12-16 1195d192ef966b3fe653af7321b525bdcc0f906b
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Yw.Basic;
 
namespace HStation.WinFrmUI.Basic
{
    public partial class AddSysTypeDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddSysTypeDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
        }
 
        public event Func<Yw.Vmo.SysTypeVmo, Task<bool>> ReloadDataEvent = null;
 
        private Yw.Vmo.SysTypeVmo _AddSysTypeDto { get; set; }
 
        public void SetBindingData(long ID)
        {
            _AddSysTypeDto = new Yw.Vmo.SysTypeVmo();
            _AddSysTypeDto.ModuleID = ID;
        }
 
        //数据验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(TextEditName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextEditName, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(TextEditCode.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextEditCode, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(TextEditExtendType.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextEditExtendType, "必填项");
                return false;
            }
            return true;
        }
 
        //完成
        private async void BtnOk_ClickAsync(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            _AddSysTypeDto.Name = TextEditName.Text.Trim();
            _AddSysTypeDto.Description = TextEditDescription.Text.Trim();
            _AddSysTypeDto.Code = TextEditCode.Text.Trim();
            if (this.TextEditExtendType.SelectedIndex == 0)
            {
                _AddSysTypeDto.ExtendType = eExtendType.Config;
            }
            else if (this.TextEditExtendType.SelectedIndex == 1)
            {
                _AddSysTypeDto.ExtendType = eExtendType.Catalog;
            }
            else
            {
                _AddSysTypeDto.ExtendType = eExtendType.None;
            }
            if (await this.ReloadDataEvent.Invoke(_AddSysTypeDto))
            {
                MessageBoxHelper.ShowSuccess("添加成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("添加失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}