namespace Yw.WinFrmUI
|
{
|
public partial class HydroFourlinkBulkSetDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public HydroFourlinkBulkSetDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
}
|
|
public event Action<List<Yw.Model.HydroFourlinkInfo>> ReloadDataEvent;
|
|
|
private List<Yw.Model.HydroFourlinkInfo> _allFourlinkList = null;
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(List<Yw.Model.HydroFourlinkInfo> allFourlinkList)
|
{
|
_allFourlinkList = allFourlinkList;
|
if (_allFourlinkList != null && _allFourlinkList.Count == 1)
|
{
|
var threelink = _allFourlinkList.First();
|
this.txtElev.EditValue = threelink.Elev;
|
this.txtMinorLoss.EditValue = threelink.MinorLoss;
|
this.txtDemand.EditValue = threelink.Demand;
|
this.txtMaterial.EditValue = threelink.Material;
|
this.txtCaliber.EditValue = threelink.Caliber;
|
}
|
}
|
|
//验证
|
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 (_allFourlinkList == null || _allFourlinkList.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 material = this.txtMaterial.Text.Trim();
|
double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString());
|
_allFourlinkList.ForEach(x =>
|
{
|
x.Elev = elev;
|
x.MinorLoss = minorLoss;
|
x.Demand = demand;
|
x.Material = material;
|
x.Caliber = caliber;
|
});
|
this.ReloadDataEvent?.Invoke(_allFourlinkList);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|