Beispiel #1
0
 static public void Create(wholesalers wholesaler)
 {
     using (var db = new StudiaProjektBazyDanychEntities())
     {
         db.wholesalers.Add(wholesaler);
         db.SaveChanges();
     }
 }
Beispiel #2
0
        static public void DeleteByName(string companyName)
        {
            using (var db = new StudiaProjektBazyDanychEntities())
            {
                wholesalers wholesaler = db.wholesalers.SingleOrDefault(x => x.company == companyName);

                var entry = db.Entry(wholesaler);
                if (entry.State == System.Data.Entity.EntityState.Detached)
                {
                    db.wholesalers.Attach(wholesaler);
                }
                db.wholesalers.Remove(wholesaler);
                db.SaveChanges();
            }
        }
        static public void FinalizeOrder(wholesalers localWholesaler, string additionalInformation)
        {
            using (var db = new StudiaProjektBazyDanychEntities())
            {
                var DBWholesaler = db.wholesalers.SingleOrDefault(t => t.id == localWholesaler.id);

                if (LocalOrder.cases != null)
                {
                    LocalOrder.id_case = LocalOrder.cases.id;
                    //db.cases.SingleOrDefault(t => t.id == LocalOrder.id_case).warehouse_orders.Add(LocalOrder);
                }
                if (LocalOrder.graphics_cards != null)
                {
                    LocalOrder.id_graphics_card = LocalOrder.graphics_cards.id;
                    //db.graphics_cards.SingleOrDefault(t => t.id == LocalOrder.id_graphics_card).warehouse_orders.Add(LocalOrder);
                }
                if (LocalOrder.motherboards != null)
                {
                    LocalOrder.id_motherboard = LocalOrder.motherboards.id;
                    //db.motherboards.SingleOrDefault(t => t.id == LocalOrder.id_motherboard).warehouse_orders.Add(LocalOrder);
                }
                if (LocalOrder.processors != null)
                {
                    LocalOrder.id_processor = LocalOrder.processors.id;
                    //db.processors.SingleOrDefault(t => t.id == LocalOrder.id_processor).warehouse_orders.Add(LocalOrder);
                }
                if (LocalOrder.ram_memories != null)
                {
                    LocalOrder.id_ram_memory = LocalOrder.ram_memories.id;
                    //db.ram_memories.SingleOrDefault(t => t.id == LocalOrder.id_ram_memory).warehouse_orders.Add(LocalOrder);
                }
                LocalOrder.id_wholesaler          = DBWholesaler.id;
                LocalOrder.wholesalers            = DBWholesaler;
                LocalOrder.additional_information = additionalInformation;
                LocalOrder.status     = (int)WarehouseOrderStatus.Ordered;
                LocalOrder.order_date = DateTime.Now;
                db.warehouse_orders.Add(LocalOrder);
                db.SaveChanges();
                ResetOrder();
            }
        }