namespace Yw.WinFrmUI
|
{
|
public partial class AddPartDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public AddPartDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<Vmo.PartVmo, Task<bool>> ReloadEvent;
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.TxtName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TxtName, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
private async void btnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid()) return;
|
var model = new Vmo.PartVmo();
|
model.Name = this.TxtName.Text;
|
model.TagName = this.TagName.Text;
|
model.Description = this.TxtDescription.Text;
|
if (this.ReloadEvent == null)
|
return;
|
if (!await this.ReloadEvent(model))
|
{
|
MessageBoxHelper.ShowError("添加失败!");
|
return;
|
}
|
MessageBoxHelper.ShowSuccess("添加成功!");
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|