duheng
2024-08-12 1a12ef2743134f7fdea6d0abbfec34543b85bdb5
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using Mapster;
using Yw.Basic;
using Yw.Dto;
 
namespace HStation.WinFrmUI.Basic
{
    public partial class EditSysPropDlg : DevExpress.XtraEditors.XtraForm
    {
        public EditSysPropDlg()
        {
            InitializeComponent();
        }
 
        public event Func<Yw.Vmo.SysProp, Task<bool>> ReloadDataEvent = null;
 
        private Yw.Vmo.SysProp _UpdatePropDto { get; set; }
 
        public async void SetBindingData(long PropID)
        {
            var model = await new Yw.BLL.SysProp().GetByID(PropID);
            _UpdatePropDto = model;
            this.TextEditName.Text = _UpdatePropDto.Name;
            this.TextEditDefaultValue.Text = _UpdatePropDto.DefaultValue;
            this.TextEditDescription.Text = _UpdatePropDto.Description;
            this.TextEditUnitName.Text = _UpdatePropDto.UnitName;
            this.TextEditCode.Text = _UpdatePropDto.Code;
            this.CheckEditIsNull.Checked = _UpdatePropDto.IsNull;
            if (_UpdatePropDto.Format == Yw.Vmo.Core.ePropFormat.Bigint)
            {
                this.TextComoBoxFormat.SelectedIndex = 1;
            }
            else if (_UpdatePropDto.Format == Yw.Vmo.Core.ePropFormat.Integer)
            {
                this.TextComoBoxFormat.SelectedIndex = 0;
            }
            else if (_UpdatePropDto.Format == Yw.Vmo.Core.ePropFormat.MultiText)
            {
                this.TextComoBoxFormat.SelectedIndex = 4;
            }
            else if (_UpdatePropDto.Format == Yw.Vmo.Core.ePropFormat.Time)
            {
                this.TextComoBoxFormat.SelectedIndex = 5;
            }
            else if (_UpdatePropDto.Format == Yw.Vmo.Core.ePropFormat.Numeric)
            {
                this.TextComoBoxFormat.SelectedIndex = 2;
            }
            else if (_UpdatePropDto.Format == Yw.Vmo.Core.ePropFormat.Text)
            {
                this.TextComoBoxFormat.SelectedIndex = 3;
            }
            else
            {
                this.TextComoBoxFormat.SelectedIndex = 6;
            }
        }
 
        //数据验证
        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(TextComoBoxFormat.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextComoBoxFormat, "必填项");
                return false;
            }
            return true;
        }
 
        //完成
        private async void BtnOk_ClickAsync(object sender, EventArgs e)
        {
            _UpdatePropDto.Name = TextEditName.Text.Trim();
            _UpdatePropDto.Description = TextEditDescription.Text.Trim();
            _UpdatePropDto.Code = TextEditCode.Text.Trim();
            _UpdatePropDto.DefaultValue = TextEditDefaultValue.Text.Trim();
            _UpdatePropDto.UnitName = TextEditUnitName.Text.Trim();
            if (TextComoBoxFormat.SelectedIndex == 0)
            {
                _UpdatePropDto.Format = (Yw.Vmo.Core.ePropFormat)ePropFormat.Integer;
            }
            else if (TextComoBoxFormat.SelectedIndex == 1)
            {
                _UpdatePropDto.Format = (Yw.Vmo.Core.ePropFormat)ePropFormat.Bigint;
            }
            else if (TextComoBoxFormat.SelectedIndex == 2)
            {
                _UpdatePropDto.Format = (Yw.Vmo.Core.ePropFormat)ePropFormat.Numeric;
            }
            else if (TextComoBoxFormat.SelectedIndex == 3)
            {
                _UpdatePropDto.Format = (Yw.Vmo.Core.ePropFormat)ePropFormat.Text;
            }
            else if (TextComoBoxFormat.SelectedIndex == 4)
            {
                _UpdatePropDto.Format = (Yw.Vmo.Core.ePropFormat)ePropFormat.MultiText;
            }
            else if (TextComoBoxFormat.SelectedIndex == 5)
            {
                _UpdatePropDto.Format = (Yw.Vmo.Core.ePropFormat)ePropFormat.Time;
            }
            else
            {
                _UpdatePropDto.Format = (Yw.Vmo.Core.ePropFormat)ePropFormat.Boolen;
            }
            _UpdatePropDto.IsNull = CheckEditIsNull.Checked;
            if (await this.ReloadDataEvent.Invoke(_UpdatePropDto))
            {
                MessageBoxHelper.ShowSuccess("修改成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("修改失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}