duheng
2025-02-07 c5136b7517998a076f1bd2e4abdda01decae8b6f
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
69
70
71
using DevExpress.XtraEditors;
using IStation.Model;
using IStation.Untity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.Basic
{
    public partial class EditMonitorDlg : DevExpress.XtraEditors.XtraForm
    {
        public EditMonitorDlg()
        {
            InitializeComponent();
        }
 
        private Model.MonitorPointExSignalExSignalType _model = null;
        public event Func<MonitorPointExSignalExSignalType ,bool> ReloadDataEvent=null;
       
        public void SetBindingData( Model.MonitorPointExSignalExSignalType model, string name)
        {
            _model=new MonitorPointExSignalExSignalType(model);
            this.TxtEditPoint.EditValue= name;
           
            InitialData();
        }
        //初始化数据
        private void InitialData()
        {
            var flags = ConstStringHelper.GetValues<LogicFlags>();
            this.selectFlagsPopupCtrl1.SetBindingData(flags, _model.Flags);
        }
 
        private bool Virify()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.TxtEditPoint.Text))
            {
                dxErrorProvider1.SetError(this.TxtEditPoint,"必填项");
                return true;
            }
            return false;
        }
 
        
        //确定
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (Virify())
                return;
            _model.Name= this.TxtEditPoint.Text;
            _model.Flags = selectFlagsPopupCtrl1.SelectedFlags;
            var isok = this.ReloadDataEvent.Invoke(_model);
            if (isok == false)
            {
                XtraMessageBox.Show("修改失败!");
                return;
            }
            XtraMessageBox.Show("修改成功!");
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
         
    }
}