コード例 #1
0
        public ActionResult EnrollmentControl(int pid, int?div, int?schedule, string name, bool?usecurrenttag, bool?excel)
        {
            var m = new EnrollmentControlModel()
            {
                prog          = pid,
                div           = div ?? 0,
                schedule      = schedule ?? 0,
                usecurrenttag = usecurrenttag ?? false
            };

            if (excel == true)
            {
                var d = from p in m.list()
                        orderby p.Name
                        select p;
                var workbook = new HSSFWorkbook();
                var sheet    = workbook.CreateSheet("EnrollmentControl");
                var rowIndex = 0;
                var row      = sheet.CreateRow(rowIndex);
                row.CreateCell(0).SetCellValue("PeopleId");
                row.CreateCell(1).SetCellValue("Name");
                row.CreateCell(2).SetCellValue("Organization");
                row.CreateCell(3).SetCellValue("Location");
                row.CreateCell(4).SetCellValue("MemberType");
                rowIndex++;
                sheet.DisplayRowColHeadings = true;

                foreach (var i in d)
                {
                    row = sheet.CreateRow(rowIndex);
                    row.CreateCell(0).SetCellValue(i.Id);
                    row.CreateCell(1).SetCellValue(i.Name);
                    row.CreateCell(2).SetCellValue(i.Organization);
                    row.CreateCell(3).SetCellValue(i.Location);
                    row.CreateCell(4).SetCellValue(i.MemberType);
                    rowIndex++;
                }
                sheet.AutoSizeColumn(0);
                sheet.AutoSizeColumn(1);
                sheet.AutoSizeColumn(2);
                sheet.AutoSizeColumn(3);
                sheet.AutoSizeColumn(4);
                string saveAsFileName = string.Format("EnrollmentControl-{0:d}.xls", DateTime.Now);
                var    ms             = new MemoryStream();
                workbook.Write(ms);
                return(File(ms.ToArray(), "application/vnd.ms-excel", "attachment;filename=" + saveAsFileName));
            }
            else
            {
                return new EnrollmentControlResult {
                           model = m
                }
            };
        }
コード例 #2
0
        public ActionResult EnrollmentControl2(int pid, int?div, int?schedule, string name, bool?usecurrenttag)
        {
            var m = new EnrollmentControlModel()
            {
                prog          = pid,
                div           = div ?? 0,
                schedule      = schedule ?? 0,
                usecurrenttag = usecurrenttag ?? false
            };

            return(View(m));
        }
コード例 #3
0
ファイル: ReportsController.cs プロジェクト: pwgoertz/bvcms
        public ActionResult EnrollmentControl(bool?excel, bool?usecurrenttag, OrgSearchModel m)
        {
            if (excel != true)
            {
                return(new EnrollmentControlResult {
                    OrgSearch = m, UseCurrentTag = usecurrenttag ?? false
                });
            }

            var d = (from p in EnrollmentControlModel.List(m, usecurrenttag: usecurrenttag ?? false)
                     orderby p.Name
                     select p).ToDataTable();

            return(d.ToExcel("EnrollmentControl.xlsx"));
        }
コード例 #4
0
ファイル: ReportsController.cs プロジェクト: pwgoertz/bvcms
        public ActionResult EnrollmentControl2b(string na, string j)
        {
            var m = OrgSearchModel.DecodedJson(j);

            return(View(EnrollmentControlModel.List(m, na)));
        }