home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form itemedit
- Caption = "Tape Inventory"
- ClientHeight = 5130
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7695
- Height = 5535
- Left = 1035
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 5130
- ScaleWidth = 7695
- Top = 1140
- Width = 7815
- Begin CommandButton ButtonDone
- Caption = "E&xIt"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 615
- Left = 6120
- TabIndex = 11
- Top = 4200
- Width = 975
- End
- Begin CommandButton ButtonDelete
- Caption = "&Delete"
- Height = 615
- Left = 4440
- TabIndex = 14
- Top = 4200
- Visible = 0 'False
- Width = 1095
- End
- Begin CommandButton ButtonCancel
- Caption = "&Cancel"
- Height = 615
- Left = 1920
- TabIndex = 13
- Top = 4200
- Visible = 0 'False
- Width = 1095
- End
- Begin CommandButton ButtonOK
- Caption = "&OK"
- Height = 615
- Left = 360
- TabIndex = 12
- Top = 4200
- Visible = 0 'False
- Width = 975
- End
- Begin CommandButton ButtonNew
- Caption = "&Add"
- Height = 495
- Left = 6120
- TabIndex = 10
- Top = 3240
- Width = 975
- End
- Begin CommandButton ButtonEdit
- Caption = "&Edit"
- Height = 495
- Left = 6120
- TabIndex = 9
- Top = 2280
- Width = 975
- End
- Begin CommandButton ButtonLast
- Caption = "&Last"
- Height = 375
- Left = 6720
- TabIndex = 8
- Top = 1560
- Width = 735
- End
- Begin CommandButton ButtonFirst
- Caption = "&First"
- Height = 375
- Left = 5880
- TabIndex = 7
- Top = 1560
- Width = 735
- End
- Begin CommandButton ButtonNext
- Caption = "&Next"
- Height = 375
- Left = 6720
- TabIndex = 6
- Top = 960
- Width = 735
- End
- Begin CommandButton ButtonPrior
- Caption = "&Prior"
- Height = 375
- Left = 5880
- TabIndex = 5
- Top = 960
- Width = 735
- End
- Begin TextBox tapetitle
- Height = 375
- Left = 2160
- TabIndex = 2
- Text = " "
- Top = 960
- Width = 3495
- End
- Begin TextBox tapenumber
- Height = 375
- Left = 2160
- TabIndex = 1
- Text = " "
- Top = 480
- Width = 1215
- End
- Begin CommandButton ButtonFind
- Caption = "&Get"
- Height = 495
- Left = 6120
- TabIndex = 3
- Top = 240
- Width = 975
- End
- Begin Label Label4
- Caption = "In/Out:"
- Height = 375
- Left = 3720
- TabIndex = 17
- Top = 1800
- Width = 735
- End
- Begin Label inout_code
- BorderStyle = 1 'Fixed Single
- Caption = " "
- Height = 375
- Left = 4560
- TabIndex = 18
- Top = 1680
- Width = 735
- End
- Begin Label custnum
- BorderStyle = 1 'Fixed Single
- Caption = " "
- Height = 375
- Left = 2160
- TabIndex = 16
- Top = 1680
- Width = 1215
- End
- Begin Label Label3
- Caption = "Custmomer checkout:"
- Height = 495
- Left = 600
- TabIndex = 15
- Top = 1680
- Width = 1215
- End
- Begin Label Label2
- Caption = "Title"
- Height = 255
- Left = 600
- TabIndex = 0
- Top = 1080
- Width = 1335
- End
- Begin Label Label1
- Caption = "Tape number:"
- Height = 255
- Left = 600
- TabIndex = 4
- Top = 600
- Width = 1455
- End
- Dim iMode As Integer
- Dim blankitemrec As ITEM
- Dim saveitemrec As ITEM
- Const EDIT_MODE = 0
- Const ADD_MODE = 1
- Const VIEW_MODE = 2
- Sub ButtonCancel_Click ()
- If iMode = ADD_MODE Then
- itemrec = saveitemrec
- rc = GetItemRec(DBKEYED)
- If rc Then
- rc = GetItemRec(DBFIRST)
- End If
- End If
- FieldsToForm
- SetEditMode VIEW_MODE
- End Sub
- Sub ButtonDelete_Click ()
- '
- ' check if user pressed OK or CANCEL
- '
- Msg$ = "OK to delete?"
- rc = MsgBox(Msg$, MB_OKCANCEL + MB_ICONQUESTION, "DELETE")
- If rc = IDCANCEL Then
- SetEditMode VIEW_MODE
- Exit Sub
- End If
- rc = DeleteItemRec()
- If rc Then
- MsgBox "Delete failed, code: " + Str$(rc)
- Beep
- End If
- rc = GetItemRec(DBNEXT)
- If rc Then
- rc = GetItemRec(DBLAST)
- End If
- FieldsToForm
- SetEditMode VIEW_MODE
- End Sub
- Sub ButtonDone_Click ()
- Unload itemedit
- End Sub
- Sub ButtonEdit_Click ()
- screen.MousePointer = POINTER_HOURGLASS
- rc = GetItemRecForUpdate()
- If rc Then
- screen.MousePointer = POINTER_DEFAULT
- Exit Sub
- End If
- '
- ' Move the fields to the form again
- ' In a network environment, someone could have
- ' changed the record since last time is was shown
- '
- FieldsToForm
- SetEditMode EDIT_MODE
- screen.MousePointer = POINTER_DEFAULT
- End Sub
- Sub ButtonFind_Click ()
- FormToFields
- rc = GetItemRec(DBKEYED)
- If rc Then
- Exit Sub
- End If
- FieldsToForm
- End Sub
- Sub ButtonFirst_Click ()
- rc = GetItemRec(DBFIRST)
- If rc = DB_OK Then
- FieldsToForm
- End If
- End Sub
- Sub ButtonLast_Click ()
- rc = GetItemRec(DBLAST)
- If rc = DB_OK Then
- FieldsToForm
- End If
- End Sub
- Sub ButtonNew_Click ()
- Dim numvalue As Long
- SetEditMode ADD_MODE
- saveitemrec = itemrec
- rc = GetItemRec(DBLAST)
- If rc Then
- numvalue = 1
- Else
- numvalue = Val(itemrec.itemnumber)
- End If
- numvalue = numvalue + 1
- itemrec = blankitemrec
- itemrec.itemnumber = LTrim$(Str$(numvalue))
- FieldsToForm
- End Sub
- Sub ButtonNext_Click ()
- rc = GetItemRec(DBNEXT)
- If rc = DB_OK Then
- FieldsToForm
- End If
- End Sub
- Sub ButtonOK_Click ()
- FormToFields
- If iMode = ADD_MODE Then
- rc = AddItemRec()
- End If
- If iMode = EDIT_MODE Then
- rc = UpdateItemRec()
- End If
- '
- ' Assume if one of these failed, a message was
- ' already displayed as part of the function.
- '
- ' What to do if the add or update failed?
- ' For now invoke the CANCEL routine as though
- ' the user clicked the cancel button.
- '
- If rc Then
- ButtonCancel_Click
- Exit Sub
- End If
- '
- ' Return to view mode
- '
- SetEditMode VIEW_MODE
- End Sub
- Sub ButtonPrior_Click ()
- rc = GetItemRec(DBPRIOR)
- If rc = DB_OK Then
- FieldsToForm
- End If
- End Sub
- Sub FieldsToForm ()
- tapenumber.text = itemrec.itemnumber
- tapetitle.text = itemrec.itemdesc
- custnum.caption = itemrec.custnum
- inout_code.caption = itemrec.inout_code
- End Sub
- Sub Form_Load ()
- screen.MousePointer = POINTER_HOURGLASS
- rc = GetItemRec(DBFIRST)
- If rc = DB_OK Then
- FieldsToForm
- End If
- SetEditMode VIEW_MODE
- screen.MousePointer = POINTER_DEFAULT
- End Sub
- Sub FormToFields ()
- itemrec.itemnumber = tapenumber.text
- itemrec.itemdesc = tapetitle.text
- End Sub
- Sub SetEditMode (ByVal mode%)
- If mode = EDIT_MODE Or mode = ADD_MODE Then
- ButtonFirst.visible = False
- ButtonNext.visible = False
- ButtonPrior.visible = False
- ButtonLast.visible = False
- ButtonEdit.visible = False
- ButtonDone.visible = False
- ButtonFind.visible = False
- ButtonNew.visible = False
- ButtonOK.visible = True
- ButtonCancel.visible = True
- If mode = EDIT_MODE Then
- ButtonDelete.visible = True
- End If
- End If
- If mode = VIEW_MODE Then
- ' If a record was locked, unlock it
- ' this may already have been done,
- ' but make the function call again to be safe...
- '
- rc = UnlockRec(ITEM_TABLE)
- '
- ButtonFirst.visible = True
- ButtonNext.visible = True
- ButtonPrior.visible = True
- ButtonLast.visible = True
- ButtonEdit.visible = True
- ButtonDone.visible = True
- ButtonFind.visible = True
- ButtonNew.visible = True
- ButtonOK.visible = False
- ButtonCancel.visible = False
- ButtonDelete.visible = False
- End If
- If mode = ADD_MODE Then
- tapenumber.enabled = False
- Else
- tapenumber.enabled = True
- End If
- '
- ' Set global value as mode indicator
- '
- iMode = mode
- End Sub
-