You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
261 lines
9.9 KiB
C#
261 lines
9.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using ICSharpCode.Core;
|
|
using Mesnac.Codd.Session;
|
|
using Mesnac.Action.Default.Entity;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
namespace Mesnac.Action.Default.Purview.BasUser
|
|
{
|
|
public partial class frmInsert : Form
|
|
{
|
|
|
|
#region 字段定义
|
|
|
|
private ActionType _actionType = ActionType.Add; //操作类别,默认为添加
|
|
BasUserModel model = null;
|
|
#endregion
|
|
|
|
#region 属性定义
|
|
/// <summary>
|
|
/// UID
|
|
/// </summary>
|
|
public string UID
|
|
{
|
|
get
|
|
{
|
|
return model.UID;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 用户名
|
|
/// </summary>
|
|
public string UserName
|
|
{
|
|
get
|
|
{
|
|
return this.txtUserName.Text;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 密码
|
|
/// </summary>
|
|
public string UserPWD
|
|
{
|
|
get
|
|
{
|
|
return this.txtUserPWD.Text;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 所属角色
|
|
/// </summary>
|
|
public string RoleGUID
|
|
{
|
|
get
|
|
{
|
|
return this.cmbRole.SelectedValue as string;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 所属角色
|
|
/// </summary>
|
|
public string RoleName
|
|
{
|
|
get
|
|
{
|
|
return this.cmbRole.SelectedValue as string;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 所属班组
|
|
/// </summary>
|
|
///
|
|
public int ClassID
|
|
{
|
|
get
|
|
{
|
|
int intClassID = 0;
|
|
//int.TryParse(this.cmbClass.SelectedValue.ToString(), out intClassID);
|
|
return intClassID;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 具体的人员姓名
|
|
/// </summary>
|
|
public string RealName
|
|
{
|
|
get
|
|
{
|
|
return this.txtRealName.Text;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 构造方法
|
|
|
|
/// <summary>
|
|
/// 无参构造方法
|
|
/// </summary>
|
|
public frmInsert()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 参数构造方法
|
|
/// </summary>
|
|
/// <param name="actionType">操作类型</param>
|
|
public frmInsert(ActionType actionType)
|
|
{
|
|
InitializeComponent();
|
|
this._actionType = actionType;
|
|
}
|
|
/// <summary>
|
|
/// 参数构造方法
|
|
/// </summary>
|
|
/// <param name="actionType">操作类型</param>
|
|
public frmInsert(ActionType actionType, BasUserModel user)
|
|
{
|
|
InitializeComponent();
|
|
this._actionType = actionType;
|
|
if (this._actionType == ActionType.Modify)
|
|
{
|
|
model = new BasUserModel();
|
|
model = user;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法定义
|
|
|
|
/// <summary>
|
|
/// 初始化界面元素
|
|
/// </summary>
|
|
public void InitUIMethod()
|
|
{
|
|
if (this._actionType == ActionType.Add)
|
|
{
|
|
this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_Text")); //添加用户
|
|
this.groupBox1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_groupBox1_Text")); //用户信息
|
|
}
|
|
else if (this._actionType == ActionType.Modify)
|
|
{
|
|
this.txtUserPWD.Enabled = true;
|
|
this.Text ="修改用户"; //修改用户
|
|
this.groupBox1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_groupBox1_Text")); //查询条件
|
|
BasUserModel userModel = new BasUserModel();
|
|
userModel.RoleGUID = model.RoleGUID;
|
|
userModel.RoleName = model.RoleName;
|
|
|
|
string f =PurviewHelper.GetRoleList().First(d=>d.RoleGUID== model.RoleGUID).UID;
|
|
|
|
this.txtUserName.Enabled = false;
|
|
this.txtUserName.Text = model.UserName;
|
|
this.txtUserPWD.Text= model.UserPWD;
|
|
this.cmbRole.SelectedIndex =Convert.ToInt32(f);
|
|
this.txtRealName.Text = model.RealName;
|
|
}
|
|
else
|
|
{
|
|
this.txtUserPWD.Enabled = false;
|
|
this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_Text_Query")); //查询用户
|
|
this.groupBox1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_groupBox1_Text_Query")); //查询条件
|
|
}
|
|
this.label1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_label1_Text")); //用户账号
|
|
this.label2.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_label2_Text")); //密码
|
|
this.label3.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_label3_Text")); //角色
|
|
//this.label4.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_label4_Text")); //班组
|
|
this.label5.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_label5_Text")); //人员姓名
|
|
this.btnOk.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnOK"));
|
|
this.btnCancel.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnCancel"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化数据
|
|
/// </summary>
|
|
public void InitData()
|
|
{
|
|
this.cmbRole.DataSource =PurviewHelper.GetRoleList();
|
|
this.cmbRole.DisplayMember = "RoleName";
|
|
this.cmbRole.ValueMember = "RoleGUID";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 事件处理
|
|
private void FrmInsert_Load(object sender, EventArgs e)
|
|
{
|
|
this.InitData();
|
|
this.InitUIMethod();
|
|
}
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
if (this._actionType == ActionType.Add)
|
|
{
|
|
if (string.IsNullOrEmpty(this.txtUserName.Text.Trim()))
|
|
{
|
|
ICSharpCode.Core.LoggingService<frmInsert>.Warn("用户账号不能为空,请输入用户账号!");
|
|
string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_msg1")); //用户账号不能为空,请输入用户账号!
|
|
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this.txtUserName.Focus();
|
|
return;
|
|
}
|
|
if (PurviewHelper.IsExistsUserName(this.txtUserName.Text.Trim()))
|
|
{
|
|
ICSharpCode.Core.LoggingService<frmInsert>.Warn("已存在此用户账号,请输入新的用户账号!");
|
|
string msg2 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_msg2")); //已存在此用户账号,请输入新的用户账号!
|
|
MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this.txtUserName.Focus();
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(this.txtUserPWD.Text.Trim()))
|
|
{
|
|
ICSharpCode.Core.LoggingService<frmInsert>.Warn("密码不能为空,请输入密码!");
|
|
string msg3 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_msg3")); //密码不能为空,请输入密码!
|
|
MessageBox.Show(msg3, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this.txtUserPWD.Focus();
|
|
return;
|
|
}
|
|
if (String.IsNullOrEmpty(this.RoleGUID))
|
|
{
|
|
ICSharpCode.Core.LoggingService<frmInsert>.Warn("所属角色不能为空,请选择角色!");
|
|
string msg4 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_msg4")); //所属角色不能为空,请选择角色!
|
|
MessageBox.Show(msg4, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this.cmbRole.Focus();
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(this.txtRealName.Text.Trim()))
|
|
{
|
|
ICSharpCode.Core.LoggingService<frmInsert>.Warn("人员姓名不能为空,请输入人员姓名!");
|
|
string msg6 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_msg6")); //人员姓名不能为空,请输入人员姓名!
|
|
MessageBox.Show(msg6, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this.txtRealName.Focus();
|
|
return;
|
|
}
|
|
}
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|