|
Welcome to our support section for the Chapter Programming Challenges!
Some of the programs can be tricky to write, particularly since
this is an Advanced Visual Basic book. We hope you enjoy
the helpful hints and screen snapshots we have created for some
of the best Challenge programs. This is a work in progress, so check
back with us from time to time so you can see what's new.
|
Select a Chapter by Number:
Chapter 7
Programming Challenge 1: Reassign Task
When you reassign a task to a different member, you need to update both
the TaskAssignment and Tasks tables. The following stored procedure can
do both at the same time:
CREATE PROCEDURE spUpdateTaskAssignment ( @memberId int, @taskId int ) AS UPDATE TaskAssignment SET Person_ID = @memberId WHERE Task_ID = @taskId; UPDATE Tasks Set Owner_ID = @memberId WHERE ID = @taskId
Programming Challenge 2: Edit Project Details
Here is a sample user interface for the window that lets the user edit
project details. To add an employee to the project, the user selects an
employee name and clicks the Add Member button. Implementing the
add and remove functions are very easy, because the Projects class already
has methods named AddPersonToProject and RemoveMember. The user can modify
all fields except the Director. Just a reminder: only the project director
should be allowed to edit the project details.

Programming Challenge 3: Remove Task
This is a relatively easy programming challenge to complete. Precondition:
Only a project director should be permitted to remove a task. Tasks
are stored in two places, so you must remember to delete the appropriate
rows from both the TaskAssignment and Tasks table. These two tables participate
in a relationship, in which TaskAssignment is the child and Tasks is the
parent. Therefore delete from the TaskAssignment table first to avoid
causing a Referential Integrity Constraint violation:
DELETE FROM TaskAssignment WHERE Task_ID = @taskId AND Project_ID = @projectId DELETE FROM Tasks WHERE ID = @taskId AND Project_ID = @projectIdd
Chapter 8
Programming Challenge 5: Karate Payments Grid
This application, unlike the other examples in the chapter, requires
you to join two tables from the Karate database: Members and Payments.
It's easiest to join tables using the Query Builder tool, which
you can activate when creating a data source. Notice the Configure
Data Source window in Figure 8-69 (page 507). If you select the radio
button that says Specify a custom SQL statement or stored procedure,
the Query Builder tool will be available after you click the Next
button.
Chapter 9
Programming Challenge 1: Computer Club Meeting
This challenge gives you practice creating a simple user interface design.
You do not have to actually send any email messages. In our sample solution
program, the user enters each message recipient's name into a TextBox
(on the left) and clicks the Add Recipient button, which appends
the name to the ListBox on the right:

Programming Challenge 2: Validating a DropDownList
There are two tricks to solving this programming challenge:
- Create a hidden TextBox containing "(select)". Use the CompareValidator
control to compare the DropDown list to the TextBox.
- The second trick, if you want the error message to disappear as soon
as the user selects an item from the DropDown list, is to avoid using
the ValidationSummary control. Instead, just use the CompareValidator.
The reason for this choice is that the ValidationSummary does not refresh
its messages until after the form is posted back to the server. Here
is a sample user interface, just after the user clicked the Submit
button, without having made a choice from the DropDown list:

Programming Challenge 3: Checking a Date with CompareValidator
This is a very short assignment. In the sample design, shown below, we
used a RequiredFieldValidator as well as a CompareValidator. If the date
is entered in a format that Visual Basic does not understand, the error
message is displayed:

Programming Challenge 4: Validating a Date Range
This project is short but tricky! There is an error in the description--you
should use the RangeValidator control, not the CompareValidator.
Aside from that, you can definitely set the MaximumValue and MinimumValue
properties of the RangeValidator at runtime. Also, your code must call
the RangeValidator's Validate method to make it all work. Here's
a sample:

Chapter 10
Programming Challenge 1: ProjectTrackAw Application - Displaying a Confirmation
Question
The easiest way to implement the confirmation question is to use a Panel
control (the second choice). In our solution program, the panel contains
a text question along with Yes and No Button controls. Initially,
the Panel is invisible. When the user clicks the Join button, code
statemens set the Panel's Visible property to True. The Click handlers
for these two buttons both set the Panel's visible property to False.
And, of course, the Click handler for the Yes button adds the person to
the selected project. One other task is important: refresh the list of
members if it is currently being displayed. Here is a sample of the confirmation
question:
Programming Challenge 4: ProjectTrackAw with My Projects
At first, this project seems deceptively simple. Our solution program
displays two LinkButton controls at the top, so the user can select All
Projects or My Projects. The trickiest part of the coding is
caused by the CreateCustomColumns method. You must find a way to
call it only once, and not call it when the user clicks on the two LinkButtons.
Otherwise, you will find that extra columns are added to the grid every
time a button is clicked. Hint: consider using an If
Not IsPostBack statement. Here is our sample:

|