<big>//Login Form</big> namespace GESTAO_CLINICA { public partial class frmLogin : Form { public frmLogin() { InitializeComponent(); txtsenha.PasswordChar = '*'; } <big>//Button Save</big> private void button2_Click(object sender, EventArgs e) { try { string sql="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=db_Maried;Data Source=TOBE-ANGOLA-PC"; SqlConnection conn=new SqlConnection (sql); SqlCommand cmd = new SqlCommand("select UserName,Senha,TipoConta from tb_login where UserName='" + this.txtUsuario.Text + "'and Senha ='" + this.txtsenha.Text + "' ;", conn); SqlDataReader leitura; conn.Open(); leitura = cmd.ExecuteReader(); int count = 0; while (leitura.Read()) { count = count + 1; } if (count == 1) { this.Hide(); Form1 c = new Form1(txtUsuario.Text); //Principal Form (Desktop) c.ShowDialog(); } else if (count > 1) { //MessageBox.Show("Usuario ou senha Duplicada....Acesso Negado"); label3.Visible = true; label3.Text = "Usuario ou senha Duplicada....Acesso Negado"; } else { //MessageBox.Show ("Usuario ou senha Errada....Por Favor Tente de Novo"); label3.Visible = true; label3.Text = "Usuario ou senha Errada....Por Favor Tente de Novo"; } conn.Close(); } catch (Exception ex) { MessageBox.Show("Erro", ex.Message); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)