示例#1
0
        private void btnSaveItem_Click(object sender, EventArgs e)
        {
            bool flag = false;

            Items _items = new Items();

            _items.Name_model_item   = txtItem.Text;
            _items.Size_model_item   = txtSize.Text;
            _items.Colour_model_item = txtColour.Text;
            _items.Price_model_item  = double.Parse(txtPrice.Text);
            _items.Item_quantity     = int.Parse(txtQuantity.Text);
            _items.Status_stock      = cmbStatus.Text;


            CtrlItems ctrl = new CtrlItems();



            if (txtItem_ID.Text != "")
            {
                _items.Id_model_item = int.Parse(txtItem_ID.Text);
                flag = ctrl.update(_items);
            }
            else
            {
                flag = ctrl.insert(_items);
            }

            if (flag)
            {
                MessageBox.Show("Item saved");
                clear_data();
                loadTable(null);
            }
        }
示例#2
0
        public void loadTable(string data)
        {
            List <Items> lista      = new List <Items>();
            CtrlItems    _ctrlItems = new CtrlItems();

            dataGridView1.DataSource = _ctrlItems.request(data);
        }
示例#3
0
        private void btnDeleteItem_Click(object sender, EventArgs e)
        {
            bool         flag    = false;
            DialogResult message = MessageBox.Show("Are you sure that you want to delete the item?", "Exit", MessageBoxButtons.YesNoCancel);

            if (message == DialogResult.Yes)
            {
                int       id    = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                CtrlItems _ctrl = new CtrlItems();
                flag = _ctrl.delete(id);

                if (flag)
                {
                    MessageBox.Show("Item saved");
                    clear_data();
                    loadTable(null);
                }
            }
        }
示例#4
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);
        }