public JsonResult GetProyectos(int idEntidad) { ProyectoBL objBL = new ProyectoBL(); var listaProyectos = objBL.getProyectosPorEntidad(idEntidad); return Json(new { listaProyectos }, JsonRequestBehavior.AllowGet); }
public ActionResult Proyecto(int? id = null, int? idEntidad = null) { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } //if (!this.isAdministrator()) { return RedirectToAction("Index"); } ViewBag.Title = "Proyecto"; MenuNavBarSelected(6); UsuarioDTO user = getCurrentUser(); ProyectoBL objBL = new ProyectoBL(); ViewBag.IdProyecto = id; ViewBag.lstComprobantes = objBL.getComprobantes_ConProyecto(user.IdEmpresa, id.GetValueOrDefault()); ResponsableBL resBL = new ResponsableBL(); ViewBag.lstResponsables = resBL.getResponsablesActivosEnEmpresa(user.IdEmpresa); EntidadResponsableBL objEntidadBL = new EntidadResponsableBL(); EntidadResponsableDTO objEntidad = objEntidadBL.getEntidadResponsableEnEmpresa(user.IdEmpresa, idEntidad.GetValueOrDefault()); if (objEntidad == null) { return RedirectToAction("EntidadesClientes", "Admin"); } var objSent = TempData["Proyecto"]; if (objSent != null) { TempData["Proyecto"] = null; return View(objSent); } if (id == 0 && idEntidad != null) { ProyectoDTO nuevo = new ProyectoDTO(); nuevo.IdEntidadResponsable = (int)idEntidad; nuevo.Estado = true; return View(nuevo); } else { if (id != null) { ProyectoDTO obj = objBL.getProyecto((int)id); if (obj == null) return RedirectToAction("Entidad", "Admin", new { id = objEntidad.IdEntidadResponsable }); if (obj.IdEntidadResponsable != objEntidad.IdEntidadResponsable) return RedirectToAction("Entidad", "Admin", new { id = objEntidad.IdEntidadResponsable }); EntidadResponsableDTO objEntidadProy = objEntidadBL.getEntidadResponsableEnEmpresa(user.IdEmpresa, obj.IdEntidadResponsable); if (objEntidadProy == null) return RedirectToAction("Entidades", "Admin"); if (objEntidadProy.IdEmpresa != user.IdEmpresa) return RedirectToAction("Entidades", "Admin"); return View(obj); } } return View(); }
public ActionResult AddProyecto(ProyectoDTO dto) { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } try { ProyectoBL objBL = new ProyectoBL(); if (dto.IdProyecto == 0) { if (objBL.add(dto)) { //objBL.ActualizarSaldos(dto.IdCuentaBancaria); createResponseMessage(CONSTANTES.SUCCESS); return RedirectToAction("Entidad", new { id = dto.IdEntidadResponsable }); } } else if (dto.IdProyecto != 0) { if (objBL.update(dto)) { //objBL.ActualizarSaldos(dto.IdCuentaBancaria); createResponseMessage(CONSTANTES.SUCCESS); return RedirectToAction("Entidad", new { id = dto.IdEntidadResponsable }); } else { createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE); } } else { createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE); } } catch (Exception e) { if (dto.IdProyecto != 0) createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE); else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE); } TempData["Proyecto"] = dto; return RedirectToAction("Proyecto"); }
public ActionResult Proyectos() { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } ProyectoBL objBL = new ProyectoBL(); return View(objBL.getProyectos()); }