using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.UserManage
{
class insertUserAction : ChemicalWeighingAction, IAction
{
#region 事件定义
///
/// 新增用户事件定义
///
public static event EventHandler OnInsertUser;
#endregion
#region 字段定义
private RuntimeParameter _runtime;
//private DbMCControl _userNameControl = null; //用户名textbox控件
//private DbMCControl _newPwdControl = null; //新密码textbox控件
//private DbMCControl _newPwdRepeatControl = null; //重复确认密码textbox控件
//private DbMCControl _userTypeControl = null; //用户类型combobox控件
#endregion
#region IAction接口实现
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
this._runtime = runtime;
this.DoWork();
}
#endregion
///
/// 新增用户
///
private void DoWork()
{
this._runtime.BaseControl.MCEnabled = false;
//创建新增用户窗体
FrmUser frmInsertUser = new FrmUser(0);
frmInsertUser.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
//点击确定按钮后DialogResult属性为OK
if (frmInsertUser.DialogResult == DialogResult.OK)
{
//获取用户对象
SimplePstUser user = frmInsertUser.User;
UserHelper.addUser(user);
#region 触发事件
if (OnInsertUser != null)
{
OnInsertUser(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
#endregion
}
frmInsertUser.Dispose();
this._runtime.BaseControl.MCEnabled = true;
}
}
}