comprehensive project
CIS 3309 Section 4 Comprehensive Lab Project The primary task is to complete an order entry system for MMA Books. The application needs to query customers and products data from a database and commit invoices to the database, while maintaining product inventory levels. The image below shows the form for the project. The form and most of the form code are completed for you. Your still need to add classes and database code, and the form code to use them. The form is divided into 3 sections: 1. The Customer section either gets a customer from or adds a customer to the database 2. The Products section shows all the MMA Books products and allows a user to select products and add a quantity of them to the cart 3. The Cart section shows the products in the care, their sum of unit prices, shipping charge, sales tax and invoice total, edit or delete products from the cart, clear the cart and submit the invoice to the database
Invoice classes and the Cart Form section
This is the most challenging task. You create all the code in this class to manage an Invoice, its
InvoiceLineItems and perform database operations on Invoice data. The database operations include
writing a one-to-many relation into the database. The Invoice classes include:
1. InvoiceLineItem – Contains data about a Product added to the Invoice
2. Invoice – Contains the Invoice data described below and a list of InvoiceLineItem
3. InvoiceDB – Static class that contains methods to get data from or put data into a database
Add code to the frmEditItem below. See comments on form for more information.
1. Add code to frmEditItem at: //*****InvoiceLineItem 1. Add code here
2. Add code to frmEditItem at: //*****InvoiceLineItem 2. Add code here
3. Add code to frmEditItem at: //*****InvoiceLineItem 3. Add code here
4. Add code to frmMain at: //*****InvoiceLineItem 4. Add code here
5. Add code to frmMain at: //*****InvoiceLineItem 5. Add code here
InvoiceLineItem
The InvoiceLineItem class needs data to contain the 5 fields from the InvoiceLineItems table in the
MMABooks database. Look at the database in Visual Studio C# again. Again, I strongly suggest that you
name the data fields in your class with the same names as the InvoiceLineItem’s field names. After
completing your InvoiceLineItems class auto-implemented properties, code the following:
1. A default constructor
2. A parameterized constructor that accepts and set all InvoiceLineItem data
3. A ToString method to return a string with all the InvoiceLineItem data on one line
Invoice
The Invoice class needs data to contain the 7 fields from the Invoices table in the MMABooks database.
You will also need to add a List of InvoiceLineItems called invoiceLineItems and an OrderOptions
reference called oo to this data. Look at the database in Visual Studio C# again. Again, I strongly suggest
that you name the data fields in your class with the same names as the Invoice’s field names. After
completing your Invoice class auto-implemented properties, code the following:
1. A method called SetDate that sets the DateTime object in the Invoice to Now
2. A default constructor that instantiates the List of InvoiceLineItems, gets the OrderOptions from
the database and calls the SetDate method
3. A parameterized constructor that accepts and set all InvoiceLineItem data, instantiates the List
of InvoiceLineItems, gets the OrderOptions from the database and calls the SetDate method
4. A ToString method to return a string with all the InvoiceLineItem data on one line
5. A property called InvoiceDate that facilitates the setting or getting of the date as a string from
outside the class
6. A read-only property called InvoiceLineItems that gets invoiceLineItems
7. A indexer called InvoiceLineItem to set or get specific elements from invoiceLineItems
8. A method called CalcProductTotal that uses a loop to calculate the sum of UnitPrices in all the
InvoiceLineItems in the List and assigns it to the ProductTotal field
9. A method called CalcShipping that calculates the shipping charge. Remember that there is a
different cost for the first book and each additional book shipped and assigns it to the Shipping
field
10. A method called CalcSalesTax that calculates the tax from the sum of ProductTotal and Shipping
fields
11. A method called CalcInvoiceTotal that calculates the sum of the ProductTotal, Shipping and
SalesTax fields and assigns it to InvoiceTotal
12. A method called CalcAll that calls the 4 previous methods in steps 8 to 11 to set all their fields
13. A method called UpdateInvoiceLineItem tha accepts the index of the element in
invoiceLineItems List that you want to update, a decimal unitPrice to update the
InvoiceLineItem’s UnitPrice and a integer quantity to update the InvoiceLineItem’s Quantity, and
calls the CalcAll to update the requisite fields
14. A method called Add to add an InvoiceLineItem to the invoiceLineItems List and calls the CalcAll
to update the requisite fields
15. A method called RemoveAt to remove an InvoiceLineItem from the invoiceLineItems List by
index and calls the CalcAll to update the requisite fields
16. A method called Clear to clear all InvoiceLineItems from the invoiceLineItems List and calls the
CalcAll to update the requisite fields
InvoiceDB
The InvoiceDB class contains methods that allow your application to get the max InvoiceID from the
database, insert an Invoice into the database, and insert the InvoiceLineItems into the database. You
will need the following methods.
1. InsertInvoiceLineItem – Insert a InsertInvoiceLineItem into the InsertInvoiceLineItems table in
the database
2. GetMaxID – Gets the max InvoiceID from the database, which is the InvoiceID of the last
inserted record
3. InsertInvoice – Inserts an invoice into the database. This requires the Invoice data to be inserted
into the database, close the connection, get the max InvoiceID from the Invoices table, and
loops to insert all InvoiceLineItem into the InsertInvoiceLineItems table in the database by
repeatedly calling the InsertInvoiceLineItem method
Cart section on Form
Please add the following code to frmMain.
1. Add code to instantiate the reference for Invoice i in class level data.
2. Add code to assign -1 to the Invoice i in class level data to record that there currently is no
Customer in reference c from class level data
3. Add code to clear Invoice i.
4. Add code to copy CustomerID from Customer c to Invoice i
5. Add code to copy Invoice i CustomerID from maxID
6. Add code to set Invoice i CustomerID to -1 to record that there currently is no Customer in
reference c
7. Add code to loop through the items in lstCart to see if the currently selected Product p is in the
cart
8. Add condition to check if previous conversion succeeded, cart item does not have more books
than are in stock and Product is not already in Cart
9. Add code to calculate cost of all items purchased for this Product (Get UnitPrice from p and qty
from TryParse)
10. Add code to instantiate class reference InvoiceLineItem li with the selected Product from the
Products section. See comment for what data to pass to the constructor.
11. Add code to add InvoiceLineItem li to Invoice i
12. Add code to add InvoiceLineItem li to lstCart
13. Add code to call UpdateInvoiceLineItem in i to pass new values for lstCart selected index
14. Add code to delete Product from Invoice i by using lstCart SelectedIndex. The List of
InvoiceLineItem and lstCart Items are parallel arrays.
15. Add code to clear Invoice i
16. Add code to check if a Customer has been found or added. If CustomerID is less than zero, there
is no Customer found or added.
17. Add code to insert an Invoice i into the database
18. Add code to copy the data from the ProductTotal, Shipping, SalesTax and InvoiceTotal from
Invoice i to the TextBoxes in the Cart section
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of