lixiaojun
2024-11-04 3effbd15ec04bbc39514c6904fa71d00631c96eb
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
using DevExpress.XtraSpreadsheet.Model;
 
namespace Yw.WinFrmUI
{
    public partial class HydroHydrantBulkSetDlg : DevExpress.XtraEditors.XtraForm
    {
        public HydroHydrantBulkSetDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
        }
 
        public event Action<List<Yw.Model.HydroHydrantInfo>> ReloadDataEvent;
 
 
        private List<Yw.Model.HydroHydrantInfo> _allHydrantList = null;
 
        /// <summary>
        /// 
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroHydrantInfo> allHydrantList)
        {
            _allHydrantList = allHydrantList;
            if (_allHydrantList != null && _allHydrantList.Count == 1)
            {
                var hydrant = _allHydrantList.First();
                this.txtElev.EditValue = hydrant.Elev;
                this.txtMinorLoss.EditValue = hydrant.MinorLoss;
                this.txtDemand.EditValue = hydrant.Demand;
                this.txtCoefficient.EditValue = hydrant.Coefficient;
            }
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (this.txtElev.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.txtElev, "必填项");
                return false;
            }
            if (this.txtCoefficient.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.txtCoefficient, "必填项");
                return false;
            }
            return true;
        }
 
        //
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (_allHydrantList == null || _allHydrantList.Count < 1)
            {
                return;
            }
            if (!Valid())
            {
                return;
            }
            var elev = double.Parse(this.txtElev.EditValue.ToString());
            double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
            double? demand = this.txtDemand.EditValue == null ? null : double.Parse(this.txtDemand.EditValue.ToString());
            var coefficient = double.Parse(this.txtCoefficient.EditValue.ToString());
            _allHydrantList.ForEach(x =>
            {
                x.Elev = elev;
                x.MinorLoss = minorLoss;
                x.Demand = demand;
                x.Coefficient = coefficient;
            });
            this.ReloadDataEvent?.Invoke(_allHydrantList);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
 
    }
}