Ejemplo n.º 1
0
        public ActionResult EmployeeReport()
        {
            ReportsProcess reportsProcess = new ReportsProcess();
            int            employeeStatus = (int)EmployeeStatus.Active;
            var            employeeList   = reportsProcess.GetEmployeeList(employeeStatus).ToList();

            DepartmentProcess department = new DepartmentProcess();
            PositionProcess   position   = new PositionProcess();

            ViewBag.Departments = department.GetDepartments().ToList();
            ViewBag.Positions   = position.GetPositions().ToList();

            return(View(employeeList));
        }
Ejemplo n.º 2
0
        public void EmployeeReport(vwEmployeeList emp)
        {
            DepartmentProcess department = new DepartmentProcess();
            PositionProcess   position   = new PositionProcess();

            ViewBag.Departments = department.GetDepartments().ToList();
            ViewBag.Positions   = position.GetPositions().ToList();

            ReportsProcess reportsProcess = new ReportsProcess();
            int            employeeStatus = (int)EmployeeStatus.Active;

            List <vwEmployeeList> sourcefile = new List <vwEmployeeList>();

            if (emp.DepartmentID != 0 && emp.PositionID != 0)
            {
                sourcefile = (reportsProcess.GetEmployeeListByDepartmentIDPositionID(employeeStatus, emp.DepartmentID, emp.PositionID));
            }
            else if (emp.DepartmentID > 0 && emp.PositionID == 0)
            {
                sourcefile = (reportsProcess.GetEmployeeListByDepartmentID(employeeStatus, emp.DepartmentID));
            }
            else if (emp.PositionID > 0 && emp.DepartmentID == 0)
            {
                sourcefile = (reportsProcess.GetEmployeeListByPositionID(employeeStatus, emp.PositionID));
            }
            else
            {
                sourcefile = (reportsProcess.GetEmployeeList(employeeStatus));
            }

            WebGrid grid     = new WebGrid(source: sourcefile, canPage: false, canSort: false);
            string  gridHtml = grid.GetHtml(
                tableStyle: "table table-striped table-hover",
                //mode: WebGridPagerModes.All,
                //firstText: "First",
                //previousText: "Prev",
                //nextText: "Next",
                //lastText: "Last",
                //htmlAttributes: new
                //{
                //    id = "grid"
                //},
                columns: grid.Columns(
                    grid.Column("EmployeeID", "Employee ID"),
                    grid.Column("FullName", "Full Name"),
                    grid.Column("FirstName", "First Name"),
                    grid.Column("MiddleName", "Middle Name"),
                    grid.Column("LastName", "Last Name"),
                    grid.Column("ManagerID", "Manager ID"),
                    grid.Column("Gender", "Gender"),
                    grid.Column("EmailAddress", "Email"),
                    grid.Column("PhoneNumber", "Phone #"),
                    grid.Column("DepartmentName", "Department"),
                    grid.Column("GroupName", "Group"),
                    grid.Column("Description", "Position"),
                    grid.Column("Status", "Status")
                    )
                ).ToString();

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment; filename=ListOfEmployees.xls");
            Response.ContentType = "application/excel";
            Response.Write(gridHtml);
            Response.End();
        }