Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

' using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace InventoryMaintenance { static class Program { /// /// The main entry point for

image text in transcribed

image text in transcribed

image text in transcribed'

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms;

namespace InventoryMaintenance { static class Program { ///

/// The main entry point for the application. /// [STAThread] static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmInvMaint()); } } }

image text in transcribed

image text in transcribed

using System; using System.Collections.Generic; using System.Text; using System.Xml;

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(); } } }

image text in transcribed

image text in transcribed

using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms;

namespace InventoryMaintenance { 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; } } }

use Visual studio 2019 please

Extra 12-1 Create and use a class 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 X Moda 3345649 Agupanthus 37.95 3762592 mm ($699 9210584 Sol pellets $12.95 4733459 Ipanese Red Maple New Inventory Hem em no 4237509 Com Desattor Gepe Myrtle 79.95 Are you want to Swe Canal Open the project and add an Invitem class 1. Open the Inventory Maintenance project in the Extra Stars 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 constructors that are shown in the table below Property Description Itendo Gets or set an int that contains the items sumber Desoription Gets or sets a string that contain the item's description Price Gets or sets adecual that contain the tem' price Method Description GetDisplayText) Returns a string that contains the itember description, and price formatted like this 3245619 Agustus (795) (The number and description are parted by four spaces Constructor Description Creates an Indien object with tedescription, price) Create an object with specified as Extra exercises for Murach's C# (7 Edition) 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 frmovMaint_Load() event handler that uses the Getitems() method of the InvitemDB class to load the items list. 8. 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. 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 luvitemDB 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. II Invitem DB.CS Program.cs + x C Inventory Maintenance 17 Eusing System; 2 using System.Collections.Generic; 3 using System.Linq; using System.Threading.Tasks; 5 using System.Windows.Forms; 4 00V WN 9 1e 11 12 B 13 namespace InventoryMaintenance { O references static class Program { 111 III The main entry point for the application. /// [STAThread] O references I B static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.Enablevisualstyles(); Application.setCompatibleTextRenderingDefault(false); Application.Run(new frmInvMaint()); 14 15 16 17 18 19 2e 21 22 23 24 Inventory Mainte InvltemDB.cs x Program.cs InventoryMaintenance using System; using System.Collections.Generic; using System.Text; Lusing System.Xml; 5 Enamespace InventoryMaintenance 2 3 4 6 7 8 9 Oreferences public static class Invitends 1e 11 private const string Path=.. ... \InventoryItems.ml"; references public static List title; set => title = value; 3 references public static bool IsPresent (TextBox textBox) if (textBox.Text = "") 17 18 19 28 21 22 23 24 25 26 27 MessageBox.Show(textBox.Tag" is a required field.", Title); textBox.Focus(); return false; return true; B 28 29 30 31 32 reference public static bool IsDecimal(textBox textBox) decimal number - da; If (Decimal. TryParse(textBox.Text, aut number)) B! return true) else 34 35 36 37 38 39 48 41 42 MessageBox.Show(textBox. Tag must be a decimal value., Title); textBox.Focus(); return false; 43 i reference public static bool Is Int32(TextBox textBox) int number - ; if (Int32. TryParse(textBox.Text, out number)) { return true: 48 37 Validator.cs + x Invitem DB.cs Program.cs C Inventory Maintenance Inventory Maintenance.Validato MessageBox.Show(textBox. Tag + must be a decimal value.", Title); 38 textBox.Focus(); 39 return false; 40 41 42 1 reference 43 B public static bool IsInt32(TextBox textBox) 44 45 int number = 0; I 46 if (Int32. TryParse(textBox.Text, out number)) 47 { 48 return true; 49 50 else 51 52 MessageBox.Show(textBox.Tag" must be an integer.", Title); 53 textBox.Focus(); 54 return false; 55 56 57 O references 58 B public static bool IswithinRange(TextBox textBox, decimol min, decimal max) decimal number - Convert.ToDecimal(textBox.Text); if (number max) 62 { MessageBox.Show(textBox.Tag + " must be between min + " and " + max + ".", Title); textBox.Focus(); 66 return false; 67 68 return true; 69 70 71 72 59 60 61 63 64 65 Extra 12-1 Create and use a class 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 X Moda 3345649 Agupanthus 37.95 3762592 mm ($699 9210584 Sol pellets $12.95 4733459 Ipanese Red Maple New Inventory Hem em no 4237509 Com Desattor Gepe Myrtle 79.95 Are you want to Swe Canal Open the project and add an Invitem class 1. Open the Inventory Maintenance project in the Extra Stars 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 constructors that are shown in the table below Property Description Itendo Gets or set an int that contains the items sumber Desoription Gets or sets a string that contain the item's description Price Gets or sets adecual that contain the tem' price Method Description GetDisplayText) Returns a string that contains the itember description, and price formatted like this 3245619 Agustus (795) (The number and description are parted by four spaces Constructor Description Creates an Indien object with tedescription, price) Create an object with specified as Extra exercises for Murach's C# (7 Edition) 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 frmovMaint_Load() event handler that uses the Getitems() method of the InvitemDB class to load the items list. 8. 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. 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 luvitemDB 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. II Invitem DB.CS Program.cs + x C Inventory Maintenance 17 Eusing System; 2 using System.Collections.Generic; 3 using System.Linq; using System.Threading.Tasks; 5 using System.Windows.Forms; 4 00V WN 9 1e 11 12 B 13 namespace InventoryMaintenance { O references static class Program { 111 III The main entry point for the application. /// [STAThread] O references I B static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.Enablevisualstyles(); Application.setCompatibleTextRenderingDefault(false); Application.Run(new frmInvMaint()); 14 15 16 17 18 19 2e 21 22 23 24 Inventory Mainte InvltemDB.cs x Program.cs InventoryMaintenance using System; using System.Collections.Generic; using System.Text; Lusing System.Xml; 5 Enamespace InventoryMaintenance 2 3 4 6 7 8 9 Oreferences public static class Invitends 1e 11 private const string Path=.. ... \InventoryItems.ml"; references public static List title; set => title = value; 3 references public static bool IsPresent (TextBox textBox) if (textBox.Text = "") 17 18 19 28 21 22 23 24 25 26 27 MessageBox.Show(textBox.Tag" is a required field.", Title); textBox.Focus(); return false; return true; B 28 29 30 31 32 reference public static bool IsDecimal(textBox textBox) decimal number - da; If (Decimal. TryParse(textBox.Text, aut number)) B! return true) else 34 35 36 37 38 39 48 41 42 MessageBox.Show(textBox. Tag must be a decimal value., Title); textBox.Focus(); return false; 43 i reference public static bool Is Int32(TextBox textBox) int number - ; if (Int32. TryParse(textBox.Text, out number)) { return true: 48 37 Validator.cs + x Invitem DB.cs Program.cs C Inventory Maintenance Inventory Maintenance.Validato MessageBox.Show(textBox. Tag + must be a decimal value.", Title); 38 textBox.Focus(); 39 return false; 40 41 42 1 reference 43 B public static bool IsInt32(TextBox textBox) 44 45 int number = 0; I 46 if (Int32. TryParse(textBox.Text, out number)) 47 { 48 return true; 49 50 else 51 52 MessageBox.Show(textBox.Tag" must be an integer.", Title); 53 textBox.Focus(); 54 return false; 55 56 57 O references 58 B public static bool IswithinRange(TextBox textBox, decimol min, decimal max) decimal number - Convert.ToDecimal(textBox.Text); if (number max) 62 { MessageBox.Show(textBox.Tag + " must be between min + " and " + max + ".", Title); textBox.Focus(); 66 return false; 67 68 return true; 69 70 71 72 59 60 61 63 64 65

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_2

Step: 3

blur-text-image_3

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

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago