protected void btnOk_Click(object sender, EventArgs e)
    {
        string id     = Request.Cookies["id"].Value.ToString();
        int    typeId = 0;

        //  typeId =Convert.ToInt32(Session["typeId"].ToString());
        typeId = Convert.ToInt32(Request.Cookies["typeId"].Value);
        string pwd    = tbANewPwd.Text;
        string oldPwd = tbOldPwd.Text;

        Fannie.Users user = new Fannie.Users();
        DataTable    dt   = user.IsPwdRight(id, oldPwd, typeId).Tables[0];

        if (dt.Rows.Count == 0)
        {
            Response.Write("<script>alert('原密码输入错误');location.href='ModifyPwd.aspx'</script>");
        }
        else
        {
            if (user.ModifyPwd(id, pwd, typeId) > 0)
            {
                Response.Write("<script>alert('修改成功');location.href='ModifyPwd.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败');location.href='ModifyPwd.aspx'</script>");
            }
        }
    }
Example #2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string id   = tbName.Text;
        string pwd  = tbPwd.Text;
        int    type = 0;

        Fannie.Users user = new Fannie.Users();
        if (rblType.SelectedIndex == 0)
        {
            type = 2;
        }
        else if (rblType.SelectedIndex == 2)
        {
            type = 0;
        }
        else if (rblType.SelectedIndex == 1)
        {
            type = 1;
        }
        int re = user.IsUserExist(id, type);

        if (re == 0)
        {
            Response.Write("<script>alert('该用户不存在');location.href='Login.aspx'</script>");
        }
        else if (re == 1)
        {
            DataTable dt = user.IsPwdRight(id, pwd, type).Tables[0];
            if (dt.Rows.Count == 0)
            {
                Response.Write("<script>alert('密码错误');location.href='Login.aspx'</script>");
            }
            else
            {
                Response.Cookies["id"].Value = id.ToString();
                Session["id"] = id.ToString();
                Response.Cookies["typeId"].Value = type.ToString();
                Session["typeId"] = type.ToString();
                Response.Redirect("~/Default.aspx");
            }
        }
    }