MIS 4372 MIDTERM PARKS FALL 2010

Answers:

  1. Execute Create and Populate the table named cookmaster (source code here)
  2. Execute Part I (source code here)
  3. Execute Part II (source code here)

Note: None of the "style" attributes that appear in the source code are required.

Exam Text Below:



1. (50 points) The Texas Youth Birdwatcher Scout Troop sells fudge cookies to raise funds. There is a table called cookmast that is used to record each scout's cookie sales (i.e, number of boxes sold) as follows:

bridge_id bigint identity (1,1),
scout_id int,
scout_first_name varchar(15),
scout_last_name varchar(15),
sales_type_1 int,     [this records the number of boxes of "Double Fudge" cookies sold]
sales_type_2 int,     [this records the number of boxes of "Mint Fudge" cookies sold]
sales_type_3 int,     [this records the number of boxes ofsales of "Cherry Fudge" cookies sold]
sales_type_4 int,     [this records the number of boxes ofsales of "Vanilla Fudge" cookies sold]
sales_type_5 int,     [this records the number of boxes ofsales of "Raspberry Fudge" cookies sold]
sales_total int,         [this records the total number of boxes of sold of ALL cookies]
PRIMARY KEY (bridge_id)

Create a three pass *.asp program named sales_update.asp to record (i.e., update) a scout's sales efforts. Assume the cookmast table exists and has data for each scout in ALL the fields (i.e., no column values are empty or null). The program should:

  1. Pass 1

    Roll out ALL the scouts (one per row) to provide a link to the second pass that allows the user to choose a scout to update by clicking on the link. The clickable part of the link should display the scout's last name and first name. The items in square brackets below should be inserted into the string -- but not the square brackets. The link format should be:

    <a href='sales_update.asp?token=2&bid=[bridge_id]'>[scout_last_name], [scout_first name]</a>

  2. Pass 2

    1. Perform an existence test for the scout that was linked in Pass 1. If not found, return an error message that says "Scout NOT found".
    2. If the record is found (and it should be), return to the user:
      1. The scout's ID; last name; and first name (display these only -- not in textboxes)
      2. Five empty textboxes to record new sales for "Double Fudge", "Mint Fudge", "Cherry Fudge", Vanille Fudge", and "Raspberry Fudge" (size="3").
      3. A hidden value for "token" with value="3"
      4. A hidden value for the scout's bridge_id
      5. A submit button
      6. Perform NO client-side edits.

  3. Pass 3

    Update scout's record in the cookmast table with the data from pass2. The FIVE values received are to be ADDED to the existing five values in the scout's table row for the cookie sales (i.e, sales_type_1, sales_type_2, sales_type_3,... etc.). You should also add up the five values submitted and ADD this sum to the scout's sales_total. Be sure to check that the five values submitted have numeric values -- if any textbox was left empty on Pass2 ADD 0 (zero) to that column. An empty textbox also will contribute 0 (zero) to the sales_total field.

Do not show the main routine -- just the asp code for the subs: Pass1; Pass2; and Pass3.

2. (50 points) Six prizes are to be awarded for the scout who sold the largest number of boxes of cookies for the five cookie types and for overall sales total. Write a single pass asp program that finds and displays the six winners. The desired output is shown below to the left:

Sales Winners
Category Scout's Name Boxes Sold
Double Fudge Boughton,Ada 59
Mint Fudge Sanders,Marvin 69
Cherry Fudge Fite,Gary 79
Vanilla Fudge Bickel,Antonio 39
Raspberry Fudge Boughton,Ada 30
Total Sales Finnell,Keith 232
You MUST use a single recordset with "Select * from cookmast" and gather the all the necessary information on a single pass through the recordset. Assume this array is defined in the program:

   labels(1)="Double Fudge"
   labels(2)="Mint Fudge"
   labels(3)="Cherry Fudge"
   labels(4)="Vanilla Fudge"
   labels(5)="Raspberry Fudge"
   labels(6)="Total Sales"

Hint: For loop purposes, the column values for the columns sales_type_1, sales_type_2, ... ,sales_total can also be found by referencing: rs(4), rs(5),...,rs(9) of each row. Do NOT use the SQL "MAX" function. Do NOT consider the issue of ties.