Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. private void btBuscar_Click(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 //aqui é passado uma string para a variavel "int" atraves do txtNome.Text
  6.                 int num = Convert.ToInt32(txtNome2.Text);
  7.                 Clientes c = Banco.buscarClienteNome(num);
  8.  
  9.                 if(c != null)
  10.                 {
  11.                     txtCod2.Text = Convert.ToString(c.codigo);
  12.                     txtBairro2.Text = c.bairro;
  13.                     txtRua2.Text = c.rua;
  14.                     txtNum2.Text = Convert.ToString(c.numero);
  15.                     dateTimePicker1.Value = Convert.ToDateTime(c.dt_nasc);
  16.                     txtTel2.Text = c.telefone;
  17.                     cbStatus2.SelectedIndex = (c.ativo == false) ? 1 : 0;
  18.                 }
  19.                 else
  20.                 {
  21.                     MessageBox.Show("Não deixe o campo 'Nome' vazio.","Buscar Clientes",
  22.                         MessageBoxButtons.OK, MessageBoxIcon.Stop);
  23.                 }
  24.             }
  25.             catch(Exception)
  26.             {
  27.                 MessageBox.Show("Erro","Buscar Clientes", MessageBoxButtons.OK, MessageBoxIcon.Error);
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement