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 userId = 0; DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; try { userId = int.Parse(Request.QueryString["userId"]); 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 = UserCostDetailsReport.GetReportData(detailType); lblTitle.Text = (String)reportData["title"]; UserDAO userDAO = new UserDAO(accountingMasterPage.dataAccess.GetConnection()); User user = userDAO.GetUser(tenant.id, userId); lblUsername.Text = "Usuário: " + user.alias; GenerateReport(userId, startDate, endDate, detailType); }
protected void Page_Load(object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); dataAccess = accountingMasterPage.dataAccess; if (!Authorization.AuthorizedAsAdministrator(Session)) { // Remove todos os controles da página configurationArea.Controls.Clear(); controlArea.Controls.Clear(); // Mostra aviso de falta de autorização WarningMessage.Show(controlArea, Authorization.GetWarning()); return; } Tenant tenant = (Tenant)Session["tenant"]; SettingsInput tenantInput = new SettingsInput(pnlTenant, null); tenantInput.Add("txtTenantAlias", "Nome amigável", tenant.alias); preferenceDAO = new PreferenceDAO(dataAccess.GetConnection()); Preference sysSender = preferenceDAO.GetTenantPreference(tenant.id, "sysSender"); Preference exportFormat = preferenceDAO.GetTenantPreference(tenant.id, "exportFormat"); if (exportFormat == null) { // Se não existe no banco cria a entrada exportFormat = new Preference(); exportFormat.id = 0; exportFormat.value = "0"; } Preference periodEndDate = preferenceDAO.GetTenantPreference(tenant.id, "periodEndDate"); if (periodEndDate == null) { // Se não existe no banco cria a entrada periodEndDate = new Preference(); periodEndDate.id = 0; periodEndDate.value = "1"; } SettingsInput tenantPreferencesInput = new SettingsInput(pnlTenantPreferences, null); tenantPreferencesInput.AddHidden("txtSysSenderId", sysSender.id.ToString()); tenantPreferencesInput.Add("txtSysSenderValue", "Remetente e-mails do sistema", sysSender.value); tenantPreferencesInput.AddHidden("txtExportFormatId", exportFormat.id.ToString()); tenantPreferencesInput.AddDropDownList("cmbExportFormatValue", "Formato de exportação", int.Parse(exportFormat.value), typeof(ExportFormatEnum)); tenantPreferencesInput.AddHidden("txtPeriodEndDateId", periodEndDate.id.ToString()); tenantPreferencesInput.AddDropDownList("cmbPeriodEndDateValue", "Fechamento de período", int.Parse(periodEndDate.value), typeof(PeriodDelimiterEnum)); }
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); }
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();"); }
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 os usuários // 0 - Excluir usuário, lista os restantes int?action = null; int?userId = null; try { if (!String.IsNullOrEmpty(Request.QueryString["action"])) { action = int.Parse(Request.QueryString["action"]); } if (!String.IsNullOrEmpty(Request.QueryString["userId"])) { userId = int.Parse(Request.QueryString["userId"]); } } 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"]; userDAO = new UserDAO(accountingMasterPage.dataAccess.GetConnection()); if (userId != null) { switch (action) { case 0: userDAO.RemoveUser(userId.Value); Response.Redirect("ConfigUsers.aspx"); // Limpa a QueryString para evitar erros break; default: break; } } List <Object> userList = userDAO.GetAllUsers(tenant.id); String[] columnNames = new String[] { "Usuário", "Nome Amigável", "Cota Mensal" }; String alterScript = "window.open('UserSettings.aspx?userId=' + {0}, 'Settings', 'width=540,height=600');"; String removeScript = "var confirmed = confirm('Deseja realmente excluir este usuário?'); if (confirmed) window.location='ConfigUsers.aspx?action=0&userId=' + {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 (User user in userList) { String quota = "-"; if (user.quota != null) { quota = String.Format("{0:0.000}", user.quota); } String[] userProperties = new String[] { user.name, user.alias, quota }; editableList.InsertItem(user.id, false, userProperties); } editableList.DrawList(); }
protected void Page_Load(object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); if (!String.IsNullOrEmpty(Request["action"])) { action = Request["action"]; } if (!String.IsNullOrEmpty(Request["currPage"])) { currentPage = int.Parse(Request["currPage"]); } if (!Page.IsPostBack) // Ajusta os valores iniciais do filtro { SqlConnection sqlConnection = accountingMasterPage.dataAccess.GetConnection(); ListItem[] userList = DropDownScaffold.Retrieve("pr_retrieveUser", sqlConnection, typeof(User)); userList[0].Text = "Todos os usuários"; cmbUser.Items.AddRange(userList); chkLastMonth.Checked = true; } // Configura os valores para a faixa de datas (considerando o periodo do último mês) DateRange dateRange = new DateRange(false); hiddenStartDate.Value = dateRange.GetFirstDay().ToString("yyyy-MM-dd"); hiddenStartHour.Value = "08:00"; hiddenEndDate.Value = dateRange.GetLastDay().ToString("yyyy-MM-dd"); hiddenEndHour.Value = "18:00"; if (chkLastMonth.Checked) { // caso o checkbox esteja marcado configura o último mês, senão recupera o viewstate txtStartDate.Value = hiddenStartDate.Value; txtStartHour.Value = hiddenStartHour.Value; txtEndDate.Value = hiddenEndDate.Value; txtEndHour.Value = hiddenEndHour.Value; } txtStartDate.Disabled = chkLastMonth.Checked; btnOpenCalendar1.Disabled = chkLastMonth.Checked; txtStartHour.Disabled = chkLastMonth.Checked; txtEndDate.Disabled = chkLastMonth.Checked; btnOpenCalendar2.Disabled = chkLastMonth.Checked; txtEndHour.Disabled = chkLastMonth.Checked; EmbedClientScript.AddButtonClickHandler(this.Page, "GenerateReport"); lblErrorMessages.Text = ""; // caso "action" não exista encerra por aqui if (action == "") { return; } int? userId = null; DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; try { userId = DropDownScaffold.GetSelectedItemId(cmbUser); startDate = DateTime.Parse(txtStartDate.Value + " " + txtStartHour.Value); endDate = DateTime.Parse(txtEndDate.Value + " " + txtEndHour.Value); } catch (System.FormatException) { lblErrorMessages.Text = "As datas informadas não estão em um formato válido."; return; } if (userId != null) { String queryString = "?userId=" + userId.ToString() + "&" + "startDate=" + startDate.ToString() + "&" + "endDate=" + endDate.ToString() + "&" + "detailType=PrintingCosts"; Response.Redirect("UserCostDetails.aspx" + queryString); return; } GenerateReport(startDate, endDate); }
protected void Page_Load(Object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); if (!String.IsNullOrEmpty(Request["action"])) { action = Request["action"]; } if (!String.IsNullOrEmpty(Request["currPage"])) { currentPage = int.Parse(Request["currPage"]); } if (!Page.IsPostBack) // Ajusta os valores iniciais do filtro { chkLastMonth.Checked = true; } // Configura os valores para a faixa de datas (considerando o periodo do último mês) DateRange dateRange = new DateRange(false); hiddenStartDate.Value = dateRange.GetFirstDay().ToString("yyyy-MM-dd"); hiddenStartHour.Value = "08:00"; hiddenEndDate.Value = dateRange.GetLastDay().ToString("yyyy-MM-dd"); hiddenEndHour.Value = "18:00"; if (chkLastMonth.Checked) { // caso o checkbox esteja marcado configura o último mês, senão recupera o viewstate txtStartDate.Value = hiddenStartDate.Value; txtStartHour.Value = hiddenStartHour.Value; txtEndDate.Value = hiddenEndDate.Value; txtEndHour.Value = hiddenEndHour.Value; } txtStartDate.Disabled = chkLastMonth.Checked; btnOpenCalendar1.Disabled = chkLastMonth.Checked; txtStartHour.Disabled = chkLastMonth.Checked; txtEndDate.Disabled = chkLastMonth.Checked; btnOpenCalendar2.Disabled = chkLastMonth.Checked; txtEndHour.Disabled = chkLastMonth.Checked; EmbedClientScript.AddButtonClickHandler(this.Page, "GenerateReport"); lblErrorMessages.Text = ""; // caso "action" não exista encerra por aqui if (action == "") { return; } DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; try { startDate = DateTime.Parse(txtStartDate.Value + " " + txtStartHour.Value); endDate = DateTime.Parse(txtEndDate.Value + " " + txtEndHour.Value); } catch (System.FormatException) { lblErrorMessages.Text = "As datas informadas não estão em um formato válido."; return; } GenerateReport(startDate, endDate); }
protected void Page_Load(object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); dataAccess = accountingMasterPage.dataAccess; if (!Authorization.AuthorizedAsAdministrator(Session)) { // Mostra aviso de falta de autorização ShowWarning(Authorization.GetWarning()); return; } int smtpServerId; Boolean paramExists = !String.IsNullOrEmpty(Request.QueryString["smtpServerId"]); Boolean isNumeric = int.TryParse(Request.QueryString["smtpServerId"], out smtpServerId); if ((paramExists) && (!isNumeric)) { // Mostra aviso de inconsistência nos parâmetros ShowWarning(ArgumentBuilder.GetWarning()); return; } smtpServerDAO = new SmtpServerDAO(dataAccess.GetConnection()); if (paramExists) // Se o parametro existe é uma exclusão { smtpServerDAO.RemoveSmtpServer(smtpServerId); Response.Redirect("ConfigSmtpServers.aspx"); // Limpa a QueryString para evitar erros } Tenant tenant = (Tenant)Session["tenant"]; List <Object> serverList = smtpServerDAO.GetAllSmtpServers(tenant.id); int defaultItemId = 0; if (serverList.Count > 0) { // Considera como sendo item default o primeiro smtp server criado para o tenant SmtpServer defaultItem = (SmtpServer)serverList[0]; defaultItemId = defaultItem.id; } String[] columnNames = new String[] { "Nome Servidor", "Endereço", "Porta" }; String alterScript = "window.open('SmtpServerSettings.aspx?smtpServerId=' + {0}, 'Settings', 'width=540,height=600');"; String removeScript = "var confirmed = confirm('Deseja realmente excluir este item?'); if (confirmed) window.location='ConfigSmtpServers.aspx?smtpServerId=' + {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); editableList.PreserveDefaultItem(); foreach (SmtpServer server in serverList) { String[] serverProperties = new String[] { server.name, server.address, server.port.ToString() }; Boolean isDefaultItem = server.id == defaultItemId; editableList.InsertItem(server.id, isDefaultItem, serverProperties); } editableList.DrawList(); // O clique do botão chama o script de alteração passando "id = 0", a tela de alteração // interpreta "id = 0" como "criar um novo", o id é então gerado no banco de dados. btnNovo.Attributes.Add("onClick", String.Format(alterScript, 0)); }
protected void Page_Load(object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); dataAccess = accountingMasterPage.dataAccess; if (!Authorization.AuthorizedAsAdministrator(Session)) { // Mostra aviso de falta de autorização ShowWarning(Authorization.GetWarning()); return; } int loginId; Boolean paramExists = !String.IsNullOrEmpty(Request.QueryString["loginId"]); Boolean isNumeric = int.TryParse(Request.QueryString["loginId"], out loginId); if ((paramExists) && (!isNumeric)) { // Mostra aviso de inconsistência nos parâmetros ShowWarning(ArgumentBuilder.GetWarning()); return; } loginDAO = new LoginDAO(dataAccess.GetConnection()); if (paramExists) // Se o parametro existe é uma exclusão { loginDAO.RemoveLogin(loginId); Response.Redirect("ConfigLogins.aspx"); // Limpa a QueryString para evitar erros } Tenant tenant = (Tenant)Session["tenant"]; List <Object> loginList = loginDAO.GetAllLogins(tenant.id); int defaultItemId = 0; if (loginList.Count > 0) { // Considera como sendo item default o primeiro login criado para o tenant AccountingLib.Entities.Login defaultItem = (AccountingLib.Entities.Login)loginList[0]; defaultItemId = defaultItem.id; } String[] columnNames = new String[] { "Login", "Grupo/Permissão" }; String alterScript = "window.open('LoginSettings.aspx?loginId=' + {0}, 'Settings', 'width=540,height=600');"; String removeScript = "var confirmed = confirm('Deseja realmente excluir este login?'); if (confirmed) window.location='ConfigLogins.aspx?loginId=' + {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); editableList.PreserveDefaultItem(); foreach (AccountingLib.Entities.Login login in loginList) { UserGroupEnum userGroup = (UserGroupEnum)login.userGroup; String[] loginProperties = new String[] { login.username, AssociatedText.GetFieldDescription(typeof(UserGroupEnum), userGroup.ToString()) }; Boolean isDefaultItem = login.id == defaultItemId; if (!isDefaultItem) { editableList.InsertItem(login.id, false, loginProperties); } } editableList.DrawList(); // O clique do botão chama o script de alteração passando "id = 0", a tela de alteração // interpreta "id = 0" como "criar um novo", o id é então gerado no banco de dados. btnNovo.Attributes.Add("onClick", String.Format(alterScript, 0)); }
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; } Tenant tenant = (Tenant)Session["tenant"]; LicenseDAO licenseDAO = new LicenseDAO(accountingMasterPage.dataAccess.GetConnection()); List <Object> licenseList = licenseDAO.GetAllLicenses(tenant.id); String[] columnNames = new String[] { "Id da Licença", "Chave Instalação(CPU/HD)", "Data Instalação", "Nome do Computador" }; String downloadScript = "window.location.replace('LicenseFile.aspx?licenseId=' + {0});"; EditableListButton[] buttons = new EditableListButton[] { // Botões que devem aparecer para os items da lista new EditableListButton("Download", downloadScript, ButtonTypeEnum.Download) }; EditableList editableList = new EditableList(displayArea, columnNames, buttons); foreach (License license in licenseList) { String licenseId = license.id.ToString(); if (license.id < 10000) { licenseId = String.Format("{0:0000}", license.id); } String installationKey = "-"; if (license.installationKey != null) { installationKey = license.installationKey; } String installationDate = "-"; if (license.installationDate != null) { installationDate = license.installationDate.Value.ToString("dd/MM/yyyy"); } String computerName = "-"; if (license.computerName != null) { computerName = license.computerName; } String[] licenseProperties = new String[] { licenseId, installationKey, installationDate, computerName }; editableList.InsertItem(license.id, false, licenseProperties); } editableList.DrawList(); }
protected void Page_Load(object sender, EventArgs e) { accountingMasterPage = (AccountingMasterPage)Page.Master; accountingMasterPage.InitializeMasterPageComponents(); dataAccess = accountingMasterPage.dataAccess; // action: // null - Sem ação, apenas lista os mailings // 0 - Excluir mailing, lista os restantes // 1 - Teste execução do mailing int?action = null; int?mailingId = null; try { if (!String.IsNullOrEmpty(Request.QueryString["action"])) { action = int.Parse(Request.QueryString["action"]); } if (!String.IsNullOrEmpty(Request.QueryString["mailingId"])) { mailingId = int.Parse(Request.QueryString["mailingId"]); } } 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"]; mailingDAO = new MailingDAO(dataAccess.GetConnection()); if (mailingId != null) { switch (action) { case 0: mailingDAO.RemoveMailing(mailingId.Value); Response.Redirect("ConfigMailing.aspx"); // Limpa a QueryString para evitar erros break; case 1: Mailing mailing = mailingDAO.GetMailing(tenant.id, mailingId); TestMailing(mailing); break; default: break; } } List <Object> mailingList = mailingDAO.GetAllMailings(tenant.id); String[] columnNames = new String[] { "Frequência de envio", "Relatório", "Destinatários" }; //String testScript = "window.location='ConfigMailing.aspx?action=1&mailingId=' + {0};"; String alterScript = "window.open('MailingSettings.aspx?mailingId=' + {0}, 'Settings', 'width=540,height=600');"; String removeScript = "var confirmed = confirm('Deseja realmente excluir este item?'); if (confirmed) window.location='ConfigMailing.aspx?action=0&mailingId=' + {0};"; EditableListButton[] buttons = new EditableListButton[] { // Botões que devem aparecer para os items da lista //new EditableListButton("Testar", testScript, ButtonTypeEnum.Execute), new EditableListButton("Editar", alterScript, ButtonTypeEnum.Edit), new EditableListButton("Excluir", removeScript, ButtonTypeEnum.Remove) }; EditableList editableList = new EditableList(configurationArea, columnNames, buttons); foreach (Mailing mailing in mailingList) { ReportFrequencyEnum frequency = (ReportFrequencyEnum)mailing.frequency; ReportTypeEnum reportType = (ReportTypeEnum)mailing.reportType; String[] mailingProperties = new String[] { AssociatedText.GetFieldDescription(typeof(ReportFrequencyEnum), frequency.ToString()), AssociatedText.GetFieldDescription(typeof(ReportTypeEnum), reportType.ToString()), mailing.recipients }; // A lista de mailings não possui item default, isDefaultItem é sempre "false" editableList.InsertItem(mailing.id, false, mailingProperties); } editableList.DrawList(); // O clique do botão chama o script de alteração passando "id = 0", a tela de alteração // interpreta "id = 0" como "criar um novo", o id é então gerado no banco de dados. btnNovo.Attributes.Add("onClick", String.Format(alterScript, 0)); }
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 os dispositivos // 0 - Excluir dispositivo, lista os restantes int?action = null; int?deviceId = null; try { if (!String.IsNullOrEmpty(Request.QueryString["action"])) { action = int.Parse(Request.QueryString["action"]); } if (!String.IsNullOrEmpty(Request.QueryString["deviceId"])) { deviceId = int.Parse(Request.QueryString["deviceId"]); } } 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"]; printingDeviceDAO = new PrintingDeviceDAO(accountingMasterPage.dataAccess.GetConnection()); if (deviceId != null) { switch (action) { case 0: printingDeviceDAO.RemovePrintingDevice(deviceId.Value); Response.Redirect("PageCounters.aspx"); // Limpa a QueryString para evitar erros break; default: break; } } List <Object> deviceList = printingDeviceDAO.GetAllPrintingDevices(tenant.id); String[] columnNames = new String[] { "Endereço IP", "Descrição", "Número de série", "Contador", "Atualizado Em" }; String viewScript = "window.open('PageCounterHistory.aspx?deviceId=' + {0}, 'Histórico do contador', 'width=540,height=600');"; String removeScript = "var confirmed = confirm('Deseja realmente excluir este dispositivo?'); if (confirmed) window.location='PageCounters.aspx?action=0&deviceId=' + {0};"; EditableListButton[] buttons = new EditableListButton[] { // Botões que devem aparecer para os items da lista new EditableListButton("Histórico", viewScript, ButtonTypeEnum.Edit), new EditableListButton("Excluir", removeScript, ButtonTypeEnum.Remove) }; EditableList editableList = new EditableList(configurationArea, columnNames, buttons); foreach (PrintingDevice device in deviceList) { String[] deviceProperties = new String[] { device.ipAddress, device.description, device.serialNumber, device.counter.ToString(), String.Format("{0:dd/MM/yyyy HH:mm}", device.lastUpdated) }; editableList.InsertItem(device.id, false, deviceProperties); } editableList.DrawList(); }