protected void Page_Load(Object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); tenant = (Tenant)Session["tenant"]; if (!String.IsNullOrEmpty(Request["action"])) { action = Request["action"]; } if (!String.IsNullOrEmpty(Request["currPage"])) { currentPage = int.Parse(Request["currPage"]); } int costCenterId = 0; DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; try { costCenterId = int.Parse(Request.QueryString["costCenterId"]); startDate = DateTime.Parse(Request.QueryString["startDate"]); endDate = DateTime.Parse(Request.QueryString["endDate"]); } catch (System.FormatException) { // Remove todos os controles da página reportSurface.Controls.Clear(); // Mostra aviso de inconsistência nos parâmetros WarningMessage.Show(reportSurface, ArgumentBuilder.GetWarning()); return; } lblTitle.Text = "Relatório de Custos de Impressão"; CostCenterDAO costCenterDAO = new CostCenterDAO(accountingMasterPage.dataAccess.GetConnection()); CostCenter costCenter = costCenterDAO.GetCostCenter(tenant.id, costCenterId); lblCostCenter.Text = "Centro de Custo: " + costCenter.name; GenerateReport(costCenterId, startDate, endDate); }
private int?parentId = null; // recebe na QueryString // Constroi o centro de custo com os parametros recebidos na QueryString private CostCenter GetCostCenter() { CostCenter costCenter = null; Tenant tenant = (Tenant)Session["tenant"]; // Alteração de um centro de custo existente if (costCenterId != null) { CostCenterDAO costCenterDAO = new CostCenterDAO(settingsMasterPage.dataAccess.GetConnection()); costCenter = costCenterDAO.GetCostCenter(tenant.id, costCenterId.Value); } // Inclusão de um novo centro de custo if (parentId != null) { costCenter = new CostCenter(); costCenter.parentId = parentId.Value; costCenter.tenantId = tenant.id; } return(costCenter); }
public override void BuildReport() { TenantDAO tenantDAO = new TenantDAO(sqlConnection); Tenant tenant = tenantDAO.GetTenant(tenantId); CostCenterDAO costCenterDAO = new CostCenterDAO(sqlConnection); CostCenter costCenter = costCenterDAO.GetCostCenter(tenantId, costCenterId); CostTreePersistence persistence = new CostTreePersistence(sqlConnection); CostTree tree = persistence.GetCostTree(tenantId); CostBranch branch = tree.GetBranchById(costCenterId); List <Object> detailedCosts = GetDetailedCosts(branch); reportBuilder.OpenMedia(reportMedia); // Abre a mídia para o output do relatório Dictionary <String, Object> reportFilter = new Dictionary <String, Object>(); reportFilter.Add("tenantId", tenantId); reportFilter.Add("costCenterId", costCenterId); reportFilter.Add("startDate", startDate); reportFilter.Add("endDate", endDate); reportBuilder.SetReportHeadings("Relatório de Custos de Impressão" + ". " + "Centro de Custo: " + costCenter.name, tenant.alias, reportFilter); String[] columnNames = new String[] { "Usuário", "Páginas Pb", "Páginas Cor", "Total Páginas", "Custo Pb", "Custo Cor", "Total Custo" }; int[] columnWidths = new int[] { 50, 15, 15, 15, 15, 15, 15 }; int rowCount = detailedCosts.Count; reportBuilder.CreateDataTable(columnNames, columnWidths, rowCount); if (reportBuilder.IsNavigable()) { Dictionary <String, Object> exportOptions = ExportFormatContext.GetExportOptions(tenantId, sqlConnection); reportBuilder.SetNavigationData(this.GetType().Name, rowCount, exportOptions); // neste caso recordCount = rowCount reportBuilder.SetReportPage(action, currentPage); } for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { UserPrintingCost userPrintingCost = (UserPrintingCost)detailedCosts[rowIndex]; ReportCell[] cells = new ReportCell[] { new ReportCell(userPrintingCost.userName), new ReportCell(userPrintingCost.bwPageCount), new ReportCell(userPrintingCost.colorPageCount), new ReportCell(userPrintingCost.totalPageCount), new ReportCell(userPrintingCost.bwCost), new ReportCell(userPrintingCost.colorCost), new ReportCell(userPrintingCost.totalCost) }; reportBuilder.InsertRow(rowIndex, cells); } ReportCell[] footerCells = new ReportCell[] { new ReportCell("TOTAL", Color.Red), new ReportCell("paginasPb", ReportCellType.Number), new ReportCell("paginasCor", ReportCellType.Number), new ReportCell("totalPaginas", ReportCellType.Number), new ReportCell("custoPb", ReportCellType.Money), new ReportCell("custoCor", ReportCellType.Money), new ReportCell("totalCusto", ReportCellType.Money) }; reportBuilder.InsertFooter(footerCells); reportBuilder.CloseMedia(); }