예제 #1
0
 private AntennaProduct addAntennaProduct(int antennaPortID, int productID)
 {
     WMScontext ctx = new WMScontext();
     AntennaProduct antennaProduct = new AntennaProduct
     {
         DateCreated = DateTime.Now,
         AntennaPortID = antennaPortID,
         ProductID = productID
     };
     return antennaProduct;
 }
예제 #2
0
 private AntennaPort addAntennaPort(int portNumber, Purpose purpose, int warehouseID)
 {
     WMScontext ctx = new WMScontext();
     AntennaPort antennaPort = new AntennaPort
     {
         PortNumber = portNumber,
         Purpose = purpose,
         DateCreated = DateTime.Now,
         WarehouseID = warehouseID
     };
     return antennaPort;
 }
예제 #3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            WMScontext ctx = new WMScontext();
            Product product1 = (Product)productCB1.SelectedItem;
            Product product2 = (Product)productCB2.SelectedItem;
            Product product3 = (Product)productCB3.SelectedItem;
            Product product4 = (Product)productCB4.SelectedItem;
            Purpose purpose1 = (Purpose)purposeCB1.SelectedItem;
            Purpose purpose2 = (Purpose)purposeCB2.SelectedItem;
            Purpose purpose3 = (Purpose)purposeCB3.SelectedItem;
            Purpose purpose4 = (Purpose)purposeCB4.SelectedItem;
            Warehouse warehouse = (from ware in ctx.Warehouses where ware.WarehouseID == 1 select ware).SingleOrDefault();

            if (antennaPortGB1.Enabled)
            {
                AntennaPort antennaPort1 = addAntennaPort(1, purpose1, warehouse.WarehouseID);
                ctx.AntennaPorts.Add(antennaPort1);
                ctx.SaveChanges();

                if (productCB1.Enabled)
                {
                    ctx.AntennaProducts.Add(addAntennaProduct(antennaPort1.AntennaPortID, product1.ProductID));
                    ctx.SaveChanges();
                }
            }

            if (antennaPortGB2.Enabled)
            {
                AntennaPort antennaPort2 = addAntennaPort(2, purpose2, warehouse.WarehouseID);
                ctx.AntennaPorts.Add(antennaPort2);
                ctx.SaveChanges();

                if (productCB2.Enabled)
                {
                    ctx.AntennaProducts.Add(addAntennaProduct(antennaPort2.AntennaPortID, product2.ProductID));
                    ctx.SaveChanges();
                }
            }

            if (antennaPortGB3.Enabled)
            {
                AntennaPort antennaPort3 = addAntennaPort(3, purpose3, warehouse.WarehouseID);
                ctx.AntennaPorts.Add(antennaPort3);
                ctx.SaveChanges();

                if (productCB3.Enabled)
                {
                    ctx.AntennaProducts.Add(addAntennaProduct(antennaPort3.AntennaPortID, product3.ProductID));
                    ctx.SaveChanges();
                }
            }

            if (antennaPortGB4.Enabled)
            {
                AntennaPort antennaPort4 = addAntennaPort(4, purpose4, warehouse.WarehouseID);
                ctx.AntennaPorts.Add(antennaPort4);
                ctx.SaveChanges();

                if (productCB4.Enabled)
                {
                    ctx.AntennaProducts.Add(addAntennaProduct(antennaPort4.AntennaPortID, product4.ProductID));
                    ctx.SaveChanges();
                }
            }
        }