namespace Yw.WinFrmUI
|
{
|
public partial class EditPartDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public EditPartDlg()
|
{
|
InitializeComponent();
|
}
|
|
private Vmo.PartVmo _part;
|
|
public event Func<Vmo.PartVmo, Task<bool>> ReloadData;
|
|
public void SetbindingData(Vmo.PartVmo part)
|
{
|
_part = part;
|
this.TxtName.Text = part.Name;
|
this.TxtDescription.Text = part.Description;
|
this.TxtTag.Text = part.TagName;
|
}
|
|
private bool Verify()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (this.TxtName.Text == null)
|
{
|
this.dxErrorProvider1.SetError(this.TxtName, "不能为空");
|
return false;
|
}
|
return true;
|
}
|
|
//确定
|
private async void btnOk_Click(object sender, EventArgs e)
|
{
|
if (!Verify())
|
return;
|
_part.TagName = this.TxtTag.Text;
|
_part.Description = this.TxtDescription.Text;
|
_part.Name = this.TxtName.Text;
|
if (this.ReloadData == null)
|
return;
|
if (!await this.ReloadData(_part))
|
{
|
MessageBoxHelper.ShowError("修改失败!");
|
return;
|
}
|
MessageBoxHelper.ShowSuccess("修改成功!");
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|