protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int Ma_Loai_Xe_canxoa = (int)GridView1.DataKeys[e.RowIndex].Value; LinQtoSQLDataContext tam_context = new LinQtoSQLDataContext(); Loai_Xe obj = tam_context.Loai_Xes.SingleOrDefault(Loai_Xe => Loai_Xe.Ma_Loai_Xe == Ma_Loai_Xe_canxoa); tam_context.Loai_Xes.DeleteOnSubmit(obj); tam_context.SubmitChanges(); show_chungloai(); }
protected void btnThem_Click1(object sender, EventArgs e) { //them moi chung loại san pham LinQtoSQLDataContext tam_context = new LinQtoSQLDataContext(); Loai_Xe obj = new Loai_Xe { Ten_Loai_Xe = txtTenLoaiXe.Text, }; tam_context.Loai_Xes.InsertOnSubmit(obj); tam_context.SubmitChanges(); show_chungloai(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //tham chieu den các đối tượng tai dong hieu chinh hien tai TextBox txt_TenLoai_Xe = GridView1.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox; //chuan bi int Ma_Loai_Xe_dangsua = (int)GridView1.DataKeys[e.RowIndex].Value; LinQtoSQLDataContext tam_context = new LinQtoSQLDataContext(); Loai_Xe obj = tam_context.Loai_Xes.SingleOrDefault(Loai_Xe => Loai_Xe.Ma_Loai_Xe == Ma_Loai_Xe_dangsua); obj.Ma_Loai_Xe = Ma_Loai_Xe_dangsua; obj.Ten_Loai_Xe = txt_TenLoai_Xe.Text; //thuc hien tam_context.SubmitChanges(); GridView1.EditIndex = -1; show_chungloai(); }