Exemplo n.º 1
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.AddMenuItems();
            administratorMasterPage.InitializeMasterPageComponents();
            dataAccess = administratorMasterPage.dataAccess;

            AdministratorLoginDAO administratorLoginDAO = new AdministratorLoginDAO(dataAccess.GetConnection());
            List <Object>         loginList             = administratorLoginDAO.GetAllLogins();

            String[] columnNames = new String[] { "Login" };
            String   alterScript = "window.open('LoginSettings.aspx?loginId=' + {0}, 'Settings', 'width=540,height=600');";

            EditableListButton[] buttons = new EditableListButton[]
            {
                // Botões que devem aparecer para os items da lista
                new EditableListButton("Editar", alterScript, ButtonTypeEnum.Edit),
            };
            EditableList editableList = new EditableList(configurationArea, columnNames, buttons);

            foreach (AdministratorLogin login in loginList)
            {
                editableList.InsertItem(login.id, false, new String[1] {
                    login.username
                });
            }
            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));
        }
Exemplo n.º 2
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.AddMenuItems();
            administratorMasterPage.InitializeMasterPageComponents();

            TenantDAO  tenantDAO  = new TenantDAO(administratorMasterPage.dataAccess.GetConnection());
            LicenseDAO licenseDAO = new LicenseDAO(administratorMasterPage.dataAccess.GetConnection());

            String[] columnNames = new String[] { "Empresa", "Quantidade de Licenças" };
            String   addScript   = "window.open('AddLicenses.aspx?tenantId=' + {0}, 'AddLicenses', 'width=540,height=600');";

            EditableListButton[] buttons = new EditableListButton[]
            {
                // Botões que devem aparecer para os items da lista
                new EditableListButton("Adicionar", addScript, ButtonTypeEnum.Edit)
            };

            EditableList  editableList = new EditableList(configurationArea, columnNames, buttons);
            List <Object> tenantList   = tenantDAO.GetAllTenants();

            foreach (Tenant tenant in tenantList)
            {
                String[] itemProperties = new String[]
                {
                    tenant.alias,
                    licenseDAO.GetAllLicenses(tenant.id).Count.ToString()
                };
                editableList.InsertItem(tenant.id, false, itemProperties);
            }
            editableList.DrawList();
        }
Exemplo n.º 3
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 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();
            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));
        }
Exemplo n.º 5
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)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.AddMenuItems();
            administratorMasterPage.InitializeMasterPageComponents();

            // action:
            //    null -  Sem ação, apenas lista os inquilinos(clientes)
            //    0    -  Excluir cliente, lista as restantes
            int?action   = null;
            int?tenantId = null;

            try
            {
                if (!String.IsNullOrEmpty(Request.QueryString["action"]))
                {
                    action = int.Parse(Request.QueryString["action"]);
                }

                if (!String.IsNullOrEmpty(Request.QueryString["tenantId"]))
                {
                    tenantId = int.Parse(Request.QueryString["tenantId"]);
                }
            }
            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, "Erro nos parâmetros passados para a página.");
                return;
            }

            TenantDAO tenantDAO = new TenantDAO(administratorMasterPage.dataAccess.GetConnection());

            if (tenantId != null)
            {
                switch (action)
                {
                case 0:
                    tenantDAO.RemoveTenant(tenantId.Value);
                    Response.Redirect("ConfigTenants.aspx");     // Limpa a QueryString para evitar erros
                    break;

                default:
                    break;
                }
            }
            List <Object> tenantList = tenantDAO.GetAllTenants();

            String[] columnNames  = new String[] { "Empresa", "Nome amigável" };
            String   alterScript  = "window.open('TenantSettings.aspx?tenantId=' + {0}, 'Settings', 'width=540,height=600');";
            String   removeScript = "var confirmed = confirm('Deseja realmente excluir este cliente?'); if (confirmed) window.location='ConfigTenants.aspx?action=0&tenantId=' + {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 (Tenant tenant in tenantList)
            {
                String[] tenantProperties = new String[]
                {
                    tenant.name,
                    tenant.alias
                };
                editableList.InsertItem(tenant.id, false, tenantProperties);
            }
            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();
        }
Exemplo n.º 8
0
        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();
        }