protected void btnModify_Click(object sender, EventArgs e) { Bll.AdminTable bAdmin = new Bll.AdminTable(); Model.AdminTable mAdmin = new Model.AdminTable(); string strWhere = "ID='" + txtID.Text + "' and AdminPwd='" + txtOldpwd.Text + "'"; DataTable dt = bAdmin.select(strWhere); if (dt.Rows.Count > 0) { if (txtNewpwd.Text == txtPwd.Text) { mAdmin.AdminPwd = txtPwd.Text; mAdmin.AdminName = txtName.Text; mAdmin.ID = Convert.ToInt32(txtID.Text); mAdmin.AdminTrouble = dt.Rows[0]["AdminTrouble"].ToString().Trim(); mAdmin.AdminAnswer = dt.Rows[0]["AdminAnserwer"].ToString().Trim(); if (bAdmin.update(mAdmin, Convert.ToInt32(txtID.Text))) { Response.Write("<script>alert('修改成功!')</script>"); } else { Response.Write("<script>alert('修改失败!')</script>"); } } else { Response.Write("<script>alert('两次密码不一致!')</script>"); } } else { Response.Write("<script>alert('密码错误!')</script>"); } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Bll.AdminTable bAdmin = new Bll.AdminTable(); Model.AdminTable mAdmin = new Model.AdminTable(); // mAdmin.ID = int.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text.ToString().Trim()); mAdmin.AdminName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim(); mAdmin.AdminPwd = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim(); mAdmin.AdminTrouble = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim(); mAdmin.AdminAnswer = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim(); bAdmin.update(mAdmin, Convert.ToInt32((GridView1.Rows[e.RowIndex].Cells[0]).Text.Trim())); GridView1.EditIndex = -1; BindData(); }
protected void btnSubmit_Click(object sender, EventArgs e) { Model.AdminTable mAdmin = new Model.AdminTable(); Bll.AdminTable bAdmin = new Bll.AdminTable(); mAdmin.AdminPwd = txtPwd.Text; mAdmin.ID = Convert.ToInt32(txtID.Text); mAdmin.AdminName = txtName.Text; mAdmin.AdminTrouble = txtTrouble.Text; mAdmin.AdminAnswer = txtAnserwer.Text; if (bAdmin.update(mAdmin, Convert.ToInt32(txtID.Text))) { Response.Write("<script>alert('修改成功!')</script>"); } else { Response.Write("<script>alert('修改失败!')</script>"); } }