public ActionResult ReportesPresupuestos(int? message = null) { if(!this.currentUser()) { return RedirectToAction("Ingresar"); } if (getCurrentUser().IdRol == 3) { return RedirectToAction("Ingresar"); } ViewBag.Title = "Reportes de Presupuesto"; MenuNavBarSelected(1, 0); EmpresaDTO empresa = (new EmpresaBL()).getEmpresa(getCurrentUser().IdEmpresa); CuentaBancariaBL objBL = new CuentaBancariaBL(); ViewBag.Categorias = CategoriasBucle(empresa.IdEmpresa, empresa.IdPeriodo.GetValueOrDefault(), null, null); PeriodoBL periodoBL = new PeriodoBL(); ViewBag.Periodos = periodoBL.getPeriodosActivosEnEmpresa(getCurrentUser().IdEmpresa); if (message != null) { switch (message) { case 1: createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_MESSAGE); break; case 2: createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_REPORTE_NO_MOVS); break; } } return View(); }
public ActionResult GetPeriodos() { PeriodoBL periodoBL = new PeriodoBL(); var periodos = periodoBL.getPeriodosEnEmpresa(getCurrentUser().IdEmpresa); return Json(periodos, JsonRequestBehavior.AllowGet); }
public ActionResult AddPeriodo(PeriodoDTO dto) { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } try { PeriodoBL objBL = new PeriodoBL(); if (dto.IdPeriodo == 0) { if (objBL.add(dto)) { createResponseMessage(CONSTANTES.SUCCESS); return RedirectToAction("Periodos"); } } else if (dto.IdPeriodo != 0) { if (objBL.update(dto)) { createResponseMessage(CONSTANTES.SUCCESS); return RedirectToAction("Periodos"); } else { createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE); } } else { createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE); } } catch (Exception e) { if (dto.IdPeriodo != 0) createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE); else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE); } TempData["Periodo"] = dto; return RedirectToAction("Periodo"); }
public ActionResult Periodo(int? id = null) { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } if (!this.isAdministrator()) { return RedirectToAction("Index"); } ViewBag.Title = "Periodo"; MenuNavBarSelected(8, 1); UsuarioDTO currentUser = getCurrentUser(); PeriodoBL objBL = new PeriodoBL(); var objSent = TempData["Periodo"]; if (objSent != null) { TempData["Periodo"] = null; return View(objSent); } PeriodoDTO obj; if (id != null) { obj = objBL.getPeriodoEnEmpresa((int)currentUser.IdEmpresa, (int)id); if (obj == null) return RedirectToAction("Periodos"); if (obj.IdEmpresa != currentUser.IdEmpresa) return RedirectToAction("Periodos"); return View(obj); } obj = new PeriodoDTO(); obj.IdEmpresa = currentUser.IdEmpresa; int dyear = DateTime.Now.Year; obj.FechaInicio = new DateTime(dyear, 1, 1); obj.FechaFin = new DateTime(dyear, 12, 31); return View(obj); }
public ActionResult Periodos(bool inactivos = false) { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } if (!isAdministrator()) { return RedirectToAction("Index"); } ViewBag.Title = "Periodos"; MenuNavBarSelected(8, 1); UsuarioDTO currentUser = getCurrentUser(); PeriodoBL objBL = new PeriodoBL(); List<PeriodoDTO> listaPeriodos = new List<PeriodoDTO>(); ViewBag.vbInactivos = inactivos; if (currentUser.IdEmpresa > 0) { if (!inactivos) { listaPeriodos = objBL.getPeriodosActivosEnEmpresa(currentUser.IdEmpresa); } else { listaPeriodos = objBL.getPeriodosEnEmpresa(currentUser.IdEmpresa); } } return View(listaPeriodos); }
/* public IList<CategoriaR_DTO> getReporteCategorias(int? IdCuentaB, DateTime? FechaInicio, DateTime? FechaFin) { using (var context = getContext()) { var result = context.SP_GetReporteResumenCategorias(IdCuentaB, FechaInicio, FechaFin).Select(r => new CategoriaR_DTO { IdCategoria = r.IdCategoria, Nombre = r.Nombre, MontoTotal = r.MontoTotal.GetValueOrDefault(), IdCategoriaPadre = r.IdCategoriaPadre }).ToList(); return result; } } public CategoriaR_DTO obtenerPadreEntidadReporte(CategoriaR_DTO obj, List<CategoriaDTO> lstCategorias, int Nivel) { if (obj.IdCategoriaPadre != null) { CategoriaR_DTO nuevo = new CategoriaR_DTO(); CategoriaDTO aux = lstCategorias.Find(x => x.IdCategoria == obj.IdCategoriaPadre); nuevo.IdCategoria = aux.IdCategoria; nuevo.Nombre = aux.Nombre; nuevo.IdCategoriaPadre = aux.IdCategoriaPadre; if (nuevo.IdCategoriaPadre != null) { nuevo = obtenerPadreEntidadReporte(nuevo, lstCategorias, Nivel); nuevo.Nivel = nuevo.Padre.Nivel + 1; } else { nuevo.Nivel = Nivel; } obj.Padre = nuevo; obj.Nivel = nuevo.Nivel + 1; if (CONSTANTES.NivelCat < obj.Nivel) CONSTANTES.NivelCat = obj.Nivel; } return obj; }*/ public List<PeriodoDTO> GetPeriodosEnEmpresaViewBag(int idEmpresa) { PeriodoBL objBL = new PeriodoBL(); return objBL.getPeriodosEnEmpresaViewBag(idEmpresa); }