lixiaojun
2024-11-30 ff39bbf7e3a3d02f7f051ce1bee06cec007be3ff
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
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
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();
        }
    }
}