public void bt_senhaAdm_Click(object sender, EventArgs e) { Locadora_2.GerenteBancoDados obj = new Locadora_2.GerenteBancoDados(); string senha; WindowsFormsApplication3.FmUsuario FmrUsuario = new WindowsFormsApplication3.FmUsuario(); senha = tb_senhaAdm.Text; try { strSql = "SELECT id_user FROM usuario WHERE SENHA = @SENHA"; obj.conectar(); SqlCommand cmd = new SqlCommand(strSql, obj.objCon); cmd.Parameters.Add("@SENHA", SqlDbType.VarChar).Value = senha; SqlDataReader objLeitura = cmd.ExecuteReader(); while (objLeitura.Read()) { label1.Visible = false; label1.Text += objLeitura["id_user"]; if (label1.Text == "1") { Senhalogado = true; this.Dispose(); } } obj.desconectar(); } catch(SqlException) { MessageBox.Show(" ERRO AO CONECTAR AO BANCO DE DADO", "ERRO"); } if (Senhalogado == false) { label1.Text = string.Empty; tb_senhaAdm.Text = string.Empty; MessageBox.Show("VERIFIQUE A SENHA", "ERRO"); Senhalogado = false; } }
private void button3_Click(object sender, EventArgs e) { WindowsFormsApplication3.frmSenhaAdm Verifica = new WindowsFormsApplication3.frmSenhaAdm(); WindowsFormsApplication3.FmUsuario frmusuario = new WindowsFormsApplication3.FmUsuario(); Verifica.ShowDialog(); if (Verifica.Senhalogado) { frmusuario.ShowDialog(); } }