home *** CD-ROM | disk | FTP | other *** search
/ DOS Wares / doswares.zip / doswares / DATABASE / DBASE5 / CUA_SAMP.ZIP / AREACODE.PRG < prev    next >
Encoding:
Text File  |  1994-06-24  |  6.4 KB  |  273 lines

  1. PROCEDURE AreaCode
  2.     PRIVATE lVoid
  3.  
  4.     IF TYPE("Area.ClassName") # "C" && make sure form doesn't already exist!
  5.         #include "AreaCode.dfm"
  6.         PUBLIC NewRecord
  7.  
  8.         NewRecord = .F.
  9.  
  10.         Area.Action = .F.
  11.         lVoid = Area.Open()
  12.     ELSE
  13.         lVoid = Area.SetFocus() && if form already exists, bring to top
  14.     ENDIF
  15. RETURN
  16. ******************
  17. PROCEDURE OpenArea
  18.     PRIVATE lOpen
  19.  
  20.     lOpen = .T.     && is .DBF already open?
  21.  
  22.     IF SELECT("AreaCode") = 0       && Check to see if file is already open
  23.         SELECT SELECT()             && Let dBASE find an open workarea
  24.         USE Codes ALIAS AreaCode ORDER City
  25.         lOpen = .F.                 && file was not already open
  26.     ELSE
  27.         SELECT AreaCode
  28.     ENDIF
  29.  
  30.     This.lOpen = lOpen  && save lOpen to form
  31.     Main.App.Are.Enabled=.F.
  32.      Main.F1.CloseAll.Enabled=.F.
  33.     Main.S.Srch.Enabled=.T.
  34.     Main.S.Tp.Enabled=.T.
  35.     Main.S.Btm.Enabled=.T.
  36.     Main.S.Pck.Enabled=.F.
  37.     Main.S.Indx.Enabled=.F.
  38.     Main.E.Undo.Enabled=.T.
  39.     Main.E.Save.Enabled=.T.
  40.     Main.V.Frm.Enabled=.F.
  41.     Main.F1.Bac.Enabled=.F.
  42.  
  43.  
  44. RETURN
  45. ******************
  46. PROCEDURE CloseArea
  47.     IF This.Action
  48.         lVoid = This.Submit()
  49.     ELSE
  50.         IF This.Modified()
  51.             DO ErrorMsg WITH "Exit Area Code without save"
  52.         ENDIF
  53.     ENDIF
  54.  
  55.     IF .NOT. This.lOpen     && if file wasn't already open on startup
  56.         USE IN AreaCode     && then shut it down
  57.     ENDIF
  58.  
  59.     USE CODES EXCLUS
  60.     DELE FOR CITY=' '
  61.     COUNT FOR DELETED() TO EmpRec
  62.     IF EmpRec<>0
  63.       PACK
  64.     ENDIF
  65.     USE
  66.  
  67.  
  68.     Main.App.Are.Enabled=.T.
  69.      Main.F1.CloseAll.Enabled=.T.
  70.     Main.S.Srch.Enabled=.F.
  71.     Main.S.Tp.Enabled=.F.
  72.     Main.S.Btm.Enabled=.F.
  73.     Main.S.Pck.Enabled=.T.
  74.     Main.S.Indx.Enabled=.T.
  75.     Main.E.Undo.Enabled=.F.
  76.     Main.E.Save.Enabled=.F.
  77.     Main.V.Frm.Enabled=.T.
  78.     Main.F1.Bac.Enabled=.T.
  79.  
  80.  
  81.     lVoid = This.Release()
  82. RETURN
  83. ******************
  84. FUNCTION FindCode
  85.     SET ORDER TO City
  86.     * Generate a form that will can be used by other procedures
  87.     DO GenForm
  88.     * Make the user select Ok before moving on
  89.     lVoid = Search.sValue.Setfocus()
  90.     lVoid = Search.ReadModal()
  91.  
  92. RETURN .T.
  93. **********************
  94. PROCEDURE GenForm
  95.     * Define a search form
  96.     DEFINE FORM Search FROM 5,10 TO 11,45 ;
  97.         PROPERTY ;
  98.             Text "Search"
  99.  
  100.     DEFINE TEXT sVal OF Search AT 1,2 ;             && adjusted column
  101.         PROPERTY ;
  102.             Text "City :"
  103.     DEFINE ENTRYFIELD Svalue OF Search AT 1,9 ;     && adjusted column
  104.         PROPERTY ;
  105.             Width 20                                && fixed entryfield width
  106.     DEFINE PUSHBUTTON sOk OF Search AT 3,12 ;
  107.         PROPERTY ;
  108.             Default .T.,;                           && made OK button the default
  109.             Text    "&OK",;
  110.             Width    10  ,;
  111.             OnClick "CloseMe"
  112. RETURN
  113. *******************
  114. PROCEDURE CloseMe
  115.     CLEAR
  116.     * Get value user entered before closing form
  117.     SearchFor = Search.Svalue.value
  118.     SearchWidth = Search.Width  && See if size is Less than 50
  119.  
  120.     lVoid = Search.Close()
  121.     * remove from memory
  122.     lVoid = Search.Release()
  123.     IF LEN(SearchFor) > 0
  124.         *Now Search for value given - Exact match
  125.         SEEK(TRIM(SearchFor))
  126.  
  127.         IF FOUND()
  128.             Area.StatusMessage = "Found City = "+TRIM(SearchFor)
  129.             * repaint the form with the current record
  130.             lVoid = Area.Refresh()
  131.         ELSE
  132.             DO Errormsg WITH "City Not Found ..."+TRIM(SearchFor)
  133.         ENDIF
  134.     ENDIF
  135. RETURN
  136.  
  137. ******************
  138. PROCEDURE PrevHand
  139.  
  140.     * Check to see that the record pointer is not at Beginning of File
  141.     IF .NOT. BOF()
  142.         lVoid = Form.Submit()
  143.         SKIP -1
  144.         IF BOF()
  145.  
  146.         ENDIF
  147.         IF DELETED()
  148.            Form.cStatus.Text = "DELETED"
  149.         ELSE
  150.            Form.cStatus.Text = ""
  151.         Endif
  152.         lVoid = Form.Refresh()
  153.     ELSE
  154.         DO ErrorMsg WITH "Top of file!"
  155.     ENDIF
  156.     Form.Action = .F.
  157. RETURN
  158.  
  159. *******************
  160. PROCEDURE SkipHand
  161.  
  162.     * Check to see that the record pointer is not end of file
  163.     IF .NOT. EOF()
  164.         lVoid = Form.Submit()
  165.         SKIP
  166.         IF STR(CODE)=' '
  167.          SKIP -1
  168.          DO ERRORMSG WITH "End of file encountered!"
  169.         ENDIF
  170.         * Show user if the record is marked for deletion
  171.         IF DELETED()
  172.            Form.cStatus.Text = "DELETED"
  173.         ELSE
  174.            Form.cStatus.Text = ""
  175.         Endif
  176.         lVoid = Form.Refresh()
  177.     ELSE
  178.         * Record pointer is at the end of file, tell user
  179.         DO ErrorMsg WITH "End of file encountered!"
  180.     ENDIF
  181.     Form.Action = .F.
  182.  
  183. RETURN
  184. ******************
  185. PROCEDURE Add_new
  186.     NewRecord = .T.
  187.     *Write data to disk
  188.     lvoid = Form.submit()
  189.     APPEND BLANK
  190.     *Refresh Screen Data
  191.     lvoid = Form.refresh()
  192.     Form.cStatus.Text=""
  193. RETURN
  194. ******************
  195. PROCEDURE DelIt
  196.     IF DELETED()
  197.       Form.cStatus.Text = ""
  198.       RECALL
  199.     ELSE
  200.       Form.cStatus.Text = "DELETED"
  201.       DELETE
  202.     ENDIF
  203.  
  204. RETURN
  205. *****************
  206. PROCEDURE CanHand
  207.     Form.Action = .F.
  208.     lVoid = Form.Close()
  209. RETURN
  210. ******************
  211. PROCEDURE PrintForm
  212.  
  213. DEFINE FORM Prt FROM 5,25 TO 16,50 ;
  214.     PROPERTY ;
  215.         TEXT "Print Form"
  216.  
  217. DEFINE TEXT t1 OF Prt AT 1,1 ;
  218.     PROPERTY ;
  219.         Text "Type :",;
  220.         COLORNORMAL "R/W"
  221.  
  222. DEFINE RADIOBUTTON Rep OF Prt AT 2,1 ;
  223.     PROPERTY ;
  224.         Text "Report",;
  225.         Group .T.,;
  226.         COLORNORMAL "N/W",;
  227.         WIDTH 15
  228.  
  229. DEFINE RADIOBUTTON Lab OF Prt AT 3,1 ;
  230.     PROPERTY ;
  231.         Text "Labels",;
  232.         Group .F.,;
  233.         COLORDISABLED "N+/W",;
  234.         WIDTH 15,;
  235.         ENABLED .F.,;
  236.         TABSTOP .F.
  237.  
  238. DEFINE TEXT T3 OF Prt AT 9,5 ;
  239.     PROPERTY ;
  240.         TEXT "PRINTING ..." ,;
  241.         VISIBLE .F.,;
  242.         WIDTH 15
  243.  
  244. DEFINE PUSHBUTTON P1 OF Prt AT 8,12 ;
  245.     PROPERTY ;
  246.         TEXT "&Ok",;
  247.         ONCLICK "RunRep",;
  248.         Width 10
  249.  
  250. DEFINE PUSHBUTTON P2 OF Prt AT 8,2 ;
  251.     PROPERTY ;
  252.         TEXT "&Cancel",;
  253.         ONCLICK "CanHand",;
  254.         Width 10
  255.  
  256. lVoid = Prt.Open()
  257.  
  258. ******************
  259. PROCEDURE Runrep
  260.  
  261. * Check for Labels or Reports
  262. DO CASE
  263.     CASE Form.Rep.Value
  264.          * display to user something is happening
  265.          Form.T3.Visible = .t.
  266.          REPORT FORM Codes TO PRINTER
  267.  
  268. ENDCASE
  269. lVoid = Form.Close()
  270. lVoid = Form.Release()
  271. RETURN
  272.  
  273.