Esempio n. 1
0
    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);
        }
    }
Esempio n. 2
0
    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="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();
        }
    }
    /// <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();
        }
    }