Esempio n. 1
0
        public static int addBikeTemplate(BikeTemplate t)
        {
            string q = tools.DatabaseQuery.addBikeTemplate(t);

            Database.setData(q);

            foreach (KitTemplate kt in t.getListKit())
            {
                link_kit_to_tbike(t, kt);
            }

            return(0);
        }
Esempio n. 2
0
        public static Dictionary <string, BikeTemplate> getBikeTemplates(List <CatalogBike> cbList, List <KitTemplate> ktList)
        {
            string    query = DatabaseQuery.getTBike();
            DataTable dt    = tools.Database.getData(query);
            Dictionary <string, BikeTemplate> Btemp = new Dictionary <string, BikeTemplate>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int id     = Convert.ToInt32(dt.Rows[i]["id"]);
                int id_cat = Convert.ToInt32(dt.Rows[i]["id_cat"]);

                foreach (CatalogBike cb in cbList)
                {
                    if (cb.getId() == id_cat)
                    {
                        BikeTemplate bt = new BikeTemplate(id, cb);

                        string    q   = DatabaseQuery.getKitId_byTBike(id);
                        DataTable kdt = Database.getData(q);

                        for (int j = 0; j < kdt.Rows.Count; j++)
                        {
                            int idK = Convert.ToInt32(kdt.Rows[j]["id"]);

                            foreach (KitTemplate kt in ktList)
                            {
                                if (kt.getId() == idK)
                                {
                                    bt.linkKitTemplate(kt);
                                }
                            }
                        }

                        if (!Btemp.ContainsKey(bt.Key))
                        {
                            Btemp.Add(bt.Key, bt);
                        }
                    }
                }
            }

            return(Btemp);
        }
        private void BT_Add_Click(object sender, RoutedEventArgs e)
        {
            int qnt = Convert.ToInt32(BikeQuantity.Text);

            string      b_name  = ((CatalogBike.displayInfo)BikeCatalog.SelectedItem).name;
            string      b_color = BikeColor.SelectedItem.ToString();
            string      b_size  = BikeSize.SelectedItem.ToString();
            CatalogBike cb      = ((CatalogBike.displayInfo)BikeCatalog.SelectedItem).CurCatBike;

            BikeBasket bb = new BikeBasket(b_name, b_color, b_size, cb, qnt);

            BikeTemplate bt = bb.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 < bb.qnt; i++)
            {
                int bikeID = Controler.Instance.getLastBikeId() + 1;

                DateTime constr_date  = TempSale.getConstrDate();
                DateTime planned_date = TempSale.getNextPrevisionDate();

                int poste = Controler.Instance.getAvailablePoste();

                Bike tempB = new Bike(bikeID, 0, -1, poste, bt, planned_date, constr_date);

                Controler.Instance.createBike(tempB);
            }

            this.Close();
        }
 public static string link_kit_to_tbike(BikeTemplate bt, KitTemplate kt)
 {
     return("INSERT INTO `bv_templatebikekit` (`id_tBike`, `id_tKit`) VALUES (" + bt.getId() + ", " + kt.getId() + ")");
 }
 public static string addBikeTemplate(BikeTemplate t)
 {
     return("INSERT INTO `bv_templatebike` (`id`, `id_cat`) VALUES (" + t.getId() + ", " + t.getCat().getId() + ")");
 }
Esempio n. 6
0
        public static int link_kit_to_tbike(BikeTemplate bt, KitTemplate kt)
        {
            string q = tools.DatabaseQuery.link_kit_to_tbike(bt, kt);

            return(Database.setData(q));
        }