Exemple #1
0
        public ActionResult Excel(Guid id, string format, bool?titles, bool?useMailFlags)
        {
            var ctl = new MailingController {
                UseTitles = titles ?? false, UseMailFlags = useMailFlags ?? false
            };

            switch (format)
            {
            case "Individual":
            case "GroupAddress":
                return(ExportPeople.FetchExcelList(id, maxExcelRows, useMailFlags ?? false).ToExcel());

            case "Library":
                return(ExportPeople.FetchExcelLibraryList(id));

            case "AllFamily":
                return(ExportPeople.FetchExcelListFamily(id));

            case "Family":
                return(ctl.FetchExcelFamily(id, maxExcelRows));

            case "ParentsOf":
                return(ctl.FetchExcelParents(id, maxExcelRows));

            case "CouplesEither":
                return(ctl.FetchExcelCouplesEither(id, maxExcelRows));

            case "CouplesBoth":
                return(ctl.FetchExcelCouplesBoth(id, maxExcelRows));

            case "Involvement":
                return(new ExcelResult(ExportInvolvements.InvolvementList(id), "Involvements.xls"));

            case "Children":
                return(ExportInvolvements.ChildrenList(id, maxExcelRows));

            case "Church":
                return(ExportInvolvements.ChurchList(id, maxExcelRows));

            case "Attend":
                return(ExportInvolvements.AttendList(id, maxExcelRows));

            case "Promotion":
                return(ExportInvolvements.PromoList(id, maxExcelRows));

            case "IndividualPicture":
                return(ExcelExportModel.Result(id));

            case "FamilyMembers":
                return(ExportPeople.FetchExcelListFamilyMembers(id));

            case "OrgMembers":
                return(OrgsMembersExcelModel.Export(Util2.CurrentOrgId ?? 0));

            case "Groups":
                return(ExportInvolvements.OrgMemberListGroups());
            }
            return(Content("no format"));
        }
Exemple #2
0
 public ActionResult Excel(Guid id, string format, bool? titles, bool? useMailFlags)
 {
     var ctl = new MailingController {UseTitles = titles ?? false, UseMailFlags = useMailFlags ?? false};
     switch (format)
     {
         case "Individual":
         case "GroupAddress":
             return ExportPeople.FetchExcelList(id, maxExcelRows, useMailFlags ?? false).ToExcel();
         case "Library":
             return ExportPeople.FetchExcelLibraryList(id);
         case "AllFamily":
             return ExportPeople.FetchExcelListFamily(id);
         case "Family":
             return ctl.FetchExcelFamily(id, maxExcelRows);
         case "ParentsOf":
             return ctl.FetchExcelParents(id, maxExcelRows);
         case "CouplesEither":
             return ctl.FetchExcelCouplesEither(id, maxExcelRows);
         case "CouplesBoth":
             return ctl.FetchExcelCouplesBoth(id, maxExcelRows);
         case "Involvement":
             return ExportInvolvements.InvolvementList(id);
         case "Involvement2":
             return ExportInvolvements.InvolvementList(id);
         case "Children":
             return ExportInvolvements.ChildrenList(id, maxExcelRows);
         case "Church":
             return ExportInvolvements.ChurchList(id, maxExcelRows);
         case "Attend":
             return ExportInvolvements.AttendList(id, maxExcelRows);
         case "Promotion":
             return ExportInvolvements.PromoList(id, maxExcelRows);
         case "IndividualPicture":
             return ExcelExportModel.Result(id);
         case "FamilyMembers":
             return ExportPeople.FetchExcelListFamilyMembers(id);
         case "OrgMembers":
             return OrgsMembersExcelModel.Export();
         case "Groups":
             return ExportInvolvements.OrgMemberListGroups();
     }
     return Content("no format");
 }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var labelNameFormat = Request.QueryString["format"];
            int?qid             = Request.QueryString["id"].ToInt2();
            var r = Response;

            r.Clear();
            var useweb = Request.QueryString["web"];

            string header =
                @"<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">
<head>
	<meta http-equiv=Content-Type content=""text/html; charset=utf-8""> 
    <style>
    <!--table
    br {mso-data-placement:same-cell;}
    tr {vertical-align:top;}
    td.Text {mso-number-format:\@}
    -->
    </style>
</head>
<body>";

            r.Charset = "";

            if (!qid.HasValue && labelNameFormat != "Groups")
            {
                r.Write("no queryid");
                r.Flush();
                r.End();
            }
            if (useweb != "true")
            {
                r.ContentType = "application/vnd.ms-excel";
                r.AddHeader("Content-Disposition", "attachment;filename=CMSPeople.xls");
            }
            r.Write(header);
            var ctl       = new MailingController();
            var useTitles = Request.QueryString["titles"];

            ctl.UseTitles = useTitles == "true";
            var dg = new DataGrid();

            dg.EnableViewState = false;
            switch (labelNameFormat)
            {
            case "Individual":
                dg.DataSource = ExportPeople.FetchExcelList(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "IndividualPicture":
                GridView1.EnableViewState = false;
                GridView1.AllowPaging     = false;
                GridView1.DataSource      = ExportPeople.FetchExcelListPics(qid.Value, maxExcelRows);
                GridView1.DataBind();
                GridView1.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Library":
                dg.DataSource = ExportPeople.FetchExcelLibraryList(qid.Value);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Family":
                dg.DataSource = ctl.FetchExcelFamily(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "FamilyMembers":
                FamilyMembers.EnableViewState = false;
                FamilyMembers.AllowPaging     = false;
                FamilyMembers.DataSource      = ExportPeople.FetchExcelListFamilyMembers(qid.Value);
                FamilyMembers.DataBind();
                FamilyMembers.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "AllFamily":
                dg.DataSource = ExportPeople.FetchExcelListFamily(qid.Value);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "ParentsOf":
                dg.DataSource = ctl.FetchExcelParents(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "CouplesEither":
                dg.DataSource = ctl.FetchExcelCouplesEither(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "CouplesBoth":
                dg.DataSource = ctl.FetchExcelCouplesBoth(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Involvement":
                dg.DataSource = ExportInvolvements.InvolvementList(qid.Value);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Children":
                dg.DataSource = ExportInvolvements.ChildrenList(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Church":
                dg.DataSource = ExportInvolvements.ChurchList(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Attend":
                dg.DataSource = ExportInvolvements.AttendList(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Organization":
                dg.DataSource = ExportInvolvements.OrgMemberList(qid.Value);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Groups":
                dg.DataSource = ExportInvolvements.OrgMemberListGroups();
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;

            case "Promotion":
                dg.DataSource = ExportInvolvements.PromoList(qid.Value, maxExcelRows);
                dg.DataBind();
                dg.RenderControl(new HtmlTextWriter(r.Output));
                break;
            }
            r.Write("</body></HTML>");
            r.Flush();
            r.End();
        }