Example #1
0
        private void lblCadastrar_Click(object sender, EventArgs e)
        {
            this.Hide();
            FrmCadastro fc = new FrmCadastro();

            fc.ShowDialog();
            if (FrmCadastro.cadastro_SUCCESS)
            {
                this.Hide();
                selecionarTeclado = new SelectKeyboard();
                selecionarTeclado.Show();
            }
            else
            {
                this.Show();
            }
        }
Example #2
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            try
            {
                //--Abrindo a conexão
                if (conexão_SQL.State != ConnectionState.Open)
                {
                    conexão_SQL.Open();
                }

                //--Criando um comando SELECT e chamando sua resposta
                String select_usuario = "SELECT senha FROM tblCliente WHERE usuario='" + txtEntrar.Text + "'";
                comando_SQL = new SqlCommand(select_usuario, conexão_SQL);
                SqlDataReader resposta_usuario = comando_SQL.ExecuteReader();

                //--Checando se houve algum valor que retornou
                if (resposta_usuario.HasRows)
                {
                    resposta_usuario.Close();
                    try
                    {
                        //--Abrindo a conexão
                        if (conexão_SQL.State != ConnectionState.Open)
                        {
                            conexão_SQL.Open();
                        }

                        //--Criando um comando SELECT e chamando sua resposta
                        String select = "SELECT senha FROM tblCliente WHERE usuario='" + txtEntrar.Text + "'";
                        comando_SQL = new SqlCommand(select, conexão_SQL);
                        SqlDataReader resposta = comando_SQL.ExecuteReader();

                        //--Checando se houve algum valor que retornou
                        if (resposta.HasRows)
                        {
                            //--Lendo a resposta
                            resposta.Read();

                            //Para pegar os valores, trate a resposta como uma Array
                            if (resposta[0].ToString().Equals(txtSenha.Text))
                            {
                                Conexao.nome_usuario = txtEntrar.Text;
                                selecionarTeclado    = new SelectKeyboard();
                                selecionarTeclado.Show();
                                this.Hide();
                            }
                            else
                            {
                                pnlQueDesce.Location = new Point(854, 482);
                                lblAviso.Text        = "A senha está incorreta.";
                                lblAviso.Visible     = true;
                                resposta.Close();
                            }
                        }
                        else
                        {
                            pnlQueDesce.Location = new Point(854, 482);
                            lblAviso.Text        = "A senha está incorreta.";
                            lblAviso.Visible     = true;
                            resposta.Close();
                        }

                        //--Fechando a conexão
                        conexão_SQL.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        conexão_SQL.Close();
                    }
                }
                else
                {
                    pnlQueDesce.Location = new Point(854, 482);
                    lblAviso.Text        = "Este usuário não existe.";
                    lblAviso.Visible     = true;
                    resposta_usuario.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                conexão_SQL.Close();
            }
        }