Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.Odbc;
- using System.Collections;
- using System.Globalization;
- namespace WinApp_FingerControl
- {
- public partial class Frm_AlterarCliente : Form
- {
- String Informacao = "";
- String TipoInfo = "";
- public Frm_AlterarCliente()
- {
- InitializeComponent();
- }
- private void rdb_Nome_CheckedChanged(object sender, EventArgs e)
- {
- //lbl_Informacao.Text = "Nome:";
- TipoInfo = "Nome";
- }
- private void rdb_RG_CheckedChanged(object sender, EventArgs e)
- {
- //lbl_Informacao.Text = "RG:";
- TipoInfo = "RG";
- }
- private void rdb_CPF_CheckedChanged(object sender, EventArgs e)
- {
- //lbl_Informacao.Text = "CPF:";
- TipoInfo = "CPF";
- }
- private void btn_Procurar_Click(object sender, EventArgs e)
- {
- string Sexo = "";
- string DataFormatada = "";
- //Declara que a informação dentro do text box.
- Informacao = tbx_Informacao.Text;
- //Realiza a conexao com o servidor
- //String de conexao
- string connStr = "Driver={MySQL ODBC 5.2 ANSI Driver}; Server=localhost; Database=db_fingercontrol; User=root; Password=;Option=3";
- OdbcConnection conn = new OdbcConnection(connStr);
- OdbcCommand stringSQL_Login = conn.CreateCommand();
- //String de conexao(codigo SQL)
- stringSQL_Login.CommandText = "SELECT Nome, RG, CPF, Telefone, Endereco, Bairro, Dt_Nasc, Sexo FROM Cliente WHERE " + TipoInfo + " = " + Informacao;
- try
- {
- conn.Open();
- OdbcDataReader reader = stringSQL_Login.ExecuteReader();
- while (reader.Read())
- {
- tbx_Nome.Text = reader["Nome"].ToString();
- tbx_RG.Text = reader["RG"].ToString();
- tbx_CPF.Text = reader["CPF"].ToString();
- tbx_Telefone.Text = reader["Telefone"].ToString();
- tbx_Endereco.Text = reader["Endereco"].ToString();
- tbx_Bairro.Text = reader["Bairro"].ToString();
- DataFormatada = reader["Dt_Nasc"].ToString();
- Sexo = reader["Sexo"].ToString();
- }
- if (Sexo == "Masculino")
- {
- rdb_Masc.Checked = true;
- rdb_Fem.Checked = false;
- }
- else if (Sexo == "Feminino")
- {
- rdb_Masc.Checked = false;
- rdb_Fem.Checked = true;
- }
- //DateTime DataFormato = Convert.ToDateTime(DataFormatada);
- DateTime dt = DateTime.ParseExact(DataFormatada, "dd-MM-yyyy", null);
- label1.Text = dt.ToString();
- //dtp_DtCliente.Value = dt;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex + " Ocorreu um erro na execução do SQL");
- conn.Close();
- }
- }
- private void Frm_AlterarCliente_Load(object sender, EventArgs e)
- {
- rdb_Nome.Checked = true;
- rdb_Masc.Checked = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment