public void inserirUsuario(string nome, string usu, string email, string cpf, string senha) { using (SqlConnection conexao_SQL = new SqlConnection(Conexao.nome_conexao)) { try { if (conexao_SQL.State == ConnectionState.Closed) { conexao_SQL.Open(); } string insert = "Exec usp_insertCliente '" + v.vacina(nome) + "', '" + v.vacina(usu) + "', '" + v.vacina(senha) + "', '" + v.vacina(email) + "', '" + v.vacina(cpf) + "'"; using (comando_SQL = new SqlCommand(insert, conexao_SQL)) { comando_SQL.ExecuteNonQuery(); conexao_SQL.Close(); } } catch { conexao_SQL.Close(); } } }
public void btnValidaEmail(TextBox txtValidaEmail, TextBox Usuario) { if (txtValidaEmail.Text.ToLower().Equals(HttpContext.Current.Session["codigo-mudanca"].ToString().ToLower())) { sql.update("tblCliente", "'usuario = ''" + HttpContext.Current.Session["usuario"].ToString() + "'''", "'" + v.vacina(HttpContext.Current.Session["novosValores"].ToString()) + "'"); HttpContext.Current.Session["usuarioNovo"] = HttpContext.Current.Session["temp"]; HttpContext.Current.Session["temp"] = null; HttpContext.Current.Response.Redirect("minha-conta.aspx"); } }
public void btnEntra(TextBox txtUsu, TextBox txtPass, CheckBox ckbLogin, Label lblMsg, String redirect) { if (!string.IsNullOrEmpty(txtUsu.Text) && !string.IsNullOrEmpty(txtPass.Text)) { if (!txtUsu.Text.Contains("@")) { try { if (sql.selectHasRows("*", "tblCliente", "usuario=''" + v.vacina(txtUsu.Text) + "''")) { txtUsu.Attributes.Add("style", "border-color:#0093ff"); if (sql.selectHasRows("usuario", "tblCliente", "senha=''" + v.vacina(txtPass.Text) + "'' and usuario=''" + v.vacina(txtUsu.Text) + "''")) { HttpContext.Current.Session["logado"] = "1"; HttpContext.Current.Session["usuario"] = txtUsu.Text; if (ckbLogin.Checked) { HttpCookie cookie = new HttpCookie("credenciais"); cookie.Values["usuario"] = txtUsu.Text; cookie.Values["senha"] = txtPass.Text; cookie.Expires = DateTime.Now.AddDays(365); HttpContext.Current.Response.Cookies.Add(cookie); } HttpContext.Current.Response.Redirect(redirect); txtPass.Attributes.Add("style", "border-color:#0093ff"); } else { lblMsg.Text = "Senha incorreta"; lblMsg.ForeColor = System.Drawing.Color.Red; txtPass.Attributes.Add("style", "border-color:red"); HttpContext.Current.Session["logado"] = "0"; } } else { lblMsg.Text = "Usuário e senha incorretos"; lblMsg.ForeColor = System.Drawing.Color.Red; txtUsu.Attributes.Add("style", "border-color:red"); txtPass.Attributes.Add("style", "border-color:red"); HttpContext.Current.Session["logado"] = "0"; } } catch (Exception ex) { } } else { try { if (sql.selectHasRows("*", "tblCliente", "email=''" + v.vacina(txtUsu.Text) + "''")) { txtUsu.Attributes.Add("style", "border-color:#0093ff"); if (sql.selectHasRows("usuario", "tblCliente", "senha=''" + v.vacina(txtPass.Text) + "'' and email=''" + v.vacina(txtUsu.Text) + "''")) { HttpContext.Current.Session["logado"] = "1"; HttpContext.Current.Session["usuario"] = sql.selectCampos("usuario", "tblCliente", "email= ''" + v.vacina(txtUsu.Text) + "''")[0]; if (ckbLogin.Checked) { HttpCookie cookie = new HttpCookie("credenciais"); cookie.Values["usuario"] = HttpContext.Current.Session["usuario"].ToString(); cookie.Values["senha"] = txtPass.Text; cookie.Expires = DateTime.Now.AddDays(365); HttpContext.Current.Response.Cookies.Add(cookie); } HttpContext.Current.Response.Redirect("~/View/galeria.aspx"); txtPass.Attributes.Add("style", "border-color:#0093ff"); } else { lblMsg.Text = "Senha incorreta"; lblMsg.ForeColor = System.Drawing.Color.Red; txtPass.Attributes.Add("style", "border-color:red"); HttpContext.Current.Session["logado"] = "0"; } } else { lblMsg.Text = "Usuário e senha incorretos"; lblMsg.ForeColor = System.Drawing.Color.Red; txtUsu.Attributes.Add("style", "border-color:red"); txtPass.Attributes.Add("style", "border-color:red"); HttpContext.Current.Session["logado"] = "0"; } } catch { } } } else { lblMsg.Text = "Campo vazio"; lblMsg.ForeColor = System.Drawing.Color.Red; if (string.IsNullOrEmpty(txtUsu.Text)) { txtUsu.Attributes.Add("style", "border-color:red"); } else { txtUsu.Attributes.Remove("style"); } if (string.IsNullOrEmpty(txtPass.Text)) { txtPass.Attributes.Add("style", "border-color:red"); } else { txtPass.Attributes.Remove("style"); } HttpContext.Current.Session["logado"] = "0"; } }