Beispiel #1
0
        private void AgregarDetalleButton_Click(object sender, EventArgs e)
        {
            List <ProductoDetalles> detalles = new List <ProductoDetalles>();
            Repositorio <Ventas>    db       = new Repositorio <Ventas>(new DAL.SistemaFarmaciaContexto());

            if (ProductoDataGridView.DataSource != null)
            {
                this.Detalle = (List <ProductoDetalles>)ProductoDataGridView.DataSource;
            }

            if (Existe())
            {
                ProductoComboBox.Focus();
                return;
            }

            this.Detalle.Add(new ProductoDetalles()
            {
                Id       = (int)ProductoComboBox.SelectedValue,
                VentaId  = (int)VentaIdNumericUpDown.Value,
                Producto = ProductoComboBox.Text,
                Cantidad = (int)CantidadNumericUpDown.Value,
                Valor    = PrecioNumericUpDown.Value * CantidadNumericUpDown.Value,
                Itbis    = (PrecioNumericUpDown.Value * CantidadNumericUpDown.Value) * 0.18m,
            });

            CargaGrid();

            CalcularSubtotal();
            CalcularItbis();
            CalcularTotal();
            ProductoComboBox.Text       = null;
            PrecioNumericUpDown.Value   = 0;
            CantidadNumericUpDown.Value = 0;
        }
Beispiel #2
0
        private bool Validar()
        {
            bool paso = true;

            if (string.IsNullOrWhiteSpace(ProductoComboBox.Text))
            {
                MyErrorProvider.SetError(ProductoComboBox, "El campo Producto no puede estar vacio.");
                ProductoComboBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(ProveedorComboBox.Text))
            {
                MyErrorProvider.SetError(ProveedorComboBox, "El campo Proveedor no puede estar vacio.");
                ProveedorComboBox.Focus();
                paso = false;
            }

            if (this.Detalle.Count == 0)
            {
                MyErrorProvider.SetError(AgregarDetalleButton, "El Detalle no puede estar vacio.");
                AgregarDetalleButton.Focus();
                paso = false;
            }

            return(paso);
        }
        private void HabilitarCampos()
        {
            ProveedorComboBox.Enabled     = true;
            ProductoComboBox.Enabled      = true;
            MarcaComboBox.Enabled         = true;
            MedidaComboBox.Enabled        = true;
            CantidadNumericUpDown.Enabled = true;

            AgregarButton.Enabled     = true;
            GrabarButton.Enabled      = true;
            CancelarButton.Enabled    = true;
            BorrarLineaButton.Enabled = true;
            BorrarTodoButton.Enabled  = true;

            GenerarPedidosAutoButton.Enabled = false;
            button1.Enabled = false;

            NuevoPedidoButton.Enabled     = false;
            ModificarPedidoButton.Enabled = false;
            BorrarPedidoButton.Enabled    = false;

            FiltrarPedidosTextBox.ReadOnly = true;
            FiltrarStockTextBox.ReadOnly   = true;

            ProductoComboBox.Focus();
        }
        private void GenerarPedidosAutoButton_Click_1(object sender, EventArgs e)
        {
            if (ProveedorComboBox.SelectedIndex == -1)
            {
                errorProvider1.SetError(ProveedorComboBox, "Seleccione un proveedor");
                ProveedorComboBox.Focus();
                return;
            }

            var rta = MessageBox.Show("¿Está seguro de generar un pedido automatizado?", "Confirmación",
                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (rta == DialogResult.No)
            {
                return;
            }

            var codProv = (int)ProveedorComboBox.SelectedValue;

            stock = new DStock();
            List <DStockParaPedidosAuto> valoresStock = stock.SelectListadoStockActualMenorAlCritico(codProv);

            if (valoresStock == null)
            {
                MessageBox.Show("No se generó el pedido, no hay productos cuyo stock actual sea menor al crítico", "Atención",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }


            int codPedido = InsertPedido(DateTime.Now, false, true, codProv);


            foreach (var stock in valoresStock)
            {
                InsertStockPedido(codPedido, stock.CodStock, stock.StockCritico - stock.StockActual, 1, 1);
            }

            var popup1 = new PopupNotifier()
            {
                Image        = Properties.Resources.sql_success1,
                TitleText    = "Mensaje",
                ContentText  = $"El pedido automatizado con código:{codPedido} fue grabado de forma exitosa",
                ContentFont  = new Font("Segoe UI Bold", 11F),
                TitleFont    = new Font("Segoe UI Bold", 10F),
                ImagePadding = new Padding(8)
            };

            popup1.Popup();

            misDetalles.Clear();
            ActualizarGrid();
            LimpiarCampos();
            DeshabilitarCampos();
            SelectPedidosReaprov();
            ProductoComboBox.Focus();
        }
        private void GrabarButton_Click_1(object sender, EventArgs e)
        {
            if (misDetalles.Count == 0)
            {
                errorProvider1.SetError(ProductoComboBox, "Debe ingresar productos en el pedido");
                ProductoComboBox.Focus();
                return;
            }
            errorProvider1.Clear();

            DialogResult rta = MessageBox.Show("¿Está seguro de grabar el pedido de reaprovisionamiento?", "Confirmación",
                                               MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (rta == DialogResult.No)
            {
                return;
            }

            var fecha = DateTime.Now;

            var codProv   = (int)ProveedorComboBox.SelectedValue;
            int codPedido = InsertPedido(fecha, false, false, codProv);

            marca  = new DMarca();
            medida = new DMedida();

            for (int i = 0; i < misDetalles.Count; i++)
            {
                int codMarca = marca.GetCodMarcaByNombreMarca(misDetalles[i].Marca);
                int codMed   = medida.GetCodMedidaByNombreMedida(misDetalles[i].Medida);

                InsertStockPedido(codPedido, misDetalles[i].CodStock, misDetalles[i].Cantidad,
                                  codMarca, codMed);
            }

            var popup1 = new PopupNotifier()
            {
                Image        = Properties.Resources.sql_success1,
                TitleText    = "Mensaje",
                ContentText  = $"El pedido de reaprovisionamiento con código:{codPedido} fue grabado de forma exitosa",
                ContentFont  = new Font("Segoe UI Bold", 11F),
                TitleFont    = new Font("Segoe UI Bold", 10F),
                ImagePadding = new Padding(8)
            };

            popup1.Popup();



            misDetalles.Clear();
            ActualizarGrid();
            LimpiarCampos();
            SelectPedidosReaprov();
            DeshabilitarCampos();
        }
Beispiel #6
0
 private void NuevoButton_Click(object sender, EventArgs e)
 {
     IdNumericUpDown.Value = 0;
     FechaDateTimePicker.ResetText();
     NombresComboBox.ResetText();
     ProductoComboBox.ResetText();
     DetalleFacturaDataGridView.DataSource = null;
     SubTotalNumericUpDown.Value           = 0;
     ItbisNumericUpDown.Value    = 0;
     TotalNumericUpDown.Value    = 0;
     CantidadNumericUpDown.Value = 0;
     detalles.Clear();
     EfectivoNumericUpDown.Value = 0;
     DevueltaNumericUpDown.Value = 0;
     MyErrorProvider.Clear();
 }
Beispiel #7
0
        private void AgregarDetalleButton_Click(object sender, EventArgs e)
        {
            RepositorioBase <Productos> Metodos = new RepositorioBase <Productos>();

            if (DetalleDataGridView.DataSource != null)
            {
                this.Detalle = (List <CompraProductosDetalle>)DetalleDataGridView.DataSource;
            }

            if (!ValidarDetalle())
            {
                return;
            }

            string Id = ProductoComboBox.SelectedValue.ToString();

            this.Detalle.Add(
                new CompraProductosDetalle(
                    id: 0,
                    compraId: (int)IdNumericUpDown.Value,
                    productoId: Convert.ToInt32(Id),
                    cantidad: Convert.ToInt32(CantidadNumericUpDown.Value),
                    precio: Convert.ToDecimal(CostoTextBox.Text)
                    )
                );

            decimal Total = 0;

            foreach (var item in this.Detalle)
            {
                Productos producto = Metodos.Buscar(item.ProductoId);
                Total += (producto.Costo * item.Cantidad);
            }
            TotalTextBox.Text = Convert.ToString(Total);
            CargarGrid();

            ProductoComboBox.Focus();
            CantidadNumericUpDown.Value = 0;
            MyErrorProvider.Clear();
            MarcaTextBox.Text   = string.Empty;
            UnidadTextBox.Text  = string.Empty;
            CostoTextBox.Text   = string.Empty;
            ImporteTextBox.Text = string.Empty;
        }
        private void AgregarButton_Click_1(object sender, EventArgs e)
        {
            if (ProductoComboBox.SelectedIndex == -1)
            {
                errorProvider1.SetError(ProductoComboBox, "Seleccione un producto");
                ProductoComboBox.Focus();
                return;
            }
            errorProvider1.Clear();


            int codStock = (int)ProductoComboBox.SelectedValue;

            marca  = new DMarca();
            medida = new DMedida();

            var detalle = new DetallePedidoReaprov
            {
                CodStock    = codStock,
                NombreStock = stock.GetNombreStockByCodStock(codStock),
                Cantidad    = Convert.ToInt32(CantidadNumericUpDown.Value),
                Marca       = marca.GetNombreMarcaByCodMarca((int)MarcaComboBox.SelectedValue),
                Medida      = medida.GetMedidaByCodMedida((int)MedidaComboBox.SelectedValue)
            };

            for (int i = 0; i < misDetalles.Count; i++)
            {
                if (misDetalles[i].CodStock == detalle.CodStock && misDetalles[i].Medida == detalle.Medida)
                {
                    MessageBox.Show("El producto ya se encuentra en el pedido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            misDetalles.Add(detalle);
            ActualizarGrid();
            LimpiarCampos();
            ProductoComboBox.Focus();
        }
Beispiel #9
0
        private bool ValidarCampos()
        {
            if (FacturaTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(FacturaTextBox, "Ingrese el Número de la Factura");
                FacturaTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (CantidadTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(CantidadTextBox, "Ingrese la cantidad");
                CantidadTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (!float.TryParse(CantidadTextBox.Text, out float cantidad))
            {
                errorProvider1.SetError(CantidadTextBox, "Debe ingresar un valor numérico entero");
                CantidadTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();
            float Existencias = float.Parse(ExistenciasTextBox.Text);

            if (Existencias < cantidad)
            {
                errorProvider1.SetError(ExistenciasTextBox, "No hay productos suficientes para esta venta");
                ExistenciasTextBox.Focus();
                return(false);
            }

            if (cantidad <= 0)
            {
                errorProvider1.SetError(CantidadTextBox, "Debe ingresar un valor mayor a cero");
                CantidadTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (ProductoComboBox.SelectedIndex == -1)
            {
                errorProvider1.SetError(AbrirProductosButton, "Seleccione un producto");
                ProductoComboBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (DescripcionTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(DescripcionTextBox, "Ingrese la descripción del producto");
                DescripcionTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (PrecioTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(PrecioTextBox, "Ingrese el Costo del Producto");
                PrecioTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (!decimal.TryParse(PrecioTextBox.Text, out decimal precio))
            {
                errorProvider1.SetError(PrecioTextBox, "Debe ingresar un valor numérico entero");
                PrecioTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (precio <= 0)
            {
                errorProvider1.SetError(PrecioTextBox, "Debe ingresar un valor mayor a cero");
                PrecioTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            return(true);
        }
Beispiel #10
0
        private bool ValidarCampos()
        {
            if (ProveedorComboBox.SelectedIndex == -1)
            {
                errorProvider1.SetError(ProveedorComboBox, "Seleccione un Proveedor");
                ProveedorComboBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (FacturaTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(FacturaTextBox, "Ingrese el Número de la Factura");
                FacturaTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (CantidadTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(CantidadTextBox, "Ingrese la cantidad");
                CantidadTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (!float.TryParse(CantidadTextBox.Text, out float cantidad))
            {
                errorProvider1.SetError(CantidadTextBox, "Debe ingresar un valor numérico entero");
                CantidadTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (cantidad <= 0)
            {
                errorProvider1.SetError(CantidadTextBox, "Debe ingresar un valor mayor a cero");
                CantidadTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (ProductoComboBox.SelectedIndex == -1)
            {
                errorProvider1.SetError(AbrirProductosButton, "Seleccione un producto");
                ProductoComboBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (DescripcionTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(DescripcionTextBox, "Ingrese la descripción del producto");
                DescripcionTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (CostoUnitarioTextBox.Text == string.Empty)
            {
                errorProvider1.SetError(CostoUnitarioTextBox, "Ingrese el Costo del Producto");
                CostoUnitarioTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (!decimal.TryParse(CostoUnitarioTextBox.Text, out decimal costo))
            {
                errorProvider1.SetError(CostoUnitarioTextBox, "Debe ingresar un valor numérico entero");
                CostoUnitarioTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            if (costo <= 0)
            {
                errorProvider1.SetError(CostoUnitarioTextBox, "Debe ingresar un valor mayor a cero");
                CostoUnitarioTextBox.Focus();
                return(false);
            }
            errorProvider1.Clear();

            return(true);
        }