Shuxia Ning
2024-07-22 952cb084d1f31a1c2634b91d4d03374c359b52da
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
65
66
67
68
using DevExpress.XtraEditors.Controls;
 
namespace HStation.WinFrmUI.Xhs.PumpProduct
{
    public partial class AddPumpProductSeriesDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddPumpProductSeriesDlg()
        {
            InitializeComponent();
        }
 
        public event Func<AddPumpSeriesDto, Task<bool>> ReloadDataEvent = null;
 
        private Yw.BLL.SysCatalog _bll = null;
 
        //数据验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(NameTextEdit.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(TextEditCatalogChoice.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextEditCatalogChoice, "必填项");
                return false;
            }
            return true;
        }
 
        //完成
        private async void BtnOk_ClickAsync(object sender, EventArgs e)
        {
            var model = new AddPumpSeriesDto();
            model.Name = NameTextEdit.Text.Trim();
            model.TagName = TagNameTextEdit.Text.Trim();
            model.MotorFrequency = MotorFrequencyTextEdit.Text.Trim();
            if (long.TryParse(TextEditCatalogChoice.EditValue.ToString(), out long catalogID))
            {
                model.CatalogID = catalogID;
            }
            if (await this.ReloadDataEvent.Invoke(model))
            {
                MessageBoxHelper.ShowSuccess("添加成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("添加失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
        //初始化
        private async void AddPumpProductSeriesDlg_Load(object sender, EventArgs e)
        {
            _bll = new Yw.BLL.SysCatalog();
            var alllist = await _bll.GetAll();
            foreach (var item in alllist)
            {
                var imageItem = new ImageComboBoxItem(item.Name, item.ID);
                TextEditCatalogChoice.Properties.Items.Add(imageItem);
            }
        }
    }
}