using DevExpress.Charts.Native;
|
using DevExpress.XtraEditors;
|
using Eventech.Common;
|
using IStation.WinFrmUI.Basic.basic.pumpmgr;
|
using System;
|
using System.ComponentModel;
|
using System.Linq;
|
|
namespace IStation.WinFrmUI.Basic
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class PumpMgrGridCtrl : XtraUserControl
|
{
|
public PumpMgrGridCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView();
|
this.gridView1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
this.layoutControl1.SetupLayoutControl();
|
}
|
|
public class CurrentViewModel : Model.Product<Model.Pump>
|
{
|
public CurrentViewModel() { }
|
public CurrentViewModel(Model.Product<Model.Pump> rhs) : base(rhs)
|
{
|
if (rhs.RatedParas != null)
|
{
|
this.Qr = rhs.RatedParas.Qr;
|
this.Hr = rhs.RatedParas.Hr;
|
this.Nr = rhs.RatedParas.Nr;
|
this.Pr = rhs.RatedParas.Pr;
|
this.Er = rhs.RatedParas.Er;
|
this.NPSHr = rhs.RatedParas.NPSHr;
|
this.StNumr = rhs.RatedParas.StNumr;
|
this.Ic = rhs.RatedParas.Ic;
|
this.Oc = rhs.RatedParas.Oc;
|
this.IOd = rhs.RatedParas.IOd;
|
this.IsBp = rhs.RatedParas.IsBp ? "是" : "否";
|
this.IsSxp = rhs.RatedParas.IsSxp ? "是" : "否";
|
}
|
}
|
public double Qr { get; set; }
|
public double Hr { get; set; }
|
public double Nr { get; set; }
|
public double Pr { get; set; }
|
public double Er { get; set; }
|
public double NPSHr { get; set; }
|
public int StNumr { get; set; }
|
public double? Ic { get; set; }
|
public double? Oc { get; set; }
|
public double? IOd { get; set; }
|
public string IsBp { get; set; }
|
public string IsSxp { get; set; }
|
|
public void Reset(CurrentViewModel vm)
|
{
|
base.Reset(vm);
|
if (vm.RatedParas != null)
|
{
|
this.Qr = vm.Qr;
|
this.Hr = vm.Hr;
|
this.Nr = vm.Nr;
|
this.Pr = vm.Pr;
|
this.Er = vm.Er;
|
this.NPSHr = vm.NPSHr;
|
this.StNumr = vm.StNumr;
|
this.Ic = vm.Ic;
|
this.Oc = vm.Oc;
|
this.IOd = vm.IOd;
|
this.IsBp = vm.IsBp;
|
this.IsSxp = vm.IsSxp;
|
}
|
}
|
|
public void Reset(Model.Product<Model.Pump> rhs)
|
{
|
base.Reset(rhs);
|
if (rhs.RatedParas != null)
|
{
|
this.Qr = rhs.RatedParas.Qr;
|
this.Hr = rhs.RatedParas.Hr;
|
this.Nr = rhs.RatedParas.Nr;
|
this.Pr = rhs.RatedParas.Pr;
|
this.Er = rhs.RatedParas.Er;
|
this.NPSHr = rhs.RatedParas.NPSHr;
|
this.StNumr = rhs.RatedParas.StNumr;
|
this.Ic = rhs.RatedParas.Ic;
|
this.Oc = rhs.RatedParas.Oc;
|
this.IOd = rhs.RatedParas.IOd;
|
this.IsBp = rhs.RatedParas.IsBp ? "是" : "否";
|
this.IsSxp = rhs.RatedParas.IsSxp ? "是" : "否";
|
}
|
}
|
}
|
|
/// <summary>
|
/// 聚焦改变事件
|
/// </summary>
|
public event Action<Model.Product<Model.Pump>> FocusedChangedEvent;
|
|
private BindingList<CurrentViewModel> _allBindingList = null;//所有绑定列表
|
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void Clear()
|
{
|
_allBindingList = new BindingList<CurrentViewModel>();
|
this.currentViewModelBindingSource.DataSource = _allBindingList;
|
this.FocusedChangedEvent?.Invoke(null);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData()
|
{
|
WaitFrmHelper.ShowWaitForm("正在加载数据...");
|
_allBindingList = new BindingList<CurrentViewModel>();
|
|
var pumps = new BLL.Product().GetAllPump();
|
if (pumps != null && pumps.Any())
|
{
|
foreach (var pump in pumps)
|
{
|
var vm = new CurrentViewModel(pump);
|
_allBindingList.Add(vm);
|
}
|
}
|
|
this.currentViewModelBindingSource.DataSource = _allBindingList;
|
this.gridView1.BestFitColumns();
|
WaitFrmHelper.HideWaitForm();
|
}
|
//修改泵基础信息
|
public void EditPumpMgr()
|
{
|
var row = gridView1.GetCurrentViewModel(_allBindingList);
|
if (row == null)
|
return;
|
var dlg = new EditPumpDlg();
|
dlg.SetBindingData(row);
|
dlg.ReLoadDataevent += (pump_info) =>
|
{
|
var bll = new BLL.Product();
|
var model = new Model.Product(pump_info);
|
model.RatedParas = pump_info.RatedParas.ToJson();
|
var isok = bll.Update(model);
|
if (isok)
|
{
|
row.Reset(pump_info);
|
return true;
|
}
|
return false;
|
};
|
dlg.ShowDialog();
|
}
|
|
//添加泵基础信息
|
public void AddPump()
|
{
|
var dlg = new AddPumpDlg();
|
dlg.SetbindingData();
|
dlg.ReloadBingData += (pump) =>
|
{
|
var bll=new BLL.Product();
|
var model=new Model.Product(pump);
|
model.RatedParas=pump.RatedParas.ToJson();
|
var isok=bll.Insert(model);
|
if (isok>0)
|
{
|
this.SetBindingData();
|
return true;
|
}
|
|
return false;
|
};
|
|
dlg.ShowDialog();
|
|
}
|
|
|
}
|
}
|