Home

XML-Based Applications:
College Park Auto-Parts

 
College Park Auto-Parts

Introduction

After our various introductions to XML, we will put it to good use with a usable application. As a meta language, XML can be used to create text-based files that can be accessed by any application that reads XML. To highly support this language, the .NET Framework provides various classes that allow you to create very effective applications without investing a lot in client/server stuff.

In this lesson, we are going to create an application for a business that sells auto parts. The items sold in the store and the inventory are stored as XML files. When an employee is performing a customer order, we make the application friendly with lists that allow the user to select the necessary information using combo boxes. These include the year, the make and the model that allow to identify the specific car that a part is made for. After selecting the necessary parts, the employee can save the order. The order also is saved as an XML file.

All the orders of one particular day are saved to a common file. This allows the management to review the orders for a particular day. To review such orders, they can open another form that is equipped with a Date Picker and a DataGrid controls. The employee selects a date and the grid displays the list of items sold for that day, if any.

Prerequisites: To follow this lesson, you should be familiar with:

 

Practical Learning Practical Learning: Introducing the Application

  1. Start Microsoft Visual Studio .NET and create a Windows Forms Application named CPAP3
  2. To add a new XML file, on the main menu, click Project -> Add New Item...
  3. In the Templates list of the Add New Item dialog box, click XML File
  4. Set the Name to Cars and click Open
  5. Complete the file as follows:
     
    <?xml version="1.0" encoding="utf-8" ?>
    <Cars>
    	<Make MakeName="Acura">
    		<Model>Integra GS 1.8L L4</Model>
    		<Model>MDX 3.5L V6</Model>
    		<Model>NSX 3.0L V6</Model>
    		<Model>NSX 3.2L V6</Model>
    		<Model>TL 3.2L V6</Model>
    	</Make>
    	<Make MakeName="Audi">
    		<Model>A4 Quattro 1.8L Turbo</Model>
    		<Model>A4 Quattro 3.0L V6</Model>
    		<Model>S4 2.7L V6</Model>
    	</Make>
    	<Make MakeName="BMW">
    		<Model>325I 2.5L L6</Model>
    		<Model>325XI 2.5L L6</Model>
    		<Model>745I 4.4L V8</Model>
    		<Model>Z3 Coupe 3.0L L6</Model>
    	</Make>
    </Cars>
  6. Add an XML file named PartCategories
  7. Fill it up with a few parts as follows:
     
    <?xml version="1.0" encoding="utf-8" ?>
    <PartCategories>
    	<PartCategory>Accessories-Exterior</PartCategory>
    	<PartCategory>Belt Drive System</PartCategory>
    	<PartCategory>Body-Exterior</PartCategory>
    	<PartCategory>Body-Interior</PartCategory>
    	<PartCategory>Brake System</PartCategory>
    	<PartCategory>Clutch</PartCategory>
    	<PartCategory>Cooling System</PartCategory>
    	<PartCategory>Drivetrain</PartCategory>
    	<PartCategory>Electrical</PartCategory>
      	<PartCategory>Miscellaneous</PartCategory>
    </PartCategories>
  8. Add an XML file named Parts
  9. Fill it up with a few parts as follows:
     
    <?xml version="1.0" encoding="utf-8" ?>
    <Parts>
    	<Part>
    		<PartNumber>293749</PartNumber>
    		<CarYear>2005</CarYear>
    		<Make>Acura</Make>
    		<Model>NSX 3.0L V6</Model>
    		<PartName Category="Engine">Oil Filter</PartName>
    		<UnitPrice>8.85</UnitPrice>
    	</Part>
    	<Part>
    		<PartNumber>283759</PartNumber>
    		<CarYear>2002</CarYear>
    		<Make>Audi</Make>
    		<Model>A4 Quattro 1.8L Turbo</Model>
    		<PartName Category="Clutch">Clutch Release Bearing</PartName>
    		<UnitPrice>55.50</UnitPrice>
    	</Part>
    	<Part>
    		<PartNumber>368374</PartNumber>
    		<CarYear>2002</CarYear>
    		<Make>Audi</Make>
    		<Model>A4 Quattro 1.8L Turbo</Model>
    		<PartName Category="Electrical">Alternator</PartName>
    		<UnitPrice>305.50</UnitPrice>
    	</Part>
    	<Part>
    		<PartNumber>485704</PartNumber>
    		<CarYear>2002</CarYear>
    		<Make>Audi</Make>
    		<Model>A4 Quattro 1.8L Turbo</Model>
    		<PartName Category="Engine">Oil Filter</PartName>
    		<UnitPrice>5.50</UnitPrice>
    	</Part>
    	<Part>
    		<PartNumber>491759</PartNumber>
    		<CarYear>1998</CarYear>
    		<Make>BMW</Make>
    		<Model>325I 2.5L L6</Model>
    		<PartName Category="Ignition">Ignition Coil</PartName>
    		<UnitPrice>60.85</UnitPrice>
    	</Part>
    </Parts>
  10. Save all
 

Home Copyright © 2004-2016, FunctionX, Inc. Next