namespace PBS.WinFrmUI.Hydro
|
{
|
public partial class InputDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public InputDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
this.layoutControl1.SetupLayoutControl();
|
this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
|
}
|
|
/// <summary>
|
/// 重载数据
|
/// </summary>
|
public event Action<double> ReloadDataEvent;
|
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(string title,double? value=null)
|
{
|
this.Text = title;
|
this.txtValue.EditValue = value;
|
}
|
|
//数据验证
|
private bool Verify()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (double.TryParse(this.txtValue.Text,out double value))
|
{
|
this.dxErrorProvider1.SetError(this.txtValue, "必填项");
|
return false;
|
}
|
|
return true;
|
}
|
|
//确定
|
private void GeneralOkAndCancelCtrl1_OkEvent()
|
{
|
if (!Verify())
|
{
|
return;
|
}
|
var value = Convert.ToDouble(this.txtValue.Text);
|
this.ReloadDataEvent?.Invoke(value);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
|
}
|
}
|