duheng
2024-07-10 2a41fffc9f962999ba163c3b471873b6b96f05bc
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
using DevExpress.XtraEditors;
 
namespace HStation.WinFrmUI.Xhs.PumpProject
{
    /// <summary>
    /// 设置使用状态
    /// </summary>
    public partial class SetUseStatusDlg : XtraForm
    {
        public SetUseStatusDlg()
        {
            InitializeComponent();
        }
 
        /// <summary>
        /// 回调函数
        /// </summary>
        public event Func<Yw.Model.eUseStatus, Task<bool>> ReloadDataEvent;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.eUseStatus UseStatus)
        {
            switch (UseStatus)
            {
                case Yw.Model.eUseStatus.Enable: this.radioGroup1.SelectedIndex = 1; break;
                case Yw.Model.eUseStatus.Disable: this.radioGroup1.SelectedIndex = 0; break;
                default: break;
            }
        }
 
        //确定
 
        private async void btnOk_Click(object sender, EventArgs e)
        {
            var status = Yw.Model.eUseStatus.Enable;
            if (this.radioGroup1.SelectedIndex == 0)
                status = Yw.Model.eUseStatus.Disable;
            else if (this.radioGroup1.SelectedIndex == 1)
                status = Yw.Model.eUseStatus.Enable;
 
            if (this.ReloadDataEvent != null)
            {
                var result = await this.ReloadDataEvent.Invoke(status);
                if (result)
                {
                    MessageBoxHelper.ShowSuccess("更新成功!");
                }
                else
                {
                    MessageBoxHelper.ShowError("更新失败!");
                    return;
                }
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}