protected void btnSalva_Click(object sender, EventArgs e) { bool[] a = new bool[5]; if (!v.validarNome(Nome.Text) || string.IsNullOrEmpty(Nome.Text)) { ut.showErrorMessageByLbl("Digite corretamente o nome", Nome, lblNome); a[0] = false; } else { ut.removeErrorMessageByLbl("Nome", Nome, lblNome); a[0] = true; } if (!v.validarNome(Sobrenome.Text) || string.IsNullOrEmpty(Sobrenome.Text)) { ut.showErrorMessageByLbl("Digite corretamente o sobrenome", Sobrenome, lblSobrenome); a[1] = false; } else { ut.removeErrorMessageByLbl("Sobrenome", Sobrenome, lblSobrenome); a[1] = true; } if (!v.validarData(DataValidade.Text) || string.IsNullOrEmpty(DataValidade.Text)) { ut.showErrorMessageByLbl("Digite corretamente data", DataValidade, lblDataValidade); a[2] = false; } else { ut.removeErrorMessageByLbl("Data", DataValidade, lblDataValidade); a[2] = true; } if (!v.Luhn(Numero.Text.Replace(" ", "")) || string.IsNullOrEmpty(Numero.Text)) { ut.showErrorMessageByLbl("Digite corretamente o no. do cartão", Numero, lblNumero); a[3] = false; } else { ut.removeErrorMessageByLbl("Número", Numero, lblNumero); a[3] = true; } if (!(CodigoSeguranca.Text.Length == 3) || !int.TryParse(CodigoSeguranca.Text, out int n) || string.IsNullOrEmpty(CodigoSeguranca.Text)) { ut.showErrorMessageByLbl("Digite corretamente o CVV", CodigoSeguranca, lblCodigo); a[4] = false; } else { ut.removeErrorMessageByLbl("Código", CodigoSeguranca, lblCodigo); a[4] = true; } if (!a.Contains(false)) { List <String> t = (List <String>)HttpContext.Current.Session["teclados"]; if (t != null) { List <String> marcas; switch (t.Count) { case 1: updateMarcas(sql.selectCampos("marca", "tblProdutoDaLoja", "id_produto IN (" + t[0] + ")")); break; case 2: updateMarcas(sql.selectMarcas("marca", "tblProdutoDaLoja", "id_produto IN (" + t[0] + "," + t[1] + ")", 2)); break; case 3: updateMarcas(sql.selectMarcas("marca", "tblProdutoDaLoja", "id_produto IN (" + t[0] + "," + t[1] + "," + t[2] + ")", 3)); break; } if (t.Contains("20")) { sql.update("tblCliente", "'usuario = ''" + HttpContext.Current.Session["usuario"] + "'''", "'tipoConta = ''p'''"); } } HttpContext.Current.Session["teclados"] = null; HttpContext.Current.Session["custom"] = null; Response.Redirect("sucesso-cc.aspx", false); } }