protected void Page_Load(object sender, EventArgs e)
    {
        // Get auth data

        this._authenticationData = GetAuthenticationDataAndCulture();

        // Get current year

        this._year = DateTime.Today.Year;

        string yearParameter = Request.QueryString["Year"];

        if (!string.IsNullOrEmpty(yearParameter))
        {
            this._year = Int32.Parse(yearParameter);  // will throw if non-numeric - don't matter for app
        }

        AnnualReport report = AnnualReport.Create(CurrentOrganization, this._year, FinancialAccountType.Result);

        LocalizeRoot(report.ReportLines);

        Response.ContentType = "application/json";

        Response.Output.WriteLine("{\"rows\": " + RecurseReport(report.ReportLines) + ", \"footer\": [" +
                                  WriteFooter(report.Totals) + "]}");

        Response.End();
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get current year

        this._year = DateTime.Today.Year;

        string yearParameter = Request.QueryString["Year"];

        if (!string.IsNullOrEmpty(yearParameter))
        {
            this._year = Int32.Parse(yearParameter);  // will throw if non-numeric - don't matter for app
        }

        AnnualReport report = AnnualReport.Create(CurrentOrganization, this._year, FinancialAccountType.Result);

        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "text/plain";
        Response.AppendHeader("Content-Disposition",
                              "attachment;filename=" + CurrentOrganization.Name.Replace(" ", "") + "-" + Ledgers.ProfitLossStatement_DownloadFileName +
                              this._year.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.Today.ToString("yyyyMMdd") + ".csv");

        if (this._year == DateTime.Today.Year)
        {
            Response.Output.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"",
                                      Ledgers.ProfitLossStatement_AccountName,
                                      Ledgers.ProfitLossStatement_LastYear,
                                      Resources.Global.Global_Q1, Resources.Global.Global_Q2, Resources.Global.Global_Q3, Resources.Global.Global_Q4,
                                      Ledgers.ProfitLossStatement_Ytd);
        }
        else
        {
            Response.Output.WriteLine("\"{0}\",\"{1}\",\"{6}-{2}\",\"{6}-{3}\",\"{6}-{4}\",\"{6}-{5}\",\"{6}\"",
                                      Ledgers.ProfitLossStatement_AccountName, this._year - 1,
                                      Resources.Global.Global_Q1, Resources.Global.Global_Q2, Resources.Global.Global_Q3, Resources.Global.Global_Q4,
                                      this._year);
        }

        LocalizeRoot(report.ReportLines);

        RecurseCsvReport(report.ReportLines, string.Empty);

        Response.End();
    }