lixiaojun
2024-11-25 839d9f96be96108dc9ca9359b3db32596e7e2454
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
namespace Yw.WinFrmUI
{
    public partial class AddHydroWorkingDlg : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public AddHydroWorkingDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
        }
 
        /// <summary>
        /// 重载数据事件
        /// </summary>
        public event Action<HydroWorkingVmo> ReloadDataEvent;
 
        private HydroWorkingVmo _working = null;//工况
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(HydroWorkingVmo working)
        {
            _working = working;
            this.txtName.EditValue = working.Name;
            this.txtDescription.EditValue = working.Description;
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtName, "必填项");
                return false;
            }
            return true;
        }
 
        //确定
        private async void GeneralOkAndCancelCtrl1_OkEvent()
        {
            if (!Valid())
            {
                return;
            }
            _working.Name = this.txtName.Text.Trim();
            _working.Description = this.txtDescription.Text.Trim();
            _working.ID = await BLLFactory<Yw.BLL.HydroWorking>.Instance.Insert(_working);
            if (_working.ID < 1)
            {
                TipFormHelper.ShowError("新增失败!");
                return;
            }
            this.ReloadDataEvent?.Invoke(_working);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
 
    }
}