Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                cbPresentacion.DisplayMember = "Text";
                cbPresentacion.ValueMember   = "Value";
                // cbPresentacion.Items.Add(new { Text = "Liquidos", Value = "Liquidos" });

                if (txtNombreDelProducto.Text == "" || txtCantidad.Text == "" || txtCostoUnitario.Text == "" || txtGrupoPerteneciente.Text == "" || txtPrecioCredito.Text == "" || txtPrecioDeContado.Text == "" || cbPresentacion.Text == "")
                {
                    MessageBox.Show("Parece que olvidaste llenar todos los campos", "¡Cuidado!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    _en.Cantidad            = decimal.Parse(txtCantidad.Text);
                    _en.CostoUnitario       = decimal.Parse(txtCostoUnitario.Text);//Tipo de variable de int a decimal
                    _en.GrupoPertenenciente = txtGrupoPerteneciente.Text;
                    _en.NombreProducto      = txtNombreDelProducto.Text;
                    // _en.PorcentajeGananciaContado = decimal.Parse(txtPorcentajeDeContado.Text);
                    //_en.PorcentajeGananciaCredito = decimal.Parse(txtPorcentajePrecioCredito.Text);sadas
                    _en.PrecioACredito = decimal.Parse(txtPrecioCredito.Text);
                    _en.PrecioContado  = decimal.Parse(txtPrecioDeContado.Text);
                    _en.Presentacion   = cbPresentacion.Text;

                    int Resultado = _inventarioBl.AgregarProductos(_en);
                    dgInventario.Refresh();
                    dgInventario.DataSource = _inventarioBl.MostrarInventario();

                    if (Resultado == 1)
                    {
                        MessageBox.Show("Se agrego el nuevo producto correctamente", "¡Éxito!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        Limpiar();
                    }
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Hubo un error al agregar el producto", "¡Advertencia!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Beispiel #2
0
        private void bAgregar_Click(object sender, EventArgs e)
        {
            try
            {//Trim sirve para borrar espacios si es que existen
                Inventario   _en            = new Inventario();
                InventarioBL _inventarioBl  = new InventarioBL();
                int          intVerificador = 0;

                string strNombreProveedor   = txtNombreProveedor.Text.ToString().Trim();
                string strFactura           = txtNoFactura.Text.ToString().Trim();
                string strFechaAdquisicion  = txtFechaAdquisicion.Text.ToString().Trim();
                string strProductoAdquirido = txtProductoAdquirido.Text.ToString().Trim();
                string strCantidad          = txtCantidad.Text.ToString().Trim();
                string strTotalAPagar       = txtMontoPagar.Text.ToString().Trim();
                string strStatus            = txtStatus.Text.ToString().Trim();



                if (txtNombreProveedor.Text == ("") || txtNoFactura.Text == ("") || txtFechaAdquisicion.Text == ("") || txtProductoAdquirido.Text == ("") || txtCantidad.Text == ("") || txtMontoPagar.Text == ("") || txtStatus.Text == (""))
                {
                    MessageBox.Show("Parece que olvidaste llenar todos los campos", "¡Cuidado!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                else
                {
                    _enCuentas.FcNombreProveedor   = txtNombreProveedor.Text;
                    _enCuentas.FiNoFactura         = int.Parse(txtNoFactura.Text);
                    _enCuentas.FDtFechaAdquisicion = txtFechaAdquisicion.Text;
                    _enCuentas.FcProductoAdquirido = txtProductoAdquirido.Text;
                    _enCuentas.FdTotalAPagar       = decimal.Parse(txtMontoPagar.Text);
                    _enCuentas.FdCantidad          = decimal.Parse(txtCantidad.Text);
                    _enCuentas.FcStatus            = txtStatus.Text;

                    foreach (var productoInventario in _inventarioBl.MostrarInventario())
                    {
                        _en.IdProducto          = productoInventario.IdProducto;
                        _en.NombreProducto      = productoInventario.NombreProducto;
                        _en.GrupoPertenenciente = productoInventario.GrupoPertenenciente;
                        _en.Cantidad            = productoInventario.Cantidad;
                        _en.Presentacion        = productoInventario.Presentacion;
                        _en.CostoUnitario       = productoInventario.CostoUnitario;
                        _en.PrecioContado       = productoInventario.PrecioContado;
                        _en.PrecioACredito      = productoInventario.PrecioACredito;

                        if (_en.NombreProducto.Equals(_enCuentas.FcProductoAdquirido))
                        {
                            _en.Cantidad = _en.Cantidad + int.Parse(_enCuentas.FdCantidad.ToString());
                            _inventarioBl.ModificarProducto(_en);
                            int Resultado = _cuentasBL.AgregarCuentasPorPagar(_enCuentas);
                            dGCuentasPagar.Refresh();
                            dGCuentasPagar.DataSource = _cuentasBL.MostrarCuentasPorPagar();
                            MessageBox.Show("¡Se realizó el registro correctamente!", "¡Éxito!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            intVerificador = 1;
                            Limpiar();
                        }
                    }
                    if (intVerificador != 1)
                    {
                        MessageBox.Show("No se encontro el producto. Favor de darlo de alta en inventario e intentarlo nuevamente.", "¡Error!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        Limpiar();
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
                MessageBox.Show("Hubo un error al agregar el registro", "¡Error!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Beispiel #3
0
        private void bAgregar_Click(object sender, EventArgs e)
        {
            try
            {//Trim sirve para borrar espacios si es que existen
                Inventario   _en            = new Inventario();
                InventarioBL _inventarioBl  = new InventarioBL();
                int          intVerificador = 0;

                string strfolioNota        = txtFolioNota.Text.ToString().Trim();
                string strNombreDelCliente = txtNombreCliente.Text.ToString().Trim();
                string strNombreProducto   = txtNombreProducto.Text.ToString().Trim();
                string strCantidad         = txtCantidad.Text.ToString().Trim();
                string strCausaD           = txtCausaDevolucion.Text.ToString().Trim();
                string strFechaDevolucion  = txtFechaDevolucion.Text.ToString().Trim(); //Aqui agregue/cambie.. SE supone que aqui agrego manualmente no.!?


                if (strfolioNota.Equals("") || strNombreProducto.Equals("") || txtCantidad.Equals("") || strCausaD.Equals("") || strNombreDelCliente.Equals("") || strFechaDevolucion.Equals(""))
                {
                    MessageBox.Show("Parece que olvidaste llenar todos los campos", "¡Cuidado!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    _enDevolucion.fiFolioVenta = int.Parse(txtFolioNota.Text);
                    _enDevolucion.fcNombreProductoDevolucion = txtNombreProducto.Text;
                    _enDevolucion.fiCantidadDevolucion       = int.Parse(txtCantidad.Text);
                    _enDevolucion.fcCausaDevolucion          = txtCausaDevolucion.Text;
                    _enDevolucion.fcFechaDevolucion          = txtFechaDevolucion.Text;
                    _enDevolucion.fcNombreDelCliente         = txtNombreCliente.Text;


                    foreach (var productoInventario in _inventarioBl.MostrarInventario())
                    {
                        _en.IdProducto          = productoInventario.IdProducto;
                        _en.NombreProducto      = productoInventario.NombreProducto;
                        _en.GrupoPertenenciente = productoInventario.GrupoPertenenciente;
                        _en.Cantidad            = productoInventario.Cantidad;
                        _en.Presentacion        = productoInventario.Presentacion;
                        _en.CostoUnitario       = productoInventario.CostoUnitario;
                        _en.PrecioContado       = productoInventario.PrecioContado;
                        _en.PrecioACredito      = productoInventario.PrecioACredito;

                        if (_en.NombreProducto.Equals(_enDevolucion.fcNombreProductoDevolucion))
                        {
                            _en.Cantidad = _en.Cantidad + _enDevolucion.fiCantidadDevolucion;
                            _inventarioBl.ModificarProducto(_en);
                            int Resultado = _bldevolucion.AgregarDevolucion(_enDevolucion);

                            MessageBox.Show("¡Se realizó la devolución correctamente!", "¡Éxito!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            intVerificador = 1;
                            Limpiar();
                        }
                    }
                    if (intVerificador != 1)
                    {
                        MessageBox.Show("No se encontro el producto. Favor de verificar", "¡Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        Limpiar();
                    }
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Hubo un error al realizar la devolución. Favor de validar", "¡Advertencia!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)//Venta a credito 08/03/19
        {
            try
            {
                strtipoDeVenta = "2";
                Inventario   _en           = new Inventario();
                InventarioBL _inventarioBl = new InventarioBL();

                //Variables del Metodo
                double doTotalSumaProductos;
                double doTotalSumaProductosCredito;
                double intCantidadProducto;
                int    intCantidadProductoafectarInventario = 0;
                string strNombreModificado   = string.Empty;
                string strIdProductoComparar = string.Empty;
                int    intCantidadModificada = 0;
                int    iteracion             = 1;


                if (!FdFechaPago.Equals(string.Empty))
                {
                    _enVentas.fDtFechaSalida  = FdFechaSalida.Text.ToString();
                    _enVentas.fcNombreCliente = FcNombreCliente.Text.ToString();
                    _enVentas.fcDomicilio     = FcDomicilio.Text.ToString();
                    _enVentas.fcCiudad        = FcCiudad.Text.ToString();
                    _enVentas.fcTelefono      = FcTelefono.Text.ToString();
                    _enVentas.fcFechaPago     = FdFechaPago.Text.ToString();                //Tenia FcDomicilio cambio de variable 08/03/19
                    //_enVentas.fiCantidad = txtCantidad.Text.ToString(); // de prueba
                    _enVentas.fiCantidad = Int32.Parse(txtCantidad.Text);                   //Agregado para ver si guarda el dato correcto, cambio de variable 08/03/19
                    //_enVentas.fiCantidad = 1; // cantidad? aqui es un elemento nada mas.. osease lo unico que puedo meter es la cantidad total de articulos adquiridos en conjunto.. no individuales
                    _enVentas.fcConcepto       = txtNombre.Text.ToString();                 //Obtiene el valor de la venta mas no de la busqueda 08/03/19
                    _enVentas.fdPrecioUnitario = decimal.Parse(txtTotalAPagarCredito.Text); //Precio por unidad 08/03/19

                    // aqui ayudame con un if

                    if (true) // si preciona el boton de imprimir y contado que le debuelva el objeto de douTotalSumaProductosCredito,
                              //en caso de lo contrario que le devuelba el objeto douTotalSumaProductos.. son doubles
                    {         //Prueba
                        intCantidadProducto         = double.Parse(txtCantidad.Text.ToString().Trim());
                        doTotalSumaProductosCredito = douTotalSumaProductosCredito + intCantidadProducto;
                    }
                    else
                    {
                        // doTotalSumaProductos = douTotalSumaProductos + intCantidadProducto;
                    }

                    _enVentas.fdTotal   = decimal.Parse(FdTotal.Text);    //Haber que hace
                    _enVentas.fdImporte = decimal.Parse(txtImporte.Text); //Haber que hace 09/03/19

                    int RespuestaTipoVenta = _ventasBL.AgregarVenta(_enVentas);

                    if (!RespuestaTipoVenta.Equals(null))
                    {
                        foreach (DataGridViewRow producto in dgTotalProductos.Rows)
                        {
                            strNombreModificado   = producto.Cells[3].Value.ToString();
                            intCantidadModificada = int.Parse(producto.Cells[1].Value.ToString());
                            strIdProductoComparar = producto.Cells[4].Value.ToString();

                            foreach (var productoInventario in _inventarioBl.MostrarInventario())
                            {
                                _en.IdProducto          = productoInventario.IdProducto;
                                _en.NombreProducto      = productoInventario.NombreProducto;
                                _en.GrupoPertenenciente = productoInventario.GrupoPertenenciente;
                                _en.Cantidad            = productoInventario.Cantidad;
                                _en.Presentacion        = productoInventario.Presentacion;
                                _en.CostoUnitario       = productoInventario.CostoUnitario;
                                _en.PrecioContado       = productoInventario.PrecioContado;
                                _en.PrecioACredito      = productoInventario.PrecioACredito;

                                if (strNombreModificado.Equals(_en.NombreProducto.ToString()) && strIdProductoComparar.Equals(_en.IdProducto.ToString()))
                                {
                                    _en.Cantidad = _en.Cantidad - intCantidadModificada;
                                    _inventarioBl.ModificarProducto(_en);
                                }
                            }
                        }
                        FNotaVenta fNuevaNotaVenta = new FNotaVenta();
                        fNuevaNotaVenta.llenarNota(_enVentas, dgTotalProductos, strtipoDeVenta, strTotalAPagarContado);
                        MessageBox.Show("¡Se realizó la venta correctamente!", "¡Éxito!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        Limpiar();
                        Limpiar_Venta();
                    }
                }
                else
                {
                    MessageBox.Show("Favor de llenar todos los campos", "¡Advertencia!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }