コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUser.Text) || string.IsNullOrEmpty(txtSenha.Text))
            {
                MessageBox.Show("Digite Usuário e Senha!");
                txtUser.Focus();
                return;
            }

            try
            {
                NpgsqlConnection conn = new NpgsqlConnection(connString);
                conn.Open();
                selecao = @"select * from u_loginProfessor(:_usuario,:_senha)";
                cmd     = new NpgsqlCommand(selecao, conn);


                cmd.Parameters.AddWithValue("_usuario", txtUser.Text);
                cmd.Parameters.AddWithValue("_senha", txtSenha.Text);

                int resultado = (int)cmd.ExecuteScalar();

                conn.Close();



                if (resultado == 1)
                {
                    this.Hide();
                    PlanilhasProf planilhaProf = new PlanilhasProf();
                    planilhaProf.Show();
                }
                else
                {
                    MessageBox.Show("Nome ou senha estão incorretos!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            catch (Npgsql.PostgresException erro)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(erro.GetType().ToString());
                sb.AppendLine(erro.Message);
                sb.Append(erro.Statement);
                sb.AppendLine("\n");
                sb.AppendLine(erro.StackTrace);
                MessageBox.Show(sb.ToString());
            }
            //tratamento dos demais erros que podem ocorrer

            catch (Exception erro)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(erro.GetType().ToString());
                sb.AppendLine(erro.Message);
                sb.AppendLine("\n");
                sb.AppendLine(erro.StackTrace);
                MessageBox.Show(sb.ToString());
            }
        }
コード例 #2
0
        private void btnPlAl_Click(object sender, EventArgs e)
        {
            this.Hide();
            PlanilhasProf planilhasProf = new PlanilhasProf();

            planilhasProf.Show();
        }