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);
|
}
|
}
|
}
|
|
|
|
|
}
|
}
|