Shuxia Ning
2024-10-08 cf4967a0aebab18c5a37137f3e4c61b2d73a54bb
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
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.Basic
{
    public partial class EditOtherNameDlg : XtraForm
    {
        public EditOtherNameDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = WinFrmUI.Properties.Resources.App;
            this.dataLayoutControl1.SetupLayoutControl();
        }
 
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Func<string, bool> ReloadDataEvent;
 
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(string name)
        {
            this.txtOtherName.EditValue = name;
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.txtOtherName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtOtherName, "必填项");
                return false;
            }
            return true;
        }
 
        //确定
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            var name = this.txtOtherName.Text.Trim();
            var result = this.ReloadDataEvent?.Invoke(name);
            if (result == null || !result.Value)
            {
                XtraMessageBox.Show("更新失败!");
                return;
            }
            XtraMessageBox.Show("更新成功!");
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
    }
}