public int Delete(DatabaseHelper help) { var t = new Chi_tiet_the_kho //Make sure you have a table called test in DB { ID_The_Kho = this.ID_the_kho, // ID = Guid.NewGuid(), Ma_phieu = this.Ma_phieu, Loai_phieu = this.Loai_phieu, Ngay_xuat_chung_tu = this.Ngay_xuat_chung_tu, Ngay_nhap_xuat = this.Ngay_nhap_xuat, Dien_giai = this.Dien_giai, SL_Nhap = this.SL_Nhap, SL_Xuat = this.SL_Xuat, SL_Ton = this.SL_Ton, Da_quyet_toan = this.Da_quyet_toan, Ghi_chu = this.Ghi_chu, }; help.ent.Chi_tiet_the_kho.Attach(t); help.ent.Chi_tiet_the_kho.Remove(t); return help.ent.SaveChanges(); }
public int Update(DatabaseHelper help) { int temp = 0; var t = new Chi_tiet_the_kho //Make sure you have a table called test in DB { ID_The_Kho = this.ID_the_kho, // ID = Guid.NewGuid(), Ma_phieu = this.Ma_phieu, Loai_phieu = this.Loai_phieu, Ngay_xuat_chung_tu = this.Ngay_xuat_chung_tu, Ngay_nhap_xuat = this.Ngay_nhap_xuat, Dien_giai = this.Dien_giai, SL_Nhap = this.SL_Nhap, SL_Xuat = this.SL_Xuat, SL_Ton = this.SL_Ton, Da_quyet_toan = this.Da_quyet_toan, Ghi_chu = this.Ghi_chu, }; try { using (var context = help.ent) { context.Chi_tiet_the_kho.Attach(t); context.Entry(t).State = EntityState.Modified; temp = help.ent.SaveChanges(); } } catch (Exception ex) { } return temp; }
public int Insert(DatabaseHelper help) { // insert { try { var t = new Chi_tiet_the_kho //Make sure you have a table called test in DB { ID_The_Kho = this.ID_the_kho, // ID = Guid.NewGuid(), Ma_phieu = this.Ma_phieu, Loai_phieu = this.Loai_phieu, Ngay_xuat_chung_tu = this.Ngay_xuat_chung_tu, Ngay_nhap_xuat = this.Ngay_nhap_xuat, Dien_giai = this.Dien_giai, SL_Nhap = this.SL_Nhap, SL_Xuat = this.SL_Xuat, SL_Ton = this.SL_Ton, Da_quyet_toan = this.Da_quyet_toan, Ghi_chu = this.Ghi_chu, }; help.ent.Chi_tiet_the_kho.Add(t); help.ent.SaveChanges(); return 1; } catch (Exception ex) { return 0; } } }