using DevExpress.XtraEditors;
|
using System;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace IStation.WinFrmUI
|
{
|
/// <summary>
|
/// 设置树排序码
|
/// </summary>
|
public partial class SetTreeSortCodeDlg : XtraForm
|
{
|
public SetTreeSortCodeDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Properties.Resources.App;
|
this.layoutControl1.SetupLayoutControl();
|
}
|
|
/// <summary>
|
/// 返回事件
|
/// </summary>
|
public event Func<long, int, Task<bool>> ReloadDataEvent;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(long ParentID, int SortCode)
|
{
|
this.txtParentID.EditValue = ParentID;
|
this.txtSortCode.EditValue = SortCode;
|
}
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.txtParentID.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtParentID, "必填项");
|
return false;
|
}
|
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 = this.ReloadDataEvent.Invoke(long.Parse(this.txtParentID.Text), int.Parse(this.txtSortCode.Text));
|
if (await result)
|
{
|
XtraMessageBox.Show("更新成功!");
|
}
|
else
|
{
|
XtraMessageBox.Show("更新失败!");
|
return;
|
}
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
|
}
|
}
|