Ejemplo n.º 1
0
        public void loadTable(string data)
        {
            List <Items> lista      = new List <Items>();
            CtrlItems    _ctrlItems = new CtrlItems();

            dataGridView1.DataSource = _ctrlItems.request(data);
        }
Ejemplo n.º 2
0
        public DateTime EstimateDeliveryTime()
        {
            string          sql          = "SELECT max(production_date) FROM command";
            MySqlConnection connectionDB = Connection.connection();

            connectionDB.Open();
            DateTime myDate = DateTime.Now;

            try
            {
                string date;


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


                if (reader.Read())
                {
                    try
                    {
                        date   = reader.GetString(0);
                        myDate = Convert.ToDateTime(date);
                        myDate = myDate.AddDays(1);
                        date   = myDate.ToString();
                        var x = date.Split(' ');
                        x[1]   = "08:00:00";
                        date   = string.Join(" ", x);
                        myDate = Convert.ToDateTime(date);
                    }
                    catch
                    {
                        myDate = myDate.AddDays(1);
                        date   = myDate.ToString();
                        var x = date.Split(' ');
                        x[1]   = "08:00:00";
                        date   = string.Join(" ", x);
                        myDate = Convert.ToDateTime(date);
                    }
                }
                CtrlItems     _ctrlItems      = new CtrlItems();
                List <Object> stock           = _ctrlItems.request(null);
                bool          notEnough       = false;
                int           production_time = 0;
                int           days            = 0;
                foreach (Model_Bike element in Form1.Instance.Cart.list_models)
                {
                    if (!notEnough)
                    {
                        foreach (KeyValuePair <string, int> item in element.items)
                        {
                            String name         = item.Key.Split('_')[0];
                            String color        = item.Key.Split('_')[1];
                            String size         = item.Key.Split('_')[2];
                            int    qtt_will_use = item.Value * element.quantity;
                            foreach (Items elem_stock in stock)
                            {
                                if (name == elem_stock.Name_model_item && color == elem_stock.Colour_model_item && size == elem_stock.Size_model_item)
                                {
                                    elem_stock.Qtt_available -= qtt_will_use;
                                    notEnough = elem_stock.Qtt_available - elem_stock.Qtt_used < 0 ? true : false;
                                    if (notEnough)
                                    {
                                        days += 7;
                                    }
                                }
                            }
                        }
                    }
                    for (int i = 0; i < element.quantity; i++)
                    {
                        if (element.type == "City")
                        {
                            production_time += 120;
                        }
                        else if (element.type == "Explorer")
                        {
                            production_time += 150;
                        }
                        else
                        {
                            production_time += 165;
                        }
                        if (production_time / 3 >= 8 * 60)
                        {
                            production_time = 0;
                            days++;
                        }
                    }
                }
                Console.WriteLine(production_time);
                production_time = production_time / 3 + 100;
                myDate          = myDate.AddDays(days);
                myDate          = myDate.AddMinutes(production_time);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally{
                connectionDB.Close();
            }


            return(myDate);
        }