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 } YearlyReport report = YearlyReport.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(); }
protected void Page_Load(object sender, EventArgs e) { // Get current year _year = DateTime.Today.Year; string yearParameter = Request.QueryString["Year"]; if (!string.IsNullOrEmpty(yearParameter)) { _year = Int32.Parse(yearParameter); // will throw if non-numeric - don't matter for app } YearlyReport report = YearlyReport.Create(this.CurrentOrganization, _year, FinancialAccountType.Balance); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "text/plain"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + Resources.Pages.Ledgers.BalanceSheet_DownloadFileName + _year.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.Today.ToString("yyyyMMdd") + ".csv"); Response.Output.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"", Resources.Pages.Ledgers.ProfitLossStatement_AccountName, Resources.Pages.Ledgers.BalanceSheet_StartYear.Replace("XXXX", _year.ToString(CultureInfo.InvariantCulture)), Resources.Pages.Ledgers.BalanceSheet_Q1, Resources.Pages.Ledgers.BalanceSheet_Q2, Resources.Pages.Ledgers.BalanceSheet_Q3, Resources.Pages.Ledgers.BalanceSheet_Q4, (_year == DateTime.Today.Year? Resources.Pages.Ledgers.BalanceSheet_Current : Resources.Pages.Ledgers.BalanceSheet_EndYear.Replace("XXXX", _year.ToString(CultureInfo.InvariantCulture)))); LocalizeRoot(report.ReportLines); RecurseCsvReport(report.ReportLines, string.Empty); Response.End(); }
public async Task <ActionResult <YearlyReport> > PostYearlyReport(YearlyReport yearlyReport) { _context.YearlyReports.Add(yearlyReport); await _context.SaveChangesAsync(); return(CreatedAtAction("GetYearlyReport", new { id = yearlyReport.Id }, yearlyReport)); }
public async Task <IActionResult> PutYearlyReport(long id, YearlyReport yearlyReport) { if (id != yearlyReport.Id) { return(BadRequest()); } _context.Entry(yearlyReport).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!YearlyReportExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public List <YearlyReport> UnpickedUpPrescriptionsByYear() { Thread.Sleep(500); // For effect var scripts = _medicationRepository.GetPrescriptions().Where(s => s.DateIssued.HasValue) .OrderBy(s => s.DateIssued).ToList(); var years = new List <string>(); var yearlyReports = new List <YearlyReport>(); var monthlyReports = new List <MonthlyReport>(); foreach (var script in scripts) { var monthInt = script.DateIssued.Value.Month; var month = Months[monthInt - 1]; var year = script.DateIssued.Value.Year; if (!years.Contains(year.ToString())) { years.Add(year.ToString()); } if (monthlyReports.Any(m => m.Month == month && m.Year == year.ToString())) { continue; } var scriptsForMonth = scripts.Where(s => s.DateIssued >= new DateTime(year, monthInt, 1) && s.DateIssued < new DateTime(year, monthInt, 1).AddMonths(1)); monthlyReports.Add(new MonthlyReport() { Month = month, Year = year.ToString(), MonthInt = monthInt, PickedUpPrescriptions = scriptsForMonth.Count(s => s.DatePickedUp != null), UnPickedUpPrescriptions = scriptsForMonth.Count(s => s.DatePickedUp == null) }); } foreach (var year in years) { var monthlyReportsForYear = monthlyReports.Where(x => x.Year == year).OrderBy(m => m.MonthInt).ToList(); var yearlyReport = new YearlyReport() { Year = year, MonthlyReports = monthlyReportsForYear }; yearlyReports.Add(yearlyReport); } return(yearlyReports); }
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 } YearlyReport report = YearlyReport.Create(CurrentOrganization, this._year, FinancialAccountType.Result); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "text/plain"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + 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, Ledgers.ProfitLossStatement_Q1, Ledgers.ProfitLossStatement_Q2, Ledgers.ProfitLossStatement_Q3, Ledgers.ProfitLossStatement_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, Ledgers.ProfitLossStatement_Q1, Ledgers.ProfitLossStatement_Q2, Ledgers.ProfitLossStatement_Q3, Ledgers.ProfitLossStatement_Q4, this._year); } LocalizeRoot(report.ReportLines); RecurseCsvReport(report.ReportLines, string.Empty); Response.End(); }