Ejemplo n.º 1
0
        private void frm_Menu_Load(object sender, EventArgs e)
        {
            string        pesq = "SELECT * FROM TB_DADOS_LOG";
            SqlCommand    cmd2 = new SqlCommand(pesq, DataBase.obterConexao());
            SqlDataReader DR2;

            try
            {
                DataBase.obterConexao();
                DR2 = cmd2.ExecuteReader();

                if (DR2.Read())
                {
                    lbl_nome.Text = DR2.GetValue(0).ToString();
                    lbl_rg.Text   = DR2.GetValue(2).ToString();
                }
                DR2.Close();
                cmd2.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DataBase.fecharConexao();
            }
        }
Ejemplo n.º 2
0
        //Quando formulario é iniciado é selecionado o ultimo protocolo que foi adicionado no banco
        //Quando formulário é iniciado seleciona o usuario logado
        private void frm_Serviços_Load(object sender, EventArgs e)
        {
            //PROTOCOLO
            string        pesquisa = "SELECT * FROM TB_PROTOCOLO";
            SqlCommand    cmd      = new SqlCommand(pesquisa, DataBase.obterConexao());
            SqlDataReader DR;

            try
            {
                DataBase.obterConexao();
                DR = cmd.ExecuteReader();

                if (DR.Read())
                {
                    lbl_prot_ocult.Text = DR.GetValue(0).ToString();
                }
                else
                {
                    MessageBox.Show("Erro para pegar o valor do protocolo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                DR.Close();
                cmd.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DataBase.fecharConexao();
            }

            //USUARIO
            string        pesq = "SELECT * FROM TB_DADOS_LOG";
            SqlCommand    cmd2 = new SqlCommand(pesq, DataBase.obterConexao());
            SqlDataReader DR2;

            try
            {
                DataBase.obterConexao();
                DR2 = cmd2.ExecuteReader();

                if (DR2.Read())
                {
                    txt_rg_func.Text          = DR2.GetValue(2).ToString();
                    lbl_exp_nome_func.Text    = DR2.GetValue(0).ToString();
                    lbl_exp_sbrnome_func.Text = DR2.GetValue(1).ToString();
                }
                DR2.Close();
                cmd2.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DataBase.fecharConexao();
            }
        }