Exemplo n.º 1
0
        static void DbAddOrder(Order order)
        {
            string   columnNames = "Order_Id, Client_Id, Date, Header_Bill, Footer_Bill";
            string   tableName   = "order_informations";
            string   Client_Id   = order.GetCurrentClient.GetId.ToString();
            BDD      database    = new BDD("kitbox");
            DateTime date        = DateTime.Now;
            string   dateString  = date.ToString();
            string   data        = "1," + Client_Id + "," + dateString + ",Header_Bill,Footer_Bill";

            database.addElement(tableName, columnNames, data);
        }
Exemplo n.º 2
0
        public static void DbAddClient(Person person)
        {
            BDD    database    = new BDD("kitbox");
            string firstname   = person.FirstName;
            string lastname    = person.LastName;
            int    phonenumber = person.PhoneNumber;
            string email       = person.Email;
            int    id          = person.Id;
            string password    = person.Password;
            Dictionary <string, object> address = person.Address;
            string data = firstname + "," + lastname + "," + phonenumber + "," + email + "," + password + "," + address["Street"] + ";" + address["Street number"] + ";" + address["Postal code"];

            database.addElement("client_table", textString.columnNames("client_table"), data);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This functions adds a the data of a new client to the database.
        /// </summary>
        /// <param name="person">Person</param>
        public static void DbAddClient(Person person)
        {
            BDD    database    = new BDD("kitbox");
            string firstname   = person.FirstName;
            string lastname    = person.LastName;
            int    phonenumber = person.PhoneNumber;
            string email       = person.Email;
            int    id          = person.Id;
            string password    = person.Password;
            Dictionary <string, object> address = person.Address;
            string data = "'" + firstname + "','" + lastname + "'," + phonenumber + ",'" + email + "','" + password + "','" + address["Street"] + ";" + Convert.ToString(address["Street number"]) + ";" + address["Postal code"].ToString() + "',''";

            database.addElement("client", "Firstname,Lastname,Phonenumber,Email,Password,Address,Favoris", data);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds in the database the order given in the parameter, fills
        /// the tables with the components and links them to the current
        /// client and his the ordrer. The order must have a current_client
        /// with an existing id
        /// </summary>
        /// <param name="order">Order.</param>
        public static void DbAddOrder(Order order)
        {
            BDD database = new BDD("kitbox");
            Dictionary <string, object> bill = textString.bill();
            Dictionary <string, Dictionary <string, object> > components = new Dictionary <string, Dictionary <string, object> >();
            string   header_bill = bill["header"].ToString();
            string   footer_bill = bill["footer"].ToString();
            string   columnNames = "Client_Id, Date, Header_Bill, Footer_Bill";
            string   tableName   = "orders";
            string   client_id   = order.CurrentClient.Id.ToString();
            DateTime date        = DateTime.Now;

            date.AddDays(order.Delayed);
            string dateString = date.ToString();
            string data       = string.Format("{0},'{1}','{2}','{3}'", client_id, dateString, header_bill, footer_bill);

            // The order id is auto incremented in the orders table and we add
            // in the orders table : the client id, the date, the header bill and the footer bill
            database.addElement(tableName, columnNames, data);
            List <List <object> > list = database.readElement("Order_Id", tableName, string.Format("WHERE Client_Id = '{0}'", client_id.ToString()));
            int           order_id     = Convert.ToInt32(list[list.Count - 1][0]);
            List <object> wardrobes    = order.Wardrobes;

            tableName   = "rel_catord";
            columnNames = "Order_Id ,Wardrobe_Id,Box_Id,Component_Id";
            data        = "";
            // Choose a wardrobe in the list of wardrobes
            for (int i = 1; i <= wardrobes.Count; i++)
            {
                Wardrobe wardrobe   = (Wardrobe)wardrobes[i - 1];
                int      number_box = wardrobe.Components["Etage"].Count;
                data = string.Format("{0},{1},{2},{3}", order_id.ToString(), i.ToString(), "", "");
                // Choose an Angle
                foreach (KeyValuePair <string, object> cornieres in wardrobe.Components["Cornieres"])
                {
                    Angle  angle = (Angle)cornieres.Value;
                    string Id    = database.readElement("Id", "catalog", string.Format("WHERE Code='{0}'", angle.Code.ToString()))[0][0].ToString();
                    data = string.Format("'{0}','{1}','{2}','{3}'", order_id.ToString(), i.ToString(), "0", Id);
                    // Add the corner and its information in the table
                    database.addElement(tableName, columnNames, data);
                }
                // Choose a box of the wardrobe
                for (int j = 1; j <= number_box; j++)
                {
                    data = string.Format("{0},{1},{2},{3}", order_id.ToString(), i.ToString(), j.ToString(), "");
                    // The "Etage" key gives all the boxes
                    foreach (KeyValuePair <string, object> kvp in wardrobe.Components["Etage"])
                    {
                        if (Convert.ToInt32(kvp.Key) == j)
                        {
                            Box box = (Box)wardrobe.Components["Etage"][j.ToString()];
                            Dictionary <string, Dictionary <string, Part> > parts = box.Pieces;
                            foreach (KeyValuePair <string, Dictionary <string, Part> > kvp2 in parts)
                            {
                                // Choose a part
                                foreach (KeyValuePair <string, Part> kvp3 in kvp2.Value)
                                {
                                    string Id = database.readElement("Id", "catalog", string.Format("WHERE Code='{0}'", kvp3.Value.Code.ToString()))[0][0].ToString();
                                    data = string.Format("{0},{1},{2},{3}", order_id.ToString(), i.ToString(), j.ToString(), Id);
                                    // Add the part of the box and its information in the database
                                    database.addElement(tableName, columnNames, data);
                                }
                            }
                        }
                    }
                }
            }
        }