📄 pa02_adduser.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using WebService;
using System.Text.RegularExpressions;
public partial class AddUser : System.Web.UI.Page
{
static int _baseOrgID = 0;
int _operatorID=-1;
string _ticket="daf";
string _expMsg = "";
static string usePwd = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.tb_addEmp.Visible = true;
this.tb_sureEmpInfo.Visible = false;
int _orgID = int.Parse(Request.QueryString["OrgID"].ToString());//获取从TreeView单击组织ID
VinciService vinciService = new VinciService();
OrganizationsEntity org;
org=vinciService.GetOrganizationInfo(_orgID, _operatorID, _ticket, out _expMsg);
lbl_regionName.Text = org.OrgID.ToString()+ org.OrgName;
lbl_regionName.DataBind();
}
}
public void AddEmployees()
{
int _orgID = int.Parse(Request.QueryString["OrgID"].ToString());
VinciService vinciService = new VinciService();
EmployeesEntity employees = new EmployeesEntity();
employees.Address = txt_adress.Text.Trim();
employees.BirthDate = ddc_brithDate.Value;
employees.City = txt_city.Text.Trim();
employees.FirstName = txt_firstName.Text.Trim();
employees.HireDate = ddc_hireDate.Value;
employees.LastName = txt_lastName.Text.Trim();
employees.LoginName = txt_loginName.Text.Trim();
employees.Notes = txt_note.Text.Trim();
employees.OrgID = _orgID;
string PassWordMd5 = FormsAuthentication.HashPasswordForStoringInConfigFile(usePwd, "md5");
employees.Title = txt_title.Text.Trim();
employees.Password = PassWordMd5;
employees.IsActive = 0;
employees.ReportsTo = _orgID;
vinciService.InsertEmployeesInfo(employees,_operatorID,_ticket);
}
protected void btn_next_Click(object sender, EventArgs e)
{
usePwd = txt_userPwd.Text.Trim();
if (CanPass())
{
this.tb_addEmp.Visible = false;
this.tb_sureEmpInfo.Visible = true;
#region
this.lbl_adress.Text = txt_adress.Text;
this.lbl_adress.DataBind();
this.lbl_brithday.Text = ddc_brithDate.Value.ToShortTimeString();
this.lbl_brithday.DataBind();
this.lbl_orgID.Text = lbl_regionName.Text;
this.lbl_orgID.DataBind();
this.lbl_city.Text = txt_city.Text;
this.lbl_city.DataBind();
this.lbl_firstname.Text = txt_firstName.Text;
this.lbl_firstname.DataBind();
this.lbl_hiredate.Text = ddc_hireDate.Value.ToShortTimeString();
this.lbl_hiredate.DataBind();
this.lbl_lastname.Text = txt_lastName.Text;
this.lbl_lastname.DataBind();
this.lbl_loginName.Text = txt_loginName.Text;
this.lbl_loginName.DataBind();
this.txt_Shownote.Text = txt_note.Text;
this.txt_Shownote.Enabled = false;
this.txt_Shownote.DataBind();
this.lbl_title.Text = txt_title.Text;
this.lbl_title.DataBind();
#endregion
}
}
protected void btn_back_Click(object sender, EventArgs e)
{
this.tb_addEmp.Visible = true;
this.tb_sureEmpInfo.Visible = false;
}
protected void btn_comit_Click(object sender, EventArgs e)
{
int _orgID = int.Parse(Request.QueryString["OrgID"].ToString());//获取从TreeView单击组织ID
AddEmployees();
Response.Redirect("PA02_UserInfo.aspx?OrgID=" + _orgID.ToString());
}
/// <summary>
/// 判断用户输入是否能通过验证
/// </summary>
/// <returns></returns>
public bool CanPass()
{
bool canPass = false;
#region///判断txt_lastName输入值
if (txt_lastName.Text.Trim() == "")
{
lbl_lastName_Msg.Text = "输入值不能为空";
}
else
{
if (Regex.Match(txt_lastName.Text.Trim(), @"^\w+$").Success)
{
lbl_lastName_Msg.Text = "";
}
else
{
lbl_lastName_Msg.Text = "只能输入数字,字母,汉字,_";
}
}
#endregion
#region///判断txt_firstName输入值
if (txt_firstName.Text.Trim() == "")
{
lbl_firstName_Msg.Text = "输入值不能为空";
}
else
{
if (Regex.Match(txt_firstName.Text.Trim(), @"^\w+$").Success)
{
lbl_firstName_Msg.Text = "";
}
else
{
lbl_firstName_Msg.Text = "只能输入数字,字母,汉字,_";
}
}
#endregion
#region///判断txt_loginName输入值
if (txt_loginName.Text.Trim() == "")
{
lbl_loginName_Msg.Text = "输入值不能为空";
}
else
{
if (Regex.Match(txt_loginName.Text.Trim(), @"^\w+$").Success)
{
lbl_loginName_Msg.Text = "";
}
else
{
lbl_loginName_Msg.Text = "只能输入数字,字母,汉字,_";
}
}
#endregion
#region///判断txt_userPwd输入值
if (txt_userPwd.Text.Trim() == "")
{
lbl_pwd_Msg.Text = "输入值不能为空";
}
else
{
lbl_pwd_Msg.Text = "";
}
#endregion
#region///判断txt_RePwd输入值
if (txt_RePwd.Text.Trim() == "")
{
lbl_rePwd_Msg.Text = "输入值不能为空";
}
else
{
if (txt_RePwd.Text==txt_userPwd.Text)
{
lbl_rePwd_Msg.Text = "";
}
else
{
lbl_rePwd_Msg.Text = "两次输入值不相同";
}
}
#endregion
#region///判断txt_title输入值
if (txt_title.Text.Trim() == "")
{
lbl_title_Msg.Text = "输入值不能为空";
}
else
{
if (Regex.Match(txt_title.Text.Trim(), @"^\w+$").Success)
{
lbl_title_Msg.Text = "";
}
else
{
lbl_title_Msg.Text = "只能输入数字,字母,汉字,_";
}
}
#endregion
#region///判断txt_city输入值
if (txt_city.Text.Trim() == "")
{
lbl_city_Msg.Text = "";
}
else
{
if (Regex.Match(txt_city.Text.Trim(), @"^\w+$").Success)
{
lbl_city_Msg.Text = "";
}
else
{
lbl_city_Msg.Text = "只能输入数字,字母,汉字,_";
}
}
#endregion
#region///判断txt_adress输入值
if (txt_adress.Text.Trim() == "")
{
lbl_adress_Msg.Text = "";
}
else
{
if (Regex.Match(txt_adress.Text.Trim(), @"^\w+$").Success)
{
lbl_adress_Msg.Text = "";
}
else
{
lbl_adress_Msg.Text = "只能输入数字,字母,汉字,_";
}
}
#endregion
#region///判断txt_note输入值
if (txt_note.Text.Trim() == "")
{
lbl_note_Msg.Text = "";
}
else
{
if (txt_note.Text.Length <= 50)
{
if (Regex.Match(txt_note.Text.Trim(), @"^\w+$").Success)
{
lbl_note_Msg.Text = "";
}
else
{
lbl_note_Msg.Text = "只能输入数字,字母,汉字,_";
}
}
else
{
lbl_note_Msg.Text = "输入字符要在50个以内";
}
}
#endregion
if (lbl_lastName_Msg.Text == "" && lbl_firstName_Msg.Text == "" && lbl_loginName_Msg.Text == "" && lbl_pwd_Msg.Text == "" && lbl_rePwd_Msg.Text == ""
&& lbl_title_Msg.Text == "" && lbl_adress_Msg.Text == "" && lbl_note_Msg.Text == "" && lbl_city_Msg.Text=="")
{
canPass= true;
}
return canPass;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -