public static bool UpdateNCC(NCC nCC) { try { using (var _context = new DBQuanLyBangBarcodeEntities()) { /* * foreach (var iTem in nCC.listitem) * { * var iTemdb = (from u in _context.items * where u.itemcode == iTem.itemcode * select u).Single(); * iTemdb.listNCC.Add(nCC); * } * nCC.listitem.Clear(); */ _context.NCCs.AddOrUpdate(nCC); _context.SaveChanges(); return(true); } } catch { return(false); } }
public static bool DeleteNCC(NCC nCC) { using (var _context = new DBQuanLyBangBarcodeEntities()) { var dbnCC = (from u in _context.NCCs where u.NCCcode == nCC.NCCcode select u).SingleOrDefault(); _context.NCCs.Remove(dbnCC); _context.SaveChanges(); return(true); } }
public static bool AddNCC(NCC nCC) { /* * using (var _context = new DBQuanLyBangBarcodeEntities()) * { * if (nCC.listitem != null) * { * foreach (var iTem in nCC.listitem) * { * var itemdb = (from i in _context.items * where i.itemcode == iTem.itemcode * select i).Single(); * // itemdb.NCCs.Add(nCC); * } * } * if (nCC.listitem != null) * { * nCC.listitem.Clear(); * } * _context.NCCs.AddOrUpdate(nCC); * _context.SaveChanges(); * return true; * } */ try { using (var _context = new DBQuanLyBangBarcodeEntities()) { _context.NCCs.Add(nCC); _context.SaveChanges(); return(true); } } catch { return(false); } }