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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using Yw.Basic;
using Yw.Dto;
 
namespace HStation.WinFrmUI.Basic
{
    public partial class AddSysPropDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddSysPropDlg()
        {
            InitializeComponent();
        }
 
        public event Func<Yw.Dto.AddSysPropInput, Task<bool>> ReloadDataEvent = null;
 
        private AddSysPropInput _AddPropDto { get; set; }
 
        private long _TypeID;
 
        public async void SetBindingData(long GroupID, long TypeID)
        {
            _AddPropDto = new AddSysPropInput();
            _AddPropDto.GroupID = GroupID;
            _TypeID = TypeID;
        }
 
        //数据验证
        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(TextEditFormat.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextEditCode, "必填项");
                return false;
            }
            return true;
        }
 
        //完成
        private async void BtnOk_ClickAsync(object sender, EventArgs e)
        {
            _AddPropDto.Name = TextEditName.Text.Trim();
            _AddPropDto.Description = TextEditDescription.Text.Trim();
            _AddPropDto.Code = TextEditCode.Text.Trim();
            _AddPropDto.DefaultValue = TextEditDefaultValue.Text.Trim();
            _AddPropDto.UnitName = TextEditUnitName.Text.Trim();
            _AddPropDto.IsNull = CheckEditIsNull.Checked;
            // _AddPropDto.Format = TextEditFormat.Text.Trim();
            if (TextEditFormat.SelectedIndex == 0)
            {
                _AddPropDto.Format = ePropFormat.Integer;
            }
            else if (TextEditFormat.SelectedIndex == 1)
            {
                _AddPropDto.Format = ePropFormat.Bigint;
            }
            else if (TextEditFormat.SelectedIndex == 2)
            {
                _AddPropDto.Format = ePropFormat.Numeric;
            }
            else if (TextEditFormat.SelectedIndex == 3)
            {
                _AddPropDto.Format = ePropFormat.Text;
            }
            else if (TextEditFormat.SelectedIndex == 4)
            {
                _AddPropDto.Format = ePropFormat.MultiText;
            }
            else if (TextEditFormat.SelectedIndex == 5)
            {
                _AddPropDto.Format = ePropFormat.Time;
            }
            else
            {
                _AddPropDto.Format = ePropFormat.Boolen;
            }
            _AddPropDto.TypeID = _TypeID;
            if (await this.ReloadDataEvent.Invoke(_AddPropDto))
            {
                MessageBoxHelper.ShowSuccess("添加成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("添加失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}