//Preconditions: click Item>Return //Postconditions: pops up dialog box to enter information. then changes books status to not checked out private void returnSubMenuItem1_Click(object sender, EventArgs e) { ReturnItemDialogBox returnDBox = new ReturnItemDialogBox(theLibrary._items); returnDBox.ShowDialog(); theLibrary.ReturnToShelf(returnDBox.ReturnItem); }
//Precondition: return menu item click //Postcondition: show return form and pass data to checkout form private void returnToolStripMenuItem_Click(object sender, EventArgs e) { ReturnForm returnDialog = new ReturnForm(LibraryData.GetItemsList()); DialogResult result; result = returnDialog.ShowDialog(); if (result == DialogResult.OK) { LibraryData.ReturnToShelf(returnDialog.items); } }
// Precondition: Item, Return menu item activated // Postcondition: The Return dialog box is displayed. If data entered // are OK, an item is returned to the library private void returnToolStripMenuItem_Click(object sender, EventArgs e) { // Extra Credit - Only display items that are already checked out List <LibraryItem> checkedOutList; // List of items checked out List <int> checkedOutIndices; // List of index values of items checked out List <LibraryItem> items; // List of library items items = _lib.GetItemsList(); checkedOutList = new List <LibraryItem>(); checkedOutIndices = new List <int>(); for (int i = 0; i < items.Count(); ++i) { if (items[i].IsCheckedOut()) // Checked out { checkedOutList.Add(items[i]); checkedOutIndices.Add(i); } } if ((checkedOutList.Count() == 0)) // Must have checked out items { MessageBox.Show("Must have items to return!", "Return Error"); } else { ReturnForm returnForm = new ReturnForm(checkedOutList); // The return dialog box form DialogResult result = returnForm.ShowDialog(); // Show form as dialog and store result if (result == DialogResult.OK) // Only add if OK { try { int itemIndex; // Index of item from full list of items itemIndex = checkedOutIndices[returnForm.ItemIndex]; // Look up index from full list decimal lateFee = _lib.ReturnToShelf(_lib.GetItemsList()[itemIndex].CallNumber); //Changed to //correspond with the new ReturnToShelf parameters; also assigns the return value to a decimal so //that it can be displayed in a MessageBox MessageBox.Show($"Late Fee: {lateFee:C}"); } catch (ArgumentOutOfRangeException) // This should never happen { MessageBox.Show("Problem with Return Index!", "Return Error"); } } returnForm.Dispose(); // Good .NET practice - will get garbage collected anyway } }
// Precondition: None // Postcondition: Returns items using return form private void returnToolStripMenuItem_Click(object sender, EventArgs e) { ReturnForm retrnForm = new ReturnForm(_lib.GetItemsList()); DialogResult result; result = retrnForm.ShowDialog(); if (result == DialogResult.OK) // Checks out item based on validated user selection { _lib.ReturnToShelf(retrnForm.ItemsValue); MessageBox.Show("You have returned this library item!"); } }
// Precondition: None // Postcondition: Return's the items that the user selects to return from the subform Returnform. private void returnToolStripMenuItem_Click(object sender, EventArgs e) { //sends the items list to the return subform ReturnForm returnForm = new ReturnForm(newLibrary._items); DialogResult result; //holds the dialog result int item; //holds the item index result = returnForm.ShowDialog(); if (result == DialogResult.OK)// Only update if user chose OK from dialog box { item = returnForm.Item; newLibrary.ReturnToShelf(item); } }
//Precondition: Item -> return item is activated //Postcondition: Item is returned private void returnToolStripMenuItem_Click(object sender, EventArgs e) { List <LibraryItem> items; //List of library items List <LibraryPatron> patrons; //List of library patrons items = library.GetItemsList(); patrons = library.GetPatronsList(); ReturnForm returnForm = new ReturnForm(items); //Check out dialog box form DialogResult result = returnForm.ShowDialog(); //Show form as dialog & store the result if (result == DialogResult.OK) { library.ReturnToShelf(returnForm.ItemIndex); } }
// Precondition: None // Postcondition: Opens a Dialog box that will return an item to the library private void returnToolStripMenuItem_Click(object sender, EventArgs e) { ReturnForm Return = new ReturnForm(); // Variable that interacts with the return form foreach (var item in _lib.GetItemsList()) { Return.returnComboBox.Items.Add($"{item.Title},{item.CallNumber}"); } int itemindex; //value that was selected from the form result = Return.ShowDialog(); if (result == DialogResult.OK) { itemindex = Return.returnComboBox.SelectedIndex; _lib.ReturnToShelf(itemindex); } }
// Precondition: The return menu button is clicked. // Postcondition: The library item is returned. // private void returnToolStripMenuItem_Click(object sender, EventArgs e) { List <LibraryItem> checkedoutitems = new List <LibraryItem>(); // A list of checked out items is created DialogResult result; // A dialog result is created // Walking through the library items list to find items that are checked out, // adding each checked-out item to the combo box in the form, // and also adding the item to the list of checked out items. foreach (LibraryItem i in newLibrary._items) { if (i.IsCheckedOut()) { checkedoutitems.Add(i); } } // A return form is created Return returnbox = new Return(checkedoutitems); // Return form is shown result = returnbox.ShowDialog(); if (result == DialogResult.OK) { //this is the item that the user wants to return var selecteditem = checkedoutitems.ElementAt(returnbox.ItemSelected); // Walking thu the library items list to find the item the user wishes to return // and returning it. foreach (LibraryItem i in newLibrary.GetItemsList()) { if (i == selecteditem) { int positionOfSelectedItem = newLibrary.GetItemsList().IndexOf(i); //position of the selected item newLibrary.ReturnToShelf(positionOfSelectedItem); } } } }
//Precondition: none //Postcondition: This will return any books and output the information onto the Return Report. private void returnToolStripMenuItem_Click(object sender, EventArgs e) { Return inputForm = new Return(_lib._items); DialogResult result = inputForm.ShowDialog(); if (result == DialogResult.OK) { string callNo = inputForm.CallNumber; int itemindex = -1; for (int x = 0; x < _lib._items.Count; ++x)//This for loop is used to make sure the user can't return a book that is not checked out. { if (_lib._items[x].CallNumber == callNo) { itemindex = x; } } if (itemindex > -1) { _lib.ReturnToShelf(itemindex); } } }
// Precondition: Item, Return menu item activated // Postcondition: The Return dialog box is displayed. If data entered // are OK, an item is returned to the library private void returnToolStripMenuItem_Click(object sender, EventArgs e) { List <LibraryItem> items; // List of library items items = _lib.GetItemsList(); if ((_lib.GetCheckedOutCount() == 0)) // Must have items to return { MessageBox.Show("Must have items to return!", "Return Error"); } else { ReturnForm returnForm = new ReturnForm(items); // The return dialog box form DialogResult result = returnForm.ShowDialog(); // Show form as dialog and store result if (result == DialogResult.OK) // Only add if OK { _lib.ReturnToShelf(returnForm.ItemIndex); } returnForm.Dispose(); // Good .NET practice - will get garbage collected anyway } }