コード例 #1
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int      id   = int.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text);
            UserInfo user = new UserInfo();

            user.userId = id;
            if (AddUserBll.DeleteUserOK(user))
            {
                Response.Write("<script>alert('ok')</script>");
                bin();
            }
        }
コード例 #2
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int      id       = int.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text);
            Control  control  = GridView1.Rows[e.RowIndex].Cells[1].Controls[0];
            TextBox  textBox  = (TextBox)control;
            string   str      = textBox.Text;
            Control  control2 = GridView1.Rows[e.RowIndex].Cells[2].Controls[0];
            TextBox  textBox2 = (TextBox)control;
            string   str1     = textBox.Text;
            UserInfo user     = new UserInfo();

            user.userName     = str;
            user.userPassword = str1;
            user.userId       = id;
            if (AddUserBll.UpdateUserOK(user))
            {
                Response.Write("<script>alert('ok')</script>");
                bin();
            }
        }
コード例 #3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         DataTable table = new DataTable();
         table = AddUserBll.GetTable();
         UserInfo user = new UserInfo();
         user.userName = txtName.Text.Trim();
         foreach (DataRow item in table.Rows)
         {
             if (item["userName"].ToString() == user.userName)
             {
                 Response.Write("<script>alert('已存在此用户')</script>");
                 return;
             }
         }
         user.userPassword = txtPwd.Text.Trim();
         if (AddUserBll.AddUserOK(user))
         {
             Response.Write("<script>alert('注册成功')</script>");
         }
     }
 }
コード例 #4
0
        public void bin()
        {
            this.GridView1.DataSource = AddUserBll.GetTable();

            this.GridView1.DataBind();
        }