// // GET: CreateEdit public ActionResult CreateEdit(Guid id) { UCountryProgramme countryProgramme = new UCountryProgramme(); countryProgramme.CountrySelect = new SelectList(countryProgService.CountryObj.GetCountries(), "Id", "Name"); countryProgramme.CurrencySelect = new SelectList(countryProgService.CurrencyObj.GetCurrencies(countryProg.Id), "Id", "Name"); if (!id.Equals(Guid.Empty)) { ViewBag.Action = "Edit"; countryProgramme._CountryProgramme = countryProgService.GetCountryProgrammeById(id); } return(View(countryProgramme)); }
public ActionResult Summary(Guid currencyId, Guid countryProgrammeId) { Dictionary <String, String> data = new Dictionary <string, string>(); Currency currency = currencyService.GetCurrency(currencyId); data.Add("{CURRENCY}", currency.Name); CountryProgramme cp = countryProgrammeSvc.GetCountryProgrammeById(countryProgrammeId); List <MBCategory> mbcList = mbService.GenerateMasterBudget(currency, cp); this.ComputeTotals(mbcList); decimal totalCommitted = 0; if (mbcList[mbcList.Count - 1].TotalCommitted.HasValue) { totalCommitted = (decimal)mbcList[mbcList.Count - 1].TotalCommitted; } decimal totalPosted = 0; if (mbcList[mbcList.Count - 1].TotalPosted.HasValue) { totalPosted = (decimal)mbcList[mbcList.Count - 1].TotalPosted; } decimal remBal = 0; if (mbcList[mbcList.Count - 1].RemainingBalance.HasValue) { remBal = (decimal)mbcList[mbcList.Count - 1].RemainingBalance; } float pctSpent = 0; if (mbcList[mbcList.Count - 1].PercentageSpent.HasValue) { pctSpent = (float)mbcList[mbcList.Count - 1].PercentageSpent; } decimal costP = 0; if (mbcList[mbcList.Count - 1].CostProjection.HasValue) { costP = (decimal)mbcList[mbcList.Count - 1].CostProjection; } decimal surplus = 0; string style = " style='color:red;' "; if (mbcList[mbcList.Count - 1].Surplus.HasValue) { surplus = (decimal)mbcList[mbcList.Count - 1].Surplus; } if (surplus > 0) { style = ""; } data.Add("{TOTAL_BUDGET}", mbcList[mbcList.Count - 1].TotalBudget.ToString("###,###.00")); data.Add("{TOTAL_COMMITTED}", totalCommitted.ToString("###,###.00")); data.Add("{TOTAL_POSTED}", totalPosted.ToString("###,###.00")); data.Add("{REMAINING_FUNDS}", remBal.ToString("###,###.00")); data.Add("{%_ACTUAL_SPENT}", pctSpent.ToString("0.00")); data.Add("{FUNDS_AVAILABLE}", remBal.ToString("###,###.00")); data.Add("{EXPENDITURE_PROJECTION}", costP.ToString("###,###.00")); data.Add("{SHORTFALL_SURPLUS}", "<span" + style + ">" + surplus.ToString("###,###.00") + "</span>"); string tbody = ""; for (int i = 0; i < mbcList.Count - 1; i++) { tbody += "<tr><td>"; tbody += mbcList[i].EntityBudgetCategory.Description + "</td><td>"; tbody += mbcList[i].Projects[0].EntityProjectDonor.ProjectNumber + "</td><td>"; tbody += mbcList[i].Projects[0].EntityProjectDonor.Donor.ShortName + "</td><td>"; tbody += mbcList[i].Projects[0].TotalBudget.ToString("###,###.00") + "</td><td>"; tbody += ND2S(mbcList[i].Projects[0].TotalCommitted) + "</td><td>"; tbody += ND2S(mbcList[i].Projects[0].TotalPosted) + "</td><td>"; tbody += ND2S(mbcList[i].Projects[0].RemainingBalance) + "</td><td>"; tbody += FD2S(mbcList[i].Projects[0].PercentageSpent) + "</td><td>"; tbody += ND2S(mbcList[i].CostProjection) + "</td><td>"; tbody += "</tr>"; } data.Add("{DETAIL}", tbody); List <String> options = new List <string>(); options.Add(" --orientation Landscape "); Byte[] output = WkHtml2Pdf.CreateReport(data, "master-budget.html", options); return(File(output, "application/pdf", "Project_Bu=dget_" + DateTime.Now.FormatDDMMMYYYYHHmm())); }