Question
In this Visual Basic exercise, youll add a class to an Inventory Maintenance application and then add code to the two forms that use this
In this Visual Basic exercise, youll add a class to an Inventory Maintenance application and then add code to the two forms that use this class.
Open the project and add an InvItem class 8. Open the InventoryMaintenance project in the Extra Exercises\InventoryMaintenance directory. Then, review the existing code for both of the forms so you get an idea of how this application should work. 9. Add a class named InvItem to this project, and add the properties, method, and constructors that are shown in the table below.
Add code to implement the New Item form 10. Display the code for the New Item form, and declare a class variable named invItem of type InvItem with an initial value of null. 11. Add a public method named GetNewItem that displays the form as a dialog box and returns an InvItem object. 12. Add code to the btnSave_Click event handler that creates a new InvItem object and closes the form if the data is valid. Add code to implement the Inventory Maintenance form 13. Display the code for the Inventory Maintenance form, and declare a class variable named invItems of type List
frmInvMaint code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace InventoryMaintenance
{
public partial class frmInvMaint : Form
{
public frmInvMaint()
{
InitializeComponent();
}
// Add a statement here that declares the list of items.
private void frmInvMaint_Load(object sender, EventArgs e)
{
// Add a statement here that gets the list of items.
FillItemListBox();
}
private void FillItemListBox()
{
lstItems.Items.Clear();
// Add code here that loads the list box with the items in the list.
}
private void btnAdd_Click(object sender, EventArgs e)
{
// Add code here that creates an instance of the New Item form
// and then gets a new item from that form.
}
private void btnDelete_Click(object sender, EventArgs e)
{
int i = lstItems.SelectedIndex;
if (i != -1)
{
// Add code here that displays a dialog box to confirm
// the deletion and then removes the item from the list,
// saves the list of products, and refreshes the list box
// if the deletion is confirmed.
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
frmNewItem code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace InventoryMaintenance { public partial class frmNewItem : Form { public frmNewItem() { InitializeComponent(); }
// Add a statement here that declares the inventory item.
// Add a method here that gets and returns a new item.
private void btnSave_Click(object sender, EventArgs e) { if (IsValidData()) { // Add code here that creates a new item // and closes the form. } }
private bool IsValidData() { return Validator.IsPresent(txtItemNo) && Validator.IsInt32(txtItemNo) && Validator.IsPresent(txtDescription) && Validator.IsPresent(txtPrice) && Validator.IsDecimal(txtPrice); }
private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } } }
Below is a link with the project folder:
https://ufile.iovoga
Inventory Maintenance 3245649 3762592 9210584 4738459 Agapanthus ($7.95) Limonium ($6.95) Snail pellets ($12.95) Japanese Red Maple (S89.95) Add tem... Delete Item... Exit Inventory Maintenance 3245649 3762592 9210584 4738459 Agapanthus ($7.95) Limonium ($6.95) Snail pellets ($12.95) Japanese Red Maple (S89.95) Add tem... Delete Item... ExitStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started