예제 #1
0
 private void BindData()
 {
     this.ddl_role.DataSource     = bllr.GetModelList("");
     this.ddl_role.DataTextField  = "RoleName";
     this.ddl_role.DataValueField = "ID";
     this.ddl_role.DataBind();
     if (Request.QueryString["id"] != null)
     {
         string ids = Request.QueryString["id"].ToString();
         if (ids != "0")
         {
             zs.Model.Tbl_User model = bll.GetModel(int.Parse(ids));
             this.tb_name.Text           = model.userName;
             this.tb_Psw.Text            = model.userPsw;
             this.ddl_role.SelectedValue = bllur.GetModelList("UserID=" + ids)[0].RoleID.ToString();
             this.Button1.Text           = "修改";
             ViewState["userid"]         = ids;
         }
     }
 }
예제 #2
0
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        zs.BLL.Tbl_User blluser  = new zs.BLL.Tbl_User();
        string          userName = CheckInput(this.tb_userName.Text.Trim());
        string          userPSW  = CheckInput(this.tb_password.Text.Trim());

        if (blluser.Exists(userName))
        {     //存在用户名
            if (blluser.GetModel(userName).userPsw == ApplicationMethod.encript(userPSW))
            { //密码正确
                Response.Cookies["userId"].Value   = blluser.GetModel(userName).id.ToString();
                Response.Cookies["userName"].Value = blluser.GetModel(userName).userName;
                Response.Redirect("./Default.aspx");
            }
            else
            {//密码错误
                ClientScript.RegisterClientScriptBlock(this.GetType(), "showPError", "<script>alert('用户名密码不正确,请确认!')</script>");
            }
        }
        else
        {//用户名不存在
            ClientScript.RegisterClientScriptBlock(this.GetType(), "showUError", "<script>alert('用户名密码不正确,请确认!')</script>");
        }
    }