public static void Create(IngresoAlmacen c)
        {
            using (SqlConnection con = Conexion.Instancia().conectar())
            {
                con.Open();
                //
                // Creacion de la Factura
                //
                //string sqlFactura = "INSERT INTO Comprobante(fecha, idCliente, totalVenta, igv, subTotal, numero)VALUES(GETDATE(), @idCliente, @totalVenta, @igv, @subTotal, @numero) SELECT SCOPE_IDENTITY()";

                SqlCommand cmd = new SqlCommand("SP_IngresoAlmacen_Insertar", con);
                cmd.CommandType = CommandType.StoredProcedure;

                //using (SqlCommand cmd = new SqlCommand(sqlFactura, con))
                {
                    cmd.Parameters.AddWithValue("FechaIngreso", c.FechaIngreso);
                    cmd.Parameters.AddWithValue("idProveedor", c.idProveedor);
                    cmd.Parameters.AddWithValue("TotalPagado", c.TotalPagado);
                    cmd.Parameters.AddWithValue("idTipoComprobante", c.idTipoComprobante);
                    cmd.Parameters.AddWithValue("idUsuario", c.idUsuario);
                    cmd.Parameters.AddWithValue("Estado", c.Estado);
                    cmd.Parameters.AddWithValue("Serie", c.Serie);
                    cmd.Parameters.AddWithValue("Correlativo", c.NroDocumento);
                    //cmd.Parameters.AddWithValue("numero", c.numero);

                    c.idIngresoAlmacen = Convert.ToInt32(cmd.ExecuteScalar());
                }


                //SqlCommand cmd2 = new SqlCommand("DetalleComprobante_Insertar_PA", con);
                //cmd.CommandType = CommandType.StoredProcedure;

                string sqlLineaFactura = "INSERT INTO DetalleIngresoAlmacen(idIngresoAlmacen, idArticulo, PrecioCompra, PrecioVenta , Cantidad, CantidadFinal) VALUES (@idIngresoAlmacen, @idArticulo, @PrecioCompra, @PrecioVenta, @Cantidad, @CantidadFinal) SELECT SCOPE_IDENTITY()";

                using (SqlCommand cmd2 = new SqlCommand(sqlLineaFactura, con))
                {
                    foreach (DetalleIngresoAlmacen d in c.Lineas)
                    {
                        //
                        // como se reutiliza el mismo objeto SqlCommand es necesario limpiar los parametros
                        // de la operacion previa, sino estos se iran agregando en la coleccion, generando un fallo
                        //
                        cmd2.Parameters.Clear();

                        cmd2.Parameters.AddWithValue("idIngresoAlmacen", c.idIngresoAlmacen);
                        cmd2.Parameters.AddWithValue("idArticulo", d.idArticulo);
                        cmd2.Parameters.AddWithValue("PrecioCompra", d.PrecioCompra);
                        cmd2.Parameters.AddWithValue("PrecioVenta", d.PrecioVenta);
                        cmd2.Parameters.AddWithValue("Cantidad", d.Cantidad);
                        cmd2.Parameters.AddWithValue("CantidadFinal", d.CantidadFinal);

                        //
                        // Si bien obtenermos el id de linea de factura, este no es usado
                        // en la aplicacion
                        //
                        d.idDetalleIngresoAlmacen = Convert.ToInt32(cmd2.ExecuteScalar());
                    }
                }
            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            IngresoAlmacen c = new IngresoAlmacen();

            //c.Correlativo = txtCorrelativo_buscar.Text;
            //c.NroDocumento = txtNro_busqueda.Text;
            dgvIngresosAlmacen.DataSource = IngresoAlmacenNEG.Instancia().listarIngresos();
        }
Пример #3
0
        public void RegistrarIngreso(IngresoAlmacen ingreso)
        {
            var client = new HttpClient();

            client.BaseAddress = new Uri(_url);
            var task = client.PostAsJsonAsync("ingreso", ingreso);

            task.Wait();
        }
Пример #4
0
        public static void RegistrarIngreso(IngresoAlmacen c)
        {
            //
            // inicializo la transacciones
            //
            using (TransactionScope scope = new TransactionScope())
            {
                //
                // Creo la factura y sus lineas
                //
                IngresoAlmacenDAO.Create(c);

                //
                // Actualizo el total
                //
                //InvoiceDAL.UpdateTotal(invoice.InvoiceId, invoice.Total);

                scope.Complete();
            }
        }
Пример #5
0
 public void RegistrarIngreso(string idAlmacen, [FromBody] IngresoAlmacen ingreso)
 {
     _service.RegistrarIngreso(idAlmacen, ingreso);
 }
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (this.codigoProveedorSeleccionado == -1)
            {
                this.mError("No ha seleccionado aún ningun Proveedor");
            }
            else
            {
                IngresoAlmacen c = new IngresoAlmacen();
                c.idTipoComprobante = cboTipoComprobante.SelectedIndex + 1;
                c.FechaIngreso      = dtpIngresoAlmacen.Value;
                c.idProveedor       = codigoProveedorSeleccionado;
                c.Serie             = txtSerie.Text;
                c.NroDocumento      = txtCorrelativo.Text;
                c.TotalPagado       = totalInvertido;
                c.igv       = igv;
                c.idUsuario = idUsuario;
                //c.numero = Convert.ToInt32(txtNumero.Text);
                c.subTotal = sub;

                if (radActivo.Enabled == true)
                {
                    c.Estado = true;
                }
                else if (radInactivo.Enabled == true)
                {
                    c.Estado = false;
                }


                foreach (DataGridViewRow row in dgvDetalle.Rows)
                {
                    DetalleIngresoAlmacen d = new DetalleIngresoAlmacen();
                    //int stockFinal = IngresoAlmacenNEG.ObtenerStockActual(Convert.ToInt32(row.Cells["idArticulo"].Value));
                    DetalleIngresoAlmacen dStockFinal = IngresoAlmacenNEG.Instancia().ObtenerStockActual(Convert.ToInt32(row.Cells["idArticulo"].Value));
                    d.idArticulo    = Convert.ToInt32(row.Cells["idArticulo"].Value);
                    d.PrecioCompra  = Convert.ToDecimal(row.Cells["PUCompra"].Value);
                    d.PrecioVenta   = Convert.ToDecimal(row.Cells["PUVenta"].Value);
                    d.Cantidad      = Convert.ToInt32(row.Cells["Cantidad"].Value);
                    d.CantidadFinal = Convert.ToInt32(row.Cells["Cantidad"].Value) + dStockFinal.CantidadFinal;
                    c.Lineas.Add(d);
                }

                IngresoAlmacenNEG.RegistrarIngreso(c);
                MessageBox.Show("El Ingreso se registro correctamente.");

                DialogResult result = MessageBox.Show("Desea realizar un nuevo ingreso?", "Ingreso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                if (result == DialogResult.Yes)
                {
                    txtCodigoArticulo.Clear();
                    txtCodigo.Clear();
                    txtCorrelativo.Clear();
                    txtNombreArticulo.Clear();
                    txtNombreProveedor.Clear();
                    txtPrecioCompra.Clear();
                    txtPrecioVenta.Clear();

                    txtSerie.Clear();

                    nudCantidad.Value = 1;


                    foreach (DataGridViewRow row in dgvDetalle.Rows)
                    {
                        //Indice dila actualmente seleccionado y que vamos a eliminar
                        int indiceFila = this.dgvDetalle.CurrentCell.RowIndex;
                        //Fila que vamos a eliminar
                        DataRow row2 = this.dtDetalle.Rows[indiceFila];
                        //Disminuimos el total a pagar
                        this.totalInvertido         = this.totalInvertido - Convert.ToDecimal(row2["subTotal"].ToString());
                        this.lblTotalInvertido.Text = "Total Pagar: S/." + totalInvertido.ToString("#0.00#");
                        //Removemos la fila
                        this.dtDetalle.Rows.Remove(row2);
                    }

                    this.lblTotalInvertido.Text = "Total Invertido: S/. 0.00";
                }
                else
                {
                    this.Dispose();
                }
            }
        }
Пример #7
0
        public void RegistrarIngreso(string idAlmacen, IngresoAlmacen ingresoAlmacen)
        {
            var mapper = MapperFactory.GetMapper <IngresoAlmacen, Ingreso>();

            _registrarMovimiento(idAlmacen, mapper.CrearEntity(ingresoAlmacen));
        }