home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / VXBASE / VXBMOD.BAS < prev    next >
BASIC Source File  |  1993-12-01  |  13KB  |  377 lines

  1.  
  2. Sub BrowseTypes ()
  3.    ' Browse Aircraft Types File
  4.    ' Called from VXFORM1 OpenTypes_click and VXFORM2.TypeBrowse
  5.    ' ----------------------------------------------------------
  6.  
  7.    ' Select Airtypes File
  8.    ' --------------------
  9.    j% = vxSelectDbf(AirtypesDbf)
  10.    j% = vxSelectNtx(AirtypesNtx)
  11.  
  12.    ' Open a browse table with full editing capabilities
  13.    ' --------------------------------------------------
  14.    TypeReturn = 0  ' declared as GLOBAL so VXFORM2 can interrogate
  15.  
  16.    ' disable menu items
  17.    ' ------------------
  18.    VXFORM1.OpenTypes.Enabled = FALSE
  19.    VXFORM1.OpenCust.Enabled = FALSE
  20.    VXFORM1.PackFiles.Enabled = FALSE
  21.    VXFORM1.TestCreate.Enabled = FALSE
  22.    VXFORM1.TestCopy.Enabled = FALSE
  23.    VXFORM1.TestDataCopy.Enabled = FALSE
  24.  
  25.    Form2Active = TRUE  ' true so will be true when browse up
  26.  
  27.    ' Execute the browse routine (will use table declared in TypesOpen)
  28.    ' -----------------------------------------------------------------
  29.    TStartRec& = 0
  30.    Call vxBrowse(VXFORM1.hWnd, AirtypesDbf, AirtypesNtx, TRUE, TRUE, TRUE, TStartRec&, "Aircraft Types", TypeReturn)
  31.    
  32.    ' Browse returns a code or record number in TypeReturn var.
  33.    ' If an edit menu item is selected, a code is returned.
  34.    ' If the enter key is pressed, the record number is returned.
  35.    ' Double clicks when EditMode is true allow user to edit onscreen.
  36.    ' (return codes defined in global vxbase.txt)
  37.    ' ----------------------------------------------------------------
  38.    Select Case TypeReturn
  39.  
  40.       Case BROWSE_ERROR
  41.          MsgBox "Error in AirTypes Browse!"
  42.          VXFORM1.OpenTypes.Enabled = TRUE
  43.          VXFORM1.OpenCust.Enabled = TRUE
  44.          VXFORM1.PackFiles.Enabled = TRUE
  45.          VXFORM1.TestCreate.Enabled = TRUE
  46.          VXFORM1.TestCopy.Enabled = TRUE
  47.          VXFORM1.TestDataCopy.Enabled = TRUE
  48.          Form2Active = FALSE
  49.          Exit Sub
  50.       
  51.       ' user closed browse with sys menu
  52.       ' --------------------------------
  53.       Case BROWSE_CLOSED
  54.          j% = vxSelectDbf(AirtypesDbf)
  55.          j% = vxClose()
  56.          VXFORM1.OpenTypes.Enabled = TRUE
  57.          VXFORM1.OpenCust.Enabled = TRUE
  58.          VXFORM1.PackFiles.Enabled = TRUE
  59.          VXFORM1.TestCreate.Enabled = TRUE
  60.          VXFORM1.TestCopy.Enabled = TRUE
  61.          VXFORM1.TestDataCopy.Enabled = TRUE
  62.          Form2Active = FALSE
  63.          Exit Sub
  64.  
  65.       ' all other choices are processed by VXFORM2
  66.       ' ------------------------------------------
  67.       Case Else
  68.          VXFORM2.Show
  69.   
  70.    End Select
  71. End Sub
  72.  
  73. Function EmptyString (TestString As String) As Integer
  74.    EmptyString = TRUE
  75.    If Len(TestString) = 0 Then Exit Function
  76.    
  77.    For i% = 1 To Len(TestString)
  78.       If Mid$(TestString, i%, 1) <> Chr$(32) Then
  79.          EmptyString = FALSE
  80.          Exit For
  81.       End If
  82.    Next
  83.  
  84. End Function
  85.  
  86. ' Browse customer file
  87. ' called from VXFORM1 OpenCust_Click and VXFORM3.CustBrowse
  88. ' ---------------------------------------------------------
  89. Sub BrowseCust ()
  90.  
  91.    ' Select Aircust File
  92.    ' --------------------
  93.    j% = vxSelectDbf(AircustDbf)
  94.    j% = vxSelectNtx(Aircust1Ntx)  ' index on customer code
  95.  
  96.    ' Open a browse table with no onscreen full editing capabilities
  97.    ' --------------------------------------------------------------
  98.    CustReturn = 0  ' declared as GLOBAL so VXFORM3 can interrogate
  99.  
  100.    ' Disable all menu items because this
  101.    ' module uses all other files and we don't want to
  102.    ' interfere with its operation
  103.    ' ------------------------------------------------
  104.    VXFORM1.OpenTypes.Enabled = FALSE
  105.    VXFORM1.OpenCust.Enabled = FALSE
  106.    VXFORM1.OpenAircraft.Enabled = FALSE
  107.    VXFORM1.LinkBuyToSell.Enabled = FALSE
  108.    VXFORM1.LinkSellToBuy.Enabled = FALSE
  109.    VXFORM1.PackFiles.Enabled = FALSE
  110.    VXFORM1.TestCreate.Enabled = FALSE
  111.    VXFORM1.TestCopy.Enabled = FALSE
  112.    VXFORM1.TestDataCopy.Enabled = FALSE
  113.    VXFORM1.FileStruc.Enabled = FALSE
  114.  
  115.    Form3Active = TRUE  ' true so will be true when browse up
  116.  
  117.    ' Execute the browse routine (will use table declared in VXFORM0)
  118.    ' ---------------------------------------------------------------
  119.    TStartRec& = 0
  120.    Call vxBrowse(VXFORM1.hWnd, AircustDbf, Aircust1Ntx, FALSE, TRUE, TRUE, TStartRec&, "Customers", CustReturn)
  121.  
  122.    ' Browse returns a code or record number in CustReturn var.
  123.    ' If an edit menu item is selected, a code is returned.
  124.    ' If the enter key is pressed, the record number is returned.
  125.    ' Double clicks when EditMode is true allow user to edit onscreen.
  126.    ' (return codes defined in global vxbase.txt). In this case,
  127.    ' the EditMode% param is set to FALSE because we have data in
  128.    ' the record that must be properly verified. The onscreen edit
  129.    ' simply blasts the new data into the field and only checks it
  130.    ' for type (Numeric fields must have numbers, etc.).
  131.    ' ----------------------------------------------------------------
  132.   Select Case CustReturn
  133.       Case BROWSE_ERROR
  134.          MsgBox "Error in AirCust Browse!"
  135.          VXFORM1.OpenTypes.Enabled = TRUE
  136.          VXFORM1.OpenCust.Enabled = TRUE
  137.          VXFORM1.OpenAircraft.Enabled = TRUE
  138.          VXFORM1.LinkBuyToSell.Enabled = TRUE
  139.          VXFORM1.LinkSellToBuy.Enabled = TRUE
  140.          VXFORM1.PackFiles.Enabled = TRUE
  141.          VXFORM1.TestCreate.Enabled = TRUE
  142.          VXFORM1.TestCopy.Enabled = TRUE
  143.          VXFORM1.TestDataCopy.Enabled = TRUE
  144.          VXFORM1.FileStruc.Enabled = TRUE
  145.          Form3Active = FALSE
  146.          Exit Sub
  147.       
  148.       ' user closed browse with sys menu
  149.       ' --------------------------------
  150.       Case BROWSE_CLOSED
  151.          j% = vxSelectDbf(AircustDbf)
  152.          j% = vxClose()
  153.          j% = vxSelectDbf(AirstateDbf)
  154.          j% = vxClose()
  155.          VXFORM1.OpenTypes.Enabled = TRUE
  156.          VXFORM1.OpenCust.Enabled = TRUE
  157.          VXFORM1.OpenAircraft.Enabled = TRUE
  158.          VXFORM1.LinkBuyToSell.Enabled = TRUE
  159.          VXFORM1.LinkSellToBuy.Enabled = TRUE
  160.          VXFORM1.PackFiles.Enabled = TRUE
  161.          VXFORM1.TestCreate.Enabled = TRUE
  162.          VXFORM1.TestCopy.Enabled = TRUE
  163.          VXFORM1.TestDataCopy.Enabled = TRUE
  164.          VXFORM1.FileStruc.Enabled = TRUE
  165.          Form3Active = FALSE
  166.          Exit Sub
  167.  
  168.       ' all other choices are processed by VXFORM3
  169.       ' ------------------------------------------
  170.       Case Else
  171.          VXFORM3.Show
  172.   
  173.    End Select
  174. End Sub
  175.  
  176. Sub BuyerOpen ()
  177.    AirbuyerDbf = vxUseDbf("\vb\vxbtest\airbuyer.dbf")
  178.    Airbuy1Ntx = vxUseNtx("\vb\vxbtest\airbuy1.ntx")
  179.    Airbuy2Ntx = vxUseNtx("\vb\vxbtest\airbuy2.ntx")
  180. End Sub
  181.  
  182. Sub StatesOpen ()
  183.  
  184. ' open state abbreviations file
  185. ' -----------------------------
  186.    AirstateDbf = vxUseDbf("\vb\vxbtest\airstate.dbf")
  187.    If AirstateDbf = FALSE Then
  188.       MsgBox "Error Opening airstate.dbf. Aborting."
  189.       End
  190.    End If
  191.    Airstat1Ntx = vxUseNtx("\vb\vxbtest\airstat1.ntx")
  192.    Airstat2Ntx = vxUseNtx("\vb\vxbtest\airstat2.ntx")
  193.  
  194. ' Declare table used in help function
  195. ' -----------------------------------
  196.    Call vxTableDeclare(VX_BLUE, ByVal 0&, ByVal 0&, 0, 1, 2)
  197.    Call vxTableField(1, "Code", "statecode", VX_FIELD)
  198.    Call vxTableField(2, "Name", "statename", VX_FIELD)
  199.  
  200. End Sub
  201.  
  202. Sub AircraftOpen ()
  203. ' open aircraft file
  204. ' ------------------
  205.    AircraftDbf = vxUseDbf("\vb\vxbtest\aircraft.dbf")
  206.    If AircraftDbf = FALSE Then
  207.       MsgBox "Error Opening aircraft.dbf. Aborting."
  208.      End
  209.    End If
  210.    Aircraf1Ntx = vxUseNtx("\vb\vxbtest\aircraf1.ntx")
  211.    Aircraf2Ntx = vxUseNtx("\vb\vxbtest\aircraf2.ntx")
  212.  
  213. ' Declare Aircraft Table
  214. ' ----------------------
  215.    Call vxTableDeclare(VX_RED, ByVal 0&, ByVal 0&, 0, 1, 6)
  216.    Call vxTableField(1, "Type", "c_cat", VX_FIELD)
  217.    Call vxTableField(2, "Description", "left(c_desc,20)", VX_EXPR)
  218.    Call vxTableField(3, "Code", "c_code", VX_FIELD)
  219.    Call vxTableField(4, "Price", "c_price", VX_FIELD)
  220.    Call vxTableField(5, "Year", "c_year", VX_FIELD)
  221.    Call vxTableField(6, "TTSN", "c_ttsn", VX_FIELD)
  222.  
  223. End Sub
  224.  
  225. Sub BrowseBuyers ()
  226. ' Select Airbuyer File
  227. ' --------------------
  228.    j% = vxSelectDbf(AirbuyerDbf)
  229.    j% = vxSelectNtx(Airbuy1Ntx)  ' index on customer code
  230.  
  231. ' Open a browse table with no onscreen full editing capabilities
  232. ' --------------------------------------------------------------
  233.    BuyerReturn = 0  ' declared as GLOBAL so VXFORM4 can interrogate
  234.  
  235. ' Execute the browse routine (will use table declared in VXFORM3)
  236. ' ---------------------------------------------------------------
  237.    Call vxBrowse(VXFORM1.hWnd, AirbuyerDbf, Airbuy1Ntx, FALSE, FALSE, TRUE, BuyerRec, "Buyer Records for " + CustKey, BuyerReturn)
  238.  
  239.    Select Case BuyerReturn
  240.  
  241.       Case BROWSE_ERROR
  242.          MsgBox "Error in AirBuyer Browse!"
  243.          
  244.          ' set up return to customer form
  245.          ' ------------------------------
  246.          j% = vxClose()
  247.          StatesOpen
  248.          j% = vxSelectDbf(AircustDbf)
  249.          VXFORM3.Show
  250.          Exit Sub
  251.  
  252.       Case BROWSE_CLOSED
  253.          j% = vxSelectDbf(AirbuyerDbf)
  254.          Call vxTableReset
  255.          j% = vxClose()
  256.          j% = vxSelectDbf(AirtypesDbf)
  257.          Call vxTableReset
  258.          j% = vxClose()
  259.          StatesOpen
  260.          j% = vxSelectDbf(AircustDbf)
  261.          j% = vxSelectNtx(Aircust1Ntx)
  262.          j% = vxSeek(CustKey)
  263.          CustReturn = BROWSE_EDIT
  264.          VXFORM3.Show
  265.  
  266.       ' other choices are processed by VXFORM4
  267.       ' ------------------------------------------
  268.       Case Else
  269.          VXFORM4.Show
  270.    End Select
  271. End Sub
  272.  
  273. Sub TypesOpen ()
  274. ' Open aircraft types file
  275. ' ------------------------
  276.    AirtypesDbf = vxUseDbf("\vb\vxbtest\airtypes.dbf")
  277.    If AirtypesDbf = FALSE Then
  278.       MsgBox "Error Opening airtypes.dbf. Aborting."
  279.       Exit Sub
  280.    End If
  281.    AirtypesNtx = vxUseNtx("\vb\vxbtest\airtypes.ntx")
  282.    If AirtypesNtx = FALSE Then
  283.       MsgBox "Error Opening airtypes.ntx. Aborting."
  284.       j% = vxClose()
  285.       Exit Sub
  286.    End If
  287.  
  288.    
  289. ' Declare types table to get nice headings
  290. ' (TableDeclare works on currently selected DBF)
  291. ' ----------------------------------------------
  292.    Call vxTableDeclare(VX_RED, ByVal 0&, ByVal 0&, 0, 1, 2)
  293.    Call vxTableField(1, "Type", "category", VX_FIELD)
  294.    Call vxTableField(2, "Description", "catname", VX_FIELD)
  295.  
  296.    Call vxFilter(".NOT. deleted()")
  297. End Sub
  298.  
  299. Sub CursorWait ()
  300.    hinst% = 0
  301.    ctype& = IDC_WAIT
  302.    hcr% = LoadCursor(hinst%, ctype&)
  303.    j% = SetCursor(hcr%)
  304. End Sub
  305.  
  306. Sub CursorArrow ()
  307.    hinst% = 0
  308.    ctype& = IDC_ARROW
  309.    hcr% = LoadCursor(hinst%, ctype&)
  310.    j% = SetCursor(hcr%)
  311. End Sub
  312.  
  313. Sub BrowseAir ()
  314.    ' Browse Aircraft File
  315.    ' Called from VXFORM1 OpenAircraft_click and VXFORM6.AirBrowse
  316.    ' ------------------------------------------------------------
  317.  
  318.    ' Select Aircraft File
  319.    ' --------------------
  320.    j% = vxSelectDbf(AircraftDbf)
  321.    j% = vxSelectNtx(Aircraf2Ntx)
  322.  
  323.    ' Open a browse table no editing capabilities
  324.    ' -------------------------------------------
  325.    AircraftReturn = 0  ' declared as GLOBAL so VXFORM6 can interrogate
  326.  
  327.    ' Disable menu items
  328.    ' ------------------
  329.    VXFORM1.OpenCust.Enabled = FALSE
  330.    VXFORM1.OpenAircraft.Enabled = FALSE
  331.    VXFORM1.LinkBuyToSell.Enabled = FALSE
  332.    VXFORM1.LinkSellToBuy.Enabled = FALSE
  333.    VXFORM1.PackFiles.Enabled = FALSE
  334.    
  335.    Form6Active = TRUE  ' true so will be true when browse up
  336.  
  337. ' Execute the browse routine (will use table declared in VXFORM0)
  338. ' ---------------------------------------------------------------
  339.    Call vxBrowse(VXFORM1.hWnd, AircraftDbf, Aircraf2Ntx, FALSE, TRUE, FALSE, 0, "Aircraft On File", AircraftReturn)
  340.  
  341.    Select Case AircraftReturn
  342.  
  343.       Case BROWSE_ERROR
  344.          MsgBox "Error in AirCraft Browse!"
  345.          VXFORM1.OpenCust.Enabled = TRUE
  346.          VXFORM1.OpenAircraft.Enabled = TRUE
  347.          VXFORM1.LinkBuyToSell.Enabled = TRUE
  348.          VXFORM1.LinkSellToBuy.Enabled = TRUE
  349.          VXFORM1.PackFiles.Enabled = TRUE
  350.          Form6Active = FALSE
  351.          Exit Sub
  352.       
  353.       ' user closed browse with sys menu
  354.       ' --------------------------------
  355.       Case BROWSE_CLOSED
  356.          j% = vxSelectDbf(AircraftDbf)
  357.          j% = vxClose()
  358.          VXFORM1.OpenCust.Enabled = TRUE
  359.          VXFORM1.OpenAircraft.Enabled = TRUE
  360.          VXFORM1.LinkBuyToSell.Enabled = TRUE
  361.          VXFORM1.LinkSellToBuy.Enabled = TRUE
  362.          VXFORM1.PackFiles.Enabled = TRUE
  363.          Form6Active = FALSE
  364.          Exit Sub
  365.  
  366.       ' the only other choice is the user double-clicked
  367.       ' a record or pressed the enter key, thereby requesting
  368.       ' a full display on VXFORM6
  369.       ' ------------------------------------------------------
  370.       Case Else
  371.          VXFORM6.Show
  372.   
  373.    End Select
  374.  
  375. End Sub
  376.  
  377.