home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / SAMPLE / CUSTOMER.PRG < prev    next >
Encoding:
Text File  |  1989-11-07  |  5.8 KB  |  237 lines

  1. * ┌─────────────────────────────────────────────────────────────────────┐ *
  2. * │  PROG NAME: CUSTOMER.PRG - Customer file maintenance.               │ *
  3. * │  Copyright (c) 1989 Tech III, Inc. All rights reserved.             │ *
  4. * │  Tech III of San Pedro, California      (213) 547-2191.             │ *
  5. * │  "The bridge connecting people and technology."(tm)                 │ *
  6. * └─────────────────────────────────────────────────────────────────────┘ *
  7.  
  8. DO set_cus
  9. STORE SPACE(6) TO mcust_id
  10. SELECT customer
  11. SET ORDER TO cus_cus
  12. IF EOF()
  13.   GO TOP
  14. ENDIF
  15. STORE cust_id TO mcust_id
  16. DO disp_cus
  17. DO show_cus
  18. STORE .t. TO in_cus
  19. DO WHILE in_cus
  20.   ACTIVATE MENU customer PAD search
  21.   IF .NOT. in_prodemo
  22.       DEACTIVATE MENU
  23.   ENDIF
  24. ENDDO
  25. DO shutdn_cus
  26. RETURN
  27.  
  28. PROCEDURE add_cus
  29.   DO disp_cus
  30.   STORE SPACE(6) TO mcust_id
  31.   ACTIVATE WINDOW custwind
  32.   @ 01,12 GET mcust_id PICT '!!!!!!'
  33.   READ
  34.   SEEK mcust_id
  35.   IF FOUND()
  36.     DO show_cus
  37.     DO standby WITH "Can't add this record: it's already on file."
  38.     RETURN
  39.   ELSE
  40.     APPEND BLANK
  41.     REPLACE NEXT 1 cust_id WITH mcust_id
  42.   ENDIF
  43.   DO edit_cus
  44.   RETURN
  45.   
  46. PROCEDURE del_cus
  47.   STORE .f. TO do_it
  48.   ACTIVATE WINDOW msg2user
  49.   @ 1,2 SAY 'Are you sure you want to delete this record? ' GET do_it PICT 'Y'
  50.   READ
  51.   DEACTIVATE WINDOW msg2user
  52.   IF .NOT. do_it
  53.     RETURN
  54.   ENDIF
  55.   DELETE
  56.   IF .NOT. EOF()
  57.     SKIP
  58.   ENDIF
  59.   IF EOF()
  60.     GO BOTTOM
  61.   ENDIF
  62.   DO show_cus
  63.   RETURN
  64.   
  65. PROCEDURE disp_cus
  66.   ACTIVATE WINDOW custwind
  67.   CLEAR
  68.   @ 01,02 SAY "Customer:"
  69.   @ 03,02 SAY " Company:"
  70.   @ 04,02 SAY " Contact:"
  71.   @ 05,02 SAY " Address:"
  72.   @ 08,02 SAY "Tax Rate:"
  73.   RETURN
  74.   
  75. PROCEDURE edit_com
  76.   ON KEY LABEL F10 KEYBOARD CHR(23)
  77.   ACTIVATE WINDOW screensim BOTTOM
  78.   SHOW WINDOW comm_help
  79.   MODIFY MEMO comments WINDOW memowind SAVE
  80.   MODIFY MEMO comments WINDOW memowind NOWAIT
  81.   HIDE WINDOW comm_help
  82.   RETURN
  83.   
  84. PROCEDURE edit_cus
  85.   ACTIVATE WINDOW custwind
  86.   @ 01,12 GET cust_id PICT '!!!!!!'
  87.   CLEAR GETS
  88.   @ 03,12 GET company
  89.   @ 04,12 GET contact
  90.   @ 05,12 GET address1
  91.   @ 06,12 GET city
  92.   @ 06,37 GET state    PICTURE '!!'  VALID V_STATE(state)
  93.   @ 06,42 GET zip      PICTURE  '99999'
  94.   @ 08,12 GET taxrate  PICTURE '9.99'
  95.   READ
  96.   DO show_cus
  97.   RETURN
  98.   
  99. PROCEDURE last_cus
  100.   GO BOTTOM
  101.   DO show_cus
  102.   RETURN
  103.   
  104. PROCEDURE next_cus
  105.   SKIP
  106.   IF EOF()
  107.     GO BOTTOM
  108.     DO standby WITH "End of file: there is no NEXT customer."
  109.   ELSE
  110.     DO show_cus
  111.   ENDIF
  112.   RETURN
  113.   
  114. PROCEDURE prev_cus
  115.   SKIP -1
  116.   IF BOF()
  117.     GO TOP
  118.     DO standby WITH "Beginning of file: there is no PREVIOUS customer."
  119.   ELSE
  120.     DO show_cus
  121.   ENDIF
  122.   RETURN
  123.   
  124. PROCEDURE quit_cus
  125.   STORE .f. TO in_cus
  126.   DEACTIVATE MENU
  127.   RETURN
  128.   
  129. PROCEDURE set_cus
  130.   SELECT 0
  131.   USE states INDEX states ALIAS states
  132.   SELECT customer
  133.   
  134.   ACTIVATE WINDOW screensim
  135.   CLEAR
  136.   
  137.   DEFINE WINDOW custwind FROM 02,02 TO 13,77 TITLE '< Customer >' COLOR SCHEME 10
  138.   DEFINE WINDOW memowind FROM 14,02 TO 21,77 TITLE '< Comments >' ;
  139.   ZOOM system COLOR SCHEME 10 && for editing comments
  140.   
  141.   DEFINE WINDOW comm_help FROM 09,17 TO 12,63 DOUBLE CLOSE COLOR SCHEME 7
  142.   ACTIVATE WINDOW comm_help NOSHOW
  143.   @ 00,01 SAY 'When finished editing, press [F10].'
  144.   HIDE WINDOW comm_help
  145.   
  146.   SET MEMOWIDTH TO 70
  147.   
  148.   DEFINE POPUP states FROM 01,35 TO 10,40 PROMPT FIELD state COLOR SCHEME 11
  149.   ON SELECTION POPUP states DEACTIVATE POPUP
  150.   
  151.   DEFINE MENU customer COLOR SCHEME 3
  152.   DEFINE PAD pnext   OF customer PROMPT '\<Next'   AT 21,01
  153.   DEFINE PAD pprev   OF customer PROMPT '\<Prev'   AT 21,08
  154.   DEFINE PAD pfirst  OF customer PROMPT '\<First'  AT 21,15
  155.   DEFINE PAD plast   OF customer PROMPT '\<Last'   AT 21,23
  156.   DEFINE PAD psearch OF customer PROMPT '\<Search' AT 21,30
  157.   DEFINE PAD pedit   OF customer PROMPT '\<Edit'   AT 21,39
  158.   DEFINE PAD pappend OF customer PROMPT '\<Add'    AT 21,46
  159.   DEFINE PAD pdelete OF customer PROMPT '\<Delete' AT 21,52
  160.   DEFINE PAD pcomm   OF customer PROMPT '\<Comment' AT 21,61
  161.   DEFINE PAD pquit   OF customer PROMPT '\<Quit'   AT 21,71
  162.   ON SELECTION PAD pnext      OF customer DO next_cus
  163.   ON SELECTION PAD pprev      OF customer DO prev_cus
  164.   ON SELECTION PAD pfirst     OF customer DO top_cus
  165.   ON SELECTION PAD plast      OF customer DO last_cus
  166.   ON SELECTION PAD psearch    OF customer DO srch_cus
  167.   ON SELECTION PAD pedit      OF customer DO edit_cus
  168.   ON SELECTION PAD pappend    OF customer DO add_cus
  169.   ON SELECTION PAD pdelete    OF customer DO del_cus
  170.   ON SELECTION PAD pcomm      OF customer DO edit_com
  171.   ON SELECTION PAD pquit      OF customer DO quit_cus
  172.   RETURN
  173.   
  174. PROCEDURE shutdn_cus
  175.   DEACTIVATE WINDOW screensim
  176.   RELEASE    WINDOW custwind
  177.   CLOSE      MEMO   comments
  178.   RELEASE    WINDOW memowind
  179.   RELEASE    POPUP  states
  180.   RELEASE    MENU   customer
  181.   SELECT states
  182.   USE
  183.   SELECT customer
  184.   ACTIVATE SCREEN
  185.   RETURN
  186.   
  187. PROCEDURE show_cus
  188.   ACTIVATE WINDOW custwind
  189.   @ 1, 12 SAY cust_id PICT '!!!!!!'
  190.   @ 3, 12 SAY company
  191.   @ 4, 12 SAY contact
  192.   @ 5, 12 SAY address1
  193.   @ 6, 12 SAY city
  194.   @ 6, 37 SAY state
  195.   @ 06,42 SAY zip
  196.   @ 08,12 SAY taxrate PICTURE '9.99'
  197.   ACTIVATE WINDOW screensim BOTTOM
  198.   MODIFY MEMO comments WINDOW memowind NOWAIT
  199.   RETURN
  200.   
  201. PROCEDURE srch_cus
  202.   ACTIVATE WINDOW custwind
  203.   last_rec=RECNO()
  204.   DO disp_cus
  205.   STORE SPACE(6) TO mcust_id
  206.   @ 1,12 GET mcust_id PICT '!!!!!!'
  207.   READ
  208.   SEEK mcust_id
  209.   IF .NOT. FOUND()
  210.     DO standby WITH "There is no such customer"
  211.     GO last_rec
  212.   ENDIF
  213.   DO show_cus
  214.   RETURN
  215.   
  216. PROCEDURE top_cus
  217.   GO TOP
  218.   DO show_cus
  219.   RETURN
  220.   
  221. FUNCTION v_state
  222.   PARAMETER state
  223.   SELECT states
  224.   SEEK customer->state
  225.   IF FOUND()
  226.     SELECT customer
  227.     RETURN .t.
  228.   ENDIF
  229.   DO WHILE .NOT. FOUND()
  230.     ACTIVATE POPUP states
  231.     SEEK PROMPT()
  232.   ENDDO
  233.   SELECT customer
  234.   REPLACE customer->state WITH PROMPT()
  235.   RETURN .t.
  236.   * EOF
  237.