示例#1
0
        private void buttonAgregarC_Click(object sender, EventArgs e)
        {
            if (textBoxNombreP.Text == "" || textBoxPrecio.Text == "" || comboBoxTipo.Text == "" || comboBoxConsola.Text == "" || comboBoxGenero.Text == "" || comboBoxStatus.Text == "")
            {
                MessageBox.Show("Rellenar todos los campos");
            }
            else
            {
                textBoxImagen.Text = textBoxImagen.Text.Replace(@"\", @"\\");
                Connection.OpenConnection();
                Class_.Producto nProducto = new Class_.Producto(1, textBoxNombreP.Text, comboBoxTipo.Text, comboBoxConsola.Text, comboBoxGenero.Text, comboBoxStatus.Text, float.Parse(textBoxPrecio.Text), 0, textBoxImagen.Text, true);
                Class_.Producto.AgregarProducto(Connection.myConnection, nProducto);
                Connection.CloseConnection();
                MessageBox.Show("Captura Exitosa");
                LoadData();
                labelIDproducto.Text = "ID " + MaxId().ToString();

                textBoxImagen.Clear();
                textBoxNombreP.Clear();
                textBoxPrecio.Clear();
                comboBoxTipo.Text    = "";
                comboBoxConsola.Text = "";
                comboBoxGenero.Text  = "";
                comboBoxStatus.Text  = "";
                //pictureBoxImage.Image = Image.FromFile("C:\\Users\\kyo_9\\Documents\\GitHub\\Gamers\\Interfaz de usuario1.1\\Interfaz de usuario\\Resources\\Question.png");
            }
        }
示例#2
0
        private void buttonConsultaC_Click(object sender, EventArgs e)
        {
            Connection.OpenConnection();
            MySqlDataReader reader = Class_.Producto.BuscarProducto(Connection.myConnection, dataGridView1.CurrentRow.Cells[0].Value.ToString());

            if (reader.Read())
            {
                if (reader.GetBoolean(9))
                {
                    Class_.Producto   nProducto         = new Class_.Producto(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetFloat(6), reader.GetInt32(7), reader.GetString(8), reader.GetBoolean(9));
                    Consulta_Producto consulta_producto = new Consulta_Producto(nProducto, Connection);
                    Connection.CloseConnection();

                    consulta_producto.ShowDialog();
                    LoadData();
                }
                else
                {
                    MessageBox.Show("ID no existe");
                }
            }
            else
            {
                MessageBox.Show("ID no existe");
            }
            Connection.CloseConnection();
        }
示例#3
0
        public Consulta_Producto(Class_.Producto Producto, Class_.Connection Connection)
        {
            InitializeComponent();

            this.Producto   = Producto;
            this.Connection = Connection;
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Connection.OpenConnection();
            MySqlDataReader reader = Class_.Producto.BuscarProducto(Connection.myConnection, textBox1.Text);

            if (reader.Read())
            {
                if (reader.GetBoolean(9))
                {
                    Class_.Producto   nProducto         = new Class_.Producto(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetFloat(6), reader.GetInt32(7), reader.GetString(8), reader.GetBoolean(9));
                    Consulta_Producto consulta_producto = new Consulta_Producto(nProducto, Connection);
                    Connection.CloseConnection();
                    this.Close();
                    consulta_producto.ShowDialog();
                }
                else
                {
                    MessageBox.Show("ID no existe");
                }
            }
            else
            {
                MessageBox.Show("ID no existe");
            }
            Connection.CloseConnection();
        }
示例#5
0
        private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                Connection.OpenConnection();

                bool flag = false;

                MySqlDataReader reader = Class_.Producto.BuscarProducto(Connection.myConnection, idProducto2);

                if (reader.Read())
                {
                    if (Duplicate(idProducto2))
                    {
                        flag = true;
                    }

                    Class_.Producto producto = GetProduct(reader);

                    if (producto.Tipo == "Videojuegos" && producto.Status == "Seminuevo")
                    {
                        double PrecioCompra = producto.Precio * .5;
                        PrecioCompra = Math.Round(PrecioCompra, 1);

                        dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index - 1);

                        Connection.CloseConnection();
                        Connection.OpenConnection();


                        if (flag)
                        {
                            AddQuantity(idProducto2);
                        }
                        else
                        {
                            dataGridView1.Rows.Add(idProducto2, producto.Nombre, producto.Status, 1, PrecioCompra, PrecioCompra);
                        }
                    }
                    else
                    {
                        if (producto.Tipo != "Videojuegos")
                        {
                            MessageBox.Show("Solo se pueden comprar Videojuegos");
                        }
                        else if (producto.Status != "Seminuevo")
                        {
                            MessageBox.Show("ERROR, Solo se pueden comprar juegos usados");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Codigo no existe");
                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index - 1);
                }
                Connection.CloseConnection();
                Total(comboBoxTipoPago.Text);
            }
        }
示例#6
0
        // Regresa un producto dependiendo del query
        private Class_.Producto GetProduct(MySqlDataReader reader)
        {
            Class_.Producto producto = new Class_.Producto(reader.GetInt32(0), reader.GetString(1), reader.GetString(2),
                                                           reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetFloat(6), reader.GetInt32(7),
                                                           reader.GetString(8), reader.GetBoolean(9));

            return(producto);
        }
示例#7
0
        //Verifica si el producto cuenta con suficiente stock para ser vendido
        private int CheckStock(string idProducto)
        {
            MySqlDataReader reader = Class_.Producto.BuscarProducto(Connection.myConnection, idProducto);

            if (reader.Read())
            {
                Class_.Producto product = GetProduct(reader);
                return(product.Stock);
            }
            return(0);
        }
示例#8
0
        //Agregar detalles con tecla Enter
        private void dataGridView1_KeyPress_1(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                Connection.OpenConnection();

                bool flag = false;

                MySqlDataReader reader = Class_.Producto.BuscarProducto(Connection.myConnection, idProducto2);

                if (reader.Read())
                {
                    if (Duplicate(idProducto2))
                    {
                        flag = true;
                    }

                    Class_.Producto producto = GetProduct(reader);

                    /*double Resultado = producto.Precio / 1.16;
                     * Resultado = Math.Round(Resultado, 1);*/

                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index - 1);

                    Connection.CloseConnection();
                    Connection.OpenConnection();

                    if (1 > producto.Stock)
                    {
                        MessageBox.Show("No hay suficiente Stock");
                    }
                    else
                    {
                        if (flag)
                        {
                            AddQuantity(idProducto2);
                        }
                        else
                        {
                            comboBoxTipoPago.Enabled = true;
                            dataGridView1.Rows.Add(idProducto2, producto.Nombre, producto.Status, 1, producto.Precio, producto.Precio);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Codigo no existe");
                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index - 1);
                }
                Connection.CloseConnection();
                Total();
            }
        }
示例#9
0
        private void buttonAccept_Click(object sender, EventArgs e)
        {
            imagen = imagen.Replace(@"\", @"\\");

            Connection.OpenConnection();
            Class_.Producto nProducto = new Class_.Producto(Producto.ID, textBoxNom.Text, comboBoxTipo.Text, comboBoxConsola.Text, comboBoxGenero.Text, comboBoxStatus.Text, float.Parse(textBoxPrec.Text), int.Parse(textBoxStock.Text), imagen, true);
            Class_.Producto.ModificarProducto(Connection.myConnection, nProducto);
            Connection.CloseConnection();

            MessageBox.Show("Datos Modificados");
            this.Close();
        }
示例#10
0
        //Funcion para disminuir el Stock del producto para cada Fila del gridview
        private void DecreaseStock()
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string idProduct     = Convert.ToString(row.Cells[0].Value);
                int    StockDecrease = Convert.ToInt32(row.Cells["Cantidad"].Value);

                Connection.OpenConnection();
                MySqlDataReader reader = Class_.Producto.BuscarProducto(Connection.myConnection, idProduct);
                if (reader.Read())
                {
                    Class_.Producto product = GetProduct(reader);
                    product.Stock = product.Stock - StockDecrease;

                    Connection.CloseConnection();

                    Connection.OpenConnection();
                    product.Ruta = product.Ruta.Replace(@"\", @"\\");
                    Class_.Producto.ModificarProducto(Connection.myConnection, product);
                }

                Connection.CloseConnection();
            }
        }