duheng
2024-04-15 154d4c352b9ab06a925451f1fdcea6afd1701e10
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
namespace ISupply.WinFrm
{
    /// <summary>
    /// 设置排序码
    /// </summary>
    public partial class SetSortCodeDlg : XtraForm
    {
        public SetSortCodeDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = ISupply.Icons.Resource.App;
            this.layoutControl1.SetupLayoutControl();
        }
 
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Func<int, bool> ReloadDataEvent;
 
        /// <summary>
        /// 绑定事件
        /// </summary>
        public void SetBindingData(int SortCode)
        {
            this.txtSortCode.EditValue = SortCode;
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.txtSortCode.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtSortCode, "必填项");
                return false;
            }
            return true;
        }
 
        //确定
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            if (this.ReloadDataEvent != null)
            {
                var result = this.ReloadDataEvent.Invoke(int.Parse(this.txtSortCode.Text));
                if (result)
                {
                    XtraMessageBox.Show("更新成功!");
                }
                else
                {
                    XtraMessageBox.Show("更新失败!");
                    return;
                }
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
    }
}