qin
2025-03-20 330002911a64ea58d6834b64228870228eb75391
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
using DevExpress.XtraEditors.Controls;
using IBox.WinFrmUI;
using System.Net.NetworkInformation;
 
namespace PBS.WinFrmUI.Box
{
    public partial class ChoiceFacilityDlg : DevExpress.XtraEditors.XtraForm
    {
        public ChoiceFacilityDlg()
        {
            InitializeComponent();
        }
 
        public event Action<bool> VisibleChanged;
 
        public async void SetDataSource()
        {
            var allFac = await new PBS.BLL.Facility().GetAll();
            foreach (var item in allFac)
            {
                var imageItem = new ImageComboBoxItem(item.Name, item.ID);
                this.imageComboBoxEdit1.Properties.Items.Add(imageItem);
            }
            this.imageComboxConnectType.Properties.AddEnum(typeof(eConnectionType));
        }
 
        private bool Verify()
        {
            bool isContinue = true;
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.TxtConnectionAddress.Text))
            {
                this.dxErrorProvider1.SetError(this.TxtConnectionAddress, "请输入连接地址");
                isContinue = false;
            }
            return isContinue;
        }
 
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (!Verify())
            {
                return;
            }
            IBoxHelper.ConnectionAddress = this.TxtConnectionAddress.Text;
            IBoxHelper.ConnectionType = (eConnectionType)this.imageComboxConnectType.EditValue;
            if (IBoxHelper.Ping())
            {
                VisibleChanged.Invoke(true);
            }
            this.Close();
         }
 
        private async void imageComboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var select = this.imageComboBoxEdit1.EditValue;
            if (select != null)
            {
                var model = await new PBS.BLL.Facility().GetByID((long)select);
                this.imageComboxConnectType.EditValue = model.ConnectionType;
                this.TxtConnectionAddress.Text = model.ConnectionAddress;
            }
        }
    }
}