예제 #1
0
 private void CreateIngreso()
 {
     try
     {
         if (nudCantidad.Text != "0" && cbComprobante.Text != "" && cbxProducto.Text != "")
         {
             Producto prod     = pservice.ReadByNombreProducto(cbxProducto.Text);
             int      cantidad = Convert.ToInt32(nudCantidad.Text);
             i.Codigo_Producto  = prod.Codigo_Producto;
             i.Fecha_Ingreso    = dtFechaIngreso.Value;
             i.Tipo_Comprobante = cbComprobante.Text;
             i.Cantidad         = Convert.ToInt32(nudCantidad.Text);
             i.FechaVen         = dtFechaVenc.Value;
             i.Total            = decimal.Parse(iservice.CalcularTotal(Convert.ToDouble(prod.Precio), cantidad).ToString());
             iservice.Create(i);
             ClearFields();
         }
         else
         {
             MessageBox.Show(this, "Complete los campos requeridos", "Error al eliminar",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception) { }
 }
예제 #2
0
        private void CreateIngreso()
        {
            //if(p == null)
            //{
            //    int idMarca = m.Codigo_Marca;
            //
            //    p = new Producto();
            //    Marca marca = mservice.ReadByIdMarca(idMarca);
            //    p.Marca = marca.Codigo_Marca;
            //
            //    int idPresentacion = p.Codigo_Producto;
            //
            //    Presentacion presentacion = prservice.ReadByIdPresentacion(idPresentacion);
            //    p.Presentacion = presentacion.Codigo_Presentacion;
            //
            //    var idCategoria = cbCategoria.SelectedIndex + 1;
            //
            //    Categoria categoria = cservice.ReadByIdCategoria(idCategoria);
            //    p.Categoria = categoria.Codigo_Categoria;
            //
            //    p.Composicion = txtComposicion.Text;
            //    p.NombreProd = txtNombre.Text;
            //    p.Prescripcion = cbPrescripcion.Checked;
            //    p.FechaVen = dtFechaVenc.Value;
            //    p.Stock = 0;
            //    p.Precio = 0;
            //
            //    pservice.CreateProducto(p);
            //
            //}
            //else
            //{
            //    this.ClearFields();
            //
            //    return;
            //}
            ClearFields();
            Producto prod     = pservice.ReadByNombreProducto(cbProducto.Text);
            int      cantidad = Convert.ToInt32(nudCantidad.Text);

            i.Codigo_Producto   = prod.Codigo_Producto;
            i.Fecha_Ingreso     = dtFechaIngreso.Value;
            i.Tipo_Comprobante  = cbComprobante.Text;
            i.Cantidad          = Convert.ToInt32(nudCantidad.Text);
            i.Fecha_Vencimiento = dtFechaVenc.Value;
            i.Total             = decimal.Parse(iservice.CalcularTotal(Convert.ToDouble(prod.Precio), cantidad).ToString());
            iservice.CreateIngreso(i);
        }
예제 #3
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            var ingreso  = iservice.ReadIngresoByID(Codigo_ingreso);
            var producto = pservice.ReadByIdProducto(ingreso.Codigo_Producto);

            //actualizamos el stock de producto
            producto.Stock           = producto.Stock - (ingreso.Cantidad - Convert.ToInt32(nudCantidad.Text));
            ingreso.Fecha_Ingreso    = dtFechaIngreso.Value;
            ingreso.FechaVen         = dtFechaVencimiento.Value;
            ingreso.Tipo_Comprobante = cbComprobante.Text;
            ingreso.Codigo_Ingreso   = Codigo_ingreso;
            ingreso.Codigo_Producto  = producto.Codigo_Producto;
            ingreso.Cantidad         = Convert.ToInt32(nudCantidad.Text);
            ingreso.Total            = decimal.Parse(iservice.CalcularTotal(Convert.ToDouble(producto.Precio), ingreso.Cantidad).ToString());
            iservice.Update(ingreso);
            pservice.Update(producto);
            MessageBox.Show("Se ha actualizado la orden de ingreso.");
            this.Close();
        }