public static void addEtude(DAOEtude etude) { string query = "INSERT INTO etude VALUES (\"" + etude.idEtudeDAO + "\",\"" + etude.nomEtudeDAO + "\",\"" + etude.dateDAO + "\",\"" + etude.idPersonneDAO + "\");"; MySqlCommand command = new MySqlCommand(query, DALConnection.Connection()); MySqlDataAdapter dataAdapter = new MySqlDataAdapter(command); command.ExecuteNonQuery(); }
public static EtudeViewModel getEtude(int id) { DAOEtude daoetude = DAOEtude.getEtude(id); int idPersonne = daoetude.idPersonneDAO; PersonneViewModel personne = ORMPersonne.getPersonne(idPersonne); EtudeViewModel etude = new EtudeViewModel(daoetude.idEtudeDAO, daoetude.nomEtudeDAO, daoetude.dateDAO, personne); return(etude); }
public static DAOEtude getEtude(int id) { string query = "SELECT * FROM etude WHERE idEtude = " + id + ";"; MySqlCommand command = new MySqlCommand(query, DALConnection.Connection()); command.ExecuteNonQuery(); MySqlDataReader reader = command.ExecuteReader(); reader.Read(); DAOEtude etude = new DAOEtude(reader.GetInt32(0), reader.GetString(1), reader.GetDateTime(2), reader.GetInt32(3)); reader.Close(); return(etude); }
public static ObservableCollection <EtudeViewModel> listeEtudes() { ObservableCollection <DAOEtude> listeDAO = DAOEtude.listeEtudes(); ObservableCollection <EtudeViewModel> listeEtudes = new ObservableCollection <EtudeViewModel>(); foreach (DAOEtude item in listeDAO) { int idPersonne = item.idPersonneDAO; PersonneViewModel personneID = ORMPersonne.getPersonne(idPersonne); EtudeViewModel etude = new EtudeViewModel(item.idEtudeDAO, item.nomEtudeDAO, item.dateDAO, personneID); listeEtudes.Add(etude); } return(listeEtudes); }
public static ObservableCollection <DAOEtude> selectEtudes() { ObservableCollection <DAOEtude> listeEtudes = new ObservableCollection <DAOEtude>(); string query = "SELECT * FROM etude;"; MySqlCommand command = new MySqlCommand(query, DALConnection.Connection()); try { command.ExecuteNonQuery(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { DAOEtude etude = new DAOEtude(reader.GetInt32(0), reader.GetString(1), reader.GetDateTime(2), reader.GetInt32(3)); listeEtudes.Add(etude); } reader.Close(); } catch (Exception e) { MessageBox.Show("Une erreur est survenue impossible de continuer..."); } return(listeEtudes); }
public static void addEtude(EtudeViewModel etude) { DAOEtude.addEtude(new DAOEtude(etude.idEtudeProperty, etude.nomEtudeProperty, etude.dateEtudeProperty, etude.idPersonne.idPersonneProperty)); }