duheng
2025-03-28 e411302bca8857e102443a5250c82b9580ef07a3
WinFrmUI/PBS.WinFrmUI/02-facility/00-core/FacilitiesCtrl.cs
@@ -1,16 +1,12 @@
namespace PBS.WinFrmUI
using DevExpress.XtraEditors.Controls;
namespace PBS.WinFrmUI
{
    public partial class FacilitiesCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public FacilitiesCtrl()
        {
            InitializeComponent();
            this.Load += FacilitiesCtrl_Load;
        }
        private void FacilitiesCtrl_Load(object sender, EventArgs e)
        {
            SetBindingData();
        }
        //基础验证
@@ -48,6 +44,11 @@
                  this.dxErrorProvider1.SetError(this.comboBoxCompletePlant, "必填项");
                  isExist = false;
              }*/
            if (this.textEditWaterModel.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.textEditWaterModel, "必填项");
                isExist = false;
            }
            if (this.comboBoxWaterSupply.Text == "请选择")
            {
                this.dxErrorProvider1.SetError(this.comboBoxWaterSupply, "必填项");
@@ -68,11 +69,20 @@
        private Vmo.FacilityVmo _facilityVmo = new Vmo.FacilityVmo();
        public async void SetBindingData()
        public async Task SetBindingData()
        {
            this.textEditWaterModel.Properties.AddEnum(typeof(HStation.PBS.eSupplyMode));
            this.comboBoxWaterSupply.Properties.AddEnum(typeof(HStation.PBS.eWaterSupply));
            this.textEditWaterModel.Properties.AddEnum(typeof(PBS.eSupplyMode));
            this.comboBoxWaterSupply.Properties.AddEnum(typeof(PBS.eWaterSupply));
            var allPackages = await new HStation.BLL.AssetsPackageMain().GetAll();
            foreach (var item in allPackages)
            {
                var imageItem = new ImageComboBoxItem(item.Name, item.ID);
                this.comboBoxPackages.Properties.Items.Add(imageItem);
            }
            var list = await new PBS.BLL.Place().GetAll();
            this.treeListLookUpEdit1TreeList.DataSource = list;
            this.imageComboBoxConnectionType.Properties.AddEnum(typeof(PBS.eConnectionType));
            this.imageComboBoxConnectionType.SelectedIndex = 1;
        }
        public void SetData(Vmo.FacilityVmo model)
@@ -87,6 +97,11 @@
            this.comboBoxWaterSupply.EditValue = model.WaterSupply;
            this.txtConstantP.EditValue = model.ConstantPressure;
            this.textEditWaterModel.EditValue = model.SupplyMode;
            this.txtEditPlace.EditValue = model.PlaceID;
            this.comboBoxPackages.EditValue = model.PackageID;
            this.imageComboBoxConnectionType.EditValue = model.ConnectionType;
            this.textEditConnectionAddress.EditValue = model.ConnectionAddress;
            this.textEditMaxHeight.EditValue = model.MaxHeight;
        }
        //获取文本信息
@@ -96,16 +111,37 @@
                return null;
            _facilityVmo.Floor = int.Parse(txtFloor.Text);
            _facilityVmo.Name = txtName.Text;
            _facilityVmo.SupplyMode = HStation.PBS.eSupplyMode.WaterTank;
            if (this.textEditWaterModel.EditValue != null)
            {
                _facilityVmo.SupplyMode = (PBS.eSupplyMode)this.textEditWaterModel.EditValue;
            }
            _facilityVmo.UseStatus = Yw.Vmo.eUseStatus.Enable;
            _facilityVmo.FloorHeight = double.Parse(txtFloorHeight.Text);
            _facilityVmo.Households = int.Parse(txtFloorHouseHolds.Text);
            _facilityVmo.ConstantPressure = double.Parse(txtConstantP.Text);
            _facilityVmo.MaxWaterDemand = Convert.ToDouble(txtMaxWaterDemand.EditValue);
            _facilityVmo.TerminalPressure = Convert.ToDouble(txtWaterPressure.EditValue);
            if (this.comboBoxPackages.EditValue != null)
            {
                _facilityVmo.PackageID = (long)this.comboBoxPackages.EditValue;
            }
            if (this.txtEditPlace.EditValue != null)
            {
                _facilityVmo.PlaceID = Convert.ToInt64(this.txtEditPlace.EditValue);
            }
            if (comboBoxWaterSupply.EditValue != null)
            {
                _facilityVmo.WaterSupply = (HStation.PBS.eWaterSupply)comboBoxWaterSupply.EditValue;
                _facilityVmo.WaterSupply = (PBS.eWaterSupply)comboBoxWaterSupply.EditValue;
            }
            if (this.imageComboBoxConnectionType.EditValue != null)
            {
                _facilityVmo.ConnectionType = (PBS.eConnectionType)this.imageComboBoxConnectionType.EditValue;
            }
            _facilityVmo.ConnectionAddress = this.textEditConnectionAddress.Text;
            if (this.textEditMaxHeight.EditValue != null)
            {
                double.TryParse(this.textEditMaxHeight.Text, out double maxHeight);
                _facilityVmo.MaxHeight = maxHeight;
            }
            return _facilityVmo;
        }