public void LoanBook(string isbn, int copy, string uId) // Låna en bok { BibliotechDAL bd = new BibliotechDAL(); Loan loan = new Loan(isbn, copy, uId); if (bd.CheckAvailability(isbn, copy) == 0) { bd.AddNewLoan(loan); } else { MessageBox.Show("Boken är redan utlånad"); } }
private void btn_userloan_Click(object sender, EventArgs e) { int i = grid_results.CurrentRow.Index; string isbn = grid_results["Isbn", i].Value.ToString(); int copy = (int)grid_results["CopyNbr", i].Value; BibliotechController bc = new BibliotechController(); BibliotechDAL bd = new BibliotechDAL(); int s = bd.CheckAvailability(isbn, copy); if (s == 1) { MessageBox.Show("Boken är utlånad"); } else { bc.LoanBook(isbn, copy, us.UserId); ShowLoans(); } }
private void btn_delbook_Click(object sender, EventArgs e) // Button Delete book { int i = grid_results_adm.CurrentRow.Index; string isbn = grid_results_adm["Isbn", i].Value.ToString(); int copy = (int)grid_results_adm["CopyNbr", i].Value; BibliotechDAL bd = new BibliotechDAL(); int s = bd.CheckAvailability(isbn, copy); if (s == 1) { MessageBox.Show("Går ej att radera, boken är lånad"); } else { bd.DeleteBook(isbn, copy); FillViewBooks(); } }