namespace Yw.WinFrmUI { public partial class SetHydroHydrantDlg : DevExpress.XtraEditors.XtraForm { public SetHydroHydrantDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; this.layoutControl1.SetupLayoutControl(); this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent; } /// /// 返回数据事件 /// public event Action> ReloadDataEvent; //所有构件列表 private List _allVisualList = null; /// /// 绑定数据 /// public void SetBindingData(Yw.Model.HydroHydrantInfo visual) { var allVisualList = visual == null ? null : new List() { visual }; SetBindingData(allVisualList); } /// /// 绑定数据 /// public void SetBindingData(List allVisualList) { _allVisualList = allVisualList; if (_allVisualList != null && _allVisualList.Count == 1) { var visual = _allVisualList.First(); this.txtElev.EditValue = visual.Elev; this.txtMinorLoss.EditValue = visual.MinorLoss; this.txtDemand.EditValue = visual.Demand; this.txtCoefficient.EditValue = visual.Coefficient; } } //确定 private void GeneralOkAndCancelCtrl1_OkEvent() { if (_allVisualList == null || _allVisualList.Count < 1) { return; } double? elev = this.txtElev.EditValue == null ? null : 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()); double? coefficient = this.txtCoefficient.EditValue == null ? null : double.Parse(this.txtCoefficient.EditValue.ToString()); _allVisualList.ForEach(x => { if (elev.HasValue) { x.Elev = elev.Value; } if (minorLoss.HasValue) { x.MinorLoss = minorLoss.Value; } if (demand.HasValue) { x.Demand = demand.Value; } if (coefficient.HasValue) { x.Coefficient = coefficient.Value; } }); this.ReloadDataEvent?.Invoke(_allVisualList); this.DialogResult = DialogResult.OK; this.Close(); } } }