using Mapster;
|
using Yw.Basic;
|
using Yw.Dto;
|
|
namespace HStation.WinFrmUI.Xhs.Project
|
{
|
public partial class EditCatlogDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public EditCatlogDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<Yw.Dto.UpdateSysCatalogInput, Task<bool>> ReloadDataEvent = null;
|
|
private UpdateSysCatalogInput _UpdateCatlogDto { get; set; }
|
|
public async Task SetBindingDataAsync(long ID)
|
{
|
_UpdateCatlogDto = new UpdateSysCatalogInput();
|
var bll = new Yw.BLL.SysCatalog();
|
var model = await bll.GetByID(ID);
|
_UpdateCatlogDto = model.Adapt<Yw.Dto.SysCatalogDto, Yw.Dto.UpdateSysCatalogInput>();
|
this.TextEditName.Text = _UpdateCatlogDto.Name;
|
this.TextEditDescription.Text = _UpdateCatlogDto.Description;
|
}
|
|
//数据验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(TextEditName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextEditName, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//完成
|
private async void BtnOk_ClickAsync(object sender, EventArgs e)
|
{
|
_UpdateCatlogDto = new UpdateSysCatalogInput();
|
_UpdateCatlogDto.Name = TextEditName.Text.Trim();
|
_UpdateCatlogDto.Description = TextEditDescription.Text.Trim();
|
if (await this.ReloadDataEvent.Invoke(_UpdateCatlogDto))
|
{
|
MessageBoxHelper.ShowSuccess("添加成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("添加失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|