namespace Yw.WinFrmUI
|
{
|
public partial class SetHydroHydrantDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public SetHydroHydrantDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
this.layoutControl1.SetupLayoutControl();
|
}
|
|
/// <summary>
|
/// 返回数据事件
|
/// </summary>
|
public event Action<List<Yw.Model.HydroHydrantInfo>> ReloadDataEvent;
|
|
//所有构件列表
|
private List<Yw.Model.HydroHydrantInfo> _allParterList = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroHydrantInfo parter)
|
{
|
var allParterList = parter == null ? null : new List<Yw.Model.HydroHydrantInfo>() { parter };
|
SetBindingData(allParterList);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(List<Yw.Model.HydroHydrantInfo> allParterList)
|
{
|
_allParterList = allParterList;
|
if (_allParterList != null && _allParterList.Count == 1)
|
{
|
var parter = _allParterList.First();
|
this.txtElev.EditValue = parter.Elev;
|
this.txtMinorLoss.EditValue = parter.MinorLoss;
|
this.txtDemand.EditValue = parter.Demand;
|
this.txtCoefficient.EditValue = parter.Coefficient;
|
}
|
}
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (this.txtElev.EditValue == null)
|
{
|
this.dxErrorProvider1.SetError(this.txtElev, "必填项");
|
return false;
|
}
|
if (this.txtCoefficient.EditValue == null)
|
{
|
this.dxErrorProvider1.SetError(this.txtCoefficient, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
if (_allParterList == null || _allParterList.Count < 1)
|
{
|
return;
|
}
|
if (!Valid())
|
{
|
return;
|
}
|
var elev = double.Parse(this.txtElev.EditValue.ToString());
|
double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
|
double? demand = this.txtDemand.EditValue == null ? null : double.Parse(this.txtDemand.EditValue.ToString());
|
var coefficient = double.Parse(this.txtCoefficient.EditValue.ToString());
|
_allParterList.ForEach(x =>
|
{
|
x.Elev = elev;
|
x.MinorLoss = minorLoss;
|
x.Demand = demand;
|
x.Coefficient = coefficient;
|
});
|
this.ReloadDataEvent?.Invoke(_allParterList);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
|
}
|
}
|