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