private void saveNewMedia() { if (validateMedia()) { if (txtMediaType.SelectedIndex == 1) { m = new Media(txtMediaTitle.Text, txtMediaAuthor.Text, MediaType.ADULTBOOK); mediaSD.Add(m.ID, m); } if (txtMediaType.SelectedIndex == 2) { m = new Media(txtMediaTitle.Text,txtMediaAuthor.Text, MediaType.CHILDBOOK); mediaSD.Add(m.ID, m); } if (txtMediaType.SelectedIndex == 3) { m = new Media(txtMediaTitle.Text, txtMediaAuthor.Text,MediaType.DVD); mediaSD.Add(m.ID, m); } if (txtMediaType.SelectedIndex == 4) { m = new Media(txtMediaType.Text,txtMediaAuthor.Text, MediaType.VIDEO); mediaSD.Add(m.ID, m); } MessageBox.Show("Media item '" +txtMediaTitle.Text+"' added successfully!"); UpdateScreens(); ClearAddMediaFields(); } }
/// <summary> /// Purpose: determine media type allowed /// </summary> /// <param name="m">Media</param> /// <returns>bool</returns> public bool allowed(Media m) { if (getAge() < 18 && m.Mtype == MediaType.ADULTBOOK) { MessageBox.Show("Checkout not allowed due to age restriction on Adult Books."); return false; } return true; }
/// <summary> /// Purpose: Check in media/ remove from _checkedout SD /// </summary> /// <param name="media">Media</param> /// <param name="ID">ID</param> public virtual void removeMedia(Media media, uint ID) { if (_currentChecked.Count == 0) { MessageBox.Show(noneChecked); } _currentChecked.Remove(ID); }
/// <summary> /// Purpose: to add media to the _checkedout SortedDictionary (check out) /// </summary> /// <param name="media">Media</param> /// <param name="ID">media ID</param> public virtual void addMedia(Media media, uint ID) { if(_currentChecked.Count <= _maxCheckouts) { _currentChecked.Add(ID, media); } else { MessageBox.Show("You have reached the maximum(" + _maxCheckouts + ") number of checkouts allowed\n"); } }