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

  1. PROCEDURE Vendors
  2.     PRIVATE mFormOpen, lVoid, mDesk, mActive, mClass
  3.  
  4.      IF TYPE("Vend.ClassName") # "C"     && if form doesn't already exist
  5.          mFormOpen=.F.
  6.          DEFINE FORM mTemp PROPERTY VISIBLE .F.
  7.          lVoid = mTemp.OPEN()
  8.          mDesk = mTemp.PARENT
  9.          lVoid = mTemp.CLOSE()
  10.  
  11.          mFormName=SPACE(8)
  12.          mActive=mDesk.ActiveControl()
  13.          IF TYPE("mActive.ClassName")="C"
  14.              mClass=mActive.ClassName
  15.              IF mClass="FORM"
  16.                  mFormName=mActive.Name
  17.                  mFormOpen=.T.
  18.              ENDIF
  19.          ENDIF
  20.  
  21.          PUBLIC NewRecord
  22.  
  23.          #include "Vendors.dfm"
  24.  
  25.  
  26.  
  27.          NewRecord = .F.
  28.  
  29.          Vend.Action = .F.
  30.          lVoid = Vend.Open()
  31.  
  32.      ELSE
  33.            lVoid = Vend.SetFocus()     && if form exists, make current
  34.      ENDIF
  35.  
  36. RETURN
  37. ******************
  38. PROCEDURE OpenVend
  39.     PRIVATE lOpen
  40.  
  41.     lOpen = .T.     && Is .DBF already open?
  42.  
  43.     IF SUBSTR(DBF(),3)<>"VENDORS.DBF"
  44.         SELECT SELECT()
  45.         USE Vendors ORDER Vendor_Id ALIAS Vendors
  46.         lOpen = .F.     &&  .DBF was not already open
  47.     ELSE
  48.         SET ORDER TO Vendor_Id
  49.     ENDIF
  50.  
  51.     This.lOpen = lOpen  && save lOpen to form
  52.  
  53.     *Update radiobuttons
  54.     DO RadioUpd
  55.  
  56.     *Update the screen
  57.     lVoid = This.Refresh()
  58.  
  59.     IF .NOT. mFormOpen
  60.         Main.F1.CloseAll.Enabled=.F.
  61.         Main.S.Srch.Enabled=.T.
  62.         Main.S.Tp.Enabled=.T.
  63.         Main.S.Btm.Enabled=.T.
  64.         Main.S.Pck.Enabled=.F.
  65.         Main.S.Indx.Enabled=.F.
  66.         Main.E.Undo.Enabled=.T.
  67.         Main.E.Save.Enabled=.T.
  68.         Main.V.Frm.Enabled=.F.
  69.         Main.App.Gds.Enabled=.F.
  70.         Main.App.Inv.Enabled=.F.
  71.         Main.F1.Bac.Enabled=.F.
  72.     ENDIF
  73.     Main.App.Vend.Enabled=.F.
  74.     lVoid = Vend.Vendorid.Setfocus()
  75.  
  76. RETURN
  77.  
  78. ******************
  79. PROCEDURE PrevHand
  80.     IF Form.Modified()
  81.         lVoid = Form.Submit()
  82.     ENDIF
  83.     IF .NOT. BOF()
  84.         SKIP -1
  85.         IF BOF()
  86.            DO ErrorMsg WITH "Top of file!"
  87.         ENDIF
  88.         * Show user if the record is marked for deletion
  89.         IF DELETED()
  90.            Form.cStatus.Text = "DELETED"
  91.         ELSE
  92.            Form.cStatus.Text = ""
  93.         Endif
  94.  
  95.         *Update the Radio buttons
  96.         DO RadioUpd
  97.  
  98.         lVoid = Form.Refresh()
  99.     ELSE
  100.         DO ErrorMsg WITH "Top of file!"
  101.     ENDIF
  102.     Form.Action = .F.
  103. RETURN
  104. ******************
  105. PROCEDURE SkipHand
  106.     IF Form.Modified()
  107.         lVoid = Form.Submit()
  108.     ENDIF
  109.     IF .NOT. EOF()
  110.         SKIP
  111.         IF VENDOR_ID=' '
  112.          SKIP -1
  113.          DO ErrorMsg WITH "End of file encountered!"
  114.         ENDIF
  115.         * Show user if the record is marked for deletion
  116.         IF DELETED()
  117.            Form.cStatus.Text = "DELETED"
  118.         ELSE
  119.            Form.cStatus.Text = ""
  120.         Endif
  121.  
  122.         * Update Radio Buttons
  123.         DO RadioUpd
  124.  
  125.         * Update Screen repaint
  126.         lVoid = Form.Refresh()
  127.     ELSE
  128.         DO ErrorMsg WITH "End of file encountered!"
  129.     ENDIF
  130.     Form.Action = .F.
  131. RETURN
  132. *******************
  133. PROCEDURE RadioUpd
  134.     DO CASE
  135.         CASE Terms = "NET 15"
  136.             Vend.Net15.value = .T.
  137.  
  138.         CASE Terms = "NET 30"
  139.             Vend.Net30.Value = .T.
  140.     ENDCASE
  141.     *Set Focus to the Vendor Id field
  142.     lVoid = Vend.Next1.SetFocus()
  143.  
  144. RETURN
  145. *******************
  146. PROCEDURE CloseVend
  147.     IF This.Action
  148.         lVoid = This.Submit()
  149.     ELSE
  150.         IF This.Modified()
  151.             DO ErrorMsg WITH "Exit Vendors without saving ..."
  152.         ENDIF
  153.     ENDIF
  154.  
  155.     IF .NOT. This.lOpen && if .DBF was not open on startup
  156.         USE IN Vendors  && shut it down
  157.     ENDIF
  158.  
  159.     lVoid = This.Release()
  160.  
  161.     mFormOpen=.F.
  162.     DEFINE FORM mTemp PROPERTY VISIBLE .F.
  163.     lVoid = mTemp.OPEN()
  164.     mDesk = mTemp.PARENT
  165.     lVoid = mTemp.CLOSE()
  166.  
  167.     mFormName=SPACE(8)
  168.     mActive=mDesk.ActiveControl()
  169.     IF TYPE("mActive.ClassName")="C"
  170.         mClass=mActive.ClassName
  171.         IF mClass="FORM"
  172.             mFormName=mActive.Name
  173.             mFormOpen=.T.
  174.         ENDIF
  175.     ENDIF
  176.  
  177.     IF .NOT. mFormOpen
  178.         Main.F1.CloseAll.Enabled=.T.
  179.         Main.S.Srch.Enabled=.F.
  180.         Main.S.Tp.Enabled=.F.
  181.         Main.S.Btm.Enabled=.F.
  182.         Main.S.Pck.Enabled=.T.
  183.         Main.S.Indx.Enabled=.T.
  184.         Main.E.Undo.Enabled=.F.
  185.         Main.E.Save.Enabled=.F.
  186.         Main.V.Frm.Enabled=.T.
  187.         Main.App.Gds.Enabled=.T.
  188.         Main.App.Inv.Enabled=.T.
  189.         Main.F1.Bac.Enabled=.T.
  190.     ENDIF
  191.     Main.App.Vend.Enabled=.T.
  192.  
  193.     RELEASE Vend
  194.  
  195. RETURN
  196. ******************
  197. FUNCTION DupCheck
  198.      If NewRecord
  199.          ? "Checking for Duplicates ..."
  200.          SEEK(Vend.VendorId.Value)
  201.          IF FOUND()
  202.              DO ErrorMsg WITH "Duplicate Found, Try Again..."+Vend.VendorId.Value
  203.              RETURN .F.
  204.          ELSE
  205.              Newrecord = .f.
  206.          ENDIF
  207.      Endif
  208. RETURN .T.
  209. ******************
  210. FUNCTION FindNum
  211.  
  212.     * Generate a form that will can be used by other procedures
  213.     DO GenForm
  214.     * Make the user select Ok before moving on
  215.     lVoid = Search.sValue.Setfocus()
  216.     lVoid = Search.ReadModal()
  217.  
  218. *    ?"FindLast ok"
  219.  
  220. RETURN .T.
  221. **********************
  222. PROCEDURE NotThisOne
  223.       DO ErrorMsg WITH "... this red text does nothing"
  224. RETURN
  225. *****************
  226. PROCEDURE CloseMe
  227.     CLEAR
  228.     * Get value user entered before closing form
  229.     SearchFor = Search.Svalue.value
  230.     SearchWidth = Search.Width  && See if size is Less than 50
  231.  
  232.     lVoid = Search.Close()
  233.     * remove from memory
  234.     lVoid = Search.Release()
  235.     IF LEN(SearchFor) > 0
  236.         *Now Search for value given - Exact match
  237.         SEEK(SearchFor)
  238.  
  239.         IF FOUND()
  240.             Vend.StatusMessage = "Found Vendor = "+SearchFor
  241.             * repaint the form with the current record
  242.             lVoid = Form.Refresh()
  243.         ELSE
  244.             DO Errormsg WITH "Vendor # Not Found ..."+SearchFor
  245.         ENDIF
  246.     ENDIF
  247. RETURN
  248. ******************
  249. PROCEDURE PrevHand
  250.  
  251.     * Check to see that the record pointer is not at Beginning of File
  252.     IF .NOT. BOF()
  253.         lVoid = Form.Submit()
  254.         SKIP -1
  255.  
  256.         IF DELETED()
  257.            Form.cStatus.Text = "DELETED"
  258.         ELSE
  259.            Form.cStatus.Text = ""
  260.         Endif
  261.         lVoid = Form.Refresh()
  262.     ELSE
  263.         DO ErrorMsg WITH "Top of file!"
  264.     ENDIF
  265.     Form.Action = .F.
  266. RETURN
  267.  
  268. *******************
  269. PROCEDURE SkipHand
  270.  
  271.     * Check to see that the record pointer is not end of file
  272.     IF .NOT. EOF()
  273.         lVoid = Form.Submit()
  274.         SKIP
  275.  
  276.         * Show user if the record is marked for deletion
  277.         IF DELETED()
  278.            Form.cStatus.Text = "DELETED"
  279.         ELSE
  280.            Form.cStatus.Text = ""
  281.         Endif
  282.         lVoid = Form.Refresh()
  283.     ELSE
  284.         * Record pointer is at the end of file, tell user
  285.         DO ErrorMsg WITH "End of file encountered!"
  286.         SKIP -1
  287.     ENDIF
  288.     Form.Action = .F.
  289.  
  290. RETURN
  291. ******************
  292. PROCEDURE Add_new
  293.     NewRecord = .T.
  294.  
  295.     *Write data to disk
  296.     lvoid = Form.submit()
  297.  
  298.     * Append a record
  299.     APPEND BLANK
  300.  
  301.     *Refresh Screen Data
  302.     lvoid = Form.refresh()
  303.     Form.cStatus.Text=""
  304. RETURN
  305. ******************
  306. PROCEDURE DelIt && Marks record for deletion
  307.     IF DELETED()
  308.       Form.cStatus.Text = ""
  309.       RECALL
  310.     ELSE
  311.       Form.cStatus.Text = "DELETED"
  312.       DELETE
  313.     ENDIF
  314.  
  315. RETURN
  316. *****************
  317. PROCEDURE CanHand
  318.     Form.Action = .F.
  319.     lVoid = Form.Close()
  320. RETURN
  321. *****************
  322. PROCEDURE RePaint
  323.     SELE Vendors
  324.     lVoid = Vend.Refresh()
  325. RETURN
  326. ******************
  327. PROCEDURE PrintForm
  328.  
  329. DEFINE FORM Prt FROM 5,25 TO 16,50 ;
  330.     PROPERTY ;
  331.         TEXT "Print Form"
  332.  
  333. DEFINE TEXT t1 OF Prt AT 1,1 ;
  334.     PROPERTY ;
  335.         Text "Type :",;
  336.         COLORNORMAL "R/W"
  337.  
  338. DEFINE RADIOBUTTON Rep OF Prt AT 2,1 ;
  339.     PROPERTY ;
  340.         Text "Report",;
  341.         Group .T.,;
  342.         COLORNORMAL "N/W",;
  343.         WIDTH 15
  344.  
  345. DEFINE RADIOBUTTON Lab OF Prt AT 3,1 ;
  346.     PROPERTY ;
  347.         Text "Labels",;
  348.         Group .F.,;
  349.         COLORNORMAL "N/W",;
  350.         WIDTH 15
  351.  
  352. DEFINE TEXT T3 OF Prt AT 9,5 ;
  353.     PROPERTY ;
  354.         TEXT "PRINTING ..." ,;
  355.         VISIBLE .F.,;
  356.         WIDTH 15
  357.  
  358. DEFINE PUSHBUTTON P1 OF Prt AT 8,12 ;
  359.     PROPERTY ;
  360.         TEXT "&Ok",;
  361.         ONCLICK "RunRep",;
  362.         Width 10
  363.  
  364. DEFINE PUSHBUTTON P2 OF Prt AT 8,2 ;
  365.     PROPERTY ;
  366.         TEXT "&Cancel",;
  367.         ONCLICK "CanHand",;
  368.         Width 10
  369.  
  370. lVoid = Prt.Open()
  371.  
  372. ******************
  373. PROCEDURE Runrep
  374.  
  375. * Check for Labels or Reports
  376. DO CASE
  377.     CASE Form.Rep.Value
  378.          * display to user something is happening
  379.          Form.T3.Visible = .t.
  380.          REPORT FORM VENDORS TO PRINTER
  381.     CASE Form.Lab.Value
  382.          * display to user something is happening
  383.          Form.T3.Visible = .t.
  384.          LABEL FORM Vendors TO PRINTER
  385.  
  386. ENDCASE
  387. lVoid = Form.Close()
  388. lVoid = Form.Release()
  389. RETURN
  390.  
  391.  
  392.  
  393.