duheng
2025-03-21 c0be7c001375f73e2c3b49a1b1d447b6fc297bdd
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
namespace PBS.WinFrmUI.Hydro
{
    public partial class InputDlg : DevExpress.XtraEditors.XtraForm
    {
        public InputDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent; 
        }
 
        /// <summary>
        /// 重载数据
        /// </summary>
        public event Action<double> ReloadDataEvent;
 
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(string title,double? value=null)
        {
            this.Text = title;
            this.txtValue.EditValue = value;
        }
 
        //数据验证
        private bool Verify()
        {
            this.dxErrorProvider1.ClearErrors();
            if (double.TryParse(this.txtValue.Text,out double value))
            {
                this.dxErrorProvider1.SetError(this.txtValue, "必填项");
                return false;
            }
          
            return true;
        }
 
        //确定
        private void GeneralOkAndCancelCtrl1_OkEvent()
        {
            if (!Verify())
            {
                return;
            }
            var value = Convert.ToDouble(this.txtValue.Text);
            this.ReloadDataEvent?.Invoke(value);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
 
    }
}