예제 #1
0
        public static bool Deleteitem(item iTem)
        {
            using (var _context = new DBQuanLyBangBarcodeEntities())
            {
                //xoa item
                var dbiTem = (from u in _context.items
                              where u.itemcode == iTem.itemcode
                              select u).SingleOrDefault();

/*
 *              foreach (var x in dbiTem.listNCC)
 *              {
 *                  foreach (var u in x.listitem)
 *                  {
 *                      if (u.itemcode == iTem.itemcode)
 *                      {
 *                          x.listitem.Remove(u);
 *                          break;
 *                      }
 *                  }
 *              }
 */
                //delete
                _context.items.Remove(dbiTem);
                _context.SaveChanges();
                return(true);
            }
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
 public static bool Updateitem(item iTem)
 {
     try
     {
         using (var _context = new DBQuanLyBangBarcodeEntities())
         {
             _context.items.AddOrUpdate(iTem);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
        public static void initializeDB()
        {
            using (var _context = new DBQuanLyBangBarcodeEntities())
            {
                var iTem = new item {
                    itemcode = "ABC0123", itemname = "Mi tom", NSX = DateTime.Now, HSD = DateTime.Now, NNK = DateTime.Now
                };
                _context.items.Add(iTem);
                var nCC = new NCC {
                    NCCcode = "123", NCCname = "Mien trung", NLDCC = DateTime.Now
                };
                _context.NCCs.Add(nCC);

                _context.SaveChanges();
            }
            MessageBox.Show("finish");
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
 public static bool Additem(item iTem)
 {
     try
     {
         using (var _context = new DBQuanLyBangBarcodeEntities())
         {
             foreach (var nCC in iTem.listNCC)
             {
                 var nCCbd = (from u in _context.NCCs
                              where u.NCCcode == nCC.NCCcode
                              select u).Single();
                 nCCbd.listitem.Add(iTem);
             }
             iTem.listNCC.Clear();
             _context.items.AddOrUpdate(iTem);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }