using Yw;
|
using Yw.WinFrmUI;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class AddRoleDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public AddRoleDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
|
}
|
|
/// <summary>
|
/// 返回数据事件
|
/// </summary>
|
public event Action<Yw.Vmo.Role> ReloadDataEvent;
|
|
//验证
|
private async Task<bool> Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtName, "必填项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(this.txtMinorLoss.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtMinorLoss, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//确定
|
private async void GeneralOkAndCancelCtrl1_OkEvent()
|
{
|
var vmo = new Yw.Vmo.RoleEx();
|
if (!await Valid())
|
{
|
return;
|
}
|
vmo.Name = this.txtName.Text.Trim();
|
vmo.Description = this.txtDescription.Text.Trim();
|
vmo.ProjectID = 1;
|
var id = await BLLFactory<Yw.BLL.Role>.Instance.InsertEx(vmo);
|
if (id < 1)
|
{
|
TipFormHelper.ShowError("添加失败!");
|
return;
|
}
|
var model = await BLLFactory<Yw.BLL.Role>.Instance.GetByID(id);
|
this.ReloadDataEvent?.Invoke(model);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|