Example #1
0
        public ActionResult ExportarServicios()
        {
            EmpresaDTO objEmpresa = (new EmpresaBL()).getEmpresa(getCurrentUser().IdEmpresa);

            ServicioBL objBL = new ServicioBL();
            List<ServicioDTO> lista = objBL.getServiciosEnEmpresa(getCurrentUser().IdEmpresa);

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Clear();

            dt.Columns.Add("Nombre");
            dt.Columns.Add("Código");
            dt.Columns.Add("Descripción");
            dt.Columns.Add("Moneda");
            dt.Columns.Add("Precio");
            dt.Columns.Add("Estado");

            foreach (var Servicio in lista)
            {
                System.Data.DataRow row = dt.NewRow();
                row["Nombre"] = Servicio.Nombre;
                row["Código"] = Servicio.Codigo;
                row["Descripción"] = Servicio.Descripcion;
                row["Moneda"] = Servicio.nMoneda;
                row["Precio"] = Servicio.Precio.GetValueOrDefault().ToString("N2", CultureInfo.InvariantCulture);
                row["Estado"] = Servicio.Estado ? "Activo" : "Inactivo";
                dt.Rows.Add(row);
            }

            GenerarPdf5(dt, "Detalle de Servicios", "Detalle_de_Servicios", objEmpresa, Response);

            createResponseMessage(CONSTANTES.SUCCESS, CONSTANTES.SUCCESS_FILE);
            return RedirectToAction("Servicios", "Admin");
        }
Example #2
0
        public ActionResult Servicio(int? id = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!this.isAdministrator()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Servicio";
            MenuNavBarSelected(11);

            UsuarioDTO user = getCurrentUser();

            ServicioBL objBL = new ServicioBL();

            MonedaBL monedaBL = new MonedaBL();
            ViewBag.lstMonedas = monedaBL.getListaMonedas();

            var objSent = TempData["Servicio"];
            if (objSent != null) { TempData["Servicio"] = null; return View(objSent); }

            ServicioDTO obj;
            if (id != null && id != 0)
            {
                obj = objBL.getServicioEnEmpresa((int)user.IdEmpresa, (int)id);
                if (obj == null) return RedirectToAction("Servicios");
                if (obj.IdEmpresa != user.IdEmpresa) return RedirectToAction("Servicios");
                return View(obj);
            }
            obj = new ServicioDTO();
            obj.IdEmpresa = user.IdEmpresa;

            return View(obj);
        }
Example #3
0
        public ActionResult AddServicio(ServicioDTO dto)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!this.isAdministrator()) { return RedirectToAction("Index"); }
            try
            {
                ServicioBL objBL = new ServicioBL();
                if (dto.IdServicio == 0)
                {
                    if (objBL.add(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Servicios");
                    }
                }
                else if (dto.IdServicio != 0)
                {
                    if (objBL.update(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Servicios");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                    }

                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                }
            }
            catch (Exception e)
            {
                if (dto.IdServicio != 0)
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
            }
            TempData["Servicio"] = dto;
            return RedirectToAction("Servicio");
        }
Example #4
0
        public ActionResult Servicios(bool inactivos = false)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!isAdministrator()) { return RedirectToAction("Index"); }
            ViewBag.Title = "Servicios";
            MenuNavBarSelected(11);
            UsuarioDTO user = getCurrentUser();

            ServicioBL objBL = new ServicioBL();
            List<ServicioDTO> listaServicios = new List<ServicioDTO>();

            ViewBag.vbInactivos = inactivos;

            if (user.IdEmpresa > 0)
            {
                if (!inactivos)
                { listaServicios = objBL.getServiciosActivosEnEmpresa(user.IdEmpresa); }
                else
                { listaServicios = objBL.getServiciosEnEmpresa(user.IdEmpresa); }
            }
            return View(listaServicios);
        }