public List <Jedi> getAllJedi() { List <Jedi> jedis = new List <Jedi>(); DataTable jedis_en_dur = SelectByDataAdapter("SELECT * FROM jedi;"); foreach (DataRow row in jedis_en_dur.Rows) // Loop over the rows. { int jediId = (int)row.ItemArray.ElementAt(0); List <Caracteristique> caracts = new List <Caracteristique>(); DataTable caracts_en_dur = SelectByDataAdapter("SELECT * FROM caracteristic,link_jedi_caracteristic" + " WHERE caracteristic.numcaract = link_jedi_caracteristic.numcaracteristic" + " AND link_jedi_caracteristic.numjedi =" + jediId + ";"); foreach (DataRow row2 in caracts_en_dur.Rows) // Loop over the rows. { caracts.Add(new Caracteristique((int)row2.ItemArray.ElementAt(0), Caracteristique.stringToEDef((string)row2.ItemArray.ElementAt(1)), (string)row2.ItemArray.ElementAt(2), Caracteristique.stringToEType((string)row2.ItemArray.ElementAt(3)), (int)row2.ItemArray.ElementAt(4))); } jedis.Add(new Jedi((int)row.ItemArray.ElementAt(0), (string)row.ItemArray.ElementAt(1), (bool)row.ItemArray.ElementAt(2), caracts)); } return(jedis); }
public List <Stade> getAllStade() { List <Stade> stades = new List <Stade>(); DataTable stade_en_dur = SelectByDataAdapter("SELECT * FROM stade;"); foreach (DataRow row in stade_en_dur.Rows) // Loop over the rows. { int stadeId = (int)row.ItemArray.ElementAt(0); List <Caracteristique> caracts = new List <Caracteristique>(); DataTable caracts_en_dur = SelectByDataAdapter("SELECT * FROM caracteristic,link_stade_caracteristic" + " WHERE caracteristic.numcaract = link_stade_caracteristic.numcaracteristic" + " AND link_stade_caracteristic.numstade =" + stadeId + ";"); foreach (DataRow row2 in caracts_en_dur.Rows) // Loop over the rows. { caracts.Add(new Caracteristique((int)row2.ItemArray.ElementAt(0), Caracteristique.stringToEDef((string)row2.ItemArray.ElementAt(1)), (string)row2.ItemArray.ElementAt(2), Caracteristique.stringToEType((string)row2.ItemArray.ElementAt(3)), (int)row2.ItemArray.ElementAt(4))); } stades.Add(new Stade((int)row.ItemArray.ElementAt(0), (int)row.ItemArray.ElementAt(1), (string)row.ItemArray.ElementAt(2), caracts)); } return(stades); }
public List <Caracteristique> getAllCaracteristic() { List <Caracteristique> caracts = new List <Caracteristique>(); DataTable caracts_en_dur = SelectByDataAdapter("SELECT * FROM caracteristic;"); foreach (DataRow row in caracts_en_dur.Rows) // Loop over the rows. { //STUB caracts.Add(new Caracteristique((int)row.ItemArray.ElementAt(0), Caracteristique.stringToEDef((string)row.ItemArray.ElementAt(1)), (string)row.ItemArray.ElementAt(2), Caracteristique.stringToEType((string)row.ItemArray.ElementAt(3)), (int)row.ItemArray.ElementAt(4))); } return(caracts); }
public Stade getStadeById(int stadeId) { Stade res; List <Stade> stades = new List <Stade>(); DataTable stade_en_dur = SelectByDataAdapter("SELECT * FROM stade WHERE numstade=" + stadeId + ";"); foreach (DataRow row in stade_en_dur.Rows) // Loop over the rows. { List <Caracteristique> caracts = new List <Caracteristique>(); DataTable caracts_en_dur = SelectByDataAdapter("SELECT * FROM caracteristic,link_stade_caracteristic" + " WHERE caracteristic.numcaract = link_stade_caracteristic.numcaracteristic" + " AND link_stade_caracteristic.numstade =" + stadeId + ";"); foreach (DataRow row2 in caracts_en_dur.Rows) // Loop over the rows. { caracts.Add(new Caracteristique((int)row2.ItemArray.ElementAt(0), Caracteristique.stringToEDef((string)row2.ItemArray.ElementAt(1)), (string)row2.ItemArray.ElementAt(2), Caracteristique.stringToEType((string)row2.ItemArray.ElementAt(3)), (int)row2.ItemArray.ElementAt(4))); } stades.Add(new Stade((int)row.ItemArray.ElementAt(0), (int)row.ItemArray.ElementAt(1), (string)row.ItemArray.ElementAt(2), caracts)); } try { res = stades[0]; } catch (Exception) { throw new Exception("Stade ID doesn't exist !"); } return(res); }
private Jedi getJediById(int jediId) { Jedi res; List <Jedi> jedis = new List <Jedi>(); DataTable jedis_en_dur = SelectByDataAdapter("SELECT * FROM jedi WHERE numjedi=" + jediId + ";"); foreach (DataRow row in jedis_en_dur.Rows) // Loop over the rows. { List <Caracteristique> caracts = new List <Caracteristique>(); DataTable caracts_en_dur = SelectByDataAdapter("SELECT * FROM caracteristic,link_stade_caracteristic" + " WHERE caracteristic.numcaract = link_stade_caracteristic.numcaracteristic" + " AND link_stade_caracteristic.numcaracteristic =" + jediId + ";"); foreach (DataRow row2 in caracts_en_dur.Rows) // Loop over the rows. { caracts.Add(new Caracteristique((int)row2.ItemArray.ElementAt(0), Caracteristique.stringToEDef((string)row2.ItemArray.ElementAt(1)), (string)row2.ItemArray.ElementAt(2), Caracteristique.stringToEType((string)row2.ItemArray.ElementAt(3)), (int)row2.ItemArray.ElementAt(4))); } jedis.Add(new Jedi((int)row.ItemArray.ElementAt(0), (string)row.ItemArray.ElementAt(1), (bool)row.ItemArray.ElementAt(2), caracts)); } try { res = jedis[0]; } catch (Exception) { throw new Exception("Jedi ID doesn't exist !"); } return(res); }