using Mapster;
|
|
namespace HStation.WinFrmUI.Xhs.PumpProduct
|
{
|
public partial class EditPumpProductSeriesDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public EditPumpProductSeriesDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<UpdatePumpSeriesDto, Task<bool>> ReloadDataEvent = null;
|
|
private UpdatePumpSeriesDto _UpdataePumpSeriesDto = null;
|
|
public async void SetBindingData(long ID)
|
{
|
var series = await new BLL.PumpSeries().GetByID(ID);
|
_UpdataePumpSeriesDto = series.Adapt<PumpSeriesDto, UpdatePumpSeriesDto>();
|
this.NameTextEdit.Text = _UpdataePumpSeriesDto.Name;
|
this.DescriptionTextEdit.Text = _UpdataePumpSeriesDto.Description;
|
this.TagNameTextEdit.Text = _UpdataePumpSeriesDto.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)
|
{
|
_UpdataePumpSeriesDto.Name = NameTextEdit.Text.Trim();
|
_UpdataePumpSeriesDto.TagName = TagNameTextEdit.Text.Trim();
|
if (await this.ReloadDataEvent.Invoke(_UpdataePumpSeriesDto))
|
{
|
MessageBoxHelper.ShowSuccess("编辑成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("编辑失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|