Exemplo n.º 1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            /* esse pequeno trecho de decisão atribuirá um código ao campo "cod_tipo"
             * dependendo de quem está acessando*/
            if (comboBox.Text == "Aluno")
            {
                texto_invisivel.Text = "1";
            }
            if (comboBox.Text == "Professor")
            {
                texto_invisivel.Text = "2";
            }

            string        strcon  = "Data Source=tcp:geasy.database.windows.net;Initial Catalog=Geasy;Persist Security Info=True;User ID=gustavo.peixinho;Password=Dfg654321";
            SqlConnection conexao = new SqlConnection(strcon);
            SqlCommand    cmd2    = new SqlCommand("Select * from  Usuario where cod_tipo=" + int.Parse(texto_invisivel.Text) + " and Nome_Usuario='" + this.login.Text + "' and Senha_Usuario='" + this.senha.Text + "';", conexao);
            SqlDataReader leitor;

            conexao.Open();
            leitor = cmd2.ExecuteReader();
            int contador = 0;

            while (leitor.Read())
            {
                contador++;
            }
            if (contador == 1)
            {
                if (comboBox.Text == "Aluno")
                {
                    MessageBox.Show("passou aluno");
                }
                else
                {
                    Main M = new Main();
                    M.Show();
                }
            }
            else
            {
                Dados_Nao_Cadastrados D = new Dados_Nao_Cadastrados();
                D.Show();
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (Validacao.ValidaCPF.IsCpf(txt2.Text))
            {
                string        strcon  = "Data Source=tcp:geasy.database.windows.net;Initial Catalog=Geasy;Persist Security Info=True;User ID=gustavo.peixinho;Password=Dfg654321";
                SqlConnection conexao = new SqlConnection(strcon);
                SqlCommand    cmd2    = new SqlCommand("Select * from Usuario where Email='" + this.txt1.Text + "' and CPF='" + this.txt2.Text + "';", conexao);
                SqlDataReader leitor;
                conexao.Open();
                leitor = cmd2.ExecuteReader();
                int contador = 0;
                while (leitor.Read())
                {
                    contador++;
                }
                if (contador == 1)
                {
                    MessageBox.Show("Dados Válidos");
                    botao_recuperar.Visibility     = Visibility.Visible;
                    Nova_Senha_TxtBlock.Visibility = Visibility.Visible;
                    Nova_Senha_txtbox.Visibility   = Visibility.Visible;
                    txt1.IsEnabled         = false;
                    txt2.IsEnabled         = false;
                    button1_Copy.IsEnabled = false;
                }

                else
                {
                    Dados_Nao_Cadastrados D = new Dados_Nao_Cadastrados();
                    D.Show();
                }
            }
            else
            {
                CPF_Invalido C = new CPF_Invalido();
                C.Show();
            }
        }