Ejemplo n.º 1
0
        //Para ver el apartado de invenrtario.
        private void dataGridView_Inventario_CellClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                // Editar
                agregarProducto.Limpiar();
                agregarProducto.id          = dataGridView_Inventario.Rows[e.RowIndex].Cells[2].Value.ToString();
                agregarProducto.marca       = dataGridView_Inventario.Rows[e.RowIndex].Cells[3].Value.ToString();
                agregarProducto.modelo      = dataGridView_Inventario.Rows[e.RowIndex].Cells[4].Value.ToString();
                agregarProducto.tipo        = dataGridView_Inventario.Rows[e.RowIndex].Cells[5].Value.ToString();
                agregarProducto.cantidad    = dataGridView_Inventario.Rows[e.RowIndex].Cells[6].Value.ToString();
                agregarProducto.descripcion = dataGridView_Inventario.Rows[e.RowIndex].Cells[7].Value.ToString();

                agregarProducto.ActualizarProducto();
                agregarProducto.ShowDialog();

                return;
            }
            if (e.ColumnIndex == 1)
            {
                // Borrar
                if (MessageBox.Show("¿Seguro de querer borrar el producto? ", "informacion", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    DBInventario.BorrarProducto(dataGridView_Inventario.Rows[e.RowIndex].Cells[2].Value.ToString());
                    MostrarProductos();
                }
                return;
            }
        }
Ejemplo n.º 2
0
        private void btn_AgregarProcuto_Click(object sender, EventArgs e)
        {
            if (txt_idProducto.Text == " ")
            {
                MessageBox.Show("Error al introducir el id de Producto");
                return;
            }

            if (txt_Marca.Text.Trim().Length <= 3)
            {
                MessageBox.Show("Marca no lo suficientemente largo.");
                return;
            }

            if (txt_Modelo.Text.Trim().Length == 40)
            {
                MessageBox.Show("Error al escribir");
                return;
            }

            if (txt_Tipo.Text.Trim().Length == 0)
            {
                MessageBox.Show("campo Incorecto");
                return;
            }

            if (txt_Descripcion.Text.Trim().Length == 20)
            {
                MessageBox.Show("Descripcion incorrecta");
                return;
            }

            if (btn_AgregarProcuto.Text == "Agregar")
            {
                Inventario inventario = new Inventario(txt_idProducto.Text, txt_Marca.Text.Trim(), txt_Modelo.Text.Trim(), txt_Tipo.Text.Trim(), Convert.ToInt32(txtCantidad.Text), txt_Descripcion.Text.Trim(), this.dateTimePicker1.Value);
                DBInventario.AgregarProducto(inventario);
                Limpiar();
            }

            if (btn_AgregarProcuto.Text == "Actualizar")
            {
                Inventario inventario = new Inventario(txt_idProducto.Text, txt_Marca.Text.Trim(), txt_Modelo.Text.Trim(), txt_Tipo.Text.Trim(), Convert.ToInt32(txtCantidad.Text.Trim()), txt_Descripcion.Text.Trim(), this.dateTimePicker1.Value);
                DBInventario.AcutalizarProducto(inventario, id);
                btn_AgregarProcuto.Text = "Agregar";
            }

            _Parent.MostrarProductos();
        }
Ejemplo n.º 3
0
 public void MostrarProductos()
 {
     DBInventario.BuscarYVerProductos("SELECT id, marca, modelo, tipo, cantidad, descripcion, fecha FROM productos", dataGridView_Inventario);
 }
Ejemplo n.º 4
0
 private void txtBuscarProductos_TextChanged(object sender, EventArgs e)
 {
     DBInventario.BuscarYVerProductos("SELECT id, marca, modelo, tipo, cantidad, descripcion, fecha FROM productos WHERE marca LIKE'%" + txtBuscarProductos.Text + "%'", dataGridView_Inventario);
 }