using Mapster;
|
using Yw.Basic;
|
using Yw.Dto;
|
|
namespace HStation.WinFrmUI.Basic
|
{
|
public partial class EditSysTypeDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public EditSysTypeDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<Yw.Vmo.SysType, Task<bool>> ReloadDataEvent = null;
|
|
private Yw.Vmo.SysType _UpdateSysTypeDto { get; set; }
|
|
public async void SetBindingData(long ID)
|
{
|
var dto = await new Yw.BLL.SysType().GetByID(ID);
|
_UpdateSysTypeDto = dto;
|
if (_UpdateSysTypeDto.ExtendType == (Yw.Vmo.eExtendType)eExtendType.None)
|
{
|
this.TextEditExType.SelectedIndex = 0;
|
}
|
else if (_UpdateSysTypeDto.ExtendType == (Yw.Vmo.eExtendType)eExtendType.Config)
|
{
|
this.TextEditExType.SelectedIndex = 1;
|
}
|
else
|
{
|
this.TextEditExType.SelectedIndex = 2;
|
}
|
this.TextEditName.Text = _UpdateSysTypeDto.Name;
|
this.TextEditDescription.Text = _UpdateSysTypeDto.Description;
|
this.TextEditCode.Text = _UpdateSysTypeDto.Code;
|
}
|
|
//数据验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(TextEditName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextEditName, "必填项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(TextEditCode.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextEditCode, "必填项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(TextEditExType.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextEditExType, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//完成
|
private async void BtnOk_ClickAsync(object sender, EventArgs e)
|
{
|
if (!Valid())
|
return;
|
_UpdateSysTypeDto.Name = TextEditName.Text.Trim();
|
_UpdateSysTypeDto.Description = TextEditDescription.Text.Trim();
|
if (this.TextEditExType.SelectedIndex == 0)
|
{
|
_UpdateSysTypeDto.ExtendType = (Yw.Vmo.eExtendType)eExtendType.None;
|
}
|
else if (this.TextEditExType.SelectedIndex == 1)
|
{
|
_UpdateSysTypeDto.ExtendType = (Yw.Vmo.eExtendType)eExtendType.Config;
|
}
|
else
|
{
|
_UpdateSysTypeDto.ExtendType = (Yw.Vmo.eExtendType)eExtendType.Catalog;
|
}
|
_UpdateSysTypeDto.Code = TextEditCode.Text.Trim();
|
if (await this.ReloadDataEvent.Invoke(_UpdateSysTypeDto))
|
{
|
MessageBoxHelper.ShowSuccess("修改成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("修改失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|