public int Delete(Loai_Phieu_Nhap dm) { DatabaseHelper help = new DatabaseHelper(); help.ConnectDatabase(); using (var dbcxtransaction = help.ent.Database.BeginTransaction()) { help.ent.Loai_Phieu_Nhap.Attach(dm); help.ent.Loai_Phieu_Nhap.Remove(dm); int temp = help.ent.SaveChanges(); dbcxtransaction.Commit(); return temp; } }
public int Update(Loai_Phieu_Nhap kho) { DatabaseHelper help = new DatabaseHelper(); help.ConnectDatabase(); int temp = 0; using (var dbcxtransaction = help.ent.Database.BeginTransaction()) { using (var context = help.ent) { context.Loai_Phieu_Nhap.Attach(kho); context.Entry(kho).State = EntityState.Modified; temp = help.ent.SaveChanges(); dbcxtransaction.Commit(); } } return temp; }