Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string sqlstr = string.Format("insert into td_user(UserName,PassWord,Email,Role) values('{0}','{1}','{2}','{3}')", txtUserName.Text, txtPassWord.Text, txtEmail.Text, "普通用户");
            bool   yesno  = DBhelper.InsertUpdateDel(sqlstr);

            if (yesno == true)
            {
                txtEmail.Text     = "";
                txtPassWord.Text  = "";
                txtPassWord2.Text = "";
                txtUserName.Text  = "";
                Response.Write("<script>alert('注册成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('注册失败!')</script>");
            }
        }
Exemplo n.º 3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Session["Role"].ToString() == "管理员")
     {
         string sqlstr = string.Format("insert into td_user(UserName,PassWord,Email,Role) values('{0}','{1}','{2}','{3}')", txtUserName.Text, txtPassWord.Text, txtEmail.Text, txtEmail.Text, DropDownList1.SelectedItem.Text);
         bool   yesno  = DBhelper.InsertUpdateDel(sqlstr);
         if (yesno == true)
         {
             Response.Write("<script>alert('保存成功')</script>");
         }
         else
         {
             Response.Write("<script>alert('保存失败')</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('无权限!')</script>");
     }
 }