using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace HySoft.BaseCallCenter.Web.sysmanage
{
public partial class ResetPassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["ResetPass"] != null)
{
string resetPassId = Request.QueryString["ResetPass"];
initistration(resetPassId);//初始化方法
}
}
}
///
/// 初始化重新设置密码的信息
///
///
public void initistration(string resetPassWord)
{
string sql = "";
if (!string.IsNullOrEmpty(resetPassWord))
{
sql = "select * from t_sys_userAccount where F_UserId ='" + resetPassWord + "'";
}
DataTable dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
if (dt.Rows.Count > 0)
{
txtWorkingCode.Text = dt.Rows[0]["F_UserCode"].ToString();
txtRealName.Text = dt.Rows[0]["F_UserName"].ToString();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string usercode = txtWorkingCode.Text.Trim();
string username = txtRealName.Text.Trim();
string password = txtone_password.Text.Trim();
string password1 = txtone_password1.Text.Trim();
string sql = string.Format("F_UserCode='{0}' and F_UserName='{1}'", usercode, username);
List tsua = new BLL.T_Sys_UserAccount().GetModelList(sql);
if (tsua.Count <= 0)
{
MessageBoxToWindow("重设密码失败:工号和姓名不匹配", "提示!", "error");
}
else if (tsua.Count == 1)
{
string userId = HySoft.Common.CookieUtil.GetCookie("BaseCallCenter_T_User", "F_UserID");
if (userId != null && !string.IsNullOrWhiteSpace(userId))
{
int ID = 0;
int.TryParse(userId, out ID);
if (ID > 0)
{
Model.T_Sys_UserAccount user = new BLL.T_Sys_UserAccount().GetModel(ID);
if (user != null)
{
if (user.F_RoleId == 17)
{
if (password == password1)
{
tsua[0].F_Password = password;
bool b = new BLL.T_Sys_UserAccount().Update(tsua[0]);
if (b) MessageBoxToWindow("重设密码成功", "提示!", "success");
}
else
{
MessageBoxToWindow("重设密码失败:新密码输入不一致", "提示!", "error");
}
}
else
{
MessageBoxToWindow("重设密码失败:权限不足", "提示!", "error");
}
}
}
}
}
else
{
MessageBoxToWindow("数据异常:存在相同工号和姓名的人员", "提示!", "catch");
}
}
#region 弹出对话框
///
/// 弹出对话框
///
///
///
///
public void MessageBoxToWindow(string title, string content, string type)
{
string script = "";
switch (type)
{
case "error"://失败
type = "error";
script = "";
break;
case "success"://成功
type = "info";
script = "";
break;
case "catch"://异常
type = "warning";
script = "";
break;
default:
type = "question";
break;
}
ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
}
#endregion
}
}