using DevExpress.XtraEditors; using System; using System.Windows.Forms; namespace IStation.WinFrmUI.Basic { public partial class EditOtherNameDlg : XtraForm { public EditOtherNameDlg() { InitializeComponent(); this.IconOptions.Icon = WinFrmUI.Properties.Resources.App; this.dataLayoutControl1.SetupLayoutControl(); } /// /// 回调事件 /// public event Func ReloadDataEvent; /// /// 绑定数据 /// public void SetBindingData(string name) { this.txtOtherName.EditValue = name; } //验证 private bool Valid() { this.dxErrorProvider1.ClearErrors(); if (string.IsNullOrEmpty(this.txtOtherName.Text.Trim())) { this.dxErrorProvider1.SetError(this.txtOtherName, "必填项"); return false; } return true; } //确定 private void btnOk_Click(object sender, EventArgs e) { if (!Valid()) return; var name = this.txtOtherName.Text.Trim(); var result = this.ReloadDataEvent?.Invoke(name); if (result == null || !result.Value) { XtraMessageBox.Show("更新失败!"); return; } XtraMessageBox.Show("更新成功!"); this.DialogResult = DialogResult.OK; this.Close(); } } }