lixiaojun
2024-12-13 c4049242a1cc73da8210f381db72d1a807bd08d4
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
using DevExpress.XtraEditors;
 
namespace HStation.WinFrmUI.Assets
{
    /// <summary>
    /// 设置使用状态
    /// </summary>
    public partial class SetDefaultStatusDlg : XtraForm
    {
        public SetDefaultStatusDlg()
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
        }
 
        /// <summary>
        /// 回调函数
        /// </summary>
        public event Func<bool, Task<bool>> ReloadDataEvent;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(bool IsDefault)
        {
            switch (IsDefault)
            {
                case true: this.radioGroup1.SelectedIndex = 1; break;
                case false: this.radioGroup1.SelectedIndex = 0; break;
            }
        }
 
        //确定
 
        private async void btnOk_Click(object sender, EventArgs e)
        {
            bool status = false;
            if (this.radioGroup1.SelectedIndex == 0)
                status = false;
            else if (this.radioGroup1.SelectedIndex == 1)
                status = true;
            if (this.ReloadDataEvent != null)
            {
                var result = await this.ReloadDataEvent.Invoke(status);
                if (result)
                {
                    XtraMessageBox.Show("更新成功!");
                }
                else
                {
                    XtraMessageBox.Show("更新失败!");
                    return;
                }
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}