public Equipage[] Equipage() { Equipage[] valiny = new Equipage[100]; Connexion con = new Connexion(); SqlConnection conn = con.ConnectToSql(); conn.Open(); SqlCommand cmd; SqlDataReader reader; string requete = ("select * from Mpiasa order by id ASC"); cmd = new SqlCommand(requete, conn); reader = cmd.ExecuteReader(); for (int i = 0; reader.Read(); i++) { String id = reader["id"].ToString(); String nom = reader["nom"].ToString(); String poste = reader["poste"].ToString(); String sexe = reader["sexe"].ToString(); float salaire = float.Parse(reader["salaire"].ToString()); valiny[i] = new Equipage(id, nom, poste, sexe, salaire); } reader.Close(); cmd.Dispose(); conn.Close(); return(valiny); }
void Button12Click(object sender, EventArgs e) { VolDao medoc = new VolDao(); Equipage me = new Equipage(textBox16.Text, textBox15.Text, textBox5.Text, textBox14.Text, float.Parse(textBox11.Text)); medoc.insertEquipage(me); }
void Button10Click(object sender, EventArgs e) { VolDao vol = new VolDao(); Equipage[] volavo = new Equipage[100]; try{ volavo = vol.Equipage(); this.dataGridView9.Rows.Clear(); for (int i = 0; i < volavo.Length; i++) { this.dataGridView9.Rows.Add(volavo[i].getnom().ToString(), volavo[i].getposte().ToString(), volavo[i].getsexe().ToString(), volavo[i].getsalaire().ToString("#,##0") + " €"); } }catch (Exception ex) { } }
public void insertEquipage(Equipage medoc) { try{ Connexion con = new Connexion(); SqlConnection conn = con.ConnectToSql(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; conn.Open(); cmd.CommandText = "insert into mpiasa values('" + medoc.getid() + "','" + medoc.getnom() + "','" + medoc.getposte() + "','" + medoc.getsexe() + "','" + medoc.getsalaire() + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Insertion reussit"); conn.Close(); } catch (Exception e) { Console.Out.Write(e.Message); } }