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"]); } if (!String.IsNullOrEmpty(Request["detailType"])) { detailType = Request["detailType"]; } int printerId = 0; DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; try { printerId = int.Parse(Request.QueryString["printerId"]); 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; } Dictionary <String, Object> reportData = DeviceCostDetailsReport.GetReportData(detailType); lblTitle.Text = (String)reportData["title"]; PrinterDAO printerDAO = new PrinterDAO(accountingMasterPage.dataAccess.GetConnection()); Printer printer = printerDAO.GetPrinter(tenant.id, printerId); lblDeviceName.Text = "Impressora: " + printer.alias; GenerateReport(printerId, startDate, endDate, detailType); }
public override void BuildReport() { Dictionary <String, Object> reportData = GetReportData(detailType); TenantDAO tenantDAO = new TenantDAO(sqlConnection); Tenant tenant = tenantDAO.GetTenant(tenantId); PrinterDAO printerDAO = new PrinterDAO(sqlConnection); Printer printer = printerDAO.GetPrinter(tenantId, printerId); DeviceCostDetailDAO deviceCostDetailDAO = new DeviceCostDetailDAO(sqlConnection); List <Object> deviceCostDetails = deviceCostDetailDAO.GetDeviceCostDetails(tenantId, printerId, startDate, endDate, detailType); 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("printerId", printerId); reportFilter.Add("startDate", startDate); reportFilter.Add("endDate", endDate); reportFilter.Add("detailType", detailType); reportBuilder.SetReportHeadings(reportData["title"] + ". " + "Impressora: " + printer.name, tenant.alias, reportFilter); String[] columnNames = (String[])reportData["columnNames"]; int[] columnWidths = (int[])reportData["columnWidths"]; int rowCount = deviceCostDetails.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++) { DeviceCostDetail deviceCostDetail = (DeviceCostDetail)deviceCostDetails[rowIndex]; reportBuilder.InsertRow(rowIndex, GetDetailRow(deviceCostDetail, detailType)); } reportBuilder.InsertFooter(GetFooterCells(detailType)); reportBuilder.CloseMedia(); }
protected void Page_Load(object sender, EventArgs e) { settingsMasterPage = (SettingsMasterPage)Page.Master; settingsMasterPage.InitializeMasterPageComponents(); int printerId; Boolean isNumeric = int.TryParse(Request.QueryString["printerId"], out printerId); if (!isNumeric) { EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true); return; } Tenant tenant = (Tenant)Session["tenant"]; printerDAO = new PrinterDAO(settingsMasterPage.dataAccess.GetConnection()); Printer printer = printerDAO.GetPrinter(tenant.id, printerId); // Não permite a criação de impressoras pois o usuário não pode fazer isso diretamente if (printer == null) { EmbedClientScript.ShowErrorMessage(this, "Falha ao obter os dados da impressora.", true); return; } lblTitle.Text = "Dados da impressora " + printer.name; SettingsInput settingsInput = new SettingsInput(settingsArea, null); settingsInput.AddHidden("txtId", printer.id.ToString()); settingsInput.AddHidden("txtTenantId", printer.tenantId.ToString()); settingsInput.AddHidden("txtName", printer.name); settingsInput.Add("txtAlias", "Nome amigável", printer.alias); settingsInput.Add("txtBwPageCost", "Custo página Pb", String.Format("{0:0.000}", printer.pageCost)); settingsInput.Add("txtColorPageCost", "Custo página Cor", String.Format("{0:0.000}", printer.pageCost + printer.colorCostDiff)); settingsInput.AddCheckBox("chkBwPrinter", "Monocromática", printer.bwPrinter); }
protected void Page_Load(object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); if (!Authorization.AuthorizedAsAdministrator(Session)) { // Mostra aviso de falta de autorização ShowWarning(Authorization.GetWarning()); return; } // action: // null - Sem ação, apenas lista as inpressoras // 0 - Excluir impressora, lista as restantes int?action = null; int?printerId = null; try { if (!String.IsNullOrEmpty(Request.QueryString["action"])) { action = int.Parse(Request.QueryString["action"]); } if (!String.IsNullOrEmpty(Request.QueryString["printerId"])) { printerId = int.Parse(Request.QueryString["printerId"]); } } catch (System.FormatException) { // Remove todos os controles da página configurationArea.Controls.Clear(); controlArea.Controls.Clear(); // Mostra aviso de inconsistência nos parâmetros WarningMessage.Show(controlArea, ArgumentBuilder.GetWarning()); return; } Tenant tenant = (Tenant)Session["tenant"]; printerDAO = new PrinterDAO(accountingMasterPage.dataAccess.GetConnection()); if (printerId != null) { switch (action) { case 0: printerDAO.RemovePrinter(printerId.Value); Response.Redirect("ConfigPrinters.aspx"); // Limpa a QueryString para evitar erros break; default: break; } } List <Object> printerList = printerDAO.GetAllPrinters(tenant.id); String[] columnNames = new String[] { "Impressora", "Custo página Pb", "Custo página Cor" }; String alterScript = "window.open('PrinterSettings.aspx?printerId=' + {0}, 'Settings', 'width=540,height=600');"; String removeScript = "var confirmed = confirm('Deseja realmente excluir esta impressora?'); if (confirmed) window.location='ConfigPrinters.aspx?action=0&printerId=' + {0};"; EditableListButton[] buttons = new EditableListButton[] { // Botões que devem aparecer para os items da lista new EditableListButton("Editar", alterScript, ButtonTypeEnum.Edit), new EditableListButton("Excluir", removeScript, ButtonTypeEnum.Remove) }; EditableList editableList = new EditableList(configurationArea, columnNames, buttons); foreach (Printer printer in printerList) { String[] printerProperties = new String[] { printer.alias, String.Format("{0:0.000}", printer.pageCost), String.Format("{0:0.000}", printer.pageCost + printer.colorCostDiff) }; editableList.InsertItem(printer.id, false, printerProperties); } editableList.DrawList(); }
public PrinterRN() { dao = new PrinterDAO(); }