tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TProduct.Model;
 
namespace TProduct.WinFrmUI.TestBench
{
    /// <summary>
    /// 
    /// </summary>
    public partial class MgrPumpBenchPressMonitorDlg : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public MgrPumpBenchPressMonitorDlg()
        {
            InitializeComponent();
 
 
            this.gridViewMain.SetNormalEditView(35);
            this.gridViewMain.SetGridMianViewColor();
            this.gridViewMain.RegistCustomDrawRowIndicator();
            //   this.gridViewMain.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
            //   this.gridViewMain.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
            //   this.gridViewMain.OptionsSelection.MultiSelect = false;//单选
            //   this.gridViewMain.OptionsBehavior.Editable = false;//只读
            //   this.gridViewMain.BestFitColumns();
            //   this.gridViewMain.IndicatorWidth = 20;
 
 
            //this.gridViewMain.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(this.GridViewMain_RowClick);
            //this.gridViewMain.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.GridViewMain_CustomDrawRowIndicator);
            //this.gridViewMain.CustomUnboundColumnData += new DevExpress.XtraGrid.Views.Base.CustomColumnDataEventHandler(this.GridViewMain_CustomUnboundColumnData);
            ////this.gridViewMain.DoubleClick += new System.EventHandler(this.GridViewMain_DoubleClick);
            //this.gridViewMain.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(this.GridViewMain_RowCellClick);
 
 
        }
 
        private void MgrPumpBenchPressMonitorDlg_Load(object sender, EventArgs e)
        {
 
        }
 
        private class CurrentViewModel : Model.WorkBenchBase
        {
            public CurrentViewModel() { }
            public CurrentViewModel(
                Model.WorkBenchBase work) : base(work)
            {
                this.NameNew = work.Name;
                var pipeParas = new Model.PipeParas4Pump(work.PipeParas);
                if (pipeParas != null)
                {
                    if (pipeParas.InletDia != null)
                        this.InletDia = pipeParas.InletDia;
                    if (pipeParas.OutletDia != null)
                        this.OutletDia = pipeParas.OutletDia;
                }
            }
            public double? OutletDia { get; set; }
            public double? InletDia { get; set; }
            public string NameNew { get; set; }
 
            public TProduct.Model.WorkBenchMonitorPoint InletPressMonitor { get; set; }
 
            public TProduct.Model.WorkBenchMonitorPoint OutletPressMonitor { get; set; }
 
            public long InletPressMonitorID { get; set; }
            public long OutletPressMonitorID { get; set; }
            public string InletPressMonitorStatus { get; set; }
            public string OutletPressMonitorStatus { get; set; }
            public double? InletPressMonitorDia { get; set; }
            public double? OutletPressMonitorDia { get; set; }
            public double? InletPressMonitorElevation { get; set; }
            public double? OutletPressMonitorElevation { get; set; }
        }
 
        private List<CurrentViewModel> _bindList = null;
        private List<Model.ProductStyle> _allProductStyle = null;
 
        /// <summary>
        /// 初始化
        /// </summary>
        public void SetBindingData()
        {
            WaitFrmHelper.ShowWaitForm();
            _allProductStyle = new BLL.ProductStyle().GetByProductType(Model.eProductType.Pump);
            var allBenchs = new BLL.WorkBenchBase().GetByProductType(Model.eProductType.Pump);
            if (allBenchs == null)
                allBenchs = new List<Model.WorkBenchBase>();
            var allPoints = new BLL.WorkBenchMonitorPoint().GetAll();
 
 
            _bindList = new List<CurrentViewModel>();
            foreach (var work in allBenchs)
            {
                var v = new CurrentViewModel(work);
 
                var point_inlet = allPoints.Find(x => x.BenchID == work.ID && x.Property == TProduct.Model.MonitorTypeProperty.进口);
                if (point_inlet != null)
                {
                    v.InletPressMonitor = point_inlet;
                    v.InletPressMonitorStatus = "已配置";
                    v.InletPressMonitorID = point_inlet.ID;
                    v.InletPressMonitorDia = point_inlet.PipeDia;
                    v.InletPressMonitorElevation = point_inlet.Elevation;
                }
                else
                {
                    v.InletPressMonitorStatus = "未配置";
                }
                var point_outlet = allPoints.Find(x => x.BenchID == work.ID && x.Property == TProduct.Model.MonitorTypeProperty.出口);
                if (point_outlet != null)
                {
                    v.OutletPressMonitor = point_outlet;
                    v.OutletPressMonitorStatus = "已配置";
                    v.OutletPressMonitorID = point_outlet.ID;
                    v.OutletPressMonitorDia = point_outlet.PipeDia;
                    v.OutletPressMonitorElevation = point_outlet.Elevation;
                }
                else
                {
                    v.OutletPressMonitorStatus = "未配置";
                }
                _bindList.Add(v);
            }
            this.bindingSource1.DataSource = _bindList;
            this.bindingSource1.ResetBindings(false);
            WaitFrmHelper.HideWaitForm();
        }
 
 
 
 
        private void barButSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            List<WorkBenchMonitorPoint> allEditPoints = new List<WorkBenchMonitorPoint>();
            List<WorkBenchBase> allBase = new List<WorkBenchBase>();
 
            foreach (var v in _bindList)
            {
                if (v.InletPressMonitor != null)
                {
                    if (v.InletPressMonitorElevation != v.InletPressMonitor.Elevation ||
                        v.InletPressMonitorDia != v.InletPressMonitor.PipeDia)
                    {
                        v.InletPressMonitor.PipeDia = v.InletPressMonitorDia;
                        v.InletPressMonitor.Elevation = v.InletPressMonitorElevation;
                        allEditPoints.Add(v.InletPressMonitor);
                    }
 
 
                }
                if (v.OutletPressMonitor != null)
                {
                    if (v.OutletPressMonitorElevation != v.OutletPressMonitor.Elevation ||
v.OutletPressMonitorDia != v.OutletPressMonitor.PipeDia)
                    {
                        v.OutletPressMonitor.PipeDia = v.OutletPressMonitorDia;
                        v.OutletPressMonitor.Elevation = v.OutletPressMonitorElevation;
                        allEditPoints.Add(v.OutletPressMonitor);
                    }
                }
 
                bool isHaveAdd = false;
                var pipeParas = new Model.PipeParas4Pump(v.PipeParas);
                if (pipeParas != null)
                {
                    if (v.InletDia != pipeParas.InletDia ||
                        v.OutletDia != pipeParas.OutletDia)
                    {
                        pipeParas.OutletDia = v.OutletDia;
                        pipeParas.InletDia = v.InletDia;
                        v.PipeParas = pipeParas.ToJsonString();
                        isHaveAdd = true;
                        allBase.Add(new WorkBenchBase(v));
                    }
                }
                if (v.Name != v.NameNew)
                {
                    v.Name = v.NameNew;
                    if (!isHaveAdd)
                        allBase.Add(new WorkBenchBase(v));
                }
            }
            if (allEditPoints.Count > 0)
            {
                new BLL.WorkBenchMonitorPoint().Updates(allEditPoints);
            }
            if (allBase.Count > 0)
            {
                new BLL.WorkBenchBase().Updates(allBase);
            }
            MessageBox.Show("已更新");
        }
 
        private void barButReset_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
 
        }
    }
}