Answered step by step
Verified Expert Solution
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 : 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.
Open the DisplayInvoicesDue application thats in your Chapter directory.
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.
Doubleclick on any one of the classes in the PayablesData project to review its
code.
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.
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.
Run the application to see how it works. Then, when youre done experimenting,
close the application.
Exercise : 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
Open the DisplayInvoicesDue application in your Chapter directory.
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.
Add a label and text box below the ListView control as shown above. Then, set the
properties for these controls.
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.
Test this modification to see how it works
Add the code for getting the invoices for a single vendor
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.
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.
Test and debug this enhancement until it works right. Try vendor IDs
and 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
Add a method named GetTotalBalanceDue to the InvoiceDB class. It should
use an aggregate query like the one in the first example in figure to get
the sum of all the unpaid invoices.
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.
Add the code to the form class that uses the methods that you created in
steps and 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.
Test and debug this enhancement until it works right
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started