Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help with is c# code, application excersise code i already have is included below COMMENTS ABOVE EACH METHOD SIGNATURE PLEASE InvItemDb// namespace InventoryMaintenance

i need help with is c# code, application excersise
code i already have is included below
COMMENTS ABOVE EACH METHOD SIGNATURE PLEASE image text in transcribed
image text in transcribed
image text in transcribed
InvItemDb//
namespace InventoryMaintenance
{
public static class InvItemDB
{
private const string Path = @"..\..\InventoryItems.xml";
public static List GetItems()
{
// create the list
List items = new List();
// create the XmlReaderSettings object
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;
// create the XmlReader object
XmlReader xmlIn = XmlReader.Create(Path, settings);
// read past all nodes to the first Book node
if (xmlIn.ReadToDescendant("Item"))
{
// create one Product object for each Product node
do
{
InvItem item = new InvItem();
xmlIn.ReadStartElement("Item");
item.ItemNo = xmlIn.ReadElementContentAsInt();
item.Description = xmlIn.ReadElementContentAsString();
item.Price = xmlIn.ReadElementContentAsDecimal();
items.Add(item);
}
while (xmlIn.ReadToNextSibling("Item"));
}
// close the XmlReader object
xmlIn.Close();
return items;
}
public static void SaveItems(List items)
{
// create the XmlWriterSettings object
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = (" ");
// create the XmlWriter object
XmlWriter xmlOut = XmlWriter.Create(Path, settings);
// write the start of the document
xmlOut.WriteStartDocument();
xmlOut.WriteStartElement("Items");
// write each product object to the xml file
foreach (InvItem item in items)
{
xmlOut.WriteStartElement("Item");
xmlOut.WriteElementString("ItemNo", Convert.ToString(item.ItemNo));
xmlOut.WriteElementString("Description", item.Description);
xmlOut.WriteElementString("Price", Convert.ToString(item.Price));
xmlOut.WriteEndElement();
}
// write the end tag for the root element
xmlOut.WriteEndElement();
// close the xmlWriter object
xmlOut.Close();
}
}
}
Validator///
public static class Validator
{
private static string title = "Entry Error";
public static string Title
{
get => title;
set => title = value;
}
public static bool IsPresent(TextBox textBox)
{
if (textBox.Text == "")
{
MessageBox.Show(textBox.Tag + " is a required field.", Title);
textBox.Focus();
return false;
}
return true;
}
public static bool IsDecimal(TextBox textBox)
{
decimal number = 0m;
if (Decimal.TryParse(textBox.Text, out number))
{
return true;
}
else
{
MessageBox.Show(textBox.Tag + " must be a decimal value.", Title);
textBox.Focus();
return false;
}
}
public static bool IsInt32(TextBox textBox)
{
int number = 0;
if (Int32.TryParse(textBox.Text, out number))
{
return true;
}
else
{
MessageBox.Show(textBox.Tag + " must be an integer.", Title);
textBox.Focus();
return false;
}
}
public static bool IsWithinRange(TextBox textBox, decimal min, decimal max)
{
decimal number = Convert.ToDecimal(textBox.Text);
if (number max)
{
MessageBox.Show(textBox.Tag + " must be between " + min
+ " and " + max + ".", Title);
textBox.Focus();
return false;
}
return true;
}
}
}

In this exercise, you'll add a class to an Inventory Maintenance application and then add code to the two forms that use this class. Inventory Maintenance Add Item 3245649 Agapanthus ($7.95) 3762592 Limonium ($6.95) 9210514 Sail pellets ($12.95) 73459 Japanese Red Maple (509.95) Delen Brit New Inventory Item Item no 4237509 Confirm Delete Description Crepe Myrtle Pike 79.95 Are you sure you want to delete monium Save Cancel No Open the project and add an Invitem class 1. Open the Inventory Maintenance project in the Extra Starts Chapter 12 directory. Then, review the existing code for both of the forms so you get an idea of how this application should work 2. Add a class named Invitem to this project, and add the properties, method, and the table balon Add code to implement the New Item form 3. Display the code for the New Item form, and declare a class-level Invitem variable named invitem with an initial value of null 4. Add a public method named GetNewItem() that displays the form as a dialog box and returns an Invitem object, 5. 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 6. Display the code for the Inventory Maintenance form, and declare a class-level List Invitem> variable named invitems with an initial value of null. 7. Add a statement to the frminvMaint_Load() event handler that uses the GetItems() method of the InvitemDB class to load the items list. 8. Add code to the FillItemListBox0 method that adds the items in the list to the Items lint box. Use the GetDisplayText() method of the Invitem claus to format the item data. 9. 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 that's returned by this method is not null, this event handler should add the new item to the list, call the Saveltems 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 10. Add code to the btnDelete_Click() event handler that removes the selected item from the list, calls the Saveltems method of the InvitemDB class to save the list, and refreshes the Items list box. Be sure to confim the delete operation Then, test the application to be sure this event handler works, DEN Search Solution Explorer P. Solution 'Inventory Mainte ? C# Inventory Maintenanc - Dependencies frmlnvMaint.cs frmNewltem.cs Inventoryltems.xml C# Invltem DB.cs C# Program.cs C# Validator.cs

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

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

More Books

Students also viewed these Databases questions