using DevExpress.XtraSpreadsheet.Model;
|
|
namespace Yw.WinFrmUI
|
{
|
public partial class HydroHydrantBulkSetDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public HydroHydrantBulkSetDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
}
|
|
public event Action<List<Yw.Model.HydroHydrantInfo>> ReloadDataEvent;
|
|
|
private List<Yw.Model.HydroHydrantInfo> _allHydrantList = null;
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(List<Yw.Model.HydroHydrantInfo> allHydrantList)
|
{
|
_allHydrantList = allHydrantList;
|
if (_allHydrantList != null && _allHydrantList.Count == 1)
|
{
|
var hydrant = _allHydrantList.First();
|
this.txtElev.EditValue = hydrant.Elev;
|
this.txtMinorLoss.EditValue = hydrant.MinorLoss;
|
this.txtDemand.EditValue = hydrant.Demand;
|
this.txtCoefficient.EditValue = hydrant.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 (_allHydrantList == null || _allHydrantList.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());
|
_allHydrantList.ForEach(x =>
|
{
|
x.Elev = elev;
|
x.MinorLoss = minorLoss;
|
x.Demand = demand;
|
x.Coefficient = coefficient;
|
});
|
this.ReloadDataEvent?.Invoke(_allHydrantList);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
|
}
|
}
|