Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 6 - 1 : Review the Invoices by Due Date application In this exercise, you ll review the Invoices by Due Date application that

Exercise 6-1: Review the Invoices by Due Date application
In this exercise, youll review the Invoices by Due Date application thats presented in this
weeks chapter. That will give you a better idea of how it works.
1. Open the DisplayInvoicesDue application thats in your Chapter 6 directory.
2. In the Solution Explorer, notice that this solution includes two projects:
DisplayInvoicesDue and PayablesData. Then, expand the PayablesData project
to see that it contains the business and database classes that are used by this
application: Invoice, InvoiceDB, and PayablesDB.
3. Double-click on any one of the classes in the PayablesData project to review its
code.
4. Display the code for the Invoices by Due Date form (frmInvoicesDue) and note the
using statement at the top of the file. For this to work, the application must include a
reference to the PayablesData project.
5. To see the required reference, expand the References folder for the project in the
Solution Explorer. If you dont see this folder, select the project and then click the
Show All Files button at the top of the Solution Explorer window.
6. Run the application to see how it works. Then, when youre done experimenting,
close the application.
Exercise 6-2: Enhance the Invoices by Due Date application
In this exercise, youll enhance the Invoices by Due Date application. This will give you a
chance to work with commands that return scalar values. When youre done, the form
for the application should look like this:
Enhance the interface
1. Open the DisplayInvoicesDue application in your Chapter 6 directory.
2. Add a ToolStrip control to the top of the Invoices by Date Due form and add the
buttons, separators, label, and text box shown above to it. Then, set the properties
for these controls.
3. Add a label and text box below the ListView control as shown above. Then, set the
properties for these controls.
4. Modify the code for the form so it displays the unpaid invoices for all vendors when
the user clicks on the Get All Invoices button in the toolbar instead of when the
form is loaded. To do that, you just need to move the code from the Load event
handler to the Click event handler for the Get All Invoices button. Or, if you prefer,
you can copy the code from the Load event handler to the Click event handler and
then comment out the code for the Load event handler.
5. Test this modification to see how it works
Add the code for getting the invoices for a single vendor
6. Add a method named GetVendorlnvoicesDue to the InvoiceDB class that
gets the unpaid invoices for a single vendor. This method should have one
parameter that accepts a vendor ID as an integer, and it should return a list
of Invoice objects that represent the unpaid invoices for that vendor ID. The
easiest way to code this method is to copy and modify the code for the
GetlnvoicesDue method. For now, you can hardcode the parameter that
contains the vender ID into the Select statement. Then, in the next chapter,
you'll learn how to work with parameter objects.
7. Add an event handler to the code for the form that handles the Click event
of the Get Vendor Invoices toolbar button. The easiest way to do that is to
copy and modify the code for the Click event of the Get All Invoices button.
8. Test and debug this enhancement until it works right. Try vendor IDs 99
and 102, and make sure the ListView control is cleared before any invoices
are added to it. To do that, you can use this command:
lvinvoices.Items.Clear();
Add the code for getting the total balances due
9. Add a method named GetTotalBalanceDue to the InvoiceDB class. It should
use an aggregate query like the one in the first example in figure 6-10 to get
the sum of all the unpaid invoices.
10. Add a method named GetVendorBalanceDue to the lnvoiceDB class. It
should have one parameter that receives a vendor ID, and it should get the
sum of all of the unpaid invoices for that vendor. Again, you can hardcode
the vendor ID parameter into the Select statement.
11. Add the code to the form class that uses the methods that you created in
steps 9 and 10 to display the total balance due for all unpaid invoices or just
one vendor's unpaid invoices when the buttons in the toolbars are clicked.
12. Test and debug this enhancement until it works right

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

4. Explain how to price managerial and professional jobs.

Answered: 1 week ago