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
namespace Yw.WinFrmUI
{
    public partial class HydroFourlinkBulkSetDlg : DevExpress.XtraEditors.XtraForm
    {
        public HydroFourlinkBulkSetDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
        }
 
        public event Action<List<Yw.Model.HydroFourlinkInfo>> ReloadDataEvent;
 
 
        private List<Yw.Model.HydroFourlinkInfo> _allFourlinkList = null;
 
        /// <summary>
        /// 
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroFourlinkInfo> allFourlinkList)
        {
            _allFourlinkList = allFourlinkList;
            if (_allFourlinkList != null && _allFourlinkList.Count == 1)
            {
                var threelink = _allFourlinkList.First();
                this.txtElev.EditValue = threelink.Elev;
                this.txtMinorLoss.EditValue = threelink.MinorLoss;
                this.txtDemand.EditValue = threelink.Demand;
                this.txtMaterial.EditValue = threelink.Material;
                this.txtCaliber.EditValue = threelink.Caliber;
            }
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (this.txtElev.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.txtElev, "必填项");
                return false;
            }
            return true;
        }
 
        //
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (_allFourlinkList == null || _allFourlinkList.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 material = this.txtMaterial.Text.Trim();
            double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString());
            _allFourlinkList.ForEach(x =>
            {
                x.Elev = elev;
                x.MinorLoss = minorLoss;
                x.Demand = demand;
                x.Material = material;
                x.Caliber = caliber;
            });
            this.ReloadDataEvent?.Invoke(_allFourlinkList);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}