tx
2025-04-10 2538101febc78f525945da72c7cdcb2589f9e6ea
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
 
 
namespace TProduct.WinFrmUI.TPump
{
    /// <summary>
    /// 性能测试
    /// </summary>
    public partial class FeatTestViewMainPage
    {
        #region 对话框操作
        private CalcFeatTestBaseDlg theCalcDataDlg = null;
        //初始化计算对话框
        private bool InitialCalcDialog(
            TProduct.Model.ProductSeries pump_series,
            TProduct.Model.ProductMainExPump pump,
            TProduct.Model.ProductMainExMotor motor,
            TProduct.Model.WorkBenchBase workBench,
            TProduct.Model.TestProjectItemView item,
            List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
        { 
            CalcFeatTestData1Dlg theCalc1Dlg = new CalcFeatTestData1Dlg();
            theCalc1Dlg.SetPumpInfo(pump_series, pump);
            theCalc1Dlg.SetMotorInfo(motor);
            theCalc1Dlg.SetTestInfo(workBench, item);
            theCalc1Dlg.InitialMonitorInfo(allMonitorList);
            theCalc1Dlg.Name = "CalcFeatTestData1Dlg";
            theCalc1Dlg.SetRecordType(TProduct.Model.eRecordType.Import);
            theCalc1Dlg.OnSaveRecord += (record, operateType) =>
            {//operateType表示操作类型 1 表示添加  2 表示更新  3表示删除
                SaveTestRecord(record, operateType);
            };
 
 
            theCalcDataDlg = theCalc1Dlg;
 
            return true;
        }
 
        #endregion
 
        #region  记录操作(增加和修改)
        /// <summary>
        /// 添加记录(手动输入,没有仪表数据)
        /// </summary>
        private void NewSingleRecordByInput()
        {
            //防止重复点击,否则会报错
            if (theCalcDataDlg.Visible)
                return;
 
            theCalcDataDlg.NewTestRecord(null, false);
 
            theCalcDataDlg.Show(this);
        }
        /// <summary>
        /// 手动导入记录(多条记录)
        /// </summary>
        private void NewMultiRecordByImport()
        {
            BatImportFeatTestPointHelper.ImportFile(this._allMonitorPointList, (records) =>
            {
                //if (this._allRecords == null)
                //  this._allRecords = new List<TProduct.Model.PumpFeatTestRecordViewModel>();
                return theCalcDataDlg.NewTestRecord4Save(records);
            });
 
 
 
            //if (this._allRecords == null || this._allRecords.Count == 0)
            //{
            //    RefreshItemPointNumber(); return;
            //}
 
            //RefreshItemPointNumber();
            //_monitorGridCtrl.RefreshData(this._allRecords);
            //_chartMainCtrl.SetRecordPoint(this._allRecords);
            //JudgeTestResult();//重新合格判断
        }
        private void EditFeatTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record)
        {
            //防止重复点击,否则会报错
            if (theCalcDataDlg.Visible)
                return;
 
            theCalcDataDlg.EditTestRecord(record);
 
            theCalcDataDlg.Show(this);
        }
        #endregion
 
        #region 删除
        /// <summary>
        /// 单条删除
        /// </summary>
        /// <param name="record"></param>
        private void DeleteFeatTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record)
        {
            if (this._allRecords == null)
                return;
            var f = this._allRecords.Find(x => x.ID == record.ID);
            if (f == null)
                return;
            DialogResult result1 = MessageBox.Show("请问是否删除所选测试数据", "询问",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Warning);
            if (result1 != DialogResult.Yes)
            {
                return;
            }
 
            this._allRecords.Remove(f);
            RefreshItemPointNumber();
            _monitorGridCtrl.RefreshData(this._allRecords);
            _chartMainCtrl.SetRecordPoint(this._allRecords);
            //if (_correctPtGridCtrl != null)
            //    _correctPtGridCtrl.RefreshData(this._allRecords);
        }
 
 
        /// <summary>
        /// 全部清空
        /// </summary>
        private void EmptyAllRecord()
        {
            if (this._allRecords == null || this._allRecords.Count() == 0)
                return;
            DialogResult result1 = MessageBox.Show("请问是否清空测试数据", "询问",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Warning);
            if (result1 != DialogResult.Yes)
            {
                return;
            }
 
            DialogResult result2 = MessageBox.Show("请问是否清空测试数据,删除后, 数据无法恢复,请再次确认", "询问",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Warning);
            if (result2 != DialogResult.Yes)
            {
                return;
            }
            new TProduct.BLL.PumpFeatTestRecord().ClearAllRecord(this._featTestItem);
            this._allRecords.Clear();
            _monitorGridCtrl.ClearData();
            _chartMainCtrl.EmptyRecordPoint();
            RefreshItemPointNumber();
        }
 
 
        #endregion
 
        #region 保存记录
        /// <summary>
        /// 保存记录 operateType表示操作类型 1 表示添加  2 表示更新  3表示删除
        /// </summary>
        /// <param name="record"></param>
        private void SaveTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record, int operateType)
        {
            if (operateType == 1)
            {
                if (this._allRecords == null)
                    this._allRecords = new List<TProduct.Model.PumpFeatTestRecordViewModel>();
 
                this._allRecords.Add(record);
            }
            if (this._allRecords == null || this._allRecords.Count == 0)
            {
                RefreshItemPointNumber(); return;
            }
 
            RefreshItemPointNumber();
            _monitorGridCtrl.RefreshData(this._allRecords);
            _chartMainCtrl.SetRecordPoint(this._allRecords);
            JudgeTestResult();//重新合格判断
        }
        #endregion
 
 
        //初始化实时测点数据表
        private void InitialMonitorGrid( )
        {
            if (_monitorGridCtrl == null)
            {
                _monitorGridCtrl = new GridFeatMonitorRecordCtrl();
                _monitorGridCtrl.Name = "GridFeatTestCtrl";
                _monitorGridCtrl.Dock = DockStyle.Fill;
                _monitorGridCtrl.OnAddRecordManu += () =>
                {//手动添加记录(单条记录)
                    NewSingleRecordByInput();
                };
                _monitorGridCtrl.OnImportRecordManu += () =>
                {//手动导入记录(多条记录)
                    NewMultiRecordByImport();
                };
                
                _monitorGridCtrl.OnDeleteRecord += (record) =>
                {
                    if (record == null)
                        return;
                    DeleteFeatTestRecord(record);
                };
                _monitorGridCtrl.OnEditRecord += (record) =>
                {
                    if (record == null)
                        return;
                        EditFeatTestRecord(record);
                };
                _monitorGridCtrl.OnEmptyAllRecord += () =>
                {
                    EmptyAllRecord();
                };
                _monitorGridCtrl.OnRefreshMotorEta += (records) =>
                {
                    if (_partInfoCtrl == null)
                        return  ;
                    var eta = _partInfoCtrl.GetMotorEta();
 
                    foreach (var record in this._allRecords)
                    {
                        theCalcDataDlg.EditTestRecord(record);
                        theCalcDataDlg.RefreshMotorEta(eta);
                    }
 
                    _monitorGridCtrl.RefreshData(this._allRecords);
                    _chartMainCtrl.SetRecordPoint(this._allRecords);
                };
 
                _monitorGridCtrl.OnRefreshCorrentByRatedn += (records) =>
                {
                    if (_currentPump == null)
                        return;
                    if (_partInfoCtrl == null)
                        return;
                    var ratedn = _partInfoCtrl.GetRatedn();
                    if (ratedn <= 10)
                        return;
 
                    foreach (var record in this._allRecords)
                    {
                        theCalcDataDlg.EditTestRecord(record);
                        theCalcDataDlg.RefreshRatedn(ratedn);
                    }
 
 
                    _monitorGridCtrl.RefreshData(this._allRecords);
                    _chartMainCtrl.SetRecordPoint(this._allRecords);
                };
                tabPageGrid.Controls.Add(_monitorGridCtrl);
            }
            _monitorGridCtrl.SetBindingData(_allMonitorPointList);
            _monitorGridCtrl.RefreshData(this._allRecords);
        }
 
 
 
        private void RefreshItemPointNumber()
        {
            if (this._allRecords == null || this._allRecords.Count == 0)
            {
                if (this._featTestItem.PointNumber != 0)
                {
                    this._featTestItem.PointNumber = 0;
                    new BLL.TestProjectItem().UpdatePointNumberOnly(this._featTestItem.ItemID,
                        this._featTestItem.PointNumber);
                }
                return;
            }
            else
            {
                if (this._featTestItem.PointNumber != this._allRecords.Count)
                {
                    this._featTestItem.PointNumber = this._allRecords.Count;
                    new BLL.TestProjectItem().UpdatePointNumberOnly(this._featTestItem.ItemID,
                        this._featTestItem.PointNumber);
                }
            }
        }
 
 
 
 
    }
}