Esempio n. 1
0
 //Вывод изделий
 public static void PrintIzdel()
 {
     using (FIScontext db = new FIScontext())
     {
         if (db.Izdels.Count() != 0)
         {
             foreach (var izdel in db.Izdels.ToList())
             {
                 Console.Write("{0} {1} {2} ", izdel.Id, izdel.Name, izdel.Price);
                 var link = db.Links.FirstOrDefault(L => L.IzdelId == izdel.Id);
                 if (link != null)
                 {
                     Console.WriteLine("{0} {1}", link.IzdelUp, link.Kol);
                 }
                 else
                 {
                     Console.WriteLine("Нет link");
                 }
             }
         }
         else
         {
             Console.WriteLine("Нет изделий");
         }
     }
 }
Esempio n. 2
0
 private void initOrder()
 {
     using (FIScontext db = new FIScontext())
     {
         var productes = db.Izdels.Join(db.Links,
                                        I => I.Id,
                                        L => L.IzdelId,
                                        (I, L) => new Product
         {
             Id            = I.Id,
             Name          = I.Name,
             Parent        = L.IzdelUp,
             Quantity      = L.Kol,
             Price         = L.Kol * I.Price,
             ChildQuantity = 0,
             Label         = false
         });
         foreach (var p in productes)
         {
             products.Add(p);
         }
     }
     for (int i = 0; i < products.Count(); ++i)
     {
         for (int j = 0; j < products.Count(); ++j)
         {
             if (products[i].Id == products[j].Parent && i != j)
             {
                 products[i].children.Add(products[j]);
                 products[i].ChildQuantity++;
             }
         }
     }
 }
Esempio n. 3
0
 public static void AddLink(Link link)
 {
     using (FIScontext db = new FIScontext())
     {
         if (link != null)
         {
             db.Links.Add(link);
             db.SaveChanges();
         }
     }
 }
Esempio n. 4
0
 public static void DeleteLink()
 {
     using (FIScontext db = new FIScontext())
     {
         foreach (var link in db.Links.ToList())
         {
             db.Links.Remove(link);
         }
         db.SaveChanges();
     }
 }
Esempio n. 5
0
 public static void AddIzdel(Izdel izdel)
 {
     using (FIScontext db = new FIScontext())
     {
         if (izdel != null)
         {
             db.Izdels.Add(izdel);
             db.SaveChanges();
         }
     }
 }
Esempio n. 6
0
 public static void DeleteLink(Link link)
 {
     using (FIScontext db = new FIScontext())
     {
         var _link = db.Links.FirstOrDefault(l => l.Id == link.Id);
         if (_link != null)
         {
             db.Links.Remove(_link);
             db.SaveChanges();
         }
     }
 }
Esempio n. 7
0
 public static void Add(Izdel izdel, Link link)
 {
     using (FIScontext db = new FIScontext())
     {
         if (izdel != null && link != null)
         {
             db.Izdels.Add(izdel);
             db.Links.Add(link);
         }
         db.SaveChanges();
     }
 }
Esempio n. 8
0
 public static void DeleteIzdel(Izdel izdel)
 {
     using (FIScontext db = new FIScontext())
     {
         var _izdel = db.Izdels.FirstOrDefault(I => I.Id == izdel.Id);
         if (_izdel != null)
         {
             db.Izdels.Remove(_izdel);
             db.Links.Remove(db.Links.FirstOrDefault(L => L.IzdelId == _izdel.Id));
             db.SaveChanges();
         }
     }
 }
Esempio n. 9
0
 public static void DeleteIzdel()
 {
     using (FIScontext db = new FIScontext())
     {
         foreach (var izdel in db.Izdels.ToList())
         {
             db.Izdels.Remove(izdel);
             var _link = db.Links.FirstOrDefault(L => L.IzdelId == izdel.Id);
             if (_link != null)
             {
                 db.Links.Remove(_link);
             }
         }
         db.SaveChanges();
     }
 }