home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 99.img / PDOX3-10.ZIP / VIDEO / VIDENT.SC < prev   
Encoding:
Text File  |  1989-09-15  |  5.5 KB  |  119 lines

  1. PROC DoCheckOut()
  2.  
  3. ; We'll enter one film per customer at a time. If a customer is renting
  4. ; more than one film, we'll use multiple records to capture the new
  5. ; information, using DITTO to grab repeated information.
  6. CLEARALL
  7. EMPTY "ordtemp"                        ; Get temporary table ready for use
  8. EDIT "ordtemp"                         ;   and drop us into empty table
  9. PICKFORM 1                             ;   using film checkout form
  10. WHILE (True)                           ; Keep entering checkouts until user says Done!
  11.   WAIT RECORD                          ; Let user enter a checkout record
  12.     PROMPT "Enter film checkout information",
  13.            "[F2] to save data, [F1] for lookup help, [Esc] to abandon entry"
  14.     UNTIL "F2","Esc"
  15.   IF retval = "Esc"                    ; Does user want to abandon record?
  16.     THEN DEL                           ; Yes, so delete it,
  17.          DO_IT!                   ;   and save other records,
  18.          QUITLOOP                      ;   and leave entry section
  19.     ELSE PGDN                          ; No, move to next record
  20.   ENDIF
  21.   ;if we were updating inventory status in FILMS table, we would do it here
  22.   ;must have pressed [F2] to get here
  23.   SHOWMENU "Another?":"Checkout another film to same customer",
  24.            "Done!":"Done entering film checkouts for this customer"
  25.   TO Choice
  26.   IF Choice = "Done!"                  ; Is user done entering info for this customer?
  27.     THEN DO_IT! QUITLOOP               ; Yes, so save and leave entry section
  28.   ENDIF
  29.   ;must want to enter another film if we get here
  30.   ;(we would print last film entered on receipt at this point)
  31.   MOVETO [Customer #]                  ; Make sure we're in first field
  32.   FOR i FROM 1 TO 4
  33.     DITTO RIGHT                        ; Copy previous record's info
  34.   ENDFOR
  35. ENDWHILE
  36. ; We've got all the films for this customer stored in ORDTEMP. Now we need
  37. ; to extract the important information for our normalized table, ORDERS.
  38. CLEAR                                  ; Clear the canvas to alert user
  39. ?? "One moment while I update the files..."
  40. ; The following query extracts the information we keep in normalized table
  41. Query
  42.  
  43.  Ordtemp | Customer # |  Date  | Return Date |
  44.          | Check      | Check  | Check       |
  45.          |            |        |             |
  46.          |            |        |             |
  47.  
  48.  Ordtemp | Operator | Film # | Due Date | Rental Rate | Days Out |
  49.          | Check    | Check  | Check    | Check       | Check    |
  50.          |          |        |          |             |          |
  51.          |          |        |          |             |          |
  52.  
  53.  Ordtemp | Rewound? | Total Due |
  54.          | Check    | Check     |
  55.          |          |           |
  56.          |          |           |
  57.  
  58. Endquery
  59. DO_IT!                                 ; Execute the query
  60. ADD "Answer" "Orders"                  ; And save the normalized results
  61. ENDPROC ;DoCheckOut
  62.  
  63.  
  64.  
  65. PROC DoReturn()
  66.  
  67. ; Instead of processing returns the same way we did rentals, we'll use a
  68. ; different method, illustrating the power of the SCAN command to step
  69. ; us through relevant records.
  70. CLEARALL                               ; Clear the workspace
  71. Total = 0                              ; So far, the customer owes us nothing
  72. @ 0,0 ?? "Enter the number for the customer returning films: "
  73. ACCEPT "N" TO CustNum                  ; Get the customer number
  74. EDIT "Orders"                          ; Put the master orders table into play
  75. PICKFORM 1                             ;   showing it in a nice, neat form
  76. SCAN FOR [Customer #] = CustNum        ; Now, look through the table for our customer
  77.   MOVETO [Return Date]                 ; Make sure we're in Return Date field
  78.   IF ISBLANK([]) THEN                  ; Has film already been returned?
  79.     WAIT RECORD                        ; No, so let's see if it is being returned
  80.       PROMPT "Enter Film Return Information",
  81.              "[F2] to save data and move to next possible film return"
  82.       UNTIL "F2"
  83.     IF NOT ISBLANK([Return Date])                               ; Yes, film was returned
  84.       THEN [Days Out] = [Return Date] - [Date]                  ;   so, calculate amt due
  85.            IF [Rewound?] <> "Y"
  86.              THEN [Total Due] = [Rental Rate] * [Days Out] + 1  ; Our rewind charge is $1
  87.              ELSE [Total Due] = [Rental Rate] * [Days Out]
  88.            ENDIF
  89.            Total = Total + [Total Due]                          ; Update the customer total
  90.            ;if we were printing receipts, this is the place we'd print info for each film
  91.            ;if we were maintaining inventory status in FILMS table, we'd do that here, too
  92.     ENDIF
  93.   ENDIF
  94. ENDSCAN                                ; Keep looking until we've examine entire table
  95. ; If we get here, we've gone through all possible returns for customer, so
  96. ; it's time to update the file and collect the damages...
  97. DO_IT!                         ; update the ORDERS table to reflect returned films
  98. CLEAR                          ; Now show the total due from customer
  99. @ 0,0 ?? "Total for this customer was $",FORMAT("W6.2",Total)
  100. ?
  101. ? "Press {Enter} when ready for next action..."
  102. x = GETCHAR()
  103. ENDPROC ;DoReturn
  104.  
  105. WHILE (True)
  106.   CLEAR
  107.   SHOWMENU
  108.     "CheckoutFilm":"Process a film rental request.",
  109.     "ReturnFilm":"Process a film return.",
  110.     "Leave":"Return to Main menu."
  111.   TO Choice
  112.   SWITCH
  113.     CASE Choice = "CheckoutFilm":DoCheckOut()
  114.     CASE Choice = "ReturnFilm":DoReturn()
  115.     OTHERWISE : CLEARALL QUITLOOP
  116.   ENDSWITCH
  117. ENDWHILE
  118.  
  119.