Esempio n. 1
0
        private void btn_set_mounters_Click(object sender, EventArgs e)
        {
            char a = Form1.Instance.index_Haut.Connection_User.Text[14];

            this.pnl_week_orders_forMounter.Controls.Clear();
            Orders = new Dictionary <Model_Bike, Client>();
            MySqlDataReader reader = null;
            String          sql    = "SELECT * from bikes, command,customer where bikes.N_command = command.id_command and customer.id = command.id_customer order by bikes.production_order";

            MySqlConnection connectionDB = Connection.connection();

            connectionDB.Open();

            try
            {
                MySqlCommand comando = new MySqlCommand(sql, connectionDB);
                reader = comando.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Model_Bike bike = new Model_Bike(reader.GetString("colour"), reader.GetString("type_bike"), reader.GetString("size"), 1, 1);
                        bike.set_id(reader.GetInt16("id_bike"));
                        bike.set_order(reader.GetInt16("production_order"));
                        bike.set_status(reader.GetString("Status"));
                        bike.set_mounter(reader.GetInt16("Id_mounter").ToString());
                        Orders.Add(bike, new Client(reader.GetString("firstname"), reader.GetString("lastname"), reader.GetString("email"), reader.GetString("adress"), int.Parse(reader.GetString("postalcode")), reader.GetString("city"), reader.GetString("business_name")));
                    }
                }
                else
                {
                    MessageBox.Show("NoOrderWasfound");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Searching error" + ex.Message);
            }
            finally
            {
                connectionDB.Close();
            }
            foreach (KeyValuePair <Model_Bike, Client> elt in Orders)
            {
                MounterOrder order = new MounterOrder(elt.Key.id_bike.ToString(), elt.Key.type, elt.Key.colour, elt.Key.size, elt.Value.last_name, elt.Value.business_name, elt.Key.order.ToString(), elt.Key.status);
                if (Form1.Instance.index_Haut.Connection_User.Text[14] == elt.Key.mounter[0])
                {
                    order.Status_bike.Enabled = true;
                }
                else if (order.Status_bike.Text != "Waiting")
                {
                    order.Status_bike.Enabled = false;
                }
                Form1.Instance.MounteurControl.pnl_week_orders_forMounter.Controls.Add(order);
            }
        }
Esempio n. 2
0
        private void btn_get_orders_Click(object sender, EventArgs e)
        {
            Form1.Instance.production_Planning.title_production_planning.Text     = "This week orders are";
            Form1.Instance.production_Planning.title_production_planning.Location = new Point(287, 57);
            Form1.Instance.production_Planning.btn_get_orders.Visible             = false;
            Form1.Instance.production_Planning.pnl_week_orders.Visible            = true;

            Dictionary <Model_Bike, Client> Orders = new Dictionary <Model_Bike, Client>();

            String          sql    = "SELECT * from bikes, command,customer where bikes.id_command = command.id_command and customer.id_customer = command.id_customer ";
            MySqlDataReader reader = null;

            /* MySqlDataReader reader = null;
             * reader    = Connection.SearchReader(sql);
             * Console.WriteLine(2);
             * if (reader.HasRows)
             * {
             *   while (reader.Read())
             *   {
             *       Console.WriteLine(1);
             *       Model_Bike bike = new Model_Bike(reader.GetString("colour"), reader.GetString("type_bike"), reader.GetString("size"), 1, 1);
             *       bike.set_id(reader.GetInt16("id_bike"));
             *
             *       Orders.Add(bike, new Client(reader.GetString("firstname"), reader.GetString("lastname"), reader.GetString("email"), reader.GetString("adress"), int.Parse(reader.GetString("postalcode")), reader.GetString("city"), reader.GetString("business_name")));
             *   }
             *
             * }
             * else
             * {
             *   MessageBox.Show("NoOrderWasfound");
             *
             * }*/

            MySqlConnection connectionDB = Connection.connection();

            connectionDB.Open();
            try
            {
                MySqlCommand comando = new MySqlCommand(sql, connectionDB);
                reader = comando.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Model_Bike bike = new Model_Bike(reader.GetString("colour"), reader.GetString("type_bike"), reader.GetString("size"), 1, 1, reader.GetString("production_date"));
                        Console.WriteLine(bike.delivery_time);
                        bike.set_id(reader.GetInt16("id_bike"));
                        bike.set_order(reader.GetInt16("production_order"));
                        Orders.Add(bike, new Client(reader.GetString("firstname"), reader.GetString("lastname"), reader.GetString("email"), reader.GetString("adress"), int.Parse(reader.GetString("postalcode")), reader.GetString("city"), reader.GetString("business_name")));
                    }
                }
                else
                {
                    MessageBox.Show("NoOrderWasfound");
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Searching error" + ex.Message);
            }
            finally
            {
                connectionDB.Close();
            }


            foreach (KeyValuePair <Model_Bike, Client> elt in Orders)
            {
                Form1.Instance.production_Planning.pnl_week_orders.Controls.Add(new WeekOrders(elt.Key.id_bike.ToString(), elt.Key.type, elt.Key.size, elt.Value.last_name, elt.Value.business_name, elt.Key.order.ToString(), elt.Key.delivery_time.Split(' ')[0]));
            }
        }