/// <summary> /// Get Articles in database. /// </summary> /// <param name="Id"><b>Id</b>The Id of the Marque to find.</param> public static List <ArticlesModel> SelectByMarque(int RefMarque) { List <ArticlesModel> Articles = new List <ArticlesModel>(); SQLiteConnection Connection = DaoContext.Connection; Connection.Open(); using (SQLiteCommand Cmd = Connection.CreateCommand()) { Cmd.CommandText = @"SELECT * FROM Articles WHERE RefMarque = @RefMarque;"; Cmd.Parameters.AddWithValue("@RefMarque", RefMarque); using (SQLiteDataReader reader = Cmd.ExecuteReader()) { while (reader.Read()) { Articles.Add(new ArticlesModel(reader["RefArticle"].ToString(), reader["Description"].ToString(), SousFamillesDao.SelectByID(int.Parse(reader["RefSousFamille"].ToString())), MarquesDao.SelectByID(int.Parse(reader["RefMarque"].ToString())), int.Parse(reader["PrixHT"].ToString()), int.Parse(reader["Quantite"].ToString()))); } reader.Close(); } } Connection.Close(); return(Articles); }
/// <summary> /// Method used to select a list of articles. /// </summary> public static List <ArticlesModel> SelectAll() { List <ArticlesModel> AllTable = new List <ArticlesModel>(); ArticlesModel Article = null; SQLiteConnection Connection = DaoContext.Connection; Connection.Open(); using (SQLiteCommand Cmd = Connection.CreateCommand()) { Cmd.CommandText = @"SELECT * FROM Articles;"; SQLiteDataReader reader = Cmd.ExecuteReader(); while (reader.Read()) { Article = new ArticlesModel(reader["RefArticle"].ToString(), reader["Description"].ToString(), SousFamillesDao.SelectByID(int.Parse(reader["RefSousFamille"].ToString())), MarquesDao.SelectByID(int.Parse(reader["RefMarque"].ToString())), int.Parse(reader["PrixHT"].ToString()), int.Parse(reader["Quantite"].ToString())); AllTable.Add(Article); } reader.Close(); } Connection.Close(); return(AllTable); }