using Mapster;
|
|
namespace HStation.WinFrmUI.Xhs.PumpProduct
|
{
|
public partial class EditPumpProductGroupDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public EditPumpProductGroupDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<UpdatePumpGroupDto, Task<bool>> ReloadDataEvent = null;
|
|
private UpdatePumpGroupDto _UpdataePumpGroupDto = null;
|
|
public async void SetBindingData(long ID)
|
{
|
var GroupDto = await new BLL.PumpGroup().GetByID(ID);
|
_UpdataePumpGroupDto = GroupDto.Adapt<PumpGroupDto, UpdatePumpGroupDto>();
|
this.NameTextEdit.Text = _UpdataePumpGroupDto.Name;
|
this.DescriptionTextEdit.Text = _UpdataePumpGroupDto.Description;
|
this.TagNameTextEdit.Text = _UpdataePumpGroupDto.TagName;
|
}
|
|
//数据验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(NameTextEdit.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//完成
|
private async void BtnOk_ClickAsync(object sender, EventArgs e)
|
{
|
_UpdataePumpGroupDto.TagName = TagNameTextEdit.Text.Trim();
|
_UpdataePumpGroupDto.Name = NameTextEdit.Text.Trim();
|
_UpdataePumpGroupDto.Description = DescriptionTextEdit.Text.Trim();
|
if (await this.ReloadDataEvent.Invoke(_UpdataePumpGroupDto))
|
{
|
MessageBoxHelper.ShowSuccess("编辑成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("编辑失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|