Example #1
0
 public static bool HasRights(enumRoles Roles)
 {
     string[] arrUserPermissions = HttpContext.Current.Session["UserPermissions"].ToString().Split(',');
     if (Array.IndexOf(arrUserPermissions, Convert.ToInt16(Roles).ToString()) >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        //public EmployeeRepository(string SpProcedureName)
        //{
        //    _dao = new DAO();
        //    _SpProcedureName = SpProcedureName;
        //}


        public Result GetAllEmployess(out List <Employee> lstEmployees, string nombre, int?PositionId, int?AreaId, DateTime?fecha_incial, DateTime?fecha_final, int?BossId, bool activo, int?EmployeeId, int?OperacionId, enumRoles Rol, int EmployeeIdConected, bool FingerPrint)
        {
            lstEmployees     = null;
            _SpProcedureName = "[dbo].[Sp_GetEmployeesByFilter]";
            Result resultado = new Result();

            try
            {
                List <SqlParameter> parametros = new List <SqlParameter> {
                    new SqlParameter("@Nombre", nombre)
                    , new SqlParameter("@PosicionId", PositionId == 0 ? null:PositionId)
                    , new SqlParameter("@AreaId", AreaId == 0 ?null:AreaId)
                    , new SqlParameter("@FechaInicial", fecha_incial)
                    , new SqlParameter("@FechaFinal", fecha_final)
                    , new SqlParameter("@BossId", BossId == 0?null :BossId)
                    , new SqlParameter("@Activo", activo)
                    , new SqlParameter("@EmployeeId", EmployeeId)
                    , new SqlParameter("@OperacionId", OperacionId == 0?null:OperacionId)
                    , new SqlParameter("@FingerPrint", FingerPrint)
                    //,new SqlParameter("@Rol", Convert.ToInt32(Rol))
                    //,new SqlParameter("@EmployeeIdConected", EmployeeIdConected)
                    //,new SqlParameter("@Rol", null)
                    //,new SqlParameter("@EmployeeIdConected", null)
                };
                SqlDataReader reader = _dao.ExecuteReader(parametros, _SpProcedureName);
                if (reader.HasRows)
                {
                    lstEmployees = new List <Employee>();
                    while (reader.Read())
                    {
                        Employee employee = new Employee();
                        employee.EmployeeId = reader["EmployeeId"].ToString();
                        //employee.CardId = reader["CardId"].ToString();
                        employee.CardNumber = reader["CardNumber"].ToString();
                        employee.FirstName  = reader["FirstName"].ToString();
                        employee.LastName   = reader["LastName"].ToString();
                        employee.MiddleName = reader["MiddleName"].ToString();
                        employee.FullName   = reader["FullName"].ToString();
                        //employee.Photo = reader["Photo"].ToString();
                        employee.Rfc                = reader["Rfc"].ToString();
                        employee.Curp               = reader["Curp"].ToString();
                        employee.NSS                = reader["NSS"].ToString();
                        employee.BirthDay           = reader["BirthDay"] == DBNull.Value?null: (DateTime?)reader["BirthDay"];
                        employee.AdmissionDate      = reader["AdmissionDate"] == DBNull.Value ? null : (DateTime?)reader["AdmissionDate"];
                        employee.StreetName         = reader["StreetName"].ToString();
                        employee.NumberExt          = reader["NumberExt"].ToString();
                        employee.NumberInt          = reader["NumberInt"].ToString();
                        employee.Delegation         = reader["Delegation"].ToString();
                        employee.Colony             = reader["Colony"].ToString();
                        employee.CP                 = reader["CP"].ToString();
                        employee.PhoneNumber        = reader["PhoneNumber"].ToString();
                        employee.CellPhoneNumber    = reader["CellPhoneNumber"].ToString();
                        employee.OfficePhone        = reader["OfficePhone"].ToString();
                        employee.OfficeExt          = reader["OfficeExt"].ToString();
                        employee.PersonalEmail      = reader["PersonalEmail"].ToString();
                        employee.CompanyEmail       = reader["CompanyEmail"].ToString();
                        employee.Enabled            = (bool)reader["Enabled"];
                        employee.LocalizationId     = reader["LocalizationId"] == DBNull.Value ?null:  (int?)reader["LocalizationId"];
                        employee.PayRollId          = reader["PayRollId"] == DBNull.Value ? null : (int?)reader["PayRollId"];
                        employee.CompanyId          = reader["CompanyId"] == DBNull.Value ? null : (int?)reader["CompanyId"];
                        employee.NationalityId      = reader["NationalityId"] == DBNull.Value ? null : (int?)reader["NationalityId"];
                        employee.EmployeePositionId = reader["EmployeePositionId"] == DBNull.Value ? null : (int?)reader["EmployeePositionId"];
                        employee.BossId             = reader["BossId"] == DBNull.Value ? null : (int?)reader["BossId"];
                        employee.BossName           = reader["BossName"].ToString();
                        employee.AreaName           = reader["AreaName"].ToString();
                        employee.PositionName       = reader["PositionName"].ToString();
                        employee.FingerPrint        = reader["FingerPrint"] == DBNull.Value?false : Convert.ToBoolean(reader["FingerPrint"])? true:false;
                        employee.ParkingSpace       = reader["ParkingSpace"].ToString();
                        employee.CardId             = reader["CardId"].ToString();

                        lstEmployees.Add(employee);
                    }
                }
                reader.Close();
                resultado.Success = true;
            }
            catch (Exception e)
            {
                resultado.Success      = false;
                resultado.ErrorMessage = String.Format("Se ha producido un error al procesar datos de archivo Error {0}", e.Message);
            }

            return(resultado);
        }