public static void IncomingRC(DirectoryRC rc, BusinessContext bc, int year, int month) { string path = Path.Combine(PATH_DIRECTORY_COST_REPORTS, PATH_INCOMING_REPORT + " " + rc.Name + " " + month + "." + year + ".xlsx"); Helpers.CompletedReport(path, new List <Action <ExcelPackage> > { (ep) => IncomingRCReport(ep, bc, year, month, rc), }); }
private static void IncomingRCReport(ExcelPackage ep, BusinessContext bc, int year, int month, DirectoryRC rc) { string name = PATH_INCOMING_REPORT + " " + rc.Name; var sheet = Helpers.GetSheet(ep, name); string rcAdvancedName = "ОТ. " + rc.Name + "/" + rc.Name[0] + " " + rc.Name.Substring(1); rcAdvancedName = rcAdvancedName.Replace("-", ""); int indexRow = 1; CreationHeader(sheet, ref indexRow, MEMORANDUM_INCOMING_RC_CONTEXT, 2); Helpers.CreateCell(sheet, indexRow, 1, rcAdvancedName, Color.Transparent, 12, true, ExcelHorizontalAlignment.Left, ExcelBorderStyle.None); indexRow++; Helpers.CreateCell(sheet, indexRow, 1, TABLE_HEADER_NAME, Color.Transparent, 12, true, ExcelHorizontalAlignment.Center); Helpers.CreateCell(sheet, indexRow, 2, TABLE_HEADER_SUMM, Color.Transparent, 12, true, ExcelHorizontalAlignment.Center); indexRow++; var infoCosts = bc.GetInfoCostsRCIncoming(year, month, rc.Name).ToList(); foreach (var infoCost in infoCosts) { Helpers.CreateCell(sheet, indexRow, 1, infoCost.ConcatNotes.ToString(), Color.Transparent, 12, false, ExcelHorizontalAlignment.Left, ExcelBorderStyle.Thin); Helpers.CreateCell(sheet, indexRow, 2, Converting.DoubleToCurrency(infoCost.Summ, infoCost.Currency), Color.Transparent, 12, false, ExcelHorizontalAlignment.Right, ExcelBorderStyle.Thin); indexRow++; } string totalSumm = ""; var totalSummsCurrency = bc.GetInfoCostsIncomingTotalSummsCurrency(year, month, rc.Name, true, "Приход").ToList(); for (int i = 0; i < totalSummsCurrency.Count(); i++) { if (totalSummsCurrency[i] != null) { totalSumm += totalSummsCurrency[i]; if (i != (totalSummsCurrency.Count() - 1)) { totalSumm += ", "; } } } Helpers.CreateCell(sheet, indexRow, 1, TABLE_FOOTER_NAME, Color.Transparent, 12, true, ExcelHorizontalAlignment.Left); Helpers.CreateCell(sheet, indexRow, 2, totalSumm, Color.Transparent, 12, true, ExcelHorizontalAlignment.Right); indexRow += 2; foreach (var totalSummCurrency in totalSummsCurrency) { if (totalSummCurrency != null) { Helpers.CreateCell(sheet, indexRow, 1, indexRow, 2, FOOTER_MEMORANDUM_FIRTST_PART + totalSummCurrency + FOOTER_MEMORANDUM_SECOND_PART, Color.Transparent, 12, false, ExcelHorizontalAlignment.Left, ExcelBorderStyle.None); indexRow++; } } indexRow += 2; Helpers.CreateCell(sheet, indexRow, 1, FOOTER_RC_APEL + rcAdvancedName, Color.Transparent, 12, false, ExcelHorizontalAlignment.Left, ExcelBorderStyle.None); if (rc.Name != "КО-2") { Helpers.CreateCell(sheet, indexRow, 2, FOOTER_RC_ALL_APEL_NAME, Color.Transparent, 12, false, ExcelHorizontalAlignment.Right, ExcelBorderStyle.None); } else { Helpers.CreateCell(sheet, indexRow, 2, FOOTER_RC_KO2_APEL_NAME, Color.Transparent, 12, false, ExcelHorizontalAlignment.Right, ExcelBorderStyle.None); } }
private void RefreshFilters() { if (RCs == null || InOuts == null || TransportCompanies == null || Notes == null) { return; } SelectedRC = RCs.First(); SelectedInOut = InOuts.First(); SelectedTransportCompany = TransportCompanies.First(); SelectedNote = Notes.First(); Filter(); BC.DataContext.Configuration.AutoDetectChangesEnabled = false; RCs.Clear(); var rcEmpty = new DirectoryRC { Name = null }; RCs.Add(rcEmpty); foreach (var rc in Costs.Select(c => c.DirectoryRC).Distinct()) { RCs.Add(rc); } InOuts.Clear(); InOuts.Add(""); if (Costs.Any(c => c.IsIncoming)) { InOuts.Add("Приход"); } if (Costs.Any(c => !c.IsIncoming)) { InOuts.Add("Расход"); } TransportCompanies.Clear(); var transportCompanyEmpty = new DirectoryTransportCompany { Name = null }; TransportCompanies.Add(transportCompanyEmpty); foreach (var transportCompany in Costs.Select(c => c.DirectoryTransportCompany).Where(t => t != null).Distinct()) { TransportCompanies.Add(transportCompany); } Notes.Clear(); var noteEmpty = new DirectoryNote { Description = null }; Notes.Add(noteEmpty); foreach (var masNotes in Costs.Select(c => c.CurrentNotes.Select(n => n.DirectoryNote))) { foreach (var note in masNotes) { if (!Notes.Contains(note)) { Notes.Add(note); } } } OrderNotes(); BC.DataContext.Configuration.AutoDetectChangesEnabled = true; }