Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (SQLiteConnection connect = new SQLiteConnection("Data Source=..\\..\\..\\..\\Kitbox.db"))
            {
                connect.Open();
                using (SQLiteCommand fmd = connect.CreateCommand())
                {
                    Guid a = Guid.NewGuid();
                    fmd.CommandText = @"INSERT INTO Orders (ID_Order, Price) VALUES('" + a + "', 333333)";
                    fmd.ExecuteNonQuery();
                }
            }


            //MessageBox.Show(fmd.CommandText);
            List <Product> products = order.GenerateOrder();

            foreach (Product product in products)
            {
                //REMOVE THE ORDERED PIECES FROM THE STOCK
                // & PLACE MISSING PIECES INTO DB (TO ORDER)
                order.UpdateDatabase(product);
            }

            //CLOSE THE FORM & THE APP
            outp.MakeFiles(order);
            this.Close();
            Form f = new ParentForm();

            f.Show();
        }
Exemplo n.º 2
0
        //makes list of items to prepare for the vendor
        public void MakeList(Order order)
        {
            string        line  = null;
            string        path  = (@"../../../List of" + now + ".txt");
            List <string> lines = new List <string>
            {
                "List of the" + now + "for" + "client",
                " ",
                "n° / item / availibility"
            };


            foreach (Product item in ProductSorter.RemoveDoubles(order.GenerateOrder()))
            {
                int n = 1;
                line = n.ToString() + "/" + item.ToString() + "/";
                if (order.CheckStock(item))
                {
                    line += "Available";
                }
                else
                {
                    line += "Not in Stock";
                }

                lines.Add(line);
                n += 1;
            }

            lines.ToArray();
            System.IO.File.WriteAllLines(path, lines);
        }
Exemplo n.º 3
0
        //calculates the total price of the cupboard
        public int TotalPrice(Order order)
        {
            int totalPrice = 0;

            foreach (Product product in order.GenerateOrder())
            {
                totalPrice += product.Price;
            }
            return(totalPrice);
        }
Exemplo n.º 4
0
        //makes a bill for the client
        public List <string> MakeBill(Order order)
        {
            string   line              = null;
            int      totalPrice        = 0;
            int      compartmentPrices = 0;
            Cupboard cupboard;

            foreach (Product product in order.GenerateOrder())
            {
                totalPrice += product.Price;
            }
            foreach (Item item in order.ItemList)
            {
                if (item is Cupboard)
                {
                    cupboard = item as Cupboard;
                    foreach (Compartment compartment in cupboard.GetAllCompartments())
                    {
                        foreach (Product product in compartment.ItemToProduct())
                        {
                            compartmentPrices += product.Price;
                        }
                    }
                }
            }

            List <string> lines = new List <string>
            {
                "Bill made on the " + now + " for the client",
                id,
                "Item bought/price/availability",
                "cupboard/" + ((totalPrice - compartmentPrices) / 10000.0).ToString() + ""//pour ici
            };

            int i = 1;

            foreach (Item item in order.ItemList)
            {
                if (item is Cupboard)
                {
                    cupboard = item as Cupboard;

                    foreach (Compartment compartment in cupboard.GetAllCompartments())
                    {
                        //SET compartment AS available
                        string availability = "Available";

                        int price = 0;

                        foreach (Product product in compartment.ItemToProduct())
                        {
                            price += product.Price;

                            //To be deleted
                            lines.Add(product.ToString() + " Available : " + order.CheckStock(product).ToString());

                            //IF one piece is missing => SET AS not in stock
                            if (!order.CheckStock(product))
                            {
                                availability = "Not in stock";
                            }
                        }
                        line = "compartment n°" + i.ToString() + "/" + (price / 10000.0).ToString() + "/" + availability;
                        i   += 1;
                        lines.Add(line);
                    }
                }
            }
            string totalPriceString = "Total price: " + (totalPrice / 10000.0).ToString();

            lines.Add(totalPriceString);
            double vat      = totalPrice * 1.21;
            string vatPrice = "Total price with VAT: " + (vat / 10000.0).ToString();

            lines.Add(vatPrice);
            return(lines);
        }