0% found this document useful (0 votes)
13 views

Eventargs: Protected Void Object Try

The document contains code for performing CRUD (create, read, update, delete) operations on a suppliers database table in ASP.NET. It includes code handlers for inserting a new supplier, deleting and editing existing suppliers, updating a supplier's details, loading suppliers data into a grid view, and searching for a supplier by ID.

Uploaded by

Hoài An
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Eventargs: Protected Void Object Try

The document contains code for performing CRUD (create, read, update, delete) operations on a suppliers database table in ASP.NET. It includes code handlers for inserting a new supplier, deleting and editing existing suppliers, updating a supplier's details, loading suppliers data into a grid view, and searching for a supplier by ID.

Uploaded by

Hoài An
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Thm

protected void Button1_Click(object sender, EventArgs e) { try { String TenNCC = txtTenNXB.Text; String Diachi = txtDiachi.Text; String Dienthoai = txtDienthoai.Text; string str = "INSERT INTO NHACUNGCAP(TenNCC,DiachiNCC,DienthoaiNCC) VALUES ('" + TenNCC + "','" + Diachi + "','" + Dienthoai + "')"; XLDL.thuchienlenh(str); Response.Redirect("~/Admin/Nhacungcap.aspx"); } catch { lbBaoloi.Text = "Tht bi!"; } }

Xa, sa
protected void GrNhaxuatban_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Nutxoa") { int chiso = int.Parse(e.CommandArgument.ToString());//CHI SO DONG int ma = int.Parse(GrNhaxuatban.Rows[chiso].Cells[0].Text);// LAY MA try { string str = "Delete from NHACUNGCAP where MaNCC=" + ma; XLDL.thuchienlenh(str); Response.Redirect("~/Admin/Nhacungcap.aspx"); } catch { lbBaoloi.Text = "Tht bi!"; } } if (e.CommandName == "Nutsua") { int chiso = int.Parse(e.CommandArgument.ToString()); TextBox1.Text = GrNhaxuatban.Rows[chiso].Cells[0].Text; TextBox1.ReadOnly = true; txtTenNCC.Text = GrNhaxuatban.Rows[chiso].Cells[1].Text; txtDiachi.Text = GrNhaxuatban.Rows[chiso].Cells[2].Text; txtDienthoai.Text = GrNhaxuatban.Rows[chiso].Cells[3].Text; } }

Sa
protected void Button1_Click(object sender, EventArgs e) { string MaNCC = TextBox1.Text; string TenNCC = txtTenNCC.Text; string DiachiNCC = txtDiachi.Text; int DienthoaiNCC = int.Parse(txtDienthoai.Text); string str2 = "UPDATE NHACUNGCAP SET TenNCC=N'" + TenNCC + "', DiachiNCC=N'" + DiachiNCC + "', DienthoaiNCC=" + txtDienthoai.Text + " Where MaNCC='"+MaNCC+"'"; XLDL.thuchienlenh(str2);

Response.Redirect("~/Admin/Nhacungcap.aspx"); }

Load
protected void Page_Load(object sender, EventArgs e) { if (Session["TenDNAdmin"] == null) Response.Redirect("~/Admin/DangnhapAdmin.aspx"); else { string s = "select * from NHACUNGCAP"; DataTable dt = new DataTable(); dt = XLDL.Docbang(s); GrNhaxuatban.DataSource = dt; GrNhaxuatban.DataBind(); TextBox1.Visible = false; } }

Tm Kim
protected void Button1_Click(object sender, EventArgs e) { string MaSv = TextBox1.Text; string str = "select MaSV, Hoten,Ngaysinh from Sinhvien where MaSV='" + MaSV + "'"; DataTable dt = XLDL.Docbang(str); Label1.Text = dt.Rows[0][0].ToString(); Label2.Text = dt.Rows[0][1].ToString(); Label3.Text = dt.Rows[0][2].ToString(); string str2 = "select M.MaMH, TenMH, Sotiet, Diem from Monhoc M, Ketquahoctap K where M.MaMH = K.MaMH and MaSV = + MaLAP + "'"; DataTable dt2 = XLDL.Docbang(str2); GridView1.DataSource = dt2; GridView1.DataBind(); }

You might also like