public override void BuildReport() { TenantDAO tenantDAO = new TenantDAO(sqlConnection); Tenant tenant = tenantDAO.GetTenant(tenantId); CostTreePersistence persistence = new CostTreePersistence(sqlConnection); CostTree tree = persistence.GetCostTree(tenantId); UserPrintingCostDAO userPrintingCostDAO = new UserPrintingCostDAO(sqlConnection); List <Object> userPrintingCosts = userPrintingCostDAO.GetUserPrintingCosts(tenantId, startDate, endDate); PrintingCostsAssembler costAssembler = new PrintingCostsAssembler(userPrintingCosts); List <Object> groupPrintingCosts = costAssembler.GetCostsOfBranches(tree); 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("startDate", startDate); reportFilter.Add("endDate", endDate); reportBuilder.SetReportHeadings("Custos de impressão por Grupo (CC)", tenant.alias, reportFilter); String[] columnNames = new String[] { "Centro de custo", "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 = groupPrintingCosts.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++) { GroupPrintingCost groupPrintingCost = (GroupPrintingCost)groupPrintingCosts[rowIndex]; ReportCell[] cells = new ReportCell[] { GetGroupCell(groupPrintingCost, reportBuilder.IsNavigable()), new ReportCell(groupPrintingCost.bwPageCount), new ReportCell(groupPrintingCost.colorPageCount), new ReportCell(groupPrintingCost.totalPageCount), new ReportCell(groupPrintingCost.bwCost), new ReportCell(groupPrintingCost.colorCost), new ReportCell(groupPrintingCost.totalCost) }; reportBuilder.InsertRow(rowIndex, cells); } reportBuilder.CloseMedia(); }
private void RemoveBranch(int costBranchId) { CostTreePersistence persistence = new CostTreePersistence(accountingMasterPage.dataAccess.GetConnection()); CostTree tree = persistence.GetCostTree(tenant.id); CostBranch costBranch = tree.GetBranchById(costBranchId); // Existe um alert avisando quando o usuário tenta excluir a raiz, mesmo assim // aqui é verificado se o nó é raiz ( assim os dados ficam protegidos ) if (costBranch.IsRoot()) { return; } persistence.RemoveBranch(costBranch); }
protected void Page_Load(object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); tenant = (Tenant)Session["tenant"]; if (!Authorization.AuthorizedAsAdministrator(Session)) { // Mostra aviso de falta de autorização ShowWarning(Authorization.GetWarning()); return; } // action: // null - Sem ação, apenas lista os centros de custo // 0 - Excluir centro de custo (e depententes), lista os restantes int?action = null; int?costCenterId = null; try { if (!String.IsNullOrEmpty(Request.QueryString["action"])) { action = int.Parse(Request.QueryString["action"]); } if (!String.IsNullOrEmpty(Request.QueryString["costCenterId"])) { costCenterId = int.Parse(Request.QueryString["costCenterId"]); } } catch (System.FormatException) { // Mostra aviso de inconsistência nos parâmetros ShowWarning(ArgumentBuilder.GetWarning()); return; } if ((action == 0) && (costCenterId != null)) { RemoveBranch(costCenterId.Value); Response.Redirect("ConfigCostCenters.aspx"); // Limpa a QueryString para evitar erros } CostTreePersistence persistence = new CostTreePersistence(accountingMasterPage.dataAccess.GetConnection()); CostTree tree = persistence.GetCostTree(tenant.id); CostTreeRenderer renderer = new CostTreeRenderer(tree, pnlCostCenters); renderer.SetNavigationData(pnlAssociates, txtSelectedNode, txtRootNode); renderer.RenderTree(); // Define botão para criar um novo centro de custo, ele é criado como filho do // centro de custo selecionado, Create() é definida na classe "CostTreeRenderer" btnCreate.Attributes.Add("onClick", "Create();"); // Define botão para remover um centro de custo, os objetos dependentes são // excluídos recursivamente, Remove() é definida na classe "CostTreeRenderer" btnRemove.Attributes.Add("onClick", "Remove();"); // Define botão para associar usuários ao centro de custo selecionado btnAssociate.Attributes.Add("onClick", "Associate();"); // Define botão para remover associações (entre usuário e centro de custo) btnDisassociate.Attributes.Add("onClick", "Disassociate();"); }
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(); }