namespace Yw.WinFrmUI
|
{
|
public partial class SetHydroFourlinkDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public SetHydroFourlinkDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
this.layoutControl1.SetupLayoutControl();
|
}
|
|
/// <summary>
|
/// 返回数据事件
|
/// </summary>
|
public event Action<List<Yw.Model.HydroFourlinkInfo>> ReloadDataEvent;
|
|
//所有构件列表
|
private List<Yw.Model.HydroFourlinkInfo> _allParterList = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroFourlinkInfo parter)
|
{
|
var allParterList = parter == null ? null : new List<Yw.Model.HydroFourlinkInfo>() { parter };
|
SetBindingData(allParterList);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(List<Yw.Model.HydroFourlinkInfo> allParterList)
|
{
|
_allParterList = allParterList;
|
if (_allParterList != null && _allParterList.Count == 1)
|
{
|
var parter = _allParterList.First();
|
this.txtMaterial.EditValue = parter.Material;
|
this.txtCaliber.EditValue = parter.Caliber;
|
this.txtElev.EditValue = Math.Round(parter.Elev, 4);
|
this.txtMinorLoss.EditValue = parter.MinorLoss;
|
}
|
}
|
|
//验证
|
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 (_allParterList == null || _allParterList.Count < 1)
|
{
|
return;
|
}
|
if (!Valid())
|
{
|
return;
|
}
|
|
var material = this.txtMaterial.Text.Trim();
|
double? caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue.ToString());
|
var elev = double.Parse(this.txtElev.EditValue.ToString());
|
double? minorLoss = this.txtMinorLoss.EditValue == null ? null : double.Parse(this.txtMinorLoss.EditValue.ToString());
|
|
_allParterList.ForEach(x =>
|
{
|
x.Elev = elev;
|
x.MinorLoss = minorLoss;
|
x.Material = material;
|
x.Caliber = caliber;
|
});
|
this.ReloadDataEvent?.Invoke(_allParterList);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|