qin
2025-03-20 330002911a64ea58d6834b64228870228eb75391
WinFrmUI/PBS.WinFrmUI.IBox/ChoiceFacilityDlg.cs
@@ -1,4 +1,8 @@
namespace PBS.WinFrmUI.Box
using DevExpress.XtraEditors.Controls;
using IBox.WinFrmUI;
using System.Net.NetworkInformation;
namespace PBS.WinFrmUI.Box
{
    public partial class ChoiceFacilityDlg : DevExpress.XtraEditors.XtraForm
    {
@@ -9,14 +13,53 @@
        public event Action<bool> VisibleChanged;
        public void SetDataSource()
        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)
        {
            VisibleChanged.Invoke(false);
            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;
            }
        }
    }
}