using DevExpress.XtraEditors; using System; using System.Windows.Forms; namespace IStation.WinFrmUI { /// /// 设置排序码 /// public partial class SetSortCodeDlg : XtraForm { public SetSortCodeDlg() { InitializeComponent(); this.IconOptions.Icon = Properties.Resources.App; this.layoutControl1.SetupLayoutControl(); } /// /// 回调事件 /// public event Func ReloadDataEvent; /// /// 绑定事件 /// public void SetBindingData(int SortCode) { this.txtSortCode.EditValue = SortCode; } //验证 private bool Valid() { this.dxErrorProvider1.ClearErrors(); if (string.IsNullOrEmpty(this.txtSortCode.Text.Trim())) { this.dxErrorProvider1.SetError(this.txtSortCode, "必填项"); return false; } return true; } //确定 private void btnOk_Click(object sender, EventArgs e) { if (!Valid()) return; if (this.ReloadDataEvent != null) { var result = this.ReloadDataEvent.Invoke(int.Parse(this.txtSortCode.Text)); if (result) { XtraMessageBox.Show("更新成功!"); } else { XtraMessageBox.Show("更新失败!"); return; } } this.DialogResult = DialogResult.OK; this.Close(); } } }