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