private void button3_Click_1(object sender, EventArgs e) { try { BEL.Eleve clt = EleveDAO.Get_client_ID(int.Parse(tbID.Text)); tbnom.Text = clt.Nom; tbprenom.Text = clt.Prenom.ToString(); tbadresse.Text = clt.adresse; tbgr.Text = clt.num_gr.ToString(); List <BEL.Eleve> L = new List <BEL.Eleve>(); L.Add(clt); grid_clients.DataSource = L; } catch (Exception) { if (tbID.Text == "") { MessageBox.Show("saisir l'id d'éleve"); } else { MessageBox.Show("Ce éleve n'existe pas"); } } }
public static Eleve Get_client_ID(int id) { string requete = String.Format("select * from eleve where Id={0};", id); OleDbDataReader rd = utils.lire(requete); BEL.Eleve c = new BEL.Eleve(); while (rd.Read()) { c.Id = rd.GetInt32(0); c.Nom = rd.GetString(1); c.Prenom = rd.GetString(2); c.adresse = rd.GetString(3); c.num_gr = rd.GetInt32(4); } utils.Disconnect(); return(c); }
private void button3_Click(object sender, EventArgs e) { try { BEL.Eleve clt = EleveDAO.Get_client_ID(int.Parse(tbID.Text)); tbnom.Text = clt.Nom; tbprenom.Text = clt.Prenom; tbadresse.Text = clt.adresse; tbgr.Text = clt.num_gr.ToString(); List <BEL.Eleve> L = new List <BEL.Eleve>(); L.Add(clt); grid_clients.DataSource = L; } catch (Exception ex) { MessageBox.Show(ex.Message); } }