protected void gvFG_RowUpdating(object sender, GridViewUpdateEventArgs e) { String tk = gvFG.DataKeys[e.RowIndex].Value.ToString(); String hoten = (gvFG.Rows[e.RowIndex].Cells[0].Controls[0] as TextBox).Text; String sdt = (gvFG.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox).Text; String email = (gvFG.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox).Text; XLDL.Execute(@"update KhachHang set HoTen= N'" + hoten + "',Email = '" + email + "', SodienThoai = '" + sdt + "' where TaiKhoan='" + tk + "'"); gvFG.EditIndex = -1; getKH(); }
protected void btThem_Click(object sender, EventArgs e) { try { String maSP = Request.QueryString["MaSP"].ToString(); XLDL.Execute("update San_Pham set TenSP = '" + txtTenSP.Text + "',DonGia='" + txtDonGia.Text + "',SoLuong='" + txtConLai.Text + "',GiamGia='" + txtMaGiamGia.Text + "',MSX='" + ddlMaMSX.SelectedItem.Value + "',NgayNhapHang='" + txtNgay.Text + "',MoTa='" + txtMoTa.InnerText + "' where Ma_SP ='" + maSP + "'"); Response.Write("<script>alert('Sửa thành công!')</script>"); } catch { Response.Write("<script>alert('Sửa thất bại!')</script>"); } }
protected void gvFG_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Xoa") { try { int chiso = int.Parse(e.CommandArgument.ToString()); String maFG = gvFG.Rows[chiso].Cells[1].Text; XLDL.Execute("delete from San_Pham where TenSP='" + maFG + "'"); Response.Redirect("QuanLy_SP.aspx"); } catch { Response.Write("<script>alert('Xóa thất bại!!!')</script>"); } } }