Ejemplo n.º 1
0
 //GET: Planilla/Ver
 public ActionResult Ver(int id = 0)
 {
     if (Session["TipoUsuario"] != null && (Session["TipoUsuario"].ToString().Equals("EMPLEADO") || Session["TipoUsuario"].ToString().Equals("ADMINISTRADOR")))
     {
         try
         {
             if (id != 0)
             {
                 AltaPlanillaViewModel viewModel = new AltaPlanillaViewModel();
                 viewModel.planilla = planillaBL.obtener(id);
                 EmpleadoBL emp = new EmpleadoBL();
                 viewModel.Empleado            = emp.obtener(Convert.ToInt32(Session["IdUsuario"]));
                 viewModel.planilla.empleado   = emp.obtener(viewModel.planilla.empleado.Id);
                 viewModel.CantidadEmpleados88 = emp.obtenerCantidadEmpleados88();
                 viewModel.PorcentajeFirmas    = viewModel.planilla.Empleados.Count * 100 / (viewModel.CantidadEmpleados88 - 1);
                 if (Session["TipoUsuario"] != null && Session["TipoUsuario"].ToString().Equals("EMPLEADO"))
                 {
                     viewModel.comprobarFirmas();
                 }
                 return(View(viewModel));
             }
             else
             {
                 ViewBag.Mensaje = "No selecciono el usuario correctamente.";
                 return(View("~/Views/Shared/_Mensajes.cshtml"));
             }
         }
         catch (ProyectoException ex)
         {
             ViewBag.Mensaje = ex.Message;
             return(View("~/Views/Shared/_Mensajes.cshtml"));
         }
     }
     else
     {
         try
         {
             ViewBag.Mensaje = "No tiene permisos para relalizar esta acción.";
             return(View("~/Views/Shared/_Mensajes.cshtml"));
         }
         catch (ProyectoException ex)
         {
             ViewBag.Mensaje = ex.Message;
             return(View("~/Views/Shared/_Mensajes.cshtml"));
         }
     }
 }
Ejemplo n.º 2
0
 public ActionResult AltaPlanilla(AltaPlanillaViewModel crearVM)
 {
     if (ModelState.IsValid)
     {
         try
         {
             crearVM.completarPlanilla();
             planillaBL.altaPlanilla(crearVM.planilla);
             return(RedirectToAction("ListaPlanillas"));
         }
         catch (ProyectoException ex)
         {
             ViewBag.Mensaje = ex.Message;
             return(View("~/Views/Shared/_Mensajes.cshtml"));
         }
     }
     else
     {
         return(View(crearVM));
     }
 }