lixiaojun
2025-02-13 bfd1b73be85fd66ee37031eadcd4d09e7dafb52f
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
namespace Yw.WinFrmUI
{
    public partial class SetHydroCoolingDlg : DevExpress.XtraEditors.XtraForm
    {
        public SetHydroCoolingDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
        }
 
        /// <summary>
        /// 返回数据事件
        /// </summary>
        public event Action<List<Yw.Model.HydroCoolingInfo>> ReloadDataEvent;
 
 
        private List<Yw.Model.HydroCoolingInfo> _allVisualList = null; //所有构件列表
        private HydroChangeHelper _changeHelper = null;//改变辅助类
        private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData
            (
                Yw.Model.HydroCoolingInfo visual,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            var allVisualList = visual == null ? null : new List<Yw.Model.HydroCoolingInfo>() { visual };
            SetBindingData(allVisualList, changeHelper, propStatusHelper);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData
            (
                List<Yw.Model.HydroCoolingInfo> allVisualList,
                HydroChangeHelper changeHelper = null,
                HydroPropStatusHelper propStatusHelper = null
            )
        {
            _allVisualList = allVisualList;
            _changeHelper = changeHelper;
            _propStatusHelper = propStatusHelper;
            if (_allVisualList != null && _allVisualList.Count == 1)
            {
                var parter = _allVisualList.First();
                this.txtMaterial.EditValue = parter.Material;
                this.txtCaliber.EditValue = parter.Caliber;
                this.txtCoefficient.EditValue = parter.Coefficient;
                this.txtLowerLimit.EditValue = parter.LowerLimit;
            }
        }
 
        //确定
        private void GeneralOkAndCancelCtrl1_OkEvent()
        {
            if (_allVisualList == null || _allVisualList.Count < 1)
            {
                return;
            }
            string material = this.txtMaterial.Text.Trim();
            double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString());
            double? coefficient = this.txtCoefficient.EditValue == null ? null : double.Parse(this.txtCoefficient.EditValue.ToString());
            double? lowerLimit = this.txtLowerLimit.EditValue == null ? null : double.Parse(this.txtLowerLimit.EditValue.ToString());
            _allVisualList.ForEach(x =>
            {
                if (!string.IsNullOrEmpty(material))
                {
                    if (x.Material != material)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Material), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Material = material;
                }
                if (caliber.HasValue)
                {
                    if (x.Caliber != caliber.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Caliber), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Caliber = caliber.Value;
                }
                if (coefficient.HasValue)
                {
                    if (x.Coefficient != coefficient.Value)
                    {
                        _changeHelper?.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.Coefficient), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.Coefficient = coefficient.Value;
                }
                if (lowerLimit.HasValue)
                {
                    if (x.LowerLimit != lowerLimit.Value)
                    {
                        _changeHelper.Append(x, eChangeType.Update);
                        _propStatusHelper?.UpdatePropStatus(x.Code, nameof(x.LowerLimit), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过设置组件修改");
                    }
                    x.LowerLimit = lowerLimit.Value;
                }
            });
            this.ReloadDataEvent?.Invoke(_allVisualList);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
 
 
    }
}