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); }
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); }
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); } }
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); }
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 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); }
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); }
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); }
protected void btnOK_Click(object sender, EventArgs e) { EmbedClientScript.CloseWindow(this); }