//the search methood that check the name or the ISBN public bool GetObject(int type, TextBox text, TextBlock infotext, TextBlock bookName, Button Rent) { if (type == 0)// 0 == search by name { a = item[text.Text]; if (a != null) { infotext.Text = a.ToString(); bookName.Text = a.Name; Rent.IsEnabled = true; return(true); } } else if (type == 1) //1 == search by ISBN { Guid d; bool b = Guid.TryParse(text.Text, out d); if (b) { a = item[d]; if (a != null) { infotext.Text = a.ToString(); bookName.Text = a.Name; return(true); } } return(false); } return(false); }
//rent methood, throw mesaage every step that refort waht goes wrong public bool RentBook(double money, TextBlock info, User user) { if (a.getCopies() <= 0) { throw new Exception("Not in stock!"); } if (money == -1) { throw new Exception("Please enter money only!"); } if (money < a.getDiscountPrice()) { throw new Exception("Please enter enought money!"); } // if this pass all the conditions he rentable a.ReduceCopyAmount(); //remove copy from our list info.Text = a.ToString(); //print the current detail's user.RentItem(a); //add the item to list of the user BookLib.ItemCollection.addToRental(user, a); //add to the Dictionary that manage the rentel return(true); }
// Show private void ShowAddCopiesControllers() { // disable id-textbox and continue-button idTbx.IsEnabled = false; addItemBtn.IsEnabled = false; // show messages that item exist if (_foundedItem != null) { errorTbl.Text = "The item is already exist"; foundedItemTbl.Text = _foundedItem.ToString(); } // show add copy part copyTbl.Visibility = Visibility.Visible; minusBtn.Visibility = Visibility.Visible; minusBtn.IsEnabled = false; _numOfcopies = 1; numOfCopiesTbx.Visibility = Visibility.Visible; numOfCopiesTbx.Text = _numOfcopies.ToString(); plusBtn.Visibility = Visibility.Visible; addCopBtn.Visibility = Visibility.Visible; undoBtn.Visibility = Visibility.Visible; }