Пример #1
0
        private string detailheight()
        {
            Dictionary <string, Object> Description = cupboard.GetDescription();

            Console.WriteLine(String.Format("total height is {0}", ((int)Description["height"]).ToString()));
            return(((int)Description["height"]).ToString());
        }
 /*Builder*/
 public Box(int height, string pannelsColor, Cupboard cupboard, string door)
 {
     this.height       = height;
     this.pannelsColor = pannelsColor;
     this.hasdoor      = (door == "No door") ? false : true;
     this.doorcolor    = ((door == "No door") || (door == "Glass")) ? null : door;
     this.typedoor     = (door == "Glass") ? "GlassDoor" : "ClassicDoor";
     this.Cupboard     = cupboard.GetDescription();
     this.depth        = Convert.ToInt32(Cupboard["depth"]);
     this.width        = Convert.ToInt32(Cupboard["width"]);
     this.stock        = new Stock("Server=localhost;Port=3306;Database=mykitbox;Uid=root;Pwd=; Connect Timeout=60");
     BuildParts();
     ComputePrice();
 }
Пример #3
0
        /*****************************************************************************
        * Pre : - Receives order's infos as parameters                              *
        *       - Database server is on                                             *
        * Post : - Calls make order for the cupboard                                *
        *        - Creates the order in the database                                *
        *        - Creates the client if he does not exist in the database yet      *
        *****************************************************************************/
        public void ConfirmOrder(string clientFirstName, string clientLastName, string adress, string zip, string phoneNumber, Cupboard cupboard)
        {
            /*First handles the order's identifiers (idcom and idclient)*/
            int idCom = 0;

            Connect();
            this.command.CommandText = "SELECT MAX(idcom) FROM client_partscommand";
            try {
                string stepIDCom = command.ExecuteScalar().ToString();
                Console.WriteLine("Command ID is :");
                Console.WriteLine(stepIDCom);
                /* Command ID*/
                idCom = Int32.Parse(stepIDCom) + 1;
            }
            /*Means that there is no command yet in database*/
            catch (FormatException ex) {
                idCom = 1;
                Console.WriteLine("no command in the database yet.");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            connection.Close();
            string idClient = FindClient(clientFirstName, clientLastName);

            /*If the client was not found in the database, that means he has to be created*/
            if (idClient == "")
            {
                Connect();
                command.CommandText = "SELECT MAX(idclient) FROM client";
                try {
                    idClient = ((int)command.ExecuteScalar() + 1).ToString();
                }
                catch (InvalidCastException) {
                    idClient = "1";
                    Console.WriteLine("No client in the database yet.");
                }
                connection.Close();
                Connect();
                command.CommandText = String.Format("INSERT INTO client(idclient, firstname, lastname, adress, zip, phonenumber) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}');", idClient, clientFirstName, clientLastName, adress, zip, phoneNumber);
                command.ExecuteNonQuery();
                connection.Close();
            }
            //Orders the parts
            Dictionary <string, int> parts = MakeOrder(cupboard);

            Connect();
            command.CommandText = String.Format("INSERT INTO client_command(idcom, idclient, description) VALUES ('{0}', '{1}', '{2}');", idCom, idClient, cupboard.GetDescription().ToString());
            foreach (string code in parts.Keys)
            {
                command.CommandText += String.Format("INSERT INTO client_partscommand VALUES ('{0}', '{1}', '{2}');", idCom, code, parts[code]);
                command.CommandText += String.Format("UPDATE part SET real_quantity= real_quantity-{0} WHERE code='{1}';", parts[code], code);
            }
            command.ExecuteNonQuery();
            connection.Close();
        }