示例#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();
            }
        }
示例#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();
            }
        }
        private void cmbsorder_SelectedIndexChanged(object sender, EventArgs e)
        {
            int so_no = Convert.ToInt32(cmbsorder.SelectedItem);
            DBSales_Item_reference si = new DBSales_Item_reference();

            DR = si.getItems(so_no);
            int    itemno;
            String itemname = "";

            while (DR.Read())
            {
                itemno = Convert.ToInt32(DR[0]);
                DBItem i = new DBItem();
                DR2 = i.getName(itemno);
                while (DR2.Read())
                {
                    itemname = DR2[0].ToString();
                }
                cmbitemname.Items.Add(itemname);
            }
        }
示例#4
0
        private void btn_pesquisar_Click_1(object sender, EventArgs e)
        {
            //PESQUISA DO DONO PELO SEU RG
            if (txt_rgDono.Text != "")
            {
                //Pesquisando Dono
                string        pesquisa = "SELECT * FROM TB_DONO WHERE RG = '" + txt_rgDono.Text + "'";
                SqlCommand    cmd      = new SqlCommand(pesquisa, DataBase.obterConexao());
                SqlDataReader DR;

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

                    if (DR.Read())
                    {
                        //Campos do Dono
                        txt_nome_dono.Text   = DR.GetValue(1).ToString();
                        txt_sobrenome.Text   = DR.GetValue(2).ToString();
                        txt_bairro.Text      = DR.GetValue(3).ToString();
                        txt_rua.Text         = DR.GetValue(4).ToString();
                        txt_num.Text         = DR.GetValue(5).ToString();
                        txt_complemento.Text = DR.GetValue(6).ToString();
                        txt_rg.Text          = DR.GetValue(7).ToString();
                        txt_telefone.Text    = DR.GetValue(8).ToString();

                        //Exibições dos botões
                        btn_cadastrar.Visible = false;
                        btn_cna.Visible       = true;
                        btn_alterar.Enabled   = true;
                        btn_excluir.Enabled   = true;

                        //Limpando Dados do Animal caso tem ocorrido alguma pesquisa anteriormente pelo protocolo
                        txt_animal.Text           = "";
                        lbl_exp_protocolo.Text    = "";
                        lbl_exp_protocolo.Visible = false;
                        cbo_esp.Text             = "";
                        cbo_raca.Text            = "";
                        txt_data_nascimento.Text = "";
                        cbo_vacinado.Text        = "";
                        cbo_castrado.Text        = "";
                        cbo_port.Text            = "";
                    }
                    else
                    {
                        MessageBox.Show("Registros do Dono não encontrados", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        //Limpando o objeto da pesquisa (txt_rgDono)
                        txt_rgDono.Text = "";

                        //Voltanco ao foco incial (Objeto txt_nome_dono)
                        txt_nome_dono.Focus();
                    }
                    DR.Close();
                    cmd.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DataBase.fecharConexao();
                }
            }

            //PESQUISA DO ANIMAL PELO SEU PROTOCOLO
            if (txt_protocolo.Text != "")
            {
                //Pesquisando Animal
                string        pesquisa = "SELECT * FROM TB_ANIMAL WHERE PROTOCOLO_ANIMAL = '" + txt_protocolo.Text + "'";
                SqlCommand    cmd2     = new SqlCommand(pesquisa, DataBase.obterConexao());
                SqlDataReader DR2;

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

                    if (DR2.Read())
                    {
                        //Campos do Animal
                        txt_animal.Text          = DR2["NOME_ANIMAL"].ToString();
                        lbl_protocolo.Visible    = false;
                        cbo_esp.Text             = DR2["ESPECIE"].ToString();
                        cbo_raca.Text            = DR2["RACA"].ToString();
                        cbo_vacinado.Text        = DR2["VACINADO"].ToString();
                        cbo_castrado.Text        = DR2["CASTRADO"].ToString();
                        txt_data_nascimento.Text = DR2["DATA_NASCIMENTO"].ToString();
                        cbo_port.Text            = DR2["PORTE"].ToString();

                        //Exibições dos botões
                        btn_cadastrar.Visible = false;
                        btn_cna.Visible       = false;
                        btn_alterar.Enabled   = true;
                        btn_excluir.Enabled   = true;
                    }
                    else
                    {
                        MessageBox.Show("Registros do Animal não encontrados", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        //Limpando o objeto da pesquisa (txt_protocolo)
                        txt_protocolo.Text = "";

                        //Voltanco ao foco incial (Objeto txt_nome_dono)
                        txt_nome_dono.Focus();
                    }
                    DR2.Close();
                    cmd2.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DataBase.fecharConexao();
                }
            }

            else if (txt_rgDono.Text == "" && txt_protocolo.Text == "")
            {
                txt_rgDono.Focus();
                MessageBox.Show("Por favor, informe o RG do Dono ou o Protocolo do Animal", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }