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.

218 lines
8.6 KiB
C#

1 year ago
using ICSharpCode.Core;
using Mesnac.Action.Default.Entity;
using Mesnac.Action.Default.Purview;
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;
namespace Mesnac.Action.Default.Test
{
public partial class FrmInsert : Form
{
#region 字段定义
private ActionType _actionType = ActionType.Add; //操作类别,默认为添加
#endregion
#region 属性定义
/// <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 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;
}
#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
{
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.GetRoleListForSelect();
//this.cmbClass.DataSource = PurviewHelper.GetClassListForSelect();
}
#endregion
#region 事件处理
private void FrmInsert_Load(object sender, EventArgs e)
{
this.InitUIMethod();
this.InitData();
}
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 (this.ClassID == 0)
//{
// ICSharpCode.Core.LoggingService<FrmInsert>.Warn("所属班组不能为空,请选择班组!");
// string msg5 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_Purview_BasUser_FrmInsert_msg5")); //所属班组不能为空,请选择班组!
// MessageBox.Show(msg5, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
// this.cmbClass.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
}
}