예제 #1
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();
        }
        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();
        }