ningshuxia
11 小时以前 71c12ff40d58c3dbdde6867396dd99224e57fc32
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
namespace Yw.WinFrmUI
{
    public partial class EditPartDlg : DevExpress.XtraEditors.XtraForm
    {
        public EditPartDlg()
        {
            InitializeComponent();
        }
 
        private Vmo.PartVmo _part;
 
        public event Func<Vmo.PartVmo, Task<bool>> ReloadData;
 
        public void SetbindingData(Vmo.PartVmo part)
        {
            _part = part;
            this.TxtName.Text = part.Name;
            this.TxtDescription.Text = part.Description;
            this.TxtTag.Text = part.TagName;
        }
 
        private bool Verify()
        {
            this.dxErrorProvider1.ClearErrors();
            if (this.TxtName.Text == null)
            {
                this.dxErrorProvider1.SetError(this.TxtName, "不能为空");
                return false;
            }
            return true;
        }
 
        //确定
        private async void btnOk_Click(object sender, EventArgs e)
        {
            if (!Verify())
                return;
            _part.TagName = this.TxtTag.Text;
            _part.Description = this.TxtDescription.Text;
            _part.Name = this.TxtName.Text;
            if (this.ReloadData == null)
                return;
            if (!await this.ReloadData(_part))
            {
                MessageBoxHelper.ShowError("修改失败!");
                return;
            }
            MessageBoxHelper.ShowSuccess("修改成功!");
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
    }
}