예제 #1
0
 public void GuardarDetalleVenta(int idProducto, int idVenta, int idProveedor, double cantidad, double subtotal)
 {
     _dv = new DetalleVentaDTO()
     {
         idProducto  = idProducto,
         idVenta     = idVenta,
         idProveedor = idProveedor,
         cantidad    = cantidad,
         total       = subtotal
     };
     _dvManager.InsertarDetalleVenta(_dv);
 }
예제 #2
0
        public IHttpActionResult Create(DetalleVentaDTO detalleVentaDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var detalleVenta = Mapper.Map <DetalleVentaDTO, DetalleVenta>(detalleVentaDTO);

            _UnityOfWork.Detalles.Add(detalleVenta);
            _UnityOfWork.SaveChanges();

            detalleVentaDTO.DetalleVentaId = detalleVenta.DetalleVentaId;

            return(Created(new Uri(Request.RequestUri + "/" + detalleVenta.DetalleVentaId), detalleVentaDTO));
        }
예제 #3
0
        public bool ActualizarCantidadesDevueltas(DetalleVentaDTO detalles, short IdBodega)
        {
            IDataParameter[] parametros = new IDataParameter[4];

            parametros[0]       = new SqlParameter("IdBodega", SqlDbType.SmallInt);
            parametros[0].Value = IdBodega;
            parametros[1]       = new SqlParameter("IdDiseño", SqlDbType.VarChar);
            parametros[1].Value = detalles.Codigo;
            parametros[2]       = new SqlParameter("IdTalla", SqlDbType.Int);
            parametros[2].Value = ObtenerIDTalla(detalles.Talla);
            parametros[3]       = new SqlParameter("Cantidad", SqlDbType.Int);
            parametros[3].Value = CantiadDePRenda(IdBodega, detalles.Codigo, ObtenerIDTalla(detalles.Talla)) + detalles.Cantidad;



            return(Conexionbd.EjecutarSPSinRetorno("ActualizarCantidades", parametros));
        }
예제 #4
0
        public bool AgregarDetallesVenta(DetalleVentaDTO detalles)
        {
            IDataParameter[] parametros = new IDataParameter[4];

            parametros[0]       = new SqlParameter("Codigo", SqlDbType.VarChar);
            parametros[0].Value = detalles.Codigo;
            parametros[1]       = new SqlParameter("Talla", SqlDbType.Float);
            parametros[1].Value = detalles.Talla;
            parametros[2]       = new SqlParameter("Cantidad", SqlDbType.Int);
            parametros[2].Value = detalles.Cantidad;
            parametros[3]       = new SqlParameter("IdVenta", SqlDbType.SmallInt);
            parametros[3].Value = detalles.IdVenta;



            return(Conexionbd.EjecutarSPSinRetorno("AgregarDetallesVentas", parametros));
        }
예제 #5
0
        public IHttpActionResult Update(int id, DetalleVentaDTO detalleVentaDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var detalleVentaInPersistence = _UnityOfWork.Detalles.Get(id);

            if (detalleVentaInPersistence == null)
            {
                return(NotFound());
            }

            Mapper.Map <DetalleVentaDTO, DetalleVenta>(detalleVentaDTO, detalleVentaInPersistence);

            _UnityOfWork.SaveChanges();

            return(Ok(detalleVentaDTO));
        }
예제 #6
0
        private void AgregarAList(short Id, string codigo, double IdTalla, int cantidad)
        {
            //pebdiente
            DetalleVentaDTO dto = new DetalleVentaDTO();

            dto.Id       = Id;
            dto.Codigo   = codigo;
            dto.Talla    = IdTalla;
            dto.Cantidad = cantidad;
            if (ListaDet == null)
            {
                ListaDet = new List <DetalleVentaDTO>();
            }
            ListaDet.Add(dto);
            listVentas.DataSource         = "";
            listVentas.DataSource         = ListaDet;
            listVentas.Columns[0].Visible = false;
            listVentas.Columns[3].Visible = false;
            listVentas.Columns[5].Visible = false;
        }
예제 #7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (dgvDetalleVenta.RowCount > 0)
            {
                try
                {
                    _venta = new VentaDTO()
                    {
                        idUsuario     = Program.usuario,
                        idTipoUsuario = Program.idTipoUsuario,
                        fechaVenta    = DateTime.Today.ToString(),
                        total         = total,
                        notas         = txtNotas.Text,
                    };
                    if (_ventaManager.InsertarVenta(_venta))
                    {
                        for (int i = 0; i < dgvDetalleVenta.RowCount - 1; i++)
                        {
                            try
                            {
                                _dv = new DetalleVentaDTO()
                                {
                                    idVenta = _ventaManager.Ventas.Last().idVenta,

                                    idProducto = Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value.ToString()),

                                    idProveedor = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).idProveedor,

                                    cantidad = Convert.ToDouble(dgvDetalleVenta.Rows[i].Cells[2].Value),

                                    total = Convert.ToDouble(dgvDetalleVenta.Rows[i].Cells[3].Value)
                                };
                                if (_dvManager.InsertarDetalleVenta(_dv))
                                {
                                    int stock = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).stockActual;

                                    stock -= Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[2].Value);

                                    if (_prod == null)
                                    {
                                        _prod = new ProductoDTO()
                                        {
                                            idProducto = Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value),

                                            nombre = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).nombre,

                                            idProveedor = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).idProveedor,

                                            idTipoProducto = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).idTipoProducto,

                                            precioVenta = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).precioVenta,

                                            precioCompra = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).precioCompra,

                                            stockActual = stock,

                                            stockMax = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).stockMax,

                                            stockMin = _prodManager.BuscarProductosPorId(Convert.ToInt32(dgvDetalleVenta.Rows[i].Cells[0].Value)).stockMin
                                        };
                                        _prodManager.ModificarProducto(_prod);
                                        cmbProductos.ResetText();
                                        txtProveedor.Clear();
                                        txtCantidad.Clear();
                                        txtSubtotal.Clear();
                                        txtNotas.Clear();
                                        cmbProductos.Focus();
                                    }
                                }
                                _prod = null;
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Error", titulo, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        MessageBox.Show("Venta registrada", titulo, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dgvDetalleVenta.Rows.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Venta no registrada", titulo, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Error", titulo, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 public bool ModificarDetalleVenta(DetalleVentaDTO detalle)
 {
     return(detalleRepository.Modificar(detalle));
 }
 public bool InsertarDetalleVenta(DetalleVentaDTO detalle)
 {
     return(detalleRepository.Insertar(detalle));
 }
 public bool EliminarDetalleVenta(DetalleVentaDTO detalle)
 {
     return(detalleRepository.Eliminar(detalle));
 }