protected void btnAdd_Click(object sender, EventArgs e)
    {
        HEemployeeData model = new HEemployeeData();
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        try
        {
            if (this.State == "1")
            {
                if (eemployeeBB.Exists(this.empNo.Text))
                {
                    this.lblMsg.Text = "Ա������Ѿ����ڣ�����������";
                    return;
                }
                this.SetModel(ref model);
                model.password = MD5Encrypt.GetMD5("123456");
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                model.isDel = false;
                this.IdValue = eemployeeBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                if (eemployeeBB.Exists(this.IdValue, this.empNo.Text))
                {
                    this.lblMsg.Text = "Ա������Ѿ����ڣ�����������";
                    return;
                }
                model = eemployeeBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                model.updtDt = DateTime.Now.ToString();
                model.updtEmpId = this.currentUser.empId;
                eemployeeBB.ModifyRecord(model);

                //ͬ��session��Ա��Ϣ
                if (this.currentUser.empNo == model.empNo)
                {
                    Session["UserData"] = model;
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            eemployeeBB.Dispose();
        }

        if (this.btnReturn.Enabled)
        {
            Response.Redirect("HEemployeeList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false);
        }
        else
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"���������޸ijɹ�!\");", true);
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string oldPassWord;
        string newPassWord;

        //if (this.newpwd.Text.IndexOf(this.txtUserNo.Text) >= 0)
        //{
        //    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('密码中不能包含用户名等信息!')", true);
        //    return;
        //}
        //if (this.newpwd.Text.IndexOf("haier") >= 0)
        //{
        //    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('密码中不能包含公司相关信息!')", true);
        //    return;
        //}

        HEemployeeData eemployeeData = new HEemployeeData();
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        try
        {
            eemployeeData = eemployeeBB.GetModel(this.UserId);

            oldPassWord = MD5Encrypt.GetMD5(this.oldpwd.Text);
            if (!String.Equals(oldPassWord, eemployeeData.password))
            {
                this.lblMsg.Visible = true;
                return;
            }
            else
            {
                this.lblMsg.Visible = false;
            }

            newPassWord = MD5Encrypt.GetMD5(this.newpwd.Text);
            eemployeeData.password = newPassWord;
            eemployeeData.preModifyPasswordDt = DateTime.Now.ToString();
            eemployeeBB.ModifyRecord(eemployeeData);
        }
        finally
        {
            eemployeeBB.Dispose();
        }
        if (Session["UserData"] != null)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('密码修改成功!')", true);
        }
        else
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"密码修改成功!\");window.location.href='../../../login.aspx';", true);
        }
    }
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(HEemployeeData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into HEemployee(");
            strSql.Append(@"empNo,empNm,password,gender,nowDepartId,userType,style,mobile,email,mark,
                            isEffect,isDel,isrtDt,isrtEmpId,updtDt,updtEmpId,isOnLine,loginDate,lastOnLineDt,
                            sessionId,preModifyPasswordDt,historyPassword,errorLoginAmount)");
            strSql.Append(" values (");
            strSql.Append(@"@empNo,@empNm,@password,@gender,@nowDepartId,@userType,@style,@mobile,@email,@mark,
                            @isEffect,@isDel,@isrtDt,@isrtEmpId,@updtDt,@updtEmpId,@isOnLine,@loginDate,@lastOnLineDt,
                            @sessionId,@preModifyPasswordDt,@historyPassword,@errorLoginAmount)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@empNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@empNm", SqlDbType.NVarChar,20),
                    new SqlParameter("@password", SqlDbType.NVarChar,128),
                    new SqlParameter("@gender", SqlDbType.NVarChar,2),
                    new SqlParameter("@nowDepartId", SqlDbType.Int),
                    new SqlParameter("@userType", SqlDbType.NVarChar,2),
                    new SqlParameter("@style", SqlDbType.Int),
                    new SqlParameter("@mobile", SqlDbType.NVarChar,20),
                    new SqlParameter("@email", SqlDbType.NVarChar,100),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isEffect", SqlDbType.Bit),
                    new SqlParameter("@isDel", SqlDbType.Bit),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@isOnLine", SqlDbType.Bit),
                    new SqlParameter("@loginDate", SqlDbType.DateTime),
                    new SqlParameter("@lastOnLineDt", SqlDbType.DateTime),
                    new SqlParameter("@sessionId", SqlDbType.NVarChar,50),
                    new SqlParameter("@preModifyPasswordDt", SqlDbType.DateTime),
                    new SqlParameter("@historyPassword", SqlDbType.NVarChar,2000),
                    new SqlParameter("@errorLoginAmount", SqlDbType.Int)
                };
            parameters[0].Value = model.empNo;
            parameters[1].Value = model.empNm;
            parameters[2].Value = model.password;
            parameters[3].Value = model.gender;
            parameters[4].Value = model.nowDepartId;
            parameters[5].Value = model.userType;
            parameters[6].Value = model.style;
            parameters[7].Value = model.mobile;
            parameters[8].Value = model.email;
            parameters[9].Value = model.mark;
            parameters[10].Value = model.isEffect;
            parameters[11].Value = model.isDel;
            parameters[12].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[13].Value = model.isrtEmpId;
            parameters[14].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[15].Value = model.updtEmpId;
            parameters[16].Value = model.isOnLine;
            parameters[17].Value = model.loginDate == string.Empty ? null : model.loginDate;
            parameters[18].Value = model.lastOnLineDt == string.Empty ? null : model.lastOnLineDt;
            parameters[19].Value = model.sessionId;
            parameters[20].Value = model.preModifyPasswordDt == string.Empty ? null : model.preModifyPasswordDt;
            parameters[21].Value = model.historyPassword;
            parameters[22].Value = model.errorLoginAmount;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(HEemployeeData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update HEemployee set ");
            strSql.Append("empNo=@empNo,");
            strSql.Append("empNm=@empNm,");
            strSql.Append("password=@password,");
            strSql.Append("gender=@gender,");
            strSql.Append("nowDepartId=@nowDepartId,");
            strSql.Append("userType=@userType,");
            strSql.Append("style=@style,");
            strSql.Append("mobile=@mobile,");
            strSql.Append("email=@email,");
            strSql.Append("mark=@mark,");
            strSql.Append("isEffect=@isEffect,");
            strSql.Append("isDel=@isDel,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("updtDt=@updtDt,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("isOnLine=@isOnLine,");
            strSql.Append("loginDate=@loginDate,");
            strSql.Append("lastOnLineDt=@lastOnLineDt,");
            strSql.Append("sessionId=@sessionId,");
            strSql.Append("preModifyPasswordDt=@preModifyPasswordDt,");
            strSql.Append("historyPassword=@historyPassword,");
            strSql.Append("errorLoginAmount=@errorLoginAmount");
            strSql.Append(" where empId = @empId ");
            SqlParameter[] parameters = {
                    new SqlParameter("@empId", SqlDbType.Int),
                    new SqlParameter("@empNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@empNm", SqlDbType.NVarChar,20),
                    new SqlParameter("@password", SqlDbType.NVarChar,128),
                    new SqlParameter("@gender", SqlDbType.NVarChar,2),
                    new SqlParameter("@nowDepartId", SqlDbType.Int),
                    new SqlParameter("@userType", SqlDbType.NVarChar,2),
                    new SqlParameter("@style", SqlDbType.Int),
                    new SqlParameter("@mobile", SqlDbType.NVarChar,20),
                    new SqlParameter("@email", SqlDbType.NVarChar,100),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isEffect", SqlDbType.Bit),
                    new SqlParameter("@isDel", SqlDbType.Bit),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@isOnLine", SqlDbType.Bit),
                    new SqlParameter("@loginDate", SqlDbType.DateTime),
                    new SqlParameter("@lastOnLineDt", SqlDbType.DateTime),
                    new SqlParameter("@sessionId", SqlDbType.NVarChar,50),
                    new SqlParameter("@preModifyPasswordDt", SqlDbType.DateTime),
                    new SqlParameter("@historyPassword", SqlDbType.NVarChar,2000),
                    new SqlParameter("@errorLoginAmount", SqlDbType.Int)
                };
            parameters[0].Value = model.empId;
            parameters[1].Value = model.empNo;
            parameters[2].Value = model.empNm;
            parameters[3].Value = model.password;
            parameters[4].Value = model.gender;
            parameters[5].Value = model.nowDepartId;
            parameters[6].Value = model.userType;
            parameters[7].Value = model.style;
            parameters[8].Value = model.mobile;
            parameters[9].Value = model.email;
            parameters[10].Value = model.mark;
            parameters[11].Value = model.isEffect;
            parameters[12].Value = model.isDel;
            parameters[13].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[14].Value = model.isrtEmpId;
            parameters[15].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[16].Value = model.updtEmpId;
            parameters[17].Value = model.isOnLine;
            parameters[18].Value = model.loginDate == string.Empty ? null : model.loginDate;
            parameters[19].Value = model.lastOnLineDt == string.Empty ? null : model.lastOnLineDt;
            parameters[20].Value = model.sessionId;
            parameters[21].Value = model.preModifyPasswordDt == string.Empty ? null : model.preModifyPasswordDt;
            parameters[22].Value = model.historyPassword;
            parameters[23].Value = model.errorLoginAmount;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="empId">����ֵ</param>
        /// <returns>model</returns>
        public HEemployeeData GetModel(int empId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select empId,empNo,empNm,password,gender,nowDepartId,userType,style,mobile,email,mark,
                            isEffect,isDel,isrtDt,isrtEmpId,updtDt,updtEmpId,isOnLine,loginDate,lastOnLineDt,sessionId,
                            preModifyPasswordDt,historyPassword,errorLoginAmount from HEemployee");
            strSql.Append(" where empId = @empId ");
            SqlParameter[] parameters = {
                    new SqlParameter("@empId", SqlDbType.Int)
                };
            parameters[0].Value = empId;

            HEemployeeData model = new HEemployeeData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["empId"] != DBNull.Value)
                {
                    model.empId = Convert.ToInt32(row["empId"]);
                }
                if (row["empNo"] != DBNull.Value)
                {
                    model.empNo = Convert.ToString(row["empNo"]);
                }
                if (row["empNm"] != DBNull.Value)
                {
                    model.empNm = Convert.ToString(row["empNm"]);
                }
                if (row["password"] != DBNull.Value)
                {
                    model.password = Convert.ToString(row["password"]);
                }
                if (row["gender"] != DBNull.Value)
                {
                    model.gender = Convert.ToString(row["gender"]);
                }
                if (row["nowDepartId"] != DBNull.Value)
                {
                    model.nowDepartId = Convert.ToInt32(row["nowDepartId"]);
                }
                if (row["userType"] != DBNull.Value)
                {
                    model.userType = Convert.ToString(row["userType"]);
                }
                if (row["style"] != DBNull.Value)
                {
                    model.style = Convert.ToInt32(row["style"]);
                }
                if (row["mobile"] != DBNull.Value)
                {
                    model.mobile = Convert.ToString(row["mobile"]);
                }
                if (row["email"] != DBNull.Value)
                {
                    model.email = Convert.ToString(row["email"]);
                }
                if (row["mark"] != DBNull.Value)
                {
                    model.mark = Convert.ToString(row["mark"]);
                }
                if (row["isEffect"] != DBNull.Value)
                {
                    model.isEffect = Convert.ToBoolean(row["isEffect"]);
                }
                if (row["isDel"] != DBNull.Value)
                {
                    model.isDel = Convert.ToBoolean(row["isDel"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["isOnLine"] != DBNull.Value)
                {
                    model.isOnLine = Convert.ToBoolean(row["isOnLine"]);
                }
                if (row["loginDate"] != DBNull.Value)
                {
                    model.loginDate = Convert.ToString(row["loginDate"]);
                }
                if (row["lastOnLineDt"] != DBNull.Value)
                {
                    model.lastOnLineDt = Convert.ToString(row["lastOnLineDt"]);
                }
                if (row["sessionId"] != DBNull.Value)
                {
                    model.sessionId = Convert.ToString(row["sessionId"]);
                }
                if (row["preModifyPasswordDt"] != DBNull.Value)
                {
                    model.preModifyPasswordDt = Convert.ToString(row["preModifyPasswordDt"]);
                }
                if (row["historyPassword"] != DBNull.Value)
                {
                    model.historyPassword = Convert.ToString(row["historyPassword"]);
                }
                if (row["errorLoginAmount"] != DBNull.Value)
                {
                    model.errorLoginAmount = Convert.ToInt32(row["errorLoginAmount"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
 //邦定人员名称
 private void BindEmp()
 {
     HEemployeeData eemployeeData = new HEemployeeData();
     HEemployeeBB eemployeeBB = new HEemployeeBB();
     try
     {
         eemployeeData = eemployeeBB.GetModel(this.EmpId);
         this.empNm.Text = "当前人员:" + eemployeeData.empNm;
     }
     finally
     {
         eemployeeBB.Dispose();
     }
 }
    /// <summary>
    /// ɾ��
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        try
        {
            //��ȡѡ�е�����Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);

                    HEemployeeData eemployeeData = new HEemployeeData();
                    eemployeeData = eemployeeBB.GetModel(id);

                    eemployeeData.isDel = true;
                    //Ϊ�˱�֤����Ա���û����Ժ�����ٴ�ע�ᣬ��ԭ��¼���˺����
                    eemployeeData.empNo = "";
                    eemployeeBB.ModifyRecord(eemployeeData);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            eemployeeBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
    /// <summary>
    /// �����ʼ��
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnPasswordInit_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        try
        {
            //��ȡѡ�е�����Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);

                    HEemployeeData eemployeeData = new HEemployeeData();
                    eemployeeData = eemployeeBB.GetModel(id);

                    eemployeeData.password = MD5Encrypt.GetMD5("123456");
                    eemployeeBB.ModifyRecord(eemployeeData);

                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"�����ʼ���ɹ�!\");", true);

                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            eemployeeBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
Exemple #9
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        this.Error += new System.EventHandler(PageBase_Error);

        if (Request.Params["itemNo"] != null)
        {
            this.itemNo = Request.QueryString["itemNo"];
        }
        if (Request.Params["pTypeNo"] != null)
        {
            this.permissionsTypeNo = Request.QueryString["pTypeNo"];
        }
        this.currentUser = this.GetCurrentUser();

        if (this.ValidateUrl())
        {
            if (this.IsHavePermissions(this.itemNo, this.permissionsTypeNo))
            {
            }
            else
            {
                Response.Clear();
                Response.Write("<script defer>window.alert('您没有权限进入本页!\\n请与管理员联系');close();history.back();</script>");
                Response.End();
                return;
            }
        }
        else
        {
            Response.Clear();
            Response.Write("<script defer>window.alert('您请求的页面不是一个合法的地址!\\n请与管理员联系');close();</script>");
            Response.End();
            return;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                this.IdValue = Convert.ToInt32(Request.Params["id"]);
            }
            if (Request.Params["state"] != null && Request.Params["state"].Trim() != string.Empty)
            {
                this.State = Request.Params["state"].ToString();
                switch (this.State)
                {
                    case "1":   //add
                        break;
                    case "2":   //update
                        //���ؿؼ�
                        if (this.IdValue != 0)
                        {
                            HEemployeeBB eemployeeBB = new HEemployeeBB();
                            HEemployeeData eemployeeData = new HEemployeeData();
                            try
                            {
                                eemployeeData = eemployeeBB.GetModel(this.IdValue);

                                this.ShowInfo(this.IdValue);
                            }
                            finally
                            {
                                eemployeeBB.Dispose();
                            }
                        }
                        else if (this.currentUser.empId != 0)
                        {
                            //�����޸�����ʱ����ֹ�޸�Ա���˺š����ż�����״̬
                            this.empNo.Enabled = false;
                            this.empNo.BackColor = System.Drawing.Color.FromName("#ECECEC");
                            this.isEffect.Enabled = false;
                            this.btnConsultDept.Disabled = true;
                            //this.password.Enabled = false;
                            //this.password.BackColor = System.Drawing.Color.FromName("#ECECEC");

                            this.IdValue = this.currentUser.empId;
                            this.ShowInfo(this.IdValue);

                            this.btnReturn.Enabled = false;
                        }
                        break;
                    default:
                        break;
                }
            }
        }
    }
 private void SetModel(ref HEemployeeData model)
 {
     model.empNo = this.empNo.Text;
     model.empNm = this.empNm.Text;
     model.gender = this.gender.SelectedValue;
     if (this.nowDepartId.Value != "")
     {
         model.nowDepartId = Convert.ToInt32(this.nowDepartId.Value);
     }
     else
     {
         model.nowDepartId = 0;
     }
     model.mobile = this.mobile.Text;
     model.email = this.email.Text;
     //if (this.style.SelectedValue != "")
     //{
     //    model.style = Convert.ToInt32(this.style.SelectedValue);
     //}
     //else
     //{
     //    model.style = 0;
     //}
     model.style = 1;
     model.mark = this.mark.Text;
     model.isEffect = this.isEffect.Checked;
 }
    /// <summary>
    /// 系统登陆
    /// </summary>
    /// <param name="user"></param>
    /// <param name="voidPin">是否验证密码</param>
    protected void UserLogin(string userName, string passWord, bool voidPin)
    {
        HEemployeeBB userBB = new HEemployeeBB();
        HEemployeeData userData = new HEemployeeData();
        try
        {
            if (userName == "")
            {
                this.lblMsg.Text = "请输入用户名!";
                return;
            }
            string validateString = userBB.ValidatePassword(userName, passWord);
            if (voidPin && validateString != "")
            {
                //记录登陆日志
                this.LoginDiary();

                switch (validateString)
                {
                    case "登陆密码错误!":
                        userData = userBB.GetModel(userName);
                        userData.errorLoginAmount += 1;  //记录连续错误登录次数
                        userBB.ModifyRecord(userData);

                        this.lblMsg.Text = validateString;
                        break;
                    case "第一次登录系统,请首先修改登录密码!":
                    case "您的密码已过期,请重新修改登录密码!":
                    case "您的密码已被初始化,请修改登录密码!":
                        this.lblMsg.Text = "";
                        userData = userBB.GetModel(userName);
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + validateString + "\");window.location.href='Page/System/ChangePwd/ChangePwd.aspx?userId=" + userData.empId.ToString() + "&userNo=" + userData.empNo + "';", true);
                        break;
                    default:
                        this.lblMsg.Text = validateString;
                        break;
                }
            }
            else
            {
                FormsAuthentication.SetAuthCookie(userName, false);
                userData = userBB.GetModel(userName);
                userData.Identity = true;

                //记录用户在线信息
                userData.isOnLine = true;
                userData.loginDate = DateTime.Now.ToString();
                userData.lastOnLineDt = DateTime.Now.ToString();
                userData.sessionId = Session.SessionID;
                userData.errorLoginAmount = 0;  //置连续错误登录次数为0
                userBB.ModifyRecord(userData);

                Session["UserData"] = userData;
                Session["Style"] = userData.style;
                //缓存用户权限
                Session["UserPermissionTable"] = userBB.GetSessionUserPermissionTable(userData.empId);

                //记录登陆日志
                this.LoginDiary();
                try
                {
                    //StringBuilder script = new StringBuilder();
                    //script.Append("<script language=\"javascript\">\r\n");
                    //script.Append("<!--\r\n");
                    //script.Append("	window.open('Main.htm','_blank', 'left=0,top=0,height='+screen.availHeight+'-20,width='+screen.availWidth+',resizable=yes,status=no,titlebar=no,toolbar=no,scrollbars=yes');\r\n");
                    //script.Append("//-->\r\n");
                    //script.Append("</script>");

                    //this.ClientScript.RegisterStartupScript(this.GetType(), "OpenRegister", script.ToString());
                    Response.Redirect("main.htm", false);
                }
                catch (Exception ex)
                {
                }
            }
        }
        catch (Exception ex)
        {
            this.lblMsg.Text = ex.Message;
        }
        finally
        {
            userBB.Dispose();
        }
    }
    public bool ValidateUserLogin(string userNo, string password, out string cMessage, out string strRealName)
    {
        cMessage = "";
        strRealName = "";

        using (HEemployeeBB userBB = new HEemployeeBB())
        {
            if (userNo == "")
            {
                cMessage = "请输入用户名!";
                return false;
            }

            string validateString = userBB.ValidatePassword(userNo, password);
            if (validateString != "")
            {
                cMessage = validateString;
                return false;
            }
            else
            {
                HEemployeeData userModel = new HEemployeeData();

                userModel = userBB.GetModel(userNo);
                cMessage = userModel.empId.ToString();
                strRealName = userModel.empNm;
                return true;
            }
        }
    }
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(HEemployeeData model)
 {
     return this.eemployeeDB.ModifyRecord(model);
 }
 //*****************************************************************************
 //do it later      do it later      do it later
 //*****************************************************************************
 /// <summary>
 /// ��ȡ��Ա����
 /// </summary>
 /// <param name="empId">��ԱId</param>
 /// <returns>��Ա����</returns>
 public string GetEmpNm(string empId)
 {
     HEemployeeData modal = new HEemployeeData();
     modal = this.GetModel(Convert.ToInt32(empId));
     return modal.empNm;
 }
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(HEemployeeData model)
 {
     return this.eemployeeDB.AddRecord(model);
 }