public void createBikeTemplate(BikeTemplate t)
        {
            DatabaseClassInterface.addBikeTemplate(t);

            if (!bikeTemplateList.ContainsKey(t.Key))
            {
                bikeTemplateList.Add(t.Key, t);
            }
        }
Ejemplo n.º 2
0
 public Bike(int id_, int status_, int id_sale_, int Poste_, BikeTemplate bt_, DateTime planned_date_, DateTime constr_date_)
 {
     id           = id_;
     status       = status_;
     BikeTemplate = bt_;
     id_sale      = id_sale_;
     Poste        = Poste_;
     PlannedDate  = planned_date_;
     ConstrucDate = constr_date_;
 }
Ejemplo n.º 3
0
        public BikeTemplate CreateBikeTemplate()
        {
            BikeTemplate bt = new BikeTemplate(-1, curbike);

            //pour chaque category de kit
            foreach (KitCategory i in Enum.GetValues(typeof(KitCategory)))
            {
                List <KitTemplate> kt_list = curbike.getKitTemplateList().Where(x => x.getCategory() == i).ToList();  //list des kits correspondant à la cat

                //si il y a que un kit -> on l'ajoute
                if (kt_list.Count == 1)
                {
                    bt.linkKitTemplate(kt_list[0]);
                }
                else if (kt_list.Count > 1)       //si plusieur -> ajoute le kit qui correspond au couleur et en taille
                {
                    foreach (KitTemplate kt in kt_list)
                    {
                        string[] props = kt.getProperties().Split('|');
                        if (props.Count() == 2)
                        {
                            if ((props[0] == size) && (props[1] == color))
                            {
                                bt.linkKitTemplate(kt);
                            }
                        }
                        else
                        {
                            if ((props[0] == color) || (props[0] == size))
                            {
                                bt.linkKitTemplate(kt);
                            }
                        }
                    }
                }
            }

            if (Controler.Instance.getBikeTemplateList().ContainsKey(bt.Key))
            {
                return(Controler.Instance.getBikeTemplateList()[bt.Key]);
            }

            return(bt);
        }
Ejemplo n.º 4
0
        public void saveSale()
        {
            saleID = Controler.Instance.getLastSaleId() + 1;

            int sellerID = Controler.Instance.getCurrentUser().getId();
            int clientID = client.getId();

            DateTime sale_date      = DateTime.Now;
            DateTime prevision_date = getNextPrevisionDate();   //date de début de constrution

            List <User>   userList   = Controler.Instance.getUserList();
            List <Client> clientList = Controler.Instance.getClientList();


            Sale sale = new Sale(saleID, sellerID, clientID, "Open", sale_date, prevision_date, userList, clientList);

            Controler.Instance.createSale(sale);


            foreach (BikeBasket b in Basket.Values)
            {
                BikeTemplate bt = b.CreateBikeTemplate();
                if (bt.getId() == -1)
                {
                    int id_bt = Controler.Instance.getLastBikeTemplateId() + 1;
                    bt.setId(id_bt);
                    Controler.Instance.createBikeTemplate(bt);
                }



                for (int i = 0; i < b.qnt; i++)
                {
                    int bikeID = Controler.Instance.getLastBikeId() + 1;

                    //check if we have a bike in stock
                    List <Bike> BikeStock = Controler.Instance.getBikesList().Where(x => ((x.getSaleId() == -1) && (x.getState() == 2) && (x.getBikeTempl().Key == bt.Key))).ToList(); // list of bike witch correspond to the requested bike

                    if (BikeStock.Count > 0)
                    {
                        Bike temp_bikeStock = BikeStock.First();
                        temp_bikeStock.setSaleId(saleID);
                        sale.addbike(temp_bikeStock);
                        DatabaseClassInterface.updateBike(temp_bikeStock);
                    }
                    else
                    {
                        // if not create a new one
                        DateTime constr_date  = getConstrDate();
                        DateTime planned_date = getNextPrevisionDate();

                        int  poste = Controler.Instance.getAvailablePoste();
                        Bike tempB = new Bike(bikeID, 0, saleID, poste, bt, planned_date, constr_date);

                        sale.addbike(tempB);
                        Controler.Instance.createBike(tempB);
                    }
                }
            }

            Bike bk = sale.getBikeList().Last();

            sale.setPrevSaleDate(bk.getPlannedtDate());

            drainTempSale();
        }
 public void link_kit_to_tbike(BikeTemplate bt, KitTemplate kt)
 {
     DatabaseClassInterface.link_kit_to_tbike(bt, kt);
 }