lixiaojun
2024-12-02 f460fd2c628ab56db7450d70f3b7ad4b3524e6c8
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
namespace Yw.WinFrmUI
{
    public partial class SetHydroValveDlg : DevExpress.XtraEditors.XtraForm
    {
        public SetHydroValveDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
        }
 
        /// <summary>
        /// 重载数据事件
        /// </summary>
        public event Action<List<Yw.Model.HydroValveInfo>> ReloadDataEvent;
 
        //所有构件列表
        private List<Yw.Model.HydroValveInfo> _allVisualList = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroValveInfo visial)
        {
            var allParterList = visial == null ? null : new List<Yw.Model.HydroValveInfo>() { visial };
            this.SetBindingData(allParterList);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Yw.Model.HydroValveInfo> allParterList)
        {
            _allVisualList = allParterList;
            if (_allVisualList != null && _allVisualList.Count == 1)
            {
                var parter = _allVisualList.First();
                this.imgCmbLinkStatus.EditValue = parter.LinkStatus;
                this.txtMaterial.EditValue = parter.Material;
                this.txtDiameter.EditValue = parter.Diameter;
                this.txtMinorLoss.EditValue = parter.MinorLoss;
            }
        }
 
 
        //确定
        private void GeneralOkAndCancelCtrl1_OkEvent()
        {
            if (_allVisualList == null || _allVisualList.Count < 1)
            {
                return;
            }
            var linkStatus = this.imgCmbLinkStatus.EditValue == null ? null : this.imgCmbLinkStatus.EditValue.ToString();
            var material = string.IsNullOrEmpty(this.txtMaterial.Text.Trim()) ? null : this.txtMaterial.Text.Trim();
            double? diameter = this.txtDiameter.EditValue == null ? null : double.Parse(this.txtDiameter.EditValue.ToString());
            double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
            _allVisualList.ForEach(x =>
            {
                if (!string.IsNullOrEmpty(linkStatus))
                {
                    x.LinkStatus = linkStatus;
                }
                if (!string.IsNullOrEmpty(material))
                {
                    x.Material = material;
                }
                if (diameter.HasValue)
                {
                    x.Diameter = diameter.Value;
                }
                if (minorLoss.HasValue)
                {
                    x.MinorLoss = minorLoss.Value;
                }
                if (x.LinkStatus == Yw.Hydro.ValveStatus.Closed)
                {
                    x.OpeningDegree = 0;
                }
            });
            this.ReloadDataEvent?.Invoke(_allVisualList);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
    }
}