コード例 #1
0
        // GET: AttendanceReport
        public ActionResult Index(int?page, string branch, string emp, string head, string hr)
        {
            if (branch == null)
            {
                branch = "";
            }
            if (emp == null)
            {
                emp = "";
            }
            if (head == null)
            {
                head = "";
            }
            if (hr == null)
            {
                hr = "";
            }
            ViewBag.Branch   = branch;
            ViewBag.Employee = emp;
            ViewBag.Head     = head;
            ViewBag.HR       = hr;

            string LoginId = Session["LoginId"].ToString();
            string Role    = Session["Role"].ToString();

            if (Role == "RL01")
            {
                ViewBag.EmployeeList = ToSelectList((from A in db.EmployeeMasters select new DropDownModel {
                    Id = A.EmployeeId.ToString(), Value = A.EmpName
                }).ToList());
                ViewBag.HeadList     = ToSelectList((from A in db.EmployeeMasters join B in db.EmployeeMasters on A.MangerID equals B.EmployeeId select new DropDownModel {
                    Id = B.EmployeeId, Value = B.EmpName
                }).Distinct().ToList());
                ViewBag.HRList       = ToSelectList((from A in db.EmployeeMasters join B in db.EmployeeMasters on A.HRID equals B.EmployeeId select new DropDownModel {
                    Id = B.EmployeeId, Value = B.EmpName
                }).Distinct().ToList());
            }
            else if (Role == "RL02")
            {
                ViewBag.EmployeeList = ToSelectList((from A in db.EmployeeMasters where A.HRID == LoginId select new DropDownModel {
                    Id = A.EmployeeId.ToString(), Value = A.EmpName
                }).ToList());
                ViewBag.HeadList     = ToSelectList((from A in db.EmployeeMasters join B in db.EmployeeMasters on A.MangerID equals B.EmployeeId where A.HRID == LoginId select new DropDownModel {
                    Id = B.EmployeeId, Value = B.EmpName
                }).Distinct().ToList());
                ViewBag.HRList       = ToSelectList((from A in db.EmployeeMasters join B in db.EmployeeMasters on A.HRID equals B.EmployeeId where A.HRID == LoginId select new DropDownModel {
                    Id = B.EmployeeId, Value = B.EmpName
                }).Distinct().ToList());
            }
            else
            {
                ViewBag.EmployeeList = ToSelectList((from A in db.EmployeeMasters where A.MangerID == LoginId select new DropDownModel {
                    Id = A.EmployeeId.ToString(), Value = A.EmpName
                }).ToList());
                ViewBag.HeadList     = ToSelectList((from A in db.EmployeeMasters join B in db.EmployeeMasters on A.MangerID equals B.EmployeeId where A.MangerID == LoginId select new DropDownModel {
                    Id = B.EmployeeId, Value = B.EmpName
                }).Distinct().ToList());
                ViewBag.HRList       = ToSelectList((from A in db.EmployeeMasters join B in db.EmployeeMasters on A.HRID equals B.EmployeeId where A.MangerID == LoginId select new DropDownModel {
                    Id = B.EmployeeId, Value = B.EmpName
                }).Distinct().ToList());
            }
            ViewBag.BranchList = ToSelectList((from A in db.SiteMasters select new DropDownModel {
                Id = A.BUCode.ToString(), Value = A.BUDescription
            }).ToList());
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            List <Sp_MonthlyAttendanceReports_Result> list = db.Sp_MonthlyAttendanceReports(Role, LoginId, emp, head, hr, branch).ToList();

            return(View(list.ToPagedList(pageNumber, pageSize)));
        }