Пример #1
0
 public CadastroRedeiros()
 {
     InitializeComponent();
     conn = new Conexao();
 }
Пример #2
0
        private void btn_buscar_Click(object sender, EventArgs e)
        {
            float devido = 0;
            float pago   = 0;

            if (string.IsNullOrEmpty(txt_codigo.Text.Trim()))
            {
                MessageBox.Show("Digite um código.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_codigo.Focus();
            }
            else
            {
                try
                {
                    Conexao      conn     = new Conexao();
                    MySqlCommand consulta = new MySqlCommand(@"SELECT * FROM tb_prestadores WHERE codigo = @codigo", conn.Conectar());
                    consulta.Parameters.AddWithValue("@codigo", txt_codigo.Text.Trim()).MySqlDbType = MySqlDbType.Int32;
                    MySqlDataReader dr = consulta.ExecuteReader();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            codigo               = int.Parse(dr["codigo"].ToString());
                            nomeprestador        = dr["nome"].ToString();
                            txt_nome.Text        = dr["nome"].ToString();
                            txt_cpf.Text         = dr["cpf"].ToString();
                            txt_telefone.Text    = dr["telefone"].ToString();
                            txt_celular.Text     = dr["celular"].ToString();
                            txt_cep.Text         = dr["cep"].ToString();
                            txt_uf.Text          = dr["uf"].ToString();
                            txt_cidade.Text      = dr["cidade"].ToString();
                            txt_endereco.Text    = dr["endereco"].ToString();
                            txt_numero.Text      = dr["numero"].ToString();
                            txt_bairro.Text      = dr["bairro"].ToString();
                            txt_complemento.Text = dr["complemento"].ToString();
                            txt_banco.Text       = dr["banco"].ToString();
                            txt_tipoconta.Text   = dr["tipoconta"].ToString();
                            txt_agencia.Text     = dr["agencia"].ToString();
                            txt_conta.Text       = dr["conta"].ToString();
                        }

                        conn.Desconectar();
                        devido        = ValorEntregas();
                        pago          = ValorPagamentos();
                        totalareceber = devido - pago;
                        AtualizaSaldo();
                    }
                    else
                    {
                        conn.Desconectar();
                        MessageBox.Show("Não foi encontrado prestador com esse código", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        limpaform();
                    }
                }
                catch (Exception erro)
                {
                    if (MessageBox.Show(erro.Message, "Erro", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                    {
                        btn_buscar_Click(null, null);
                    }
                }
            }
        }