340 likes | 552 Views
Project 7: Northwind Traders Order Entry. Northwind Order Entry. Extend the Select Customer program from Project 6 to permit the user to enter orders. Add orders to the database. Print invoices. Refer the Concept Document for background material:
E N D
Northwind Order Entry • Extend the Select Customer program from Project 6 to permit the user to enter orders. • Add orders to the database. • Print invoices. • Refer the Concept Document for background material: • http://www.cse.usf.edu/~turnerr/Software_Systems_Development/Downloads/Northwind_Call_Center/ • Note: This project is just a start. It does not fully implement the system described in the Concept Document.
Database Tables • Use copies of the Northwind Traders Database tables in your own database on scorpius. • Do not use the real Northwind database, which is read only. • You should have already added these tables to your scorpius database.
Orders Table For this project, use only OrderID, CustomerID, and OrderDate. Note that OrderID is an Identity field.
Order Details Table For this project, set Discount to 0.00. Other columns will have real values.
Products Table For this project, ignore SupplierID, QuantityPerUnit, UnitsInStock, UnitsOnOrder, ReorderLevel, and Discontinued.
Entity Classes • Define an Entity class corresponding to each database table used by the project. • Customers • Order Details • Orders • Products
Database Classes • Objects of Entity classes encapsulate information corresponding to one row of a database table. • The Entity classes encapsulate knowledge of how to access the database as well as information from the database.
Home Form • Add a button to the Home Form labeled Enter Order. • Enabled only when a customer is selected. • This button brings up a new form that permits the user to enter an order for the selected customer.
Order Entry Form • The Category dropdown list is bound to the Categories table. • Display Member: Category Name • Value Member: CategoryID • List never changes. • When a category is selected, the Product list is set up with products having the selected category.
Order Entry Form • The Product dropdown list is bound to the Products table, but only lists products in the selected category. • When a product is selected, its Unit Cost should appear in the Unit Cost textbox, a default value of 1 should appear in the Quantity textbox, and the Add to Order button should be enabled.
Adding an Item to the Order • After selecting a product, the user can enter a different value into the Quantity textbox if desired. • Must be a positive integer. • Less than 1000.
Adding an Item to the Order • When the user clicks Add to Order, a line item is added to the order as shown in the DataGridView below the dropdown lists. • At this time the Submit Order button should be enabled. • It should be disabled until the first line item is added to the order. • In this project, we will not implement reservations for products in pending orders as described in the concept document.
Entering an Order • The user can continue adding line items up to a maximum of 10. • The user can click Cancel to delete the current order and return to the Home form. • When all items have been entered, the user clicks Submit Order to add this order to the database. • One row is added to the Orders table. • One row is added to the Order Details table for each line item of the order.
Entering an Order • When the user clicks Submit Order the Print Invoice button is enabled. • The Submit Order button is now disabled. • The text on the Cancel button becomes Return. • User can no longer cancel the order.
Print Invoice • The Print Invoice button outputs order information to a printer. • Use a Print Dialog to let the user select a printer. • Always print “all” pages. • There will only be one page • Use a fixed width font for line items so that columns of numbers can be aligned.
Implementation Specifications • Use a DataGridView to show the line items of the order on the Order Entry form. • Use a DataTable to hold the order information as the order is being entered. • Do not put anything into the database until the user clicks Submit Order.
Implementation Specifications • Declare the DataTable as a member of the Order Entry Form class. • Add columns programatically in the form class constructor. • Add rows to the DataTable as line items are added to the order.
Implementation Specifications • Bind the DataGridView to the DataTable in the form class constructor. • Set DataGridView column widths and style programatically. • http://www.cse.usf.edu/~turnerr/Software_Systems_Development/044_DataGridView.pdf
Printing Tip • Numerical quantities should be right aligned in their boxes. • DrawString specifies position of left edge. • Where to you put the left edge of the string so that the right edge comes out at the right edge of the box? • We need to know how long the printed string will be.
Printing Tip • In Visual Studio Help • Search for MeasureText http://msdn.microsoft.com/en-us/library/system.windows.forms.textrenderer.measuretext(VS.80).aspx http://msdn.microsoft.com/en-us/library/y4xdbe66(VS.80).aspx
MeasureText Example private void print_line_item(Graphics g, Order_Detail od, ref int y_pos) { Font f = new Font("Courier New", 10); int h = invoice_font.Height; Brush b = invoice_brush; Rectangle r; Pen p = SystemPens.WindowText; Size size; String str = " "; int space; r = new Rectangle(50, y_pos, dataGridView1.Columns[0].Width, h); g.DrawString(od.Product.ProductName, f, b, r.X + 5, y_pos); g.DrawRectangle(p, r); r.X += dataGridView1.Columns[0].Width; r.Width = dataGridView1.Columns[1].Width; str = od.Product.UnitPrice.ToString("C"); size = TextRenderer.MeasureText(str, f); space = r.Width - size.Width - 10; g.DrawString(str, f, b, r.X + space, y_pos); g.DrawRectangle(p, r);
Ground Rules • You may work with one other person. • OK to work alone if you prefer. • If you do work as a pair • Both members are expected to contribute. • Submit a single program. • Both members should understand the program in detail. • It is OK to discuss the project, but ... • Do not share your work with other students. • Before or after submitting the project. • Do not copy any other student’s work. • Don’t look at anyone else’s program.
Ground Rules Except for code currently posted on the class web site • Do not copy code from the Internet • or any other source. • Write your own code.
Submission • Project is due before 11:59 PM, Monday night, April 25. • Deliverables: • Entire project folder, zipped • Please use Windows “Send to” command to zip the folder. • Submit your project using the Blackboard Assignment for this class. • If done as a pair, only one member should submit the project. • Include both names in the assignment comments and in source file comments. • Other student submit just a comment with both names. End of Presentation