Пример #1
0
        private void pbx_inventario_Click(object sender, EventArgs e)
        {
            if (dgv_inventario.SelectedRows.Count == 1)
            {
                label39.Visible                 = false;
                pictureBox9.Visible             = false;
                pbx_inventario.Visible          = false;
                lbl_inventario.Visible          = false;
                lbl_cantidad_inventario.Visible = true;
                lbl_ok.Visible                = true;
                lbl_cancel.Visible            = true;
                pbx_ok_inventario.Visible     = true;
                pbx_cancel_inventario.Visible = true;
                cantidad_txt.Visible          = true;
                int id = Convert.ToInt32(dgv_inventario.CurrentRow.Cells[0].Value);

                InventarioSeleccionado = InventarioDAL.ObtenerProducto(id);
                cantidad_txt.Text      = InventarioDAL.ObtenerProducto(id).Existencias.ToString();
            }
            else
            {
                MessageBox.Show("Selecciona un producto para modificar");
            }
        }
Пример #2
0
        private void btn_agregar_prod_Click(object sender, EventArgs e)
        {
            int    categoria     = cbx_categorias.SelectedIndex + 1;
            int    proveedor     = cbx_provedores.SelectedIndex + 1;
            int    presentacion  = cbx_presentacion.SelectedIndex + 1;
            int    paquete       = cbx_paquete.SelectedIndex + 1;
            double precio_compra = double.Parse(precio_compra_txt.Text.Trim());
            double precio_venta  = double.Parse(precio_venta_txt.Text.Trim());

            //try
            //{
            Inventario pInventario             = new Inventario();
            Producto   pProducto               = new Producto();
            Productos_presentaciones pPP       = new Productos_presentaciones();
            Productos_paquetes       pPack     = new Productos_paquetes();
            Pedidos_productos        pPed_Prod = new Pedidos_productos();
            int id_ultimo = Convert.ToInt32(ProductoDAL.ObtenerUltimoIDProducto().Id_producto_ultimo);

            pProducto.Nombre = nombre_prod_txt.Text.Trim();
            //pProducto.Precio_compra = precio_compra;
            //pProducto.Precio_venta = precio_venta;
            pProducto.Categoria = categoria;
            pProducto.Proveedor = proveedor;
            int insert_producto = ProductoDAL.Agregar(pProducto);     //AGREGAR PRODUCTO

            pPP.Id_producto     = id_ultimo;
            pPP.Id_presentacion = presentacion;     //AGREGAR CONTENIDO NETO FK

            pPack.Id_producto = id_ultimo;
            pPack.Id_paquete  = paquete;           //AGREGARR PAQUETE FK

            pInventario.productos_id_producto = id_ultimo;
            pInventario.Existencias           = Int32.Parse(existencias_txt.Text.Trim()); //AGREGAR INVENTARIO FK

            pPed_Prod.Id_Producto = id_ultimo;                                            //AGREGAR PRODUCTO A PEDIDOS FK

            int inset_invent            = InventarioDAL.Agregar(pInventario);
            int inset_pedidos_productos = Pedidos_productosDAL.Agregar_producto(pPed_Prod);

            if (insert_producto > 0 && inset_invent > 0 && inset_pedidos_productos > 0)
            {
                MessageBox.Show("Producto Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                llenar.GridView_productos(dgv_productos);
                Limpiar();

                if (cbx_categorias.SelectedIndex == 0 || cbx_categorias.SelectedIndex == 1 || cbx_categorias.SelectedIndex == 2)
                {
                    int insert_prodcuto_pesent  = Productos_presentaciones.Agregar_productos_presentaciones(pPP);
                    int insert_producto_paquete = Productos_paquetes.Agregar_productos_paquetes(pPack);
                    if (insert_prodcuto_pesent > 0 && insert_producto_paquete > 0)
                    {
                        MessageBox.Show("Producto con Presentacion Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        llenar.GridView_productos(dgv_productos);
                        ActualizarComboBoxProductos();
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo guardar el Producto con Presentacion", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        ActualizarComboBoxProductos();
                        llenar.GridView_productos(dgv_productos);
                    }
                }
            }

            else
            {
                MessageBox.Show("No se pudo guardar el Producto Normal", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                ActualizarComboBoxProductos();
                llenar.GridView_productos(dgv_productos);
            }
            //}
            //catch (Exception)
            //{
            //    MessageBox.Show("ERROR. Completa los campos correspondientes");
            //}
        }