Esempio n. 1
0
        public ActionResult Create()
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OVMUser      = new UserViewModel();
                    var ListCompania = wdb.Company.ToList();
                    var ListRoles    = wdb.Role.ToList();
                    OVMUser.ListCompania = ListCompania;
                    OVMUser.ListRoles    = ListRoles;

                    return(View(OVMUser));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;
                return(RedirectToAction("Index", "Usuario"));
            }
        }
        public ActionResult Create()
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ListTipo     = wdb.ShiftType.ToList();
                    var ListDescanso = wdb.Break.ToList();

                    var OVMHorario = new HorarioViewModel
                    {
                        ListaTipo     = new SelectList(ListTipo, "ShiftTypeID", "Description"),
                        ListaDescanso = ListDescanso
                    };
                    return(View(OVMHorario));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;
                return(RedirectToAction("Index", "Horario"));
            }
        }
        public ActionResult Edit(int Id)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OCCosto = wdb.CostCenter.Where(a => a.CostCenterID == Id).FirstOrDefault();



                    var OVMCCosto = new CCostoViewModel
                    {
                        CostCenterID = OCCosto.CostCenterID,
                        Code         = OCCosto.Code,
                        Name         = OCCosto.Name,
                        Description  = OCCosto.Description,
                        IsActive     = OCCosto.IsActive
                    };

                    return(View(OVMCCosto));
                }
            }

            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;

                return(RedirectToAction("Index", "CCosto"));
            }
        }
Esempio n. 4
0
        public ActionResult Edit(int Id)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OTurno = wdb.Schedule.Where(a => a.ScheduleID == Id).FirstOrDefault();

                    var OVMTurno = new TurnoViewModel
                    {
                        ScheduleID = OTurno.ScheduleID,
                        Name       = OTurno.Name
                    };

                    return(View(OVMTurno));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;

                return(RedirectToAction("Index", "Turno"));
            }
        }
        public ActionResult SeguimientoFichaje(ReportesViewModel OModelo)
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                string   wUsuario      = User.Identity.Name;
                string   wMaquina      = Environment.MachineName;
                DateTime wDesde        = OModelo.FechaDesde;
                DateTime wHasta        = OModelo.FechaHasta;
                int      wEmpleado     = OModelo.Empleado;
                string   wDepartamento = "";
                foreach (var item in OModelo.ListaCodigoDepartamentosSeleccionados)
                {
                    wDepartamento = wDepartamento + item.ToString() + ";";
                }

                if (wDepartamento == null || wDepartamento == "")
                {
                    wDepartamento = "1;2;3;";
                }


                List <SeguimientoFichajeViewModel> ListSeguimientoFichaje = wdb.Database.SqlQuery <SeguimientoFichajeViewModel>("").ToList();

                ViewBag.IsReporte = true;
                return(View(ListSeguimientoFichaje));
            }
        }
        public ActionResult ControlAsistenciaBN(ReportesViewModel OModelo)
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                string   wUsuario      = User.Identity.Name;
                string   wMaquina      = Environment.MachineName;
                DateTime wDesde        = OModelo.FechaDesde;
                DateTime wHasta        = OModelo.FechaHasta;
                int      wEmpleado     = OModelo.Empleado;
                string   wDepartamento = "";
                foreach (var item in OModelo.ListaCodigoDepartamentosSeleccionados)
                {
                    wDepartamento = wDepartamento + item.ToString() + ";";
                }

                if (wDepartamento == null || wDepartamento == "")
                {
                    wDepartamento = "1;2;3;";
                }


                List <ControlAsistenciaBNViewModel> ListControlAsistenciaBN = wdb.Database.SqlQuery <ControlAsistenciaBNViewModel>("exec [AssistControl].[rptControlAssistance] @User='******',@Station='" + wMaquina + "',@Action='G',@StartDate = '" + wDesde + "', @EndDate = '" + wHasta + "', @DepartmentId = '" + wDepartamento + "', @EmployeeId = " + wEmpleado).ToList();

                ViewBag.IsReporte = true;
                return(View(ListControlAsistenciaBN));
            }
        }
        public ActionResult Create()
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ListEmpresa = wdb.Company.ToList();
                    var ListTur     = wdb.Schedule.ToList();

                    var OVMDepartamentos = new DepartamentosViewModel
                    {
                        ListaEmpresa = new SelectList(ListEmpresa, "CompanyID", "Name"),
                        ListaTurno   = new SelectList(ListTur, "ScheduleID", "Name"),
                    };

                    return(View(OVMDepartamentos));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;
                return(RedirectToAction("Index", "Departamentos"));
            }
        }
Esempio n. 8
0
        public ActionResult Create()
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ListPais   = wdb.Country.ToList();
                    var LisEstado  = wdb.State.ToList();
                    var ListCiudad = wdb.City.ToList();

                    var OVMEmpresa = new EmpresaViewModel
                    {
                        ListaPais   = new SelectList(ListPais, "CountryID", "Name"),
                        ListaEstado = new SelectList(LisEstado, "StateID", "Name"),
                        ListaCiudad = new SelectList(ListCiudad, "CityID", "Name"),
                    };

                    return(View(OVMEmpresa));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;
                return(RedirectToAction("Index", "Empresa"));
            }
        }
Esempio n. 9
0
        public ActionResult Edit(int Id)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ORole        = wdb.Role.Where(a => a.RoleID == Id).FirstOrDefault();
                    var ListOpciones = wdb.Option.Where(a => a.CodeTop != null).ToList();
                    var ListOpcionesSeleccionadas = wdb.RoleOption.Where(a => a.RoleID == Id).ToList();

                    var OVMRole = new RoleViewModel
                    {
                        RoleID      = ORole.RoleID,
                        Description = ORole.Description,
                        IsActive    = ORole.IsActive,
                        LisOpciones = ListOpciones,
                        LisOpcionesSeleccionados = ListOpcionesSeleccionadas
                    };



                    return(View(OVMRole));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;

                return(RedirectToAction("Index", "Role"));
            }
        }
        public ActionResult Eliminar(int Id)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ODescanso = wdb.Break.Where(a => a.BreakID == Id).FirstOrDefault();

                    wdb.Break.Remove(ODescanso);
                    wdb.SaveChanges();


                    OMensaje.Tipo      = "Exito";
                    OMensaje.Msg       = "Descanso Eliminado con exito";
                    Session["Mensaje"] = OMensaje;
                    return(RedirectToAction("Index", "Descanso"));
                }
            }
            catch (DbEntityValidationException e)
            {
                var errorMessages    = e.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);

                var exceptionMessage = string.Concat(e.Message, " El error de validacion es: ", fullErrorMessage);

                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = exceptionMessage;
                Session["Mensaje"] = OMensaje;
                return(RedirectToAction("Index", "Descanso"));
            }
        }
Esempio n. 11
0
        public ActionResult Edit(int Id)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ODiasFestivo        = wdb.HolidayType.Where(a => a.HolidayTypeID == Id).FirstOrDefault();
                    var ODiasFestivoDetalle = wdb.HolidayDetails.Where(a => a.HolidayTypeID == Id).FirstOrDefault();


                    var OVMDiasFestivo = new DiasFestivoViewModel
                    {
                        HolidayTypeID = ODiasFestivo.HolidayTypeID,
                        Name          = ODiasFestivo.Name,
                        StartDate     = ODiasFestivoDetalle.StartDate
                    };

                    return(View(OVMDiasFestivo));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;

                return(RedirectToAction("Index", "DiasFestivo"));
            }
        }
Esempio n. 12
0
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListTurnos = wdb.Schedule.OrderByDescending(a => a.ScheduleID).ToList();

                return(View(ListTurnos));
            }
        }
        public ActionResult Create(DepartamentosViewModel Omodelo)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OUltimoDepartaCode = wdb.Department.OrderByDescending(a => a.DepartmentID).FirstOrDefault();
                    int wCode = (OUltimoDepartaCode.Code) + 1;


                    var ODepartamentoNuevo = new Department
                    {
                        Code         = wCode,
                        DepartmentID = wCode,
                        Name         = Omodelo.Name,
                        CompanyID    = Omodelo.CompanyID,
                        ScheduleID   = Omodelo.ScheduleID
                    };
                    wdb.Department.Add(ODepartamentoNuevo);
                    wdb.SaveChanges();



                    OMensaje.Tipo      = "Exito";
                    OMensaje.Msg       = "Departamento Creado con exito";
                    Session["Mensaje"] = OMensaje;

                    return(RedirectToAction("Index", "Departamentos"));
                }
            }
            catch (DbEntityValidationException e)
            {
                var errorMessages    = e.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);

                var exceptionMessage = string.Concat(e.Message, " El error de validacion es: ", fullErrorMessage);

                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = exceptionMessage;
                Session["Mensaje"] = OMensaje;

                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ListEmpresa = wdb.Company.ToList();
                    var ListTur     = wdb.Schedule.ToList();


                    Omodelo.ListaEmpresa = new SelectList(ListEmpresa, "CompanyID", "Name");
                    Omodelo.ListaTurno   = new SelectList(ListTur, "ScheduleID", "Name");


                    return(View(Omodelo));
                }
            }
        }
        // GET: Departamentos
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListDepartamentos = wdb.Department.ToList();

                return(View(ListDepartamentos));
            }
        }
Esempio n. 15
0
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListEmpresa = wdb.Company.OrderByDescending(a => a.CompanyID).ToList();

                return(View(ListEmpresa));
            }
        }
Esempio n. 16
0
        public ActionResult Edit(RoleViewModel Omodelo)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ORole = wdb.Role.Where(a => a.RoleID == Omodelo.RoleID).FirstOrDefault();

                    ORole.Description = Omodelo.Description;
                    ORole.IsActive    = Omodelo.IsActive;

                    wdb.Entry(ORole).State = EntityState.Modified;
                    wdb.SaveChanges();

                    foreach (var item in Omodelo.LisCodigoOpcionesSeleccionados)
                    {
                        var OExiste = wdb.RoleOption.Where(a => a.RoleID == ORole.RoleID && a.OptionID == item).FirstOrDefault();
                        if (OExiste == null)
                        {
                            var OUltimoRoleOption = wdb.RoleOption.OrderByDescending(a => a.RoleOptionID).FirstOrDefault();
                            int wID = OUltimoRoleOption.RoleOptionID + 1;

                            var ORoleOption = new RoleOption
                            {
                                RoleOptionID = wID,
                                RoleID       = Omodelo.RoleID,
                                OptionID     = item
                            };
                            wdb.RoleOption.Add(ORoleOption);
                            wdb.SaveChanges();
                        }
                    }


                    OMensaje.Tipo      = "Exito";
                    OMensaje.Msg       = "El Rol Fue Modificado con exito";
                    Session["Mensaje"] = OMensaje;

                    return(RedirectToAction("Index", "Role"));
                }
            }
            catch (DbEntityValidationException e)
            {
                var errorMessages    = e.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);

                var exceptionMessage = string.Concat(e.Message, " El error de validacion es: ", fullErrorMessage);

                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = exceptionMessage;
                Session["Mensaje"] = OMensaje;

                return(View(Omodelo));
            }
        }
        // GET: CCosto
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListCCosto = wdb.CostCenter.ToList();

                return(View(ListCCosto));
            }
        }
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListHorarios = wdb.Shift.OrderByDescending(a => a.ShiftID).ToList();

                return(View(ListHorarios));
            }
        }
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListDescanso = wdb.Break.OrderByDescending(a => a.BreakID).ToList();

                return(View(ListDescanso));
            }
        }
Esempio n. 20
0
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListDispositivo = wdb.Terminal.ToList();

                return(View(ListDispositivo));
            }
        }
Esempio n. 21
0
        public ActionResult Index()
        {
            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                var ListEmpleado = wdb.Employee.OrderByDescending(a => a.EmployeeID).ToList();

                return(View(ListEmpleado));
            }
        }
        public ActionResult Edit(int Id)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OHorario = wdb.Shift.Where(a => a.ShiftID == Id).FirstOrDefault();

                    var ListTipo                 = wdb.ShiftType.ToList();
                    var ListDescanso             = wdb.Break.ToList();
                    var ListDescansoSeleccionada = wdb.BreakShift.ToList();

                    var OVMHorario = new HorarioViewModel
                    {
                        ShiftID                   = OHorario.ShiftID,
                        Code                      = OHorario.Code,
                        Name                      = OHorario.Name,
                        ShiftTypeID               = OHorario.ShiftTypeID,
                        Color                     = OHorario.Color,
                        Flexible                  = OHorario.Flexible,
                        Start                     = OHorario.Start,
                        End                       = OHorario.End,
                        RangeStartIni             = OHorario.RangeStartIni,
                        RangeStartFin             = OHorario.RangeStartFin,
                        RangeEndIni               = OHorario.RangeEndIni,
                        RangeEndFin               = OHorario.RangeEndFin,
                        AllowBefore               = Convert.ToBoolean(OHorario.AllowBefore ?? false),
                        BeforeStart               = OHorario.BeforeStart,
                        AfterEnd                  = OHorario.AfterEnd,
                        AllowAfter                = Convert.ToBoolean(OHorario.AllowAfter ?? false),
                        Late                      = Convert.ToBoolean(OHorario.Late ?? false),
                        LateCome                  = OHorario.LateCome,
                        Early                     = Convert.ToBoolean(OHorario.Early ?? false),
                        EarlyOut                  = OHorario.EarlyOut,
                        EarlyCome                 = OHorario.EarlyCome,
                        ListaTipo                 = new SelectList(ListTipo, "ShiftTypeID", "Description"),
                        ListaDescanso             = ListDescanso,
                        ListDescansoSeleccionados = ListDescansoSeleccionada
                    };



                    return(View(OVMHorario));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;

                return(RedirectToAction("Index", "Horario"));
            }
        }
        public ActionResult Edit(DescansoViewModel Omodelo)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ODescanso = wdb.Break.Where(a => a.BreakID == Omodelo.BreakID).FirstOrDefault();

                    ODescanso.Name            = Omodelo.Name;
                    ODescanso.AuditUserUpd    = User.Identity.Name;
                    ODescanso.AuditDateUpd    = DateTime.Now;
                    ODescanso.AuditStationUpd = Environment.MachineName;
                    if (Omodelo.Tipo == 1)
                    {
                        ODescanso.Deduct     = true;
                        ODescanso.AutoDeduct = false;
                        ODescanso.NeedCheck  = false;
                    }
                    else if (Omodelo.Tipo == 2)
                    {
                        ODescanso.Deduct     = false;
                        ODescanso.AutoDeduct = true;
                        ODescanso.NeedCheck  = false;
                    }
                    else
                    {
                        ODescanso.Deduct     = false;
                        ODescanso.AutoDeduct = false;
                        ODescanso.NeedCheck  = true;
                    }
                    wdb.Entry(ODescanso).State = EntityState.Modified;
                    wdb.SaveChanges();

                    OMensaje.Tipo      = "Exito";
                    OMensaje.Msg       = "El Descanso Fue Modificado con exito";
                    Session["Mensaje"] = OMensaje;

                    return(RedirectToAction("Index", "Descanso"));
                }
            }
            catch (DbEntityValidationException e)
            {
                var errorMessages    = e.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);

                var exceptionMessage = string.Concat(e.Message, " El error de validacion es: ", fullErrorMessage);

                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = exceptionMessage;
                Session["Mensaje"] = OMensaje;

                return(View(Omodelo));
            }
        }
Esempio n. 24
0
        public JsonResult EstadoPais(int wCountryID)
        {
            var ListEstado = new List <State>();

            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                ListEstado = wdb.State.Where(a => a.CountryID == wCountryID).ToList();
            }
            return(new JsonResult {
                Data = ListEstado, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 25
0
        public ActionResult Edit(DiasFestivoViewModel Omodelo)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OEMDiasFestivo      = wdb.HolidayType.Where(a => a.HolidayTypeID == Omodelo.HolidayTypeID).FirstOrDefault();
                    var ODiasFestivoDetalle = wdb.HolidayDetails.Where(a => a.HolidayTypeID == Omodelo.HolidayTypeID).FirstOrDefault();

                    OEMDiasFestivo.Name                 = Omodelo.Name;
                    ODiasFestivoDetalle.StartDate       = Omodelo.StartDate;
                    OEMDiasFestivo.AuditUserUpd         = User.Identity.Name;
                    OEMDiasFestivo.AuditDateUpd         = DateTime.Now;
                    OEMDiasFestivo.AuditStationUpd      = Environment.MachineName;
                    ODiasFestivoDetalle.AuditUserUpd    = User.Identity.Name;
                    ODiasFestivoDetalle.AuditDateUpd    = DateTime.Now;
                    ODiasFestivoDetalle.AuditStationUpd = Environment.MachineName;


                    wdb.Entry(OEMDiasFestivo).State = EntityState.Modified;
                    wdb.SaveChanges();

                    wdb.Entry(ODiasFestivoDetalle).State = EntityState.Modified;
                    wdb.SaveChanges();



                    OMensaje.Tipo      = "Exito";
                    OMensaje.Msg       = "Dias Festivo Fue Modificado con exito";
                    Session["Mensaje"] = OMensaje;

                    return(RedirectToAction("Index", "DiasFestivo"));
                }
            }
            catch (DbEntityValidationException e)
            {
                var errorMessages    = e.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);

                var exceptionMessage = string.Concat(e.Message, " El error de validacion es: ", fullErrorMessage);

                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = exceptionMessage;
                Session["Mensaje"] = OMensaje;

                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    return(View(Omodelo));
                }
            }
        }
        public ActionResult Edit(DepartamentosViewModel Omodelo)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OEMDepata = wdb.Department.Where(a => a.DepartmentID == Omodelo.DepartmentID).FirstOrDefault();

                    OEMDepata.Name       = Omodelo.Name;
                    OEMDepata.CompanyID  = Omodelo.CompanyID;
                    OEMDepata.ScheduleID = Omodelo.ScheduleID;


                    wdb.Entry(OEMDepata).State = EntityState.Modified;
                    wdb.SaveChanges();



                    OMensaje.Tipo      = "Exito";
                    OMensaje.Msg       = "Departamento Fue Modificado con exito";
                    Session["Mensaje"] = OMensaje;

                    return(RedirectToAction("Index", "Departamentos"));
                }
            }
            catch (DbEntityValidationException e)
            {
                var errorMessages    = e.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);

                var exceptionMessage = string.Concat(e.Message, " El error de validacion es: ", fullErrorMessage);

                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = exceptionMessage;
                Session["Mensaje"] = OMensaje;

                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var ListEmpresa = wdb.Company.ToList();
                    var ListTur     = wdb.Schedule.ToList();


                    Omodelo.ListaEmpresa = new SelectList(ListEmpresa, "CompanyID", "Name");
                    Omodelo.ListaTurno   = new SelectList(ListTur, "ScheduleID", "Name");


                    return(View(Omodelo));
                }
            }
        }
Esempio n. 27
0
        public ActionResult Create()
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    //var OEmpleado = wdb.Employee.Where(a=> a.EmployeeID == Id).FirstOrDefault();

                    var ListDepar  = wdb.Department.ToList();
                    var ListTur    = wdb.Schedule.ToList();
                    var ListPais   = wdb.Country.ToList();
                    var LisEstado  = wdb.State.ToList();
                    var ListCiudad = wdb.City.ToList();
                    var OGenero    = new Genero
                    {
                        Id     = "M",
                        Nombre = "MASCULINO"
                    };
                    var OGenero2 = new Genero
                    {
                        Id     = "F",
                        Nombre = "FEMENINO"
                    };
                    var ListGenero = new List <Genero>
                    {
                        OGenero,
                        OGenero2
                    };

                    var OVMEmpleado = new EmpleadoViewModel
                    {
                        ListaDepartamento = new SelectList(ListDepar, "DepartmentID", "Name"),
                        ListaTurno        = new SelectList(ListTur, "ScheduleID", "Name"),
                        ListaPais         = new SelectList(ListPais, "CountryID", "Name"),
                        ListaEstado       = new SelectList(LisEstado, "StateID", "Name"),
                        ListaCiudad       = new SelectList(ListCiudad, "CityID", "Name"),
                        ListaGenero       = new SelectList(ListGenero, "Id", "Nombre"),
                    };

                    return(View(OVMEmpleado));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;
                return(RedirectToAction("Index", "Empleado"));
            }
        }
Esempio n. 28
0
        public JsonResult CiudadEstado(int wStateID)
        {
            var ListCiudad = new List <City>();

            using (RELOJBIOEntities wdb = new RELOJBIOEntities())
            {
                ListCiudad = wdb.City.Where(a => a.StateID == wStateID).ToList();
            }

            return(new JsonResult {
                Data = ListCiudad, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 29
0
        public ActionResult Edit(int Id)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var  OUsuario         = wdb.User.Where(a => a.UserID == Id).FirstOrDefault();
                    bool wPasswordExpires = false;
                    if (OUsuario.PasswordExpires == "S")
                    {
                        wPasswordExpires = true;
                    }

                    var ListCompania = wdb.Company.ToList();
                    var ListRoles    = wdb.Role.ToList();
                    var ListCompaniaSeleccionadas = wdb.UserCompany.Where(a => a.UserID == OUsuario.UserID).ToList();
                    var ListRolesSeleccionados    = wdb.UserRole.Where(a => a.UserID == OUsuario.UserID).ToList();


                    var OVMUsuario = new UserViewModel
                    {
                        UserID                    = OUsuario.UserID,
                        FullName                  = OUsuario.FullName,
                        Login                     = OUsuario.Login,
                        Password                  = OUsuario.Password,
                        PasswordExpires           = wPasswordExpires,
                        DaysValidity              = OUsuario.DaysValidity,
                        LastChangePassword        = Convert.ToDateTime(OUsuario.LastChangePassword ?? DateTime.Now),
                        IsActive                  = OUsuario.IsActive,
                        ListCompania              = ListCompania,
                        ListRoles                 = ListRoles,
                        ListCompaniaSeleccionadas = ListCompaniaSeleccionadas,
                        ListRolesSeleccionados    = ListRolesSeleccionados
                    };



                    return(View(OVMUsuario));
                }
            }
            catch (Exception e)
            {
                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = e.ToString();
                Session["Mensaje"] = OMensaje;

                return(RedirectToAction("Index", "Usuario"));
            }
        }
Esempio n. 30
0
        public ActionResult Create(DispositivosViewModel Omodelo)
        {
            var OMensaje = new Mensaje();

            try
            {
                using (RELOJBIOEntities wdb = new RELOJBIOEntities())
                {
                    var OUltimoDispositivos = wdb.Terminal.OrderByDescending(a => a.TerminalID).FirstOrDefault();
                    int wId = OUltimoDispositivos.TerminalID + 1;

                    var ODispositivos = new Terminal
                    {
                        TerminalID      = wId,
                        Number          = wId,
                        Name            = Omodelo.Name,
                        ConnectPwd      = Omodelo.ConnectPwd,
                        Type            = Omodelo.Type,
                        Faces           = Omodelo.Faces,
                        Port            = Omodelo.Port,
                        TcpIp           = Omodelo.TcpIp,
                        IsActive        = Omodelo.IsActive,
                        AuditDateIns    = DateTime.Now,
                        AuditStationIns = Environment.MachineName,
                        AuditUserIns    = User.Identity.Name
                    };
                    wdb.Terminal.Add(ODispositivos);
                    wdb.SaveChanges();


                    OMensaje.Tipo      = "Exito";
                    OMensaje.Msg       = "Dispositivos Creado con exito";
                    Session["Mensaje"] = OMensaje;

                    return(RedirectToAction("Index", "Dispositivos"));
                }
            }
            catch (DbEntityValidationException e)
            {
                var errorMessages    = e.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);

                var exceptionMessage = string.Concat(e.Message, " El error de validacion es: ", fullErrorMessage);

                OMensaje.Tipo      = "Error";
                OMensaje.Msg       = exceptionMessage;
                Session["Mensaje"] = OMensaje;

                return(View(Omodelo));
            }
        }