qin
2025-03-18 8044d55d7b2ef859e926f6968b239fa3212552bb
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using DevExpress.XtraEditors.Controls;
 
namespace PBS.WinFrmUI
{
    public partial class FacilitiesCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public FacilitiesCtrl()
        {
            InitializeComponent();
        }
 
        //基础验证
        public bool Valid()
        {
            bool isExist = true;
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtName, "必填项");
                isExist = false;
            }
            if (string.IsNullOrEmpty(this.txtFloor.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtFloor, "必填项");
                isExist = false;
            }
            if (string.IsNullOrEmpty(this.txtFloorHeight.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtFloorHeight, "必填项");
                isExist = false;
            }
            if (string.IsNullOrEmpty(this.txtFloorHouseHolds.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtFloorHouseHolds, "必填项");
                isExist = false;
            }
            if (string.IsNullOrEmpty(this.txtConstantP.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtConstantP, "必填项");
                isExist = false;
            }
            /*  if (this.comboBoxCompletePlant.Text == "请选择")
              {
                  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, "必填项");
                isExist = false;
            }
            if (string.IsNullOrEmpty(this.txtMaxWaterDemand.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtMaxWaterDemand, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(this.txtWaterPressure.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtWaterPressure, "必填项");
                return false;
            }
            return isExist;
        }
 
        private Vmo.FacilityVmo _facilityVmo = new Vmo.FacilityVmo();
 
        public async Task SetBindingData()
        {
            this.textEditWaterModel.Properties.AddEnum(typeof(HStation.PBS.eSupplyMode));
            this.comboBoxWaterSupply.Properties.AddEnum(typeof(HStation.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;
        }
 
        public void SetData(Vmo.FacilityVmo model)
        {
            _facilityVmo = model;
            this.txtName.EditValue = model.Name;
            this.txtFloor.EditValue = model.Floor;
            this.txtFloorHouseHolds.EditValue = model.Households;
            this.txtFloorHeight.EditValue = model.FloorHeight;
            this.txtMaxWaterDemand.EditValue = model.MaxWaterDemand;
            this.txtWaterPressure.EditValue = model.TerminalPressure;
            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;
        }
 
        //获取文本信息
        public Vmo.FacilityVmo GetData()
        {
            if (!Valid())
                return null;
            _facilityVmo.Floor = int.Parse(txtFloor.Text);
            _facilityVmo.Name = txtName.Text;
            if (this.textEditWaterModel.EditValue != null)
            {
                _facilityVmo.SupplyMode = (HStation.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;
            }
            return _facilityVmo;
        }
    }
}