/// <summary> /// count the rows of an exitsting item in the DB /// </summary> /// <param name="itemType">type of the item (Book, journal...)</param> /// <param name="item">the item to check in db</param> /// <returns>number of result rows (if 1 so item exist in DB)</returns> private int rowsCount(string itemType, AbstractItem item) { try { cmd = new SqlCommand("select 1 from " + itemType + " where isbn=@ISBN", con); cmd.Parameters.Add("@ISBN", item.Isbn); adpt = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adpt.Fill(ds); int count = ds.Tables[0].Rows.Count; return(count); } catch (Exception ex) { log.LogWrite("Get number of rows by isbn error in table " + itemType); throw new Exception("Get number of rows by isbn error in table " + itemType); } }
public async void ReturnItem(AbstractItem item) { try { if (!(Library.Contains(item))) { throw new InvalidOperationException("Error: item" + item + "does not appear in Library!"); } if (!item.IsBorrowed) { throw new InvalidOperationException("Error: item" + item + "is not borrowed"); } item.IsBorrowed = false; } catch (InvalidOperationException) { await new MessageDialog("Error : cannot return this item, please try another action.").ShowAsync(); } }
public async void UserReturnItem(AbstractItem item, AUser user) { try { if (!item.IsBorrowed) { throw new InvalidOperationException("Item is already returned and in library!"); } else { user.Borrowed.Remove(item); item.IsBorrowed = false; } } catch (InvalidOperationException) { await new MessageDialog("Item is already returned and in library!").ShowAsync(); } }
public void AddItem(AbstractItem item) { if (item is Book) { if (item.Name == "") { MessageDialog showDialog = new MessageDialog("Did not receive input, please try again. "); } Library.Add(item); } else if (item is Journal) { if (item.Name == "") { } MessageDialog showDialog = new MessageDialog("Did not receive input, please try again. "); Library.Add(item); } }
public void RentItem(AbstractItem item) { items.Add(item); }
//ctor public RentItem(AbstractItem item) { _rentedItem = item; _dateOfRent = DateTime.Now.ToString(); }
public static void ReturnItem(AbstractItem item) { item.IsBorrowed = false; }
public static void AddItem(AbstractItem newItem) { newItem.isbn = Guid.NewGuid(); itemList.Add(newItem); }
//rent and return func public static void removeFromRental(User user, AbstractItem item) { rental[user].Remove(item); }
// method which add item to items and update the dictioneries public void AddItem(AbstractItem item) { _items.Add(item); dicISBN.Add(item.ISBN, item); UpdateDicName(item); }