using DevExpress.XtraEditors;
|
using System;
|
using System.Windows.Forms;
|
|
namespace HStation.WinFrmUI
|
{
|
/// <summary>
|
/// 设置排序码
|
/// </summary>
|
public partial class SetSortCodeDlg : XtraForm
|
{
|
public SetSortCodeDlg()
|
{
|
InitializeComponent();
|
}
|
|
/// <summary>
|
/// 回调事件
|
/// </summary>
|
public event Func<int, Task<bool>> ReloadDataEvent;
|
|
/// <summary>
|
/// 绑定事件
|
/// </summary>
|
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 async void btnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid())
|
return;
|
if (this.ReloadDataEvent != null)
|
{
|
var result = await this.ReloadDataEvent.Invoke(int.Parse(this.txtSortCode.Text));
|
if (result)
|
{
|
MessageBoxHelper.ShowSuccess("更新成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("更新失败!");
|
return;
|
}
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|