//Search Methods: ID public static Book SearchISBN(long isbn) { Book bk = new Book(); StreamReader sReader = new StreamReader(bkFilePath); string line = sReader.ReadLine(); while (line != null) { string[] fields = line.Split(','); if (isbn == Convert.ToInt64(fields[0])) { bk.BkISBN = Convert.ToInt64(fields[0]); bk.BkTitle = fields[1]; bk.BkQOH = Convert.ToInt32(fields[2]); bk.BkDate = Convert.ToDateTime(fields[3]); bk.BkAuthor = AuthorDA.SearchID(Convert.ToInt32(fields[4])); bk.BkCategory = fields[5]; bk.BkPublisher = fields[6]; bk.BkUnitPrice = Convert.ToDecimal(fields[7]); sReader.Close(); return(bk); } line = sReader.ReadLine(); } sReader.Close(); return(null); }
//List Method public static void ListBooks(ListView listview) { listview.Items.Clear(); StreamReader sReader = new StreamReader(bkFilePath); string line = sReader.ReadLine(); while (line != null) { string[] fields = line.Split(','); ListViewItem bk = new ListViewItem(fields[0]); Author aAuthor = AuthorDA.SearchID(Convert.ToInt32(fields[4])); bk.SubItems.Add(fields[1]); bk.SubItems.Add(fields[2]); bk.SubItems.Add(fields[3]); bk.SubItems.Add(aAuthor.AutLastN + ", " + aAuthor.AutFirstN); bk.SubItems.Add(fields[5]); bk.SubItems.Add(fields[6]); bk.SubItems.Add(fields[7]); listview.Items.Add(bk); line = sReader.ReadLine(); } sReader.Close(); }