public SendEmail(Form1 _f1) { InitializeComponent(); f1 = _f1; customers = CustomerActiveRecord.Find(); rentals = RentalActiveRecord.Find(); for (int i = 0; i < customers.Count; i++) { bool remove = true; foreach (RentalActiveRecord rental in rentals) { if (rental.ReturnDate == null && rental.Customer.ID == customers[i].ID) { remove = false; break; } } if (remove) { customers.RemoveAt(i); } } if (customers.Count == 0) { MessageBox.Show("V databazi neexistuje zakaznik s aktivni vypujckou."); f1.Show(); this.Hide(); } }
private void b_ukoncit_Click(object sender, EventArgs e) { RentalActiveRecord returned = (RentalActiveRecord)cb_rentals.SelectedItem; List <BookInRentalActiveRecord> booksInRental = BookInRentalActiveRecord.Find(); for (int i = 0; i < booksInRental.Count; i++) { if (!(booksInRental[i].Rental.ID == returned.ID)) { booksInRental.RemoveAt(i); } } foreach (BookInRentalActiveRecord b in booksInRental) { b.Book.Available += 1; b.Book.Save(); } returned.ReturnDate = DateTime.Now; returned.Vraceno = true; returned.Save(); f1.Show(); this.Hide(); }
public IActionResult RentalList() { Dictionary <RentalActiveRecord, List <BookActiveRecord> > rentalDictionary = new Dictionary <RentalActiveRecord, List <BookActiveRecord> >(); List <RentalActiveRecord> rentals = RentalActiveRecord.Find(); List <RentalActiveRecord> customerRentals = new List <RentalActiveRecord>(); List <BookInRentalActiveRecord> booksInRental = BookInRentalActiveRecord.Find(); foreach (RentalActiveRecord rental in rentals) { if (rental.Customer.ID == Var.zakaznik.ID) { customerRentals.Add(rental); } } foreach (RentalActiveRecord rental in customerRentals) { List <BookActiveRecord> tmpBooks = new List <BookActiveRecord>(); foreach (BookInRentalActiveRecord book in booksInRental) { if (book.Rental.ID == rental.ID) { tmpBooks.Add(BookActiveRecord.Find((int)book.Book.ID)); } } rentalDictionary.Add(rental, tmpBooks); } ViewBag.Rentals = rentalDictionary; return(View()); }
public IActionResult Extend(ExtendForm form) { RentalActiveRecord rental = RentalActiveRecord.Find(form.id); rental.Extended = true; rental.Save(); return(RedirectToAction("RentalList", "Home")); }
private void button1_Click(object sender, EventArgs e) { List <BookActiveRecord> knihy = BookActiveRecord.Find(); List <LibrarianActiveRecord> knihovnici = LibrarianActiveRecord.Find(); List <CustomerActiveRecord> zakaznici = CustomerActiveRecord.Find(); List <RentalActiveRecord> vypujcky = RentalActiveRecord.Find(); List <BookInRentalActiveRecord> knihyVeVypujce = BookInRentalActiveRecord.Find(); List <AuthorActiveRecord> autori = AuthorActiveRecord.Find(); AddBook addBookForm = new AddBook(this); addBookForm.Show(); this.Hide(); }
public ReturnRental(Form1 _f1) { InitializeComponent(); f1 = _f1; rentals = RentalActiveRecord.Find(); for (int i = 0; i < rentals.Count; i++) { if (rentals[i].Vraceno == true) { rentals.RemoveAt(i); } } cb_rentals.DataSource = rentals; }
private void button2_Click(object sender, EventArgs e) { RentalActiveRecord rental = new RentalActiveRecord(Var.knihovnik, (CustomerActiveRecord)cb_zakaznik.SelectedItem, DateTime.Now, null, false); rental.Save(); foreach (BookActiveRecord b in booksToRent) { BookInRentalActiveRecord tmp = new BookInRentalActiveRecord(b, rental); tmp.Save(); b.Available -= 1; b.Save(); } f1.Show(); this.Hide(); }