namespace Yw.WinFrmUI
|
{
|
public partial class SetHydroMeterDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public SetHydroMeterDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
}
|
|
public event Action<List<Yw.Model.HydroMeterInfo>> ReloadDataEvent;
|
|
|
private List<Yw.Model.HydroMeterInfo> _allMeterList = null;
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(List<Yw.Model.HydroMeterInfo> allMeterList)
|
{
|
_allMeterList = allMeterList;
|
if (_allMeterList != null && _allMeterList.Count == 1)
|
{
|
var meter = _allMeterList.First();
|
this.txtElev.EditValue = meter.Elev;
|
this.txtMinorLoss.EditValue = meter.MinorLoss;
|
this.txtDemand.EditValue = meter.Demand;
|
}
|
}
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (this.txtElev.EditValue == null)
|
{
|
this.dxErrorProvider1.SetError(this.txtElev, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
if (_allMeterList == null || _allMeterList.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());
|
_allMeterList.ForEach(x =>
|
{
|
x.Elev = elev;
|
x.MinorLoss = minorLoss;
|
x.Demand = demand;
|
});
|
this.ReloadDataEvent?.Invoke(_allMeterList);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|