示例#1
0
        // GET: Manager
        public ActionResult Index(int?page, int?pageSize, string searchString)
        {
            #region "BTSS"
            string role;
            string user_name;
            try
            {
                role      = Session["role"].ToString();
                user_name = Session["logon_user"].ToString();
                string grp_id = Session["grp_id"].ToString();
                ViewBag.CanView   = af.CanView(grp_id, "Manager");
                ViewBag.CanAdd    = af.CanAdd(grp_id, "Manager");
                ViewBag.CanEdit   = af.CanEdit(grp_id, "Manager");
                ViewBag.CanDelete = af.CanDelete(grp_id, "Manager");

                if (!ViewBag.CanView)
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception exception)
            {
                //session expired
                string result = exception.Message.ToString();
                return(HttpNotFound());
            }
            #endregion "BTSS"
            #region "Table"
            int?defaultPageSize = 10;
            if (pageSize != null)
            {
                defaultPageSize = pageSize;
            }
            var managers = (from m in db.Managers select m);
            if (!String.IsNullOrEmpty(searchString))
            {
                managers = managers.Where(r => r.PRDUserId.Contains(searchString) || r.Name.Contains(searchString));
            }
            #endregion "Table"
            #region "Return"
            return(View(managers.OrderBy(r => r.Name).ToPagedList(page ?? 1, (int)defaultPageSize)));

            #endregion "Return"
        }
示例#2
0
        // GET: Department
        public ActionResult Index(int?page, int?pageSize, string searchString)
        {
            #region "BTSS"
            string role;
            string user_name;
            try
            {
                role      = Session["role"].ToString();
                user_name = Session["logon_user"].ToString();
                string grp_id = Session["grp_id"].ToString();
                ViewBag.CanView   = af.CanView(grp_id, "Department");
                ViewBag.CanAdd    = af.CanAdd(grp_id, "Department");
                ViewBag.CanEdit   = af.CanEdit(grp_id, "Department");
                ViewBag.CanDelete = af.CanDelete(grp_id, "Department");

                if (!ViewBag.CanView)
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception exception)
            {
                //session expired
                string result = exception.Message.ToString();
                return(HttpNotFound());
            }

            var departments = from d in db.Departments
                              select d;
            switch (role)
            {
            case "Manager":
                List <long> depIds = new List <long>();
                OSC_Manager mgr    = db.Managers.Where(t => t.PRDUserId == user_name).FirstOrDefault();
                if (mgr == null)
                {
                    departments = (from d in db.Departments
                                   where d.DepartmentId == 0
                                   select d);;
                }
                else
                {
                    foreach (OSC_ManageGroup obj in db.ManageGroups.Where(t => t.ManagerId == mgr.ManagerId))
                    {
                        if (obj.Type == "DEPT")
                        {
                            depIds.Add(obj.EntityId);
                        }
                    }
                    departments = (from d in db.Departments
                                   where depIds.Contains(d.DepartmentId) && d.IsActive
                                   select d);
                }
                break;

            case "Team Leader":
            case "Department Analyst":
            case "Staff":
                departments = (from d in db.Departments
                               where d.DepartmentId == 0
                               select d);
                break;
            }
            #endregion "BTSS"
            #region "Table"
            int?defaultPageSize = 10;
            if (pageSize != null)
            {
                defaultPageSize = pageSize;
            }
            if (!String.IsNullOrEmpty(searchString))
            {
                departments = departments.Where(d => d.DepartmentName.Contains(searchString));
            }
            #endregion "Table"
            #region "Return"
            return(View(departments.OrderBy(d => d.DepartmentName).ToPagedList(page ?? 1, (int)defaultPageSize)));

            #endregion "Return"
        }
示例#3
0
        // GET: Representative
        public ActionResult Index(int?page, int?pageSize, string searchByRep, string searchByTeam, string searchByRole, string searchByLocation)
        {
            #region "InitializeRepresentatives"
            af.InitializeRepresentatives(db);
            #endregion "InitializeRepresentatives"
            #region "BTSS"
            string role;
            string user_name;
            try
            {
                role      = Session["role"].ToString();
                user_name = Session["logon_user"].ToString();
                string grp_id = Session["grp_id"].ToString();
                ViewBag.CanView   = af.CanView(grp_id, "Representative");
                ViewBag.CanAdd    = af.CanAdd(grp_id, "Representative");
                ViewBag.CanEdit   = af.CanEdit(grp_id, "Representative");
                ViewBag.CanDelete = af.CanDelete(grp_id, "Representative");

                if (!ViewBag.CanView)
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception exception)
            {
                //session expired
                string result = exception.Message.ToString();
                return(HttpNotFound());
            }

            var reps = (from r in db.Representatives
                        select r);
            List <long> TeamIds = new List <long>();
            switch (role)
            {
            case "Manager":
            case "Team Leader":
            case "Department Analyst":
                foreach (OSC_Representative obj in reps)
                {
                    if (af.IsManaged(obj.TeamId, user_name, role))
                    {
                        if (!TeamIds.Contains((long)obj.TeamId))
                        {
                            TeamIds.Add((long)obj.TeamId);
                        }
                    }
                }
                reps = (from r in db.Representatives
                        where TeamIds.Contains((long)r.TeamId) && r.IsActive == true
                        select r);
                break;

            case "Staff":
                OSC_Representative oSC_Representative = af.GetRepresentativeByPRD(user_name);
                long repId;
                repId = 0;
                if (oSC_Representative != null)
                {
                    repId = oSC_Representative.RepId;
                }
                reps = reps.Where(r => r.RepId == repId && r.IsActive);
                break;
            }
            #endregion "BTSS"
            #region "Table"
            int?defaultPageSize = 10;
            if (pageSize != null)
            {
                defaultPageSize = pageSize;
            }
            if (searchByRep != null || searchByTeam != null || searchByRole != null || searchByLocation != null)
            {
                //Session["RepFilter"] = true;
                List <long> TeamIdResult = new List <long>();
                TeamIdResult = null;
                if (!String.IsNullOrEmpty(searchByTeam))
                {
                    TeamIdResult = (from list in db.Teams where list.TeamName == searchByTeam select list.TeamId).ToList();
                    if (role != "Admin")
                    {
                        TeamIdResult = (from list in db.Teams where list.TeamName == searchByTeam && list.IsActive select list.TeamId).ToList();
                    }
                }
                List <int> RoleIdResult = new List <int>();
                RoleIdResult = null;
                if (!String.IsNullOrEmpty(searchByRole))
                {
                    RoleIdResult = (from list in db.CoreRoles where list.CoreRole == searchByRole select list.CoreRoleId).ToList();
                }
                List <int> LocationIdResult = new List <int>();
                LocationIdResult = null;
                if (!String.IsNullOrEmpty(searchByLocation))
                {
                    LocationIdResult = (from list in db.Locations where list.Location == searchByLocation select list.LocationId).ToList();
                }

                if (searchByRep != "")
                {
                    reps = reps.Where(t => t.FirstName + " " + t.LastName == searchByRep);
                }
                if (searchByTeam != "")
                {
                    reps = reps.Where(t => TeamIdResult.Contains((long)t.TeamId));
                }
                if (searchByRole != "")
                {
                    reps = reps.Where(t => RoleIdResult.Contains((int)t.CoreRoleId));
                }
                if (searchByLocation != "")
                {
                    reps = reps.Where(t => LocationIdResult.Contains((int)t.LocationId));
                }
                if (role != "Admin")
                {
                    reps = reps.Where(t => t.IsActive);
                }
            }
            #endregion "Table"
            #region "ViewBagFilters"
            if (searchByRep != null)
            {
                //Session["RepFilter_Rep"] = searchByRep;
                ViewBag.Representative = searchByRep;
            }
            else
            {
                //Session["RepFilter_Rep"] = "";
                ViewBag.Representative = "";
            }
            if (searchByTeam != null)
            {
                //Session["RepFilter_Team"] = searchByTeam;
                ViewBag.Team = searchByTeam;
            }
            else
            {
                //Session["RepFilter_Team"] = "";
                ViewBag.Team = "";
            }
            if (searchByRole != null)
            {
                //Session["RepFilter_Role"] = searchByRole;
                ViewBag.CoreRole = searchByRole;
            }
            else
            {
                //Session["RepFilter_Role"] = "";
                ViewBag.CoreRole = "";
            }
            if (searchByLocation != null)
            {
                //Session["RepFilter_Location"] = searchByLocation;
                ViewBag.Location = searchByLocation;
            }
            else
            {
                //Session["RepFilter_Location"] = "";
                ViewBag.Location = "";
            }
            #endregion "ViewBagFilters"
            #region "Return"
            return(View(reps.OrderBy(r => r.TeamId).ThenBy(r => r.FirstName).ToPagedList(page ?? 1, (int)defaultPageSize)));

            #endregion "Return"
        }
        // GET: ActivityTracker
        public ActionResult Index(int?page, int?pageSize, string searchByActivity, string searchByTeam, string searchByRep, string searchByDateFrom, string searchByDateTo)
        {
            #region "Initialize"
            af.InitializeActivities(db);
            #endregion "Initialize"
            #region "BTSS"
            string role;
            string user_name;
            try
            {
                role      = Session["role"].ToString();
                user_name = Session["logon_user"].ToString();
                string grp_id = Session["grp_id"].ToString();
                ViewBag.CanView   = af.CanView(grp_id, "Activity Tracker");
                ViewBag.CanAdd    = af.CanAdd(grp_id, "Activity Tracker");
                ViewBag.CanEdit   = af.CanEdit(grp_id, "Activity Tracker");
                ViewBag.CanDelete = af.CanDelete(grp_id, "Activity Tracker");

                if (!ViewBag.CanView)
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception exception)
            {
                //session expired
                string result = exception.Message.ToString();
                return(HttpNotFound());
            }

            var acts = (from a in db.ActivityTrackers
                        where a.Activity != "Attendance"
                        select a);
            List <long> TeamIds = new List <long>();
            switch (role)
            {
            case "Manager":
            case "Team Leader":
            case "Department Analyst":
                foreach (OSC_ActivityTracker obj in acts)
                {
                    if (af.IsManaged(obj.TeamId, user_name, role))
                    {
                        if (!TeamIds.Contains(obj.TeamId))
                        {
                            TeamIds.Add(obj.TeamId);
                        }
                    }
                }
                acts = (from a in db.ActivityTrackers
                        where a.Activity != "Attendance" && TeamIds.Contains(a.TeamId) && a.IsActive
                        select a);
                break;

            case "Staff":
                OSC_Representative oSC_Representative = af.GetRepresentativeByPRD(user_name);
                long repId;
                repId = 0;
                if (oSC_Representative != null)
                {
                    repId = oSC_Representative.RepId;
                }
                acts = acts.Where(a => a.RepId == repId && a.IsActive);
                break;
            }
            #endregion "BTSS"
            #region "Table"
            int?defaultPageSize = 10;
            if (pageSize != null)
            {
                defaultPageSize = pageSize;
            }
            if (searchByActivity != null || searchByTeam != null || searchByRep != null || searchByDateFrom != null || searchByDateTo != null)
            {
                Session["ActivityFilter"] = true;
                List <long> TeamIdResult = new List <long>();
                TeamIdResult = null;
                if (!String.IsNullOrEmpty(searchByTeam))
                {
                    TeamIdResult = (from list in db.Teams where list.TeamName == searchByTeam select list.TeamId).ToList();
                    if (role != "Admin")
                    {
                        TeamIdResult = (from list in db.Teams where list.TeamName == searchByTeam && list.IsActive select list.TeamId).ToList();
                    }
                }
                List <long> RepIdResult = new List <long>();
                if (!String.IsNullOrEmpty(searchByRep))
                {
                    RepIdResult = (from list in db.Representatives where list.FirstName + " " + list.LastName == searchByRep select list.RepId).ToList();
                    if (role != "Admin")
                    {
                        RepIdResult = (from list in db.Representatives where (list.FirstName + " " + list.LastName == searchByRep) && list.IsActive select list.RepId).ToList();
                    }
                }

                if (searchByActivity != "")
                {
                    acts = acts.Where(t => t.Activity == searchByActivity);
                }
                if (searchByTeam != "")
                {
                    acts = acts.Where(t => TeamIdResult.Contains((long)t.TeamId));
                }
                if (searchByRep != "")
                {
                    acts = acts.Where(t => RepIdResult.Contains((long)t.RepId));
                }
                if (searchByDateFrom != "")
                {
                    var dt = Convert.ToDateTime(searchByDateFrom);
                    acts = acts.Where(t => dt == t.DateFrom);
                }
                if (searchByDateTo != "")
                {
                    var dt = Convert.ToDateTime(searchByDateTo);
                    acts = acts.Where(t => dt == t.DateTo);
                }
                if (role != "Admin")
                {
                    acts = acts.Where(t => t.IsActive);
                }
            }
            #endregion "Table"
            #region "ViewBagFilters"
            if (searchByActivity != null)
            {
                Session["ActivityFilter_Activity"] = searchByActivity;
                ViewBag.Activity = searchByActivity;
            }
            else
            {
                Session["ActivityFilter_Activity"] = "";
                ViewBag.Activity = "";
            }
            if (searchByTeam != null)
            {
                Session["ActivityFilter_Team"] = searchByTeam;
                ViewBag.Team = searchByTeam;
            }
            else
            {
                Session["ActivityFilter_Team"] = "";
                ViewBag.Team = "";
            }
            if (searchByRep != null)
            {
                Session["ActivityFilter_Rep"] = searchByRep;
                ViewBag.Representative        = searchByRep;
            }
            else
            {
                Session["ActivityFilter_Rep"] = "";
                ViewBag.Representative        = "";
            }
            if (searchByDateFrom != null)
            {
                Session["ActivityFilter_DateFrom"] = searchByDateFrom;
                ViewBag.DateFrom = searchByDateFrom;
            }
            else
            {
                Session["ActivityFilter_DateFrom"] = "";
                ViewBag.DateFrom = "";
            }
            if (searchByDateTo != null)
            {
                Session["ActivityFilter_DateTo"] = searchByDateTo;
                ViewBag.DateTo = searchByDateTo;
            }
            else
            {
                Session["ActivityFilter_DateTo"] = "";
                ViewBag.DateTo = "";
            }
            #endregion "ViewBagFilters"
            #region "Return"
            return(View(acts.OrderByDescending(a => a.Year).ThenByDescending(a => a.Month).ThenByDescending(a => a.TeamId).ToPagedList(page ?? 1, (int)defaultPageSize)));

            #endregion "Return"
        }
示例#5
0
        // GET: Team
        public ActionResult Index(int?page, int?pageSize, string searchString)
        {
            #region "Initialize"
            af.InitializeTeams(db);
            #endregion "Initialize"
            #region "BTSS"
            string role;
            string user_name;
            try
            {
                role      = Session["role"].ToString();
                user_name = Session["logon_user"].ToString();
                string grp_id = Session["grp_id"].ToString();
                ViewBag.CanView   = af.CanView(grp_id, "Team");
                ViewBag.CanAdd    = af.CanAdd(grp_id, "Team");
                ViewBag.CanEdit   = af.CanEdit(grp_id, "Team");
                ViewBag.CanDelete = af.CanDelete(grp_id, "Team");

                if (!ViewBag.CanView)
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception exception)
            {
                //session expired
                string result = exception.Message.ToString();
                return(HttpNotFound());
            }

            var teams = (from t in db.Teams
                         select t);
            List <long> TeamIds = new List <long>();
            switch (role)
            {
            case "Manager":
            case "Team Leader":
            case "Department Analyst":
            case "Staff":
                foreach (OSC_Team obj in teams)
                {
                    if (af.IsManaged(obj.TeamId, user_name, role))
                    {
                        if (!TeamIds.Contains(obj.TeamId))
                        {
                            TeamIds.Add(obj.TeamId);
                        }
                    }
                }
                teams = (from t in db.Teams
                         where TeamIds.Contains(t.TeamId) && t.IsActive
                         select t);
                break;
            }
            #endregion "BTSS"
            #region "Table"
            int?defaultPageSize = 10;
            if (pageSize != null)
            {
                defaultPageSize = pageSize;
            }
            if (!String.IsNullOrEmpty(searchString))
            {
                teams = teams.Where(t => t.TeamName.Contains(searchString));
            }
            #endregion "Table"
            #region "Return"
            return(View(teams.OrderBy(t => t.DepartmentId).ThenBy(t => t.TeamName).ToPagedList(page ?? 1, (int)defaultPageSize)));

            #endregion "Return"
        }
示例#6
0
        // GET: ManualEntry
        public ActionResult Index(int?page, int?pageSize, string searchString)
        {
            #region "Initialize"
            af.InitializeManualEntries(db);
            #endregion "Initialize"
            #region "BTSS"
            string role;
            string user_name;
            try
            {
                role      = Session["role"].ToString();
                user_name = Session["logon_user"].ToString();
                string grp_id = Session["grp_id"].ToString();
                ViewBag.CanView   = af.CanView(grp_id, "Manual Entries");
                ViewBag.CanAdd    = af.CanAdd(grp_id, "Manual Entries");
                ViewBag.CanEdit   = af.CanEdit(grp_id, "Manual Entries");
                ViewBag.CanDelete = af.CanDelete(grp_id, "Manual Entries");

                if (!ViewBag.CanView)
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception exception)
            {
                //session expired
                string result = exception.Message.ToString();
                return(HttpNotFound());
            }

            var mes = (from m in db.ManualEntries
                       select m);
            List <long> TeamIds = new List <long>();
            switch (role)
            {
            case "Manager":
            case "Team Leader":
            case "Department Analyst":
                foreach (OSC_ManualEntry obj in mes)
                {
                    if (af.IsManaged(obj.TeamId, user_name, role))
                    {
                        if (!TeamIds.Contains((long)obj.TeamId))
                        {
                            TeamIds.Add((long)obj.TeamId);
                        }
                    }
                }
                mes = (from m in db.ManualEntries
                       where TeamIds.Contains((long)m.TeamId) && m.IsActive == true
                       select m);
                break;

            case "Staff":
                OSC_Representative oSC_Representative = af.GetRepresentativeByPRD(user_name);
                long repId;
                repId = 0;
                if (oSC_Representative != null)
                {
                    repId = oSC_Representative.RepId;
                }
                mes = mes.Where(m => m.RepId == repId && m.IsActive);
                break;
            }
            #endregion "BTSS"
            #region "Table"
            int?defaultPageSize = 10;
            if (pageSize != null)
            {
                defaultPageSize = pageSize;
            }
            if (!String.IsNullOrEmpty(searchString))
            {
                mes = mes.Where(m => m.MonthName.Contains(searchString) || m.Year.ToString().Contains(searchString));
            }
            #endregion "Table"
            #region "Return"
            return(View(mes.OrderByDescending(m => m.Year).ThenByDescending(m => m.Month).ThenByDescending(m => m.TeamId).ToPagedList(page ?? 1, (int)defaultPageSize)));

            #endregion "Return"
        }