private void btnEntrar_Click(object sender, EventArgs e) { if (txtLogin.Text == string.Empty || txtSenha.Text == string.Empty) { MessageBox.Show("Atenção, todos os campos presisão ser preenchidos.", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { classLogin log = new classLogin(); arr = log.Logar(txtLogin.Text.ToString(), txtSenha.Text.ToString()); int aux = arr.Count; if (aux == 1) { classLogin.codUsuario = (((classLogin)arr[0]).codigo); classLogin.nomeUsuario = (((classLogin)arr[0]).nome); this.Hide(); txtLogin.Text = ""; txtSenha.Text = ""; LoginOK = true; } else { MessageBox.Show("Login ou senha estão incorretos,\n tente novamente."); } } }
public void Login() { //método para testar login e senha if (txtLogin.Text == string.Empty || txtSenha.Text == string.Empty) { MudarLabel(); MessageBox.Show("Atenção! Todos os campos com * precisam ser preenchidos.", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { classLogin log = new classLogin(); arr = log.Logar(txtLogin.Text.ToString(), txtSenha.Text.ToString()); int aux = arr.Count; if (aux == 1) { classLogin.codUsuario = (((classLogin)arr[0]).codigo); classLogin.nomeUsuario = (((classLogin)arr[0]).nome); this.Hide(); txtLogin.Text = ""; txtSenha.Text = ""; LoginOK = true; } else { MessageBox.Show("Login ou senha estão incorretos!\n Tente novamente."); } } }
public ArrayList Logar(string login, string senha) { ArrayList arr = new ArrayList(); string sql = "SELECT iddentista,nome FROM dentista where login = '******' and senha = '" + senha + "' ;"; MySqlCommand commS = new MySqlCommand(sql, Conn.mConn); DataTable dt = Conn.ExecuteQuery(commS); if (dt != null) { int i = 0; while (i < dt.Rows.Count) { classLogin u = new classLogin(); u.codigo = dt.Rows[i][0].ToString(); u.nome = dt.Rows[i][1].ToString(); arr.Add(u); i++; } } return arr; }