Exemplo n.º 1
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Response.Buffer      = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.Charset     = "";
            var    dg       = new DataGrid();
            string filename = null;

            switch (type)
            {
            case "donorfundtotals":
                filename      = "DonorFundTotals";
                dg.DataSource = ExportPeople.ExcelDonorFundTotals(Dt1, Dt2, fundid, campusid, pledges, nontaxdeductible, IncUnclosedBundles);
                break;

            case "donortotals":
                filename      = "DonorTotals";
                dg.DataSource = ExportPeople.ExcelDonorTotals(Dt1, Dt2, campusid, pledges, nontaxdeductible, IncUnclosedBundles);
                break;

            case "donordetails":
                filename      = "DonorDetails";
                dg.DataSource = ExportPeople.DonorDetails(Dt1, Dt2, fundid, campusid, pledges, nontaxdeductible, IncUnclosedBundles);
                break;
            }
            dg.DataBind();
            Response.AddHeader("Content-Disposition", "attachment;filename={0}.xls".Fmt(filename));
            dg.RenderControl(new HtmlTextWriter(Response.Output));
        }
        public EpplusResult ToExcel(string type)
        {
            bool?nontaxdeductible = null;  // both

            switch (TaxDedNonTax)
            {
            case "TaxDed":
                nontaxdeductible = false;
                break;

            case "NonTaxDed":
                nontaxdeductible = true;
                break;
            }
            switch (type)
            {
            case "donorfundtotals.xlsx":
                return(ExportPeople.ExcelDonorFundTotals(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles)
                       .ToExcel("DonorFundTotals"));

            case "donortotals":
                return(ExportPeople.ExcelDonorTotals(Dt1, Dt2, campusid, false, nontaxdeductible, IncUnclosedBundles)
                       .ToExcel("DonorTotals.xlsx"));

            case "donordetails":
                return(ExportPeople.DonorDetails(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles)
                       .ToExcel("DonorDetails.xlsx"));
            }
            return(null);
        }
Exemplo n.º 3
0
        public EpplusResult ToExcel(string type)
        {
            bool?nontaxdeductible = null;  // both

            switch (TaxDedNonTax)
            {
            case "TaxDed":
                nontaxdeductible = false;
                break;

            case "NonTaxDed":
                nontaxdeductible = true;
                break;
            }

            var tagid = FilterByActiveTag ? DbUtil.Db.TagCurrent()?.Id : (int?)null;
            //var fundids = APIContributionSearchModel.GetCustomFundSetList(DbUtil.Db. FundSet);

            var customFundIds     = APIContributionSearchModel.GetCustomFundSetList(DbUtil.Db, FundSet);
            var authorizedFundIds = DbUtil.Db.ContributionFunds.ScopedByRoleMembership().Select(f => f.FundId).ToList();

            string fundIds = string.Empty;

            if (customFundIds?.Count > 0)
            {
                fundIds = authorizedFundIds.Where(f => customFundIds.Contains(f)).JoinInts(",");
            }
            else
            {
                fundIds = authorizedFundIds.JoinInts(",");
            }

            switch (type)
            {
            case "ledgerincome":
                var cd = new CommandDefinition("dbo.LedgerIncomeExport", new
                {
                    fd = Dt1,
                    td = Dt2,
                    campusid,
                    nontaxded       = nontaxdeductible,
                    includeunclosed = IncUnclosedBundles
                }, commandType: CommandType.StoredProcedure);
                return(DbUtil.Db.Connection.ExecuteReader(cd).ToExcel("LedgerIncome.xlsx"));

            case "donorfundtotals":
                return(ExportPeople.ExcelDonorFundTotals(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles, tagid, fundIds)
                       .ToExcel("DonorFundTotals.xlsx"));

            case "donortotals":
                return(ExportPeople.ExcelDonorTotals(Dt1, Dt2, campusid, false, nontaxdeductible, IncUnclosedBundles, tagid, fundIds)
                       .ToExcel("DonorTotals.xlsx"));

            case "donordetails":
                return(ExportPeople.DonorDetails(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles, tagid, fundIds)
                       .ToExcel("DonorDetails.xlsx"));
            }
            return(null);
        }
Exemplo n.º 4
0
        public EpplusResult ToExcel(string type)
        {
            bool?nontaxdeductible = null;  // both

            switch (TaxDedNonTax)
            {
            case "TaxDed":
                nontaxdeductible = false;
                break;

            case "NonTaxDed":
                nontaxdeductible = true;
                break;
            }

            var tagid   = FilterByActiveTag ? DbUtil.Db.TagCurrent()?.Id : (int?)null;
            var fundids = APIContributionSearchModel.GetCustomFundSetList(FundSet);
            var funds   = fundids.JoinInts(",");

            switch (type)
            {
            case "ledgerincome":
                var cd = new CommandDefinition("dbo.LedgerIncomeExport", new
                {
                    fd = Dt1,
                    td = Dt2,
                    campusid,
                    nontaxded       = nontaxdeductible,
                    includeunclosed = IncUnclosedBundles
                }, commandType: CommandType.StoredProcedure);
                return(DbUtil.Db.Connection.ExecuteReader(cd).ToExcel("LedgerIncome.xlsx"));

            case "donorfundtotals":
                return(ExportPeople.ExcelDonorFundTotals(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles, tagid, funds)
                       .ToExcel("DonorFundTotals.xlsx"));

            case "donortotals":
                return(ExportPeople.ExcelDonorTotals(Dt1, Dt2, campusid, false, nontaxdeductible, IncUnclosedBundles, tagid, funds)
                       .ToExcel("DonorTotals.xlsx"));

            case "donordetails":
                return(ExportPeople.DonorDetails(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles, tagid, funds)
                       .ToExcel("DonorDetails.xlsx"));
            }
            return(null);
        }
Exemplo n.º 5
0
        public EpplusResult ToExcel(string type)
        {
            bool?nontaxdeductible = null;  // both

            switch (TaxDedNonTax)
            {
            case "TaxDed":
                nontaxdeductible = false;
                break;

            case "NonTaxDed":
                nontaxdeductible = true;
                break;
            }
            switch (type)
            {
            case "ledgerincome":
                var cd = new CommandDefinition("dbo.LedgerIncomeExport", new
                {
                    fd = Dt1,
                    td = Dt2,
                    campusid,
                    nontaxded       = nontaxdeductible,
                    includeunclosed = IncUnclosedBundles
                }, commandType: CommandType.StoredProcedure);
                return(DbUtil.Db.Connection.ExecuteReader(cd).ToExcel("LedgerIncome.xlsx"));

            case "donorfundtotals":
                return(ExportPeople.ExcelDonorFundTotals(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles)
                       .ToExcel("DonorFundTotals.xlsx"));

            case "donortotals":
                return(ExportPeople.ExcelDonorTotals(Dt1, Dt2, campusid, false, nontaxdeductible, IncUnclosedBundles)
                       .ToExcel("DonorTotals.xlsx"));

            case "donordetails":
                return(ExportPeople.DonorDetails(Dt1, Dt2, fundid, campusid, false, nontaxdeductible, IncUnclosedBundles)
                       .ToExcel("DonorDetails.xlsx"));
            }
            return(null);
        }