home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbpxen / itemedit.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-10-23  |  10.1 KB  |  373 lines

  1. VERSION 2.00
  2. Begin Form itemedit 
  3.    Caption         =   "Tape Inventory"
  4.    ClientHeight    =   5130
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   7695
  8.    Height          =   5535
  9.    Left            =   1035
  10.    LinkMode        =   1  'Source
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5130
  13.    ScaleWidth      =   7695
  14.    Top             =   1140
  15.    Width           =   7815
  16.    Begin CommandButton ButtonDone 
  17.       Caption         =   "E&xIt"
  18.       FontBold        =   -1  'True
  19.       FontItalic      =   0   'False
  20.       FontName        =   "MS Sans Serif"
  21.       FontSize        =   12
  22.       FontStrikethru  =   0   'False
  23.       FontUnderline   =   0   'False
  24.       Height          =   615
  25.       Left            =   6120
  26.       TabIndex        =   11
  27.       Top             =   4200
  28.       Width           =   975
  29.    End
  30.    Begin CommandButton ButtonDelete 
  31.       Caption         =   "&Delete"
  32.       Height          =   615
  33.       Left            =   4440
  34.       TabIndex        =   14
  35.       Top             =   4200
  36.       Visible         =   0   'False
  37.       Width           =   1095
  38.    End
  39.    Begin CommandButton ButtonCancel 
  40.       Caption         =   "&Cancel"
  41.       Height          =   615
  42.       Left            =   1920
  43.       TabIndex        =   13
  44.       Top             =   4200
  45.       Visible         =   0   'False
  46.       Width           =   1095
  47.    End
  48.    Begin CommandButton ButtonOK 
  49.       Caption         =   "&OK"
  50.       Height          =   615
  51.       Left            =   360
  52.       TabIndex        =   12
  53.       Top             =   4200
  54.       Visible         =   0   'False
  55.       Width           =   975
  56.    End
  57.    Begin CommandButton ButtonNew 
  58.       Caption         =   "&Add"
  59.       Height          =   495
  60.       Left            =   6120
  61.       TabIndex        =   10
  62.       Top             =   3240
  63.       Width           =   975
  64.    End
  65.    Begin CommandButton ButtonEdit 
  66.       Caption         =   "&Edit"
  67.       Height          =   495
  68.       Left            =   6120
  69.       TabIndex        =   9
  70.       Top             =   2280
  71.       Width           =   975
  72.    End
  73.    Begin CommandButton ButtonLast 
  74.       Caption         =   "&Last"
  75.       Height          =   375
  76.       Left            =   6720
  77.       TabIndex        =   8
  78.       Top             =   1560
  79.       Width           =   735
  80.    End
  81.    Begin CommandButton ButtonFirst 
  82.       Caption         =   "&First"
  83.       Height          =   375
  84.       Left            =   5880
  85.       TabIndex        =   7
  86.       Top             =   1560
  87.       Width           =   735
  88.    End
  89.    Begin CommandButton ButtonNext 
  90.       Caption         =   "&Next"
  91.       Height          =   375
  92.       Left            =   6720
  93.       TabIndex        =   6
  94.       Top             =   960
  95.       Width           =   735
  96.    End
  97.    Begin CommandButton ButtonPrior 
  98.       Caption         =   "&Prior"
  99.       Height          =   375
  100.       Left            =   5880
  101.       TabIndex        =   5
  102.       Top             =   960
  103.       Width           =   735
  104.    End
  105.    Begin TextBox tapetitle 
  106.       Height          =   375
  107.       Left            =   2160
  108.       TabIndex        =   2
  109.       Text            =   " "
  110.       Top             =   960
  111.       Width           =   3495
  112.    End
  113.    Begin TextBox tapenumber 
  114.       Height          =   375
  115.       Left            =   2160
  116.       TabIndex        =   1
  117.       Text            =   " "
  118.       Top             =   480
  119.       Width           =   1215
  120.    End
  121.    Begin CommandButton ButtonFind 
  122.       Caption         =   "&Get"
  123.       Height          =   495
  124.       Left            =   6120
  125.       TabIndex        =   3
  126.       Top             =   240
  127.       Width           =   975
  128.    End
  129.    Begin Label Label4 
  130.       Caption         =   "In/Out:"
  131.       Height          =   375
  132.       Left            =   3720
  133.       TabIndex        =   17
  134.       Top             =   1800
  135.       Width           =   735
  136.    End
  137.    Begin Label inout_code 
  138.       BorderStyle     =   1  'Fixed Single
  139.       Caption         =   " "
  140.       Height          =   375
  141.       Left            =   4560
  142.       TabIndex        =   18
  143.       Top             =   1680
  144.       Width           =   735
  145.    End
  146.    Begin Label custnum 
  147.       BorderStyle     =   1  'Fixed Single
  148.       Caption         =   " "
  149.       Height          =   375
  150.       Left            =   2160
  151.       TabIndex        =   16
  152.       Top             =   1680
  153.       Width           =   1215
  154.    End
  155.    Begin Label Label3 
  156.       Caption         =   "Custmomer checkout:"
  157.       Height          =   495
  158.       Left            =   600
  159.       TabIndex        =   15
  160.       Top             =   1680
  161.       Width           =   1215
  162.    End
  163.    Begin Label Label2 
  164.       Caption         =   "Title"
  165.       Height          =   255
  166.       Left            =   600
  167.       TabIndex        =   0
  168.       Top             =   1080
  169.       Width           =   1335
  170.    End
  171.    Begin Label Label1 
  172.       Caption         =   "Tape number:"
  173.       Height          =   255
  174.       Left            =   600
  175.       TabIndex        =   4
  176.       Top             =   600
  177.       Width           =   1455
  178.    End
  179. Dim iMode As Integer
  180. Dim blankitemrec As ITEM
  181. Dim saveitemrec As ITEM
  182. Const EDIT_MODE = 0
  183. Const ADD_MODE = 1
  184. Const VIEW_MODE = 2
  185. Sub ButtonCancel_Click ()
  186.     If iMode = ADD_MODE Then
  187.         itemrec = saveitemrec
  188.         rc = GetItemRec(DBKEYED)
  189.         If rc Then
  190.             rc = GetItemRec(DBFIRST)
  191.         End If
  192.     End If
  193.     FieldsToForm
  194.     SetEditMode VIEW_MODE
  195. End Sub
  196. Sub ButtonDelete_Click ()
  197.     '
  198.     '  check if user pressed OK or CANCEL
  199.     '
  200.     Msg$ = "OK to delete?"
  201.     rc = MsgBox(Msg$, MB_OKCANCEL + MB_ICONQUESTION, "DELETE")
  202.     If rc = IDCANCEL Then
  203.         SetEditMode VIEW_MODE
  204.         Exit Sub
  205.     End If
  206.     rc = DeleteItemRec()
  207.     If rc Then
  208.         MsgBox "Delete failed, code: " + Str$(rc)
  209.         Beep
  210.     End If
  211.     rc = GetItemRec(DBNEXT)
  212.     If rc Then
  213.         rc = GetItemRec(DBLAST)
  214.     End If
  215.     FieldsToForm
  216.     SetEditMode VIEW_MODE
  217. End Sub
  218. Sub ButtonDone_Click ()
  219.     Unload itemedit
  220. End Sub
  221. Sub ButtonEdit_Click ()
  222.     screen.MousePointer = POINTER_HOURGLASS
  223.     rc = GetItemRecForUpdate()
  224.     If rc Then
  225.         screen.MousePointer = POINTER_DEFAULT
  226.         Exit Sub
  227.     End If
  228.     '
  229.     '  Move the fields to the form again
  230.     '  In a network environment, someone could have
  231.     '  changed the record since last time is was shown
  232.     '
  233.     FieldsToForm
  234.     SetEditMode EDIT_MODE
  235.     screen.MousePointer = POINTER_DEFAULT
  236. End Sub
  237. Sub ButtonFind_Click ()
  238.     FormToFields
  239.     rc = GetItemRec(DBKEYED)
  240.     If rc Then
  241.         Exit Sub
  242.     End If
  243.     FieldsToForm
  244. End Sub
  245. Sub ButtonFirst_Click ()
  246.     rc = GetItemRec(DBFIRST)
  247.     If rc = DB_OK Then
  248.         FieldsToForm
  249.     End If
  250. End Sub
  251. Sub ButtonLast_Click ()
  252.     rc = GetItemRec(DBLAST)
  253.     If rc = DB_OK Then
  254.         FieldsToForm
  255.     End If
  256. End Sub
  257. Sub ButtonNew_Click ()
  258.     Dim numvalue As Long
  259.     SetEditMode ADD_MODE
  260.     saveitemrec = itemrec
  261.     rc = GetItemRec(DBLAST)
  262.     If rc Then
  263.         numvalue = 1
  264.     Else
  265.         numvalue = Val(itemrec.itemnumber)
  266.     End If
  267.     numvalue = numvalue + 1
  268.     itemrec = blankitemrec
  269.     itemrec.itemnumber = LTrim$(Str$(numvalue))
  270.     FieldsToForm
  271. End Sub
  272. Sub ButtonNext_Click ()
  273.     rc = GetItemRec(DBNEXT)
  274.     If rc = DB_OK Then
  275.         FieldsToForm
  276.     End If
  277. End Sub
  278. Sub ButtonOK_Click ()
  279.    FormToFields
  280.     If iMode = ADD_MODE Then
  281.         rc = AddItemRec()
  282.     End If
  283.     If iMode = EDIT_MODE Then
  284.         rc = UpdateItemRec()
  285.     End If
  286.     '
  287.     '  Assume if one of these failed, a message was
  288.     '  already displayed as part of the function.
  289.     '
  290.     '  What to do if the add or update failed?
  291.     '  For now invoke the CANCEL routine as though
  292.     '  the user clicked the cancel button.
  293.     '
  294.     If rc Then
  295.         ButtonCancel_Click
  296.         Exit Sub
  297.     End If
  298.     '
  299.     '  Return to view mode
  300.     '
  301.     SetEditMode VIEW_MODE
  302. End Sub
  303. Sub ButtonPrior_Click ()
  304.     rc = GetItemRec(DBPRIOR)
  305.     If rc = DB_OK Then
  306.         FieldsToForm
  307.     End If
  308. End Sub
  309. Sub FieldsToForm ()
  310.     tapenumber.text = itemrec.itemnumber
  311.     tapetitle.text = itemrec.itemdesc
  312.     custnum.caption = itemrec.custnum
  313.     inout_code.caption = itemrec.inout_code
  314. End Sub
  315. Sub Form_Load ()
  316.     screen.MousePointer = POINTER_HOURGLASS
  317.     rc = GetItemRec(DBFIRST)
  318.     If rc = DB_OK Then
  319.         FieldsToForm
  320.     End If
  321.     SetEditMode VIEW_MODE
  322.     screen.MousePointer = POINTER_DEFAULT
  323. End Sub
  324. Sub FormToFields ()
  325.     itemrec.itemnumber = tapenumber.text
  326.     itemrec.itemdesc = tapetitle.text
  327. End Sub
  328. Sub SetEditMode (ByVal mode%)
  329.     If mode = EDIT_MODE Or mode = ADD_MODE Then
  330.         ButtonFirst.visible = False
  331.         ButtonNext.visible = False
  332.         ButtonPrior.visible = False
  333.         ButtonLast.visible = False
  334.         ButtonEdit.visible = False
  335.         ButtonDone.visible = False
  336.         ButtonFind.visible = False
  337.         ButtonNew.visible = False
  338.         ButtonOK.visible = True
  339.         ButtonCancel.visible = True
  340.         If mode = EDIT_MODE Then
  341.             ButtonDelete.visible = True
  342.         End If
  343.     End If
  344.     If mode = VIEW_MODE Then
  345.         '  If a record was locked, unlock it
  346.         '  this may already have been done,
  347.         '  but make the function call again to be safe...
  348.         '
  349.         rc = UnlockRec(ITEM_TABLE)
  350.         '
  351.         ButtonFirst.visible = True
  352.         ButtonNext.visible = True
  353.         ButtonPrior.visible = True
  354.         ButtonLast.visible = True
  355.         ButtonEdit.visible = True
  356.         ButtonDone.visible = True
  357.         ButtonFind.visible = True
  358.         ButtonNew.visible = True
  359.         ButtonOK.visible = False
  360.         ButtonCancel.visible = False
  361.         ButtonDelete.visible = False
  362.     End If
  363.     If mode = ADD_MODE Then
  364.         tapenumber.enabled = False
  365.     Else
  366.         tapenumber.enabled = True
  367.     End If
  368.     '
  369.     '  Set global value as mode indicator
  370.     '
  371.     iMode = mode
  372. End Sub
  373.