Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

image text in transcribedimage text in transcribed 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.

image text in transcribed

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 with an initial value of null. 14. Add a statement to the frmInvMaint_Load event handler that uses the GetItems method of the InvItemDB class to load the items list. 15. Add code to the FillItemListBox method that adds the items in the list to the Items list box. Use the GetDisplayText method of the InvItem class to format the item data. 16. Add code to the btnAdd_Click event handler that creates a new instance of the New Item form and executes the GetNewItem method of that form. If the InvItem object thats returned by this method is not null, this event handler should add the new item to the list, call the SaveItems method of the InvItemDB class to save the list, and then refresh the Items list box. Test the application to be sure this event handler works. 17. Add code to the btnDelete_Click event handler that removes the selected item from the list, calls the SaveItems method of the InvItemDB class to save the list, and refreshes the Items list box. Be sure to confirm the delete operation. Then, test the application to be sure this event handler works.

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... Exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

To solve p + 3q = 5z + tan( y - 3x)

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago