public static ObservableCollection <LotDAO> selectLots() { ObservableCollection <LotDAO> l = new ObservableCollection <LotDAO>(); string query = "SELECT * FROM lot;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataReader reader = null; try { cmd.ExecuteNonQuery(); reader = cmd.ExecuteReader(); while (reader.Read()) { LotDAO p = new LotDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2)); l.Add(p); } } catch (Exception e) { MessageBox.Show("Il y a un problème dans la table Lot : {0}", e.StackTrace); } reader.Close(); return(l); }
public static LotViewModel getLot(int idLot) { LotDAO lDAO = LotDAO.getLot(idLot); LotViewModel p = new LotViewModel(lDAO.idLotDAO, lDAO.nomLotDAO, lDAO.descriptionLotDAO); return(p); }
public static void updateLot(LotDAO p) { string query = "UPDATE lot set nomLot=\"" + p.nomLotDAO + "\", descriptionLot=\"" + p.descriptionLotDAO + "\" where idLot=" + p.idLotDAO + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); }
public static void insertLot(LotDAO p) { int id = getMaxIdLot() + 1; string query = "INSERT INTO lot VALUES (\"" + id + "\",\"" + p.nomLotDAO + "\",\"" + p.descriptionLotDAO + "\");"; MySqlCommand cmd2 = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2); cmd2.ExecuteNonQuery(); }
public static ObservableCollection <LotViewModel> listeLots() { ObservableCollection <LotDAO> lDAO = LotDAO.listeLots(); ObservableCollection <LotViewModel> l = new ObservableCollection <LotViewModel>(); foreach (LotDAO element in lDAO) { LotViewModel p = new LotViewModel(element.idLotDAO, element.nomLotDAO, element.descriptionLotDAO); l.Add(p); } return(l); }
public static LotDAO getLot(int idLot) { string query = "SELECT * FROM lot WHERE id=" + idLot + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); LotDAO pers = new LotDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2)); reader.Close(); return(pers); }
public static void insertLot(LotViewModel l) { LotDAO.insertLot(new LotDAO(l.idLotProperty, l.nomLotProperty, l.descriptionLotProperty)); }
public static void supprimerLot(int id) { LotDAO.supprimerLot(id); }
public static void insertLot(LotDAO p) { LotDAL.insertLot(p); }
public static void updateLot(LotDAO p) { LotDAL.updateLot(p); }
public static LotDAO getLot(int idLot) { LotDAO p = LotDAL.getLot(idLot); return(p); }