private void btnReserve_Click(object sender, RoutedEventArgs e) { ModelObjBook selectedRow = (ModelObjBook)dtagrdBooks.SelectedItem; int selectedPKey = selectedRow.pkey; ControllerBook C_ControllerBook = new ControllerBook(); bool bookAvaiable = C_ControllerBook.bookAvaiable(selectedPKey); if (bookAvaiable == true) { } else { MessageBox.Show("Book already reserved", "Book reservation", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
public List <ModelObjBook> getBooks(string t_name) { string dbHost = "LOCALHOST"; string databaseName = "Librarysystem"; // Connection string DataContext dbLibrarysystem = new DataContext("Server=" + dbHost + "\\SQLEXPRESS;Database=" + databaseName + ";Connection timeout=30;Integrated Security=True"); Table <ModelMapping.tblBook> tblBookGet = dbLibrarysystem.GetTable <ModelMapping.tblBook>(); var returnList = new List <ModelObjBook>(); var returnListFinal = new List <ModelObjBook>(); //Auswerten der typisierten Liste var tblBookValues = from my_val in tblBookGet select my_val; foreach (var value in tblBookValues) { var book = new ModelObjBook(value.PKey_1, value.Name, value.ISBN, value.Author, value.Publisher); returnList.Add(book); } if (t_name != "All") { foreach (var value in returnList) { if (value.name == t_name || value.isbn == t_name || value.author == t_name || value.publisher == t_name) { var book = new ModelObjBook(value.pkey, value.name, value.isbn, value.author, value.publisher); returnListFinal.Add(book); } } return(returnListFinal); } else { return(returnList); } }