/// <summary> /// Adds issues to an observable collection for each entry int the database /// </summary> /// <param name="ID">The ID of the selected series. Acts as a foreign key</param> #region Update Listview Issues public void UpdateListviewIssues(int ID) { //Clears listViewIssues if entries already exist if (listViewIssues.Count > 0) { listViewIssues.Clear(); } //Uses strSQL to select all entries and adds them to listViewIssues string strSQL = $"SELECT * FROM Issues WHERE SeriesID = '{ID}'"; using (var ctx = new ComicsContext()) { var Issues = ctx.Issues.SqlQuery(strSQL); foreach (Issues i in Issues) { ClassComics CC = new ClassComics(i); CC.IssuesData = i; listViewIssues.Add(CC); } } }
/// <summary> /// Finds entries in the table issues matching the search query. Int version /// </summary> /// <param name="strSearch">The search query used</param> public void SearchIssues(int intSearch) { //Checks if items are already present in listViewIssues and clears if true if (listViewIssues.Count > 0) { listViewIssues.Clear(); } //Uses strSQL to find all entries related to the search query and adds them to listViewIssues string strSQL = $"SELECT * FROM Issues WHERE ((intNumber LIKE '%{intSearch}%') OR (dtDate LIKE '%{intSearch}%'))"; using (var ctx = new ComicsContext()) { var issue = ctx.Issues.SqlQuery(strSQL); foreach (Issues i in issue) { ClassComics CC = new ClassComics(i); CC.IssuesData = i; listViewIssues.Add(CC); } } }
/// <summary> /// Adds series to an observable collection for each entry in the database /// </summary> #region Update Listview Series public void UpdateListviewSeries() { //Clears listViewSeries if entries already exist if (listViewSeries.Count > 0) { listViewSeries.Clear(); } //Uses strSQL to select all entries and adds them to listViewSeries string strSQL = "SELECT * FROM Series"; using (var ctx = new ComicsContext()) { var Series = ctx.Series.SqlQuery(strSQL); foreach (Series s in Series) { ClassComics CC = new ClassComics(s); CC.SeriesData = s; listViewSeries.Add(CC); } } }
/// <summary> /// Finds entries in the table series matching the search query. Int version /// </summary> /// <param name="strSearch">The search query used</param> public void SearchSeries(int intSearch) { //Checks if items are already present in listViewSeries and clears if true if (listViewSeries.Count > 0) { listViewSeries.Clear(); } //Uses strSQL to find all entries related to the search query and adds them to listViewSeries string strSQL = $"SELECT * FROM Series WHERE ((intCollIss LIKE '%{intSearch}%') OR (intYear LIKE '%{intSearch}%'))"; using (var ctx = new ComicsContext()) { var series = ctx.Series.SqlQuery(strSQL); foreach (Series s in series) { ClassComics CC = new ClassComics(s); CC.SeriesData = s; listViewSeries.Add(CC); } } }