// GET: Empleados/Details/5
        public ActionResult Details(int id)
        {
            _base = new EmpleadoBL();
            Empleado _empleado = (Empleado)_base.ObtenerId(id);

            return(View(_empleado));
        }
Ejemplo n.º 2
0
 // GET: Cliente/Details/5
 public ActionResult Details(int?id)
 {
     if (id != null)
     {
         int.TryParse(id.ToString(), out int idCliente);
         Cliente _registro = new Cliente();
         _base     = new ClienteBL();
         _registro = (Cliente)_base.ObtenerId(idCliente);
         return(View(_registro));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
 // GET: Cliente/Details/5
 public ActionResult Details(int?id)
 {
     if (id != null)
     {
         int.TryParse(id.ToString(), out int _idProducto);
         Producto _registro = new Producto();
         _base     = new ProductoBL();
         _registro = (Producto)_base.ObtenerId(_idProducto);
         return(View(_registro));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        // GET: Cliente/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                _base = new ProductoBL();
                Producto _registro = new Producto();
                int.TryParse(id.ToString(), out int _idProducto);
                _registro            = (Producto)_base.ObtenerId(_idProducto);
                _registro.Categorias = CategoriaBL.ObtenerTodos();

                return(View(_registro));
            }
        }
Ejemplo n.º 5
0
        // GET: Cliente/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                _base = new ClienteBL();
                Cliente _registro = new Cliente();
                int.TryParse(id.ToString(), out int _idCliente);
                _registro = (Cliente)_base.ObtenerId(_idCliente);

                _registro.Ciudades = new List <Ciudad>();

                _registro.Ciudades = CiudadBL.ObtenerTodos();
                return(View(_registro));
            }
        }
        public ActionResult Facturar(int?id)
        {
            int.TryParse(id.ToString(), out int _id);
            if (id > 0)
            {
                //OBTENIENDO EL OBJETO FACTURA
                _base = new FacturaBL();
                var        _factura = (Factura)_base.ObtenerId(_id);
                FacturaXML _xml     = new FacturaXML();
                _xml.Cliente  = _factura.Cliente.nombres;
                _xml.Vendedor = _factura.Usuario.userName;
                DateTime _fechaCompra = DateTime.Parse(_factura.fechaCompra.ToString());
                _xml.FechaCompra   = _fechaCompra.ToString("dd/MM/yyyy hh:mm:ss");
                _xml.CodigoFactura = Encriptacion.Encrypt(_factura.id.ToString().PadRight(20));
                _xml.Detalle       = new List <FacturaXML.DetalleProducto>();

                _xml.Detalle = new List <FacturaXML.DetalleProducto>();

                foreach (var item in _factura.DetalleFactura)
                {
                    _xml.Detalle.Add(new FacturaXML.DetalleProducto
                    {
                        NombreProducto = item.Producto.nombre,
                        Precio         = item.Producto.precio.ToString()
                    }
                                     );
                }

                string _serializado = SerializeObject(_xml);


                CargarArchivoXML(_serializado);
                return(RedirectToAction("Index", "Facturacion"));
            }
            else
            {
                return(RedirectToAction("Index", "Facturacion"));
            }
        }
        public ActionResult CrearFactura(int?id, int?idFactura, int?idProducto)
        {
            int.TryParse(idFactura.ToString(), out int _idFactura);
            int.TryParse(id.ToString(), out int _idCliente);
            Factura _registro;

            if (id > 0)
            {
                var _usuarioLogeado = (Usuario)Session["User"];
                _registro            = new Factura();
                _registro.idVendedor = _usuarioLogeado.id;
                _registro.idCliente  = _idCliente;
                _registro.facturado  = false;
                _registro.valorTotal = 0;
                _base     = new FacturaBL();
                _registro = (Factura)_base.Guardar(_registro);
                return(RedirectToAction("CrearFactura", "Facturacion", new { @id = 0, @idFactura = _registro.id }));
            }
            else if (_idFactura > 0)
            {
                //EXISTE FACTURA
                _base     = new FacturaBL();
                _registro = (Factura)_base.ObtenerId(_idFactura);
                _base     = new ProductoBL();
                var _productos = (_base.ObtenerTodos()).Cast <Producto>().ToList();
                _registro.Productos = _productos;

                //SE VERIFICA SI SELECCIONARON PRODUCTOS NUEVOS
                int.TryParse(idProducto.ToString(), out int _idProducto);

                if (_idProducto > 0)
                {
                    //SE CREA EL DETALLE EN LA FACTURA
                    _base = new DetalleFacturaBL();

                    var _detalle = new DetalleFactura();
                    _detalle.cantidad   = 1;
                    _detalle.idFactura  = _idFactura;
                    _detalle.idProducto = _idProducto;
                    _detalle.precio     = _registro.Productos.Where(x => x.id == _idProducto).FirstOrDefault().precio;
                    _base.Guardar(_detalle);
                    double _valorTotal = 0;
                    //SE ACTUALIZA LA FACTURA EL VALOR A PAGAR (MEJORABLE CON LAS SUMAS DE LOS DETALLES)
                    Parallel.ForEach(_registro.DetalleFactura.Cast <DetalleFactura>(),
                                     currentElement =>
                    {
                        _valorTotal += currentElement.precio;
                    });
                    _registro.valorTotal = _valorTotal;
                    _base               = new FacturaBL();
                    _registro           = (Factura)_base.Editar(_registro);
                    _registro.Productos = _productos;
                }


                return(View(_registro));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }