Exemplo n.º 1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         Entidades.Stock _stock = CargarEntidad();
         bool            Exito  = Negocio.Stock.CargarStock(_stock);
         if (Exito == true)
         {
             ProgressBar();
             const string message2 = "Se registro el stock exitosamente.";
             const string caption2 = "Éxito";
             var          result2  = MessageBox.Show(message2, caption2,
                                                     MessageBoxButtons.OK,
                                                     MessageBoxIcon.Asterisk);
             LimpiarCampos();
             Lista = new List <ListaStock>();
             Lista = Negocio.Consultar.ListaDeStock();
         }
     }
     catch (Exception ex)
     {
         const string message = "Error en el sistema. Intente nuevamente o comuniquese con el administrador.";
         const string caption = "Atención";
         var          result  = MessageBox.Show(message, caption,
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Warning);
         throw new Exception();
     }
 }
Exemplo n.º 2
0
        private Entidades.Stock CargarEntidad()
        {
            Entidades.Stock _stock            = new Entidades.Stock();
            int             idusuarioLogueado = Sesion.UsuarioLogueado.IdUsuario;

            _stock.idProducto     = ProductoIngresado;
            _stock.CodigoProducto = txtCodigoProducto.Text;
            if (String.IsNullOrEmpty(txtCantidad.Text))
            {
                _stock.Cantidad = 0;
            }
            else
            {
                _stock.Cantidad = Convert.ToInt32(txtCantidad.Text);
            }
            _stock.Proveedor = cmbProveedor.Text;
            DateTime fechaActual = DateTime.Now;

            _stock.FechaActual = fechaActual;
            _stock.FechaCompra = dtFechaCompra.Value;
            if (!String.IsNullOrEmpty(txtValorUni.Text))
            {
                _stock.ValorUnitario = Convert.ToDecimal(txtValorUni.Text);
            }
            if (!String.IsNullOrEmpty(txtTotalCompra.Text))
            {
                _stock.ValorCompra = Convert.ToDecimal(txtTotalCompra.Text);
            }
            _stock.Remito          = txtRemito.Text;
            _stock.VencimientoLote = dtFechaVencimiento.Value;
            if (String.IsNullOrEmpty(txtReditoPorcentual.Text))
            {
                _stock.ReditoPorcentual = "0 %";
            }
            else
            {
                _stock.ReditoPorcentual = txtReditoPorcentual.Text;
            }
            if (!String.IsNullOrEmpty(txtPrecioVenta.Text))
            {
                _stock.PrecioDeVenta = Convert.ToDecimal(txtPrecioVenta.Text);
            }
            _stock.idUsuario = idusuarioLogueado;
            return(_stock);
        }