DISC 4372 FINAL FALL 2003 Parks Part 1
Name_______________________________________________SS#____________________________
DSN __________________e-mail address__________________________________________________
1. (60 points) TO BE COMPLETED IN CLASS
A personal computer company sends user purchase requests from the client to the server in the form of an XML string. This string is part of a form with a single name-value pair. The name of the the form object is completed_order and is sent to the server using METHOD=POST. The DTD for the XML is:
<?xml version="1.0"?> <!DOCTYPE completed_order [
<!ELEMENT completed_order (line_item+) >
<!ELEMENT line_item (model_number, model_quantity, option*)>
<!ELEMENT model_number (#PCDATA)>
<!ELEMENT model_quantity (#PCDATA)>
<!ELEMENT option (option_number, option_quantity)>
<!ELEMENT option_number (#PCDATA)>
<!ELEMENT option_quantity (#PCDATA)>
]
On the server side, the table named inventory contains all of the product items. This table has the following structure:
  • item_id int,
  • item_name varchar(30),
  • units_on_hand int,
  • units_committed int,
  • unit_price decimal (12,2)
    The primary key is item_id. The table contains inventory information for both the computers (i.e., model_number) and the options (i.e., option_number). The asp program is required to:
    1. look up each item (computer models or options) to determine if there is sufficient inventory (units_on_hand) to fullfill the order. Note: a model_number and an option_number in the XML both have a corresponding item_id in the table.
    2. return to the user an HTML page that summarizes their order status. This should include:
      1. for each line_item:
        1. model_number (this is item_id in the table)
        2. model_name (i.e., item_name from the table)
        3. quantity (this is model_quantity in the XML)
        4. price (unit_price from the table)
        5. extension (i.e., price * quantity)
        and under a model, for each of its option(s):
        1. option_number (this is item_id in the table)
        2. option_name (i.e., item_name from the table)
        3. quantity (this is option_quantity from the XML)
        4. price (from the table)
        5. extension (i.e., price * quantity * quantity of this model)
      2. grand total for all price extensions
      If the entire quantity requested for a computer model is not available for a line_item, in the report show a zero quantity and zeroes in the price field. When there are insufficient quantities of a model on a line_item, no options are to be delivered for the line_item even if the options are available (i.e., if you cannot ship the computer, you cannot ship any optional add-ons). If a there are options with insufficient inventory, show a zero quantity on the report and a zero price -- for that option on that line item only. As with models, make no partial fills for an option. If any option is not available -- but the computer model is available, fill the model part of the order and any available option(s). NOTE: You can ship models with missing options (i.e., options with insuffivcient inventory) -- but you cannot ship ANY options if the base computer models are not available for the line_item.
    3. once the report has been generated, update the inventory table by reducing the units_on_hand by the amount shown on the report for each model or option. Add these same quantities to the units_committed field.
    Assume in the asp code that the XML string has been rolled into the XMLDOM. Further, there is a prewritten sub named get_next that you can call. You pass no arguments to get_next. When called, get_next updates three global variables: sn (a sequence number for the line_item -- starts at 1 and is incremented by 1 each time the line_item changes); inum (the model or option number from the XML); q (the associated quantity for this line item's model or option from the XML). Successive calls to this sub update the three global variables in the correct XML sequence. When all the XML has been processed, a call to the sub sets sn to -1 (i.e., when sn=-1, the XML file has been fully traversed). Do not write get_next, just use it. Note that you are processing a line_item individually, so when processing the order do not aggregate (i.e, add up) any quantities over multiple line_items in order to evaluate availability.