Exemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            sqlHelper sh = new sqlHelper();

            string strCmd = "select * from userslogin where username='******' and password='******'";
            bool flag = sh.excuteReader(strCmd);

            if (flag)
            {
                DataTable dt = sh.GetList(strCmd).Tables[0];
                if (txtPassword1.Text != "" && txtPassword1.Text != "")
                {
                    if (int.Parse(txtPassword1.Text) == int.Parse(txtPassword.Text))
                    {
                        Response.Write("<script>alert('和原密码相同,修改失败!')</script>");
                    }
                    else if (int.Parse(txtPassword1.Text) != int.Parse(txtPassword2.Text))
                    {
                        Response.Write("<script>alert('密码不一致!')</script>");
                    }
                    else
                    {
                        string sql = "update userslogin set password='******'where username ='******'";
                        if (sh.excuteNonQuery(sql))
                        {
                            Response.Write("<script>alert('修改成功');window.location='login.aspx';</script>");
                        }
                    }
                }
                else
                {
                    Response.Write("<script>alert('修改值不能为空!')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('用户名或密码错误!')</script>");
            }
        }
Exemplo n.º 2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            sqlHelper sh = new sqlHelper();

            string strCmd = "select * from userslogin where username='******' and password='******'";

            bool flag = sh.excuteReader(strCmd);

            if (flag)
            {
                //使用数据访问类中的GetList方法获取数据表,并返回给dt对象
                DataTable dt = sh.GetList(strCmd).Tables[0];
                //Session对象保存用户登录名、用户类型
                Session["name"] = dt.Rows[0]["username"];
                Session["type"] = dt.Rows[0]["type"];
                Response.Redirect("default.aspx");
            }
            else
            {
                Response.Write("<script>alert('用户名或密码错误!')</script>");
            }
        }