public static void readSoldBooksFromFile(TwoWayLinkedList soldBooks) { StreamReader sr = new StreamReader("soldBookFile.txt"); for (int i = 0; !sr.EndOfStream; i++) { Book temp = new Book(); temp.BookName = sr.ReadLine(); temp.WriterName = sr.ReadLine(); temp.PublicationYear = Convert.ToInt32(sr.ReadLine()); temp.Price = Convert.ToInt32(sr.ReadLine()); soldBooks.InsertAtBack(temp); sr.ReadLine();//baraye rad kardane yek khat setare } sr.Close(); }
private void btn_buy_Click(object sender, RoutedEventArgs e) { try { int index = new int(); index = listBox_books.SelectedIndex; listBox_boughtBooks.Items.Add(listBox_books.Items.GetItemAt(listBox_books.SelectedIndex)); listBox_books.Items.RemoveAt(listBox_books.SelectedIndex); Book temp = (Book)books.RemoveAt(listBox_books.SelectedIndex); FoundPerson.ShoppingBag.pushBack(temp); soldBooks.InsertAtBack(temp); } catch (ArgumentOutOfRangeException) { MessageBox.Show("لطفا یک کتاب انتخاب کنید."); } }