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