예제 #1
0
        private void btnAceptarAgregar_Click(object sender, EventArgs e)
        {
            Producto         agregar    = new Producto();
            ProductoNegocio  negocio    = new ProductoNegocio();
            Proveedor        Aux        = new Proveedor();
            ProveedorNegocio auxnegocio = new ProveedorNegocio();

            if (txtNombreAgregar.Text == "" || txtMarcaAgregar.Text == "" || txtPrecioAgregar.Text == "" || txtStockAgregar.Text == "")
            {
                MessageBox.Show("Debe completar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    decimal aux;

                    agregar.descripcion = txtNombreAgregar.Text;
                    agregar.marca       = txtMarcaAgregar.Text;
                    agregar.precio      = decimal.Parse(txtPrecioAgregar.Text);
                    aux = int.Parse(txtPorcentaje.Text);
                    agregar.precioVenta     = (agregar.precio * aux / 100) + agregar.precio;
                    agregar.porcentGanancia = int.Parse(txtPorcentaje.Text);
                    agregar.stock           = int.Parse(txtStockAgregar.Text);
                    agregar.estado          = true;
                    Aux = (Proveedor)cbxProveedores.SelectedItem;

                    negocio.Agregarproducto(agregar);

                    agregar.idProducto = negocio.buscar_ultimo_idprod();
                    auxnegocio.CargarProdXProv(Aux.idProveedor, agregar.idProducto);

                    cargarGrilla();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }