protected void Button1_Click(object sender, EventArgs e)
        {
            string name     = TextBox1.Text;
            string password = TextBox2.Text;

            if (name == "" || password == "")
            {
                Response.Write("<script>alert('用户名或密码不能为空')</script>");
            }
            else
            {
                string  sqlstr = string.Format("select * from td_user where UserName='******' and PassWord ='******'", name, password);
                DataSet ds     = DBhelper.GetDataSet(sqlstr);
                if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    Session["UserName"] = name;
                    Session["Role"]     = ds.Tables[0].Rows[0]["Role"].ToString();
                    Response.Redirect("index.aspx");
                }
                else
                {
                    Response.Write("<script>alert('用户名或密码不正确')</script>");
                }
            }
        }
Example #2
0
        public void LoadData(string name)
        {
            string sqlstr = "select * from td_user";

            if (name != "")
            {
                sqlstr += " where UserName like'%" + name + "%'";
            }
            DataSet ds = DBhelper.GetDataSet(sqlstr);

            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
        }