protected void Page_Load(Object sender, EventArgs e)
        {
            settingsMasterPage = (SettingsMasterPage)Page.Master;
            settingsMasterPage.InitializeMasterPageComponents();

            int     userId;
            Boolean isNumeric = int.TryParse(Request.QueryString["userId"], out userId);

            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"];

            userDAO = new UserDAO(settingsMasterPage.dataAccess.GetConnection());
            AccountingLib.Entities.User user = userDAO.GetUser(tenant.id, userId);
            if (user == null)
            {
                EmbedClientScript.ShowErrorMessage(this, "Falha ao obter os dados do usuário.", true);
                return;
            }

            lblTitle.Text = "Dados do usuário " + user.name;
            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", user.id.ToString());
            settingsInput.AddHidden("txtTenantId", user.tenantId.ToString());
            settingsInput.AddHidden("txtName", user.name);
            settingsInput.Add("txtAlias", "Nome amigável", user.alias);
            settingsInput.Add("txtQuota", "Cota Mensal", String.Format("{0:0.000}", user.quota));
        }
Example #2
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.InitializeMasterPageComponents();
            dataAccess = administratorMasterPage.dataAccess;

            int     tenantId;
            Boolean isNumeric = int.TryParse(Request.QueryString["tenantId"], out tenantId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            TenantDAO tenantDAO = new TenantDAO(dataAccess.GetConnection());
            Tenant    tenant    = tenantDAO.GetTenant(tenantId);

            // Caso a empresa não exista cria uma nova
            if (tenant == null)
            {
                tenant = new Tenant();
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", tenant.id.ToString());
            settingsInput.Add("txtName", "Identificador", tenant.name);
            settingsInput.Add("txtAlias", "Nome amigável", tenant.alias);
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Abre a conexão com o banco
            dataAccess = DataAccess.Instance;
            dataAccess.MountConnection(FileResource.MapWebResource(Server, "DataAccess.xml"), DatabaseEnum.PrintAccounting);
            dataAccess.OpenConnection();

            String buttonScript = "window.open('ChangePassword.aspx', 'PasswordSettings', 'width=540,height=450');";

            EmbedClientScript.AddElementClickHandler(this.Page, "btnChangePassword", buttonScript);
            // Limpa as mensagens de erro
            lblErrorMessages.Text = "";

            // action:
            //    null -  Sem ação, apenas abre a página de login
            //    0    -  Efetua o Logout, removendo a autenticação previa do usuário
            int     action;
            Boolean paramExists = !String.IsNullOrEmpty(Request.QueryString["action"]);
            Boolean isNumeric   = int.TryParse(Request.QueryString["action"], out action);

            if ((paramExists) && (!isNumeric))
            {
                // Remove todos os controles da página
                controlArea.Controls.Clear();

                // Mostra aviso de inconsistência nos parâmetros
                WarningMessage.Show(controlArea, ArgumentBuilder.GetWarning());
                return;
            }
            if ((paramExists) && (action == 0))
            {
                Authentication.Disauthenticate(Session);
                Response.Redirect("LoginPage.aspx"); // Limpa a QueryString para evitar erros
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            settingsMasterPage = (SettingsMasterPage)Page.Master;
            settingsMasterPage.InitializeMasterPageComponents();

            int     loginId;
            Boolean isNumeric = int.TryParse(Request.QueryString["loginId"], out loginId);

            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"];

            loginDAO = new LoginDAO(settingsMasterPage.dataAccess.GetConnection());
            AccountingLib.Entities.Login login = loginDAO.GetLogin(tenant.id, loginId);
            if (login == null)
            {
                login          = new AccountingLib.Entities.Login();
                login.tenantId = tenant.id;
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", login.id.ToString());
            settingsInput.AddHidden("txtTenantId", login.tenantId.ToString());
            settingsInput.AddHidden("txtPassword", login.password);
            settingsInput.Add("txtUsername", "Login", login.username);
            settingsInput.AddDropDownList("cmbUserGroup", "Grupo/Permissão", login.userGroup, typeof(UserGroupEnum));
        }
Example #5
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.InitializeMasterPageComponents();

            int     loginId;
            Boolean isNumeric = int.TryParse(Request.QueryString["loginId"], out loginId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            administratorLoginDAO = new AdministratorLoginDAO(administratorMasterPage.dataAccess.GetConnection());
            AdministratorLogin login = administratorLoginDAO.GetLogin(loginId);

            // Caso o login não exista cria um novo (não é uma edição e sim uma inclusão)
            if (login == null)
            {
                login = new AdministratorLogin();
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", login.id.ToString());
            settingsInput.Add("txtUsername", "Username", login.username);
            settingsInput.Add("txtPassword", "Password", "", true, null); // deixa o password vazio, não recupera
        }
        private void ProcessSubmitClick()
        {
            SqlConnection          sqlConnection = settingsMasterPage.dataAccess.GetConnection();
            CostCenterAssociateDAO associateDAO  = new CostCenterAssociateDAO(sqlConnection);

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("transferedItem"))
                {
                    int    idPos     = fieldName.IndexOf("transferedItem") + "transferedItem".Length;
                    int    itemId    = int.Parse(fieldName.Substring(idPos));
                    String itemValue = Request.Form[fieldName];

                    //O valor dos items na lista pode ser o "id do usuário" ou o "id da associação"
                    // dependendo da ação (action=Associate  ou  action=Disassociate)
                    if (action == "Associate")
                    {
                        associateDAO.SetAssociate(NewAssociate(itemId));
                    }
                    if (action == "Disassociate")
                    {
                        associateDAO.RemoveAssociate(itemId);
                    }
                }
            }

            EmbedClientScript.CloseWindow(this);
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            settingsMasterPage = (SettingsMasterPage)Page.Master;
            settingsMasterPage.InitializeMasterPageComponents();

            int     deviceId;
            Boolean isNumeric = int.TryParse(Request.QueryString["deviceId"], out deviceId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            printingDeviceDAO = new PrintingDeviceDAO(settingsMasterPage.dataAccess.GetConnection());
            List <Object> counterHistory = printingDeviceDAO.GetCounterHistory(deviceId);

            String[]     columnNames  = new String[] { "Contador", "Data" };
            EditableList editableList = new EditableList(displayArea, columnNames, null);

            foreach (Object counter in counterHistory)
            {
                PageCounter pageCounter       = (PageCounter)counter;
                String[]    counterProperties = new String[]
                {
                    pageCounter.counter.ToString(),
                            String.Format("{0:dd/MM/yyyy HH:mm}", pageCounter.date)
                };
                editableList.InsertItem(pageCounter.id, false, counterProperties);
            }
            editableList.DrawList();
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            settingsMasterPage = (SettingsMasterPage)Page.Master;
            settingsMasterPage.InitializeMasterPageComponents();

            int     smtpServerId;
            Boolean isNumeric = int.TryParse(Request.QueryString["smtpServerId"], out smtpServerId);

            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"];

            smtpServerDAO = new SmtpServerDAO(settingsMasterPage.dataAccess.GetConnection());
            SmtpServer smtpServer = smtpServerDAO.GetSmtpServer(tenant.id, smtpServerId);

            if (smtpServer == null)
            {
                smtpServer          = new SmtpServer();
                smtpServer.tenantId = tenant.id;
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", smtpServer.id.ToString());
            settingsInput.AddHidden("txtTenantId", smtpServer.tenantId.ToString());
            settingsInput.Add("txtName", "Nome", smtpServer.name);
            settingsInput.Add("txtAddress", "Endereço", smtpServer.address);
            settingsInput.Add("txtPort", "Porta", smtpServer.port.ToString());
            settingsInput.Add("txtUsername", "Usuário", smtpServer.username);
            settingsInput.Add("txtPassword", "Senha", smtpServer.password, true, null);
        }
        protected void Page_Load(Object sender, EventArgs e)
        {
            settingsMasterPage = (SettingsMasterPage)Page.Master;
            settingsMasterPage.InitializeMasterPageComponents();

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

                if (!String.IsNullOrEmpty(Request.QueryString["parentId"]))
                {
                    parentId = int.Parse(Request.QueryString["parentId"]);
                }
            }
            catch (System.FormatException)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.Add("txtName", "Nome", GetCostCenter().name);
        }
        protected void Page_Load(Object sender, EventArgs e)
        {
            if (!Authentication.IsAuthenticated(Session))
            {
                Response.Redirect("LoginPage.aspx");
            }

            Tenant tenant = (Tenant)Session["tenant"];

            if (tenant == null)
            {
                EmbedClientScript.ShowErrorMessage(this, "Sessão inválida.", true);
                return;
            }

            int     licenseId;
            Boolean isNumeric = int.TryParse(Request.QueryString["licenseId"], out licenseId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            // Abre a conexão com o banco
            DataAccess dataAccess = DataAccess.Instance;

            dataAccess.MountConnection(FileResource.MapWebResource(this.Page.Server, "DataAccess.xml"), DatabaseEnum.PrintAccounting);
            dataAccess.OpenConnection();

            ApplicationParamDAO appParamDAO = new ApplicationParamDAO(dataAccess.GetConnection());
            ApplicationParam    urlParam    = appParamDAO.GetParam("url", "webAccounting");

            // Fecha a conexão com o banco
            dataAccess.CloseConnection();
            dataAccess = null;

            if (urlParam == null)
            {
                EmbedClientScript.ShowErrorMessage(this, "Falha ao buscar url do sistema no banco.", true);
                return;
            }

            String serviceUrl = urlParam.value + "/JobRoutingService.aspx";

            DateTime oneYearFromNow = DateTime.Now.AddYears(1);
            DateTime expirationDate = new DateTime(oneYearFromNow.Year, oneYearFromNow.Month, oneYearFromNow.Day, 0, 0, 0);


            this.Response.Clear();
            this.Response.ContentType = "application/octet-stream";
            this.Response.AddHeader("content-disposition", "attachment; filename=ProductKey.bin");

            String licenseKey = LicenseKeyMaker.GenerateKey(serviceUrl, tenant.id, licenseId, expirationDate);

            Response.Write(licenseKey);

            this.Response.End();
        }
Example #11
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Tenant     tenant     = (Tenant)Session["tenant"];
            SmtpServer smtpServer = new SmtpServer();

            try
            {
                foreach (String fieldName in Request.Form)
                {
                    if (fieldName.Contains("txtId"))
                    {
                        smtpServer.id = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtTenantId"))
                    {
                        smtpServer.tenantId = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtName"))
                    {
                        smtpServer.name = Request.Form[fieldName];
                        if (String.IsNullOrEmpty(smtpServer.name))
                        {
                            throw new FormatException();
                        }
                    }
                    if (fieldName.Contains("txtAddress"))
                    {
                        smtpServer.address = Request.Form[fieldName];
                        if (String.IsNullOrEmpty(smtpServer.address))
                        {
                            throw new FormatException();
                        }
                    }
                    if (fieldName.Contains("txtPort"))
                    {
                        smtpServer.port = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtUsername"))
                    {
                        smtpServer.username = Request.Form[fieldName];
                    }
                    if (fieldName.Contains("txtPassword"))
                    {
                        smtpServer.password = Request.Form[fieldName];
                    }
                }
            }
            catch (System.FormatException)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }
            smtpServer.hash = Cipher.GenerateHash(tenant.name + smtpServer.name);

            smtpServerDAO.SetSmtpServer(smtpServer);
            EmbedClientScript.CloseWindow(this);
        }
Example #12
0
        /// <summary>
        /// Fecha a mídia ( página aberta anteriormente )
        /// </summary>
        public void CloseMedia()
        {
            if (reportTable != null)
            {
                reportTable.FinishDrawing();
            }

            EmbedClientScript.PrintWindow(media);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            AccountingLib.Entities.Login login = new AccountingLib.Entities.Login();
            try
            {
                foreach (String fieldName in Request.Form)
                {
                    if (fieldName.Contains("txtId"))
                    {
                        login.id = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtTenantId"))
                    {
                        login.tenantId = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtPassword"))
                    {
                        login.password = Request.Form[fieldName];
                    }
                    if (fieldName.Contains("txtUsername"))
                    {
                        login.username = Request.Form[fieldName];
                        if (String.IsNullOrEmpty(login.username))
                        {
                            throw new FormatException();
                        }
                    }
                    if (fieldName.Contains("cmbUserGroup"))
                    {
                        login.userGroup = int.Parse(Request.Form[fieldName]);
                    }
                }
            }
            catch (System.FormatException)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            try
            {
                ResourceProtector.RectifyPassword(login); // caso o login seja novo gera a senha padrão
                loginDAO.SetLogin(login);
                EmbedClientScript.CloseWindow(this);
            }
            catch (Exception genericException)
            {
                if (genericException.Message.Contains("Violation of UNIQUE KEY"))
                {
                    EmbedClientScript.ShowErrorMessage(this, "Este login já existe!");
                    return;
                }

                EmbedClientScript.ShowErrorMessage(this, genericException.Message);
            }
        }
Example #14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Mailing mailing = new Mailing();

            try
            {
                foreach (String fieldName in Request.Form)
                {
                    if (fieldName.Contains("txtId"))
                    {
                        mailing.id = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtTenantId"))
                    {
                        mailing.tenantId = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("cmbSmtpServer"))
                    {
                        mailing.smtpServer = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("cmbFrequency"))
                    {
                        mailing.frequency = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("cmbReportType"))
                    {
                        mailing.reportType = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtRecipients"))
                    {
                        mailing.recipients = Request.Form[fieldName];

                        // Verifica o formato da string de destinatários, caso não seja um
                        // formato válido gera uma exceção (formatException)
                        if (String.IsNullOrEmpty(mailing.recipients))
                        {
                            throw new FormatException();
                        }
                        MailAddressCollection recipients = new MailAddressCollection();
                        recipients.Add(mailing.recipients); // gera formatException caso não estejam separados por vírgula
                    }
                    if (fieldName.Contains("txtLastSend"))
                    {
                        mailing.lastSend = DateTime.Parse(Request.Form[fieldName]);
                    }
                }
            }
            catch (System.FormatException)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            mailingDAO.SetMailing(mailing);
            EmbedClientScript.CloseWindow(this);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Printer printer              = new Printer();
            Decimal colorPageCost        = 0;
            Boolean blackAndWhitePrinter = false;

            try
            {
                foreach (String fieldName in Request.Form)
                {
                    if (fieldName.Contains("txtId"))
                    {
                        printer.id = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtTenantId"))
                    {
                        printer.tenantId = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtName"))
                    {
                        printer.name = Request.Form[fieldName];
                    }
                    if (fieldName.Contains("txtAlias"))
                    {
                        printer.alias = Request.Form[fieldName];
                        if (String.IsNullOrEmpty(printer.alias))
                        {
                            throw new FormatException();
                        }
                    }
                    if (fieldName.Contains("txtBwPageCost"))
                    {
                        printer.pageCost = Decimal.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtColorPageCost"))
                    {
                        colorPageCost = Decimal.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("chkBwPrinter"))
                    {
                        blackAndWhitePrinter = true; // o checkbox só é enviado no Post se estiver marcado
                    }
                }
                printer.colorCostDiff = colorPageCost - printer.pageCost;
                printer.bwPrinter     = blackAndWhitePrinter;
            }
            catch (System.FormatException)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            printerDAO.SetPrinter(printer);
            EmbedClientScript.CloseWindow(this);
        }
Example #16
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            SqlConnection sqlConnection = settingsMasterPage.dataAccess.GetConnection();

            String loginName            = "";
            String password             = "";
            String newPassword          = "";
            String confirmationPassword = "";

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtLoginName"))
                {
                    loginName = Request.Form[fieldName];
                }
                if (fieldName.Contains("txtOldPassword"))
                {
                    password = Request.Form[fieldName];
                }
                if (fieldName.Contains("txtNewPassword"))
                {
                    newPassword = Request.Form[fieldName];
                }
                if (fieldName.Contains("txtConfirmation"))
                {
                    confirmationPassword = Request.Form[fieldName];
                }
            }

            CredentialManager credentialManager = new CredentialManager(loginName, password, sqlConnection);

            if (!credentialManager.ValidateCredentials())
            {
                EmbedClientScript.ShowErrorMessage(this.Page, credentialManager.GetLastError());
                return;
            }

            // Verifica se a nova senha foi digitada duas vezes
            if (!ConfirmNewPassword(newPassword, confirmationPassword))
            {
                EmbedClientScript.ShowErrorMessage(this.Page, "Digite a nova senha nas duas caixas de texto.");
                return;
            }

            // Atualiza o senha no banco
            Login login = credentialManager.GetLogin();

            login.password = Cipher.GenerateHash(newPassword);
            LoginDAO loginDAO = new LoginDAO(sqlConnection);

            loginDAO.SetLogin(login);

            EmbedClientScript.CloseWindow(this);
        }
        protected void btnSubmit_Click(Object sender, EventArgs e)
        {
            AccountingLib.Entities.User user = new AccountingLib.Entities.User();
            try
            {
                foreach (String fieldName in Request.Form)
                {
                    if (fieldName.Contains("txtId"))
                    {
                        user.id = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtTenantId"))
                    {
                        user.tenantId = int.Parse(Request.Form[fieldName]);
                    }
                    if (fieldName.Contains("txtName"))
                    {
                        user.name = Request.Form[fieldName];
                    }
                    if (fieldName.Contains("txtAlias"))
                    {
                        user.alias = Request.Form[fieldName];
                    }
                    if (fieldName.Contains("txtQuota"))
                    {
                        user.quota = Decimal.Parse(Request.Form[fieldName]);
                    }
                }
            }
            catch (System.FormatException)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            if (String.IsNullOrEmpty(user.alias))
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            userDAO.SetUser(user);
            EmbedClientScript.CloseWindow(this);
        }
        protected void Page_Load(Object sender, EventArgs e)
        {
            administratorMasterPage = (AdministratorMasterPage)Page.Master;
            administratorMasterPage.InitializeMasterPageComponents();

            int     tenantId;
            Boolean isNumeric = int.TryParse(Request.QueryString["tenantId"], out tenantId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", tenantId.ToString());
            settingsInput.Add("txtAmmount", "Quantidade", "1");
        }
        protected void btnAdd_Click(Object sender, EventArgs e)
        {
            LicenseDAO linceseDAO = new LicenseDAO(administratorMasterPage.dataAccess.GetConnection());
            License    license    = new License();

            license.id = 0; // adicionar uma nova licença
            String ammount = "";

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtId"))
                {
                    license.tenantId = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("txtAmmount"))
                {
                    ammount = Request.Form[fieldName];
                }
            }

            int     licenseAmmount = 0;
            Boolean isNumeric      = int.TryParse(ammount, out licenseAmmount);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            if (licenseAmmount < 1)
            {
                EmbedClientScript.ShowErrorMessage(this, "Quantidade inválida!");
                return;
            }

            for (int index = 0; index < licenseAmmount; index++)
            {
                linceseDAO.SetLicense(license);
            }

            EmbedClientScript.CloseWindow(this);
        }
Example #20
0
        protected void btnSubmit_Click(Object sender, EventArgs e)
        {
            AdministratorLogin login = new AdministratorLogin();

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtId"))
                {
                    login.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("txtUsername"))
                {
                    login.username = Request.Form[fieldName];
                }
                if (fieldName.Contains("txtPassword"))
                {
                    login.password = Request.Form[fieldName];
                }
            }

            if ((String.IsNullOrEmpty(login.username)) || (String.IsNullOrEmpty(login.password)))
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            login.password = Cipher.GenerateHash(login.password);

            try
            {
                administratorLoginDAO.SetLogin(login);
            }
            catch (Exception exc)
            {
                EmbedClientScript.ShowErrorMessage(this, exc.Message);
                return;
            }

            EmbedClientScript.CloseWindow(this);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            String costCenterName = null;

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtName"))
                {
                    costCenterName = Request.Form[fieldName];
                }
            }
            if (String.IsNullOrEmpty(costCenterName))
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            CostCenter costCenter = GetCostCenter();

            costCenter.name = costCenterName;

            try
            {
                CostCenterDAO costCenterDAO = new CostCenterDAO(settingsMasterPage.dataAccess.GetConnection());
                costCenterDAO.SetCostCenter(costCenter);
            }
            catch (Exception genericException)
            {
                if (genericException.Message.Contains("Violation of UNIQUE KEY"))
                {
                    EmbedClientScript.ShowErrorMessage(this, "Este centro de custo já existe!");
                    return;
                }

                EmbedClientScript.ShowErrorMessage(this, genericException.Message);
            }

            EmbedClientScript.CloseWindow(this);
        }
Example #22
0
        protected void btnSubmit_Click(Object sender, EventArgs e)
        {
            Tenant tenant = new Tenant();

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtId"))
                {
                    tenant.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("txtName"))
                {
                    tenant.name = Request.Form[fieldName];
                }
                if (fieldName.Contains("txtAlias"))
                {
                    tenant.alias = Request.Form[fieldName];
                }
            }

            if ((String.IsNullOrEmpty(tenant.name)) || (String.IsNullOrEmpty(tenant.alias)))
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            if (!FieldParser.IsAlphaNumeric(tenant.name))
            {
                EmbedClientScript.ShowErrorMessage(this, "O identificador deve conter apenas letras e números!");
                return;
            }

            // Executa o conjunto de operações para a criação do Tenant
            TenantTransaction transaction = new TenantTransaction(tenant, dataAccess.GetConnection());

            transaction.Execute();
            EmbedClientScript.CloseWindow(this);
        }
Example #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            settingsMasterPage = (SettingsMasterPage)Page.Master;
            settingsMasterPage.InitializeMasterPageComponents();
            DataAccess dataAccess = settingsMasterPage.dataAccess;

            int     mailingId;
            Boolean isNumeric = int.TryParse(Request.QueryString["mailingId"], out mailingId);

            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"];

            mailingDAO = new MailingDAO(dataAccess.GetConnection());
            Mailing mailing = mailingDAO.GetMailing(tenant.id, mailingId);

            if (mailing == null)
            {
                mailing          = new Mailing();
                mailing.tenantId = tenant.id;
            }

            SettingsInput settingsInput = new SettingsInput(settingsArea, null);

            settingsInput.AddHidden("txtId", mailing.id.ToString());
            settingsInput.AddHidden("txtTenantId", mailing.tenantId.ToString());
            ListItem[] items = DropDownScaffold.RetrieveStrict("pr_retrieveSmtpServer", dataAccess.GetConnection(), typeof(SmtpServer));
            settingsInput.AddDropDownList("cmbSmtpServer", "Servidor SMTP", mailing.smtpServer, items);
            settingsInput.AddDropDownList("cmbFrequency", "Frequencia de Envio", mailing.frequency, typeof(ReportFrequencyEnum));
            settingsInput.AddDropDownList("cmbReportType", "Relatório", mailing.reportType, typeof(ReportTypeEnum));
            settingsInput.Add("txtRecipients", "Enviar para", mailing.recipients);
            settingsInput.AddHidden("txtLastSend", mailing.lastSend.ToShortDateString());
        }
        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 (!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)
        {
            settingsMasterPage = (SettingsMasterPage)Page.Master;
            settingsMasterPage.InitializeMasterPageComponents();
            tenant = (Tenant)Session["tenant"];

            if (String.IsNullOrEmpty(Request.QueryString["action"]))
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }
            action = Request.QueryString["action"];

            Boolean isNumeric = int.TryParse(Request.QueryString["costCenterId"], out costCenterId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            if (Page.IsPostBack)
            {
                ProcessSubmitClick();
                return;
            }


            ListItem[] items = null;
            if (action == "Associate")
            {
                lblTitle.Text    = "Associação";
                lblPageInfo.Text = lblPageInfo.Text + "Será criada a associação entre usuário e centro de custo.";
                List <Object> userList = GetAllUsers();
                if (userList.Count < 1)
                {
                    EmbedClientScript.ShowErrorMessage(this, "Nenhum usuário existente para associação.", true);
                    return;
                }
                items = GetAvailableUsers(userList);
                if (items.Length < 1)
                {
                    EmbedClientScript.ShowErrorMessage(this, "Todos os usuários já estão associados a centros de custo.", true);
                    return;
                }
            }
            if (action == "Disassociate")
            {
                lblTitle.Text    = "Disassociação";
                lblPageInfo.Text = lblPageInfo.Text + "Será removida a associação entre usuário e centro de custo.";
                items            = GetAssociates(costCenterId);
                if (items.Length < 1)
                {
                    EmbedClientScript.ShowErrorMessage(this, "Nenhuma associação existente para remoção.", true);
                    return;
                }
            }

            // Monta a lista com o nome dos usuários. O valor dos items na lista pode ser o "id do usuário"
            // ou o "id da associação" dependendo da ação (action=Associate  ou  action=Disassociate)
            listAvailable.Items.AddRange(items);
        }
Example #27
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Tenant tenant = (Tenant)Session["tenant"];

            Preference sysSender = new Preference();

            sysSender.tenantId = tenant.id;
            sysSender.name     = "sysSender";
            sysSender.type     = "System.String";

            Preference exportFormat = new Preference();

            exportFormat.tenantId = tenant.id;
            exportFormat.name     = "exportFormat";
            exportFormat.type     = "System.Int32";

            Preference periodEndDate = new Preference();

            periodEndDate.tenantId = tenant.id;
            periodEndDate.name     = "periodEndDate";
            periodEndDate.type     = "System.Int32";

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtTenantAlias"))
                {
                    tenant.alias = Request.Form[fieldName];
                }

                if (fieldName.Contains("txtSysSenderId"))
                {
                    sysSender.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("txtSysSenderValue"))
                {
                    sysSender.value = Request.Form[fieldName];
                }

                if (fieldName.Contains("txtExportFormatId"))
                {
                    exportFormat.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("cmbExportFormatValue"))
                {
                    exportFormat.value = Request.Form[fieldName];
                }

                if (fieldName.Contains("txtPeriodEndDateId"))
                {
                    periodEndDate.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("cmbPeriodEndDateValue"))
                {
                    periodEndDate.value = Request.Form[fieldName];
                }
            }

            // Verifica se os campos foram preenchidos
            if ((String.IsNullOrEmpty(tenant.alias)) || (String.IsNullOrEmpty(sysSender.value)))
            {
                EmbedClientScript.ShowErrorMessage(this, "Favor preencher todos os campos!");
            }

            try
            {
                // Verifica o formato do endereço de e-mail
                MailAddress mailAddress = new MailAddress(sysSender.value);
            }
            catch
            {
                EmbedClientScript.ShowErrorMessage(this, "O endereço de e-mail não está em um formato válido!");
            }

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

            tenantDAO.SetTenant(tenant);
            preferenceDAO.SetTenantPreference(sysSender);
            preferenceDAO.SetTenantPreference(exportFormat);
            preferenceDAO.SetTenantPreference(periodEndDate);
        }
Example #28
0
 protected void btnOK_Click(object sender, EventArgs e)
 {
     EmbedClientScript.CloseWindow(this);
 }
Example #29
0
        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);
        }