home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / timetrak / ttrak.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  11.9 KB  |  417 lines

  1. VERSION 2.00
  2. Begin Form ttrak 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Project Time Tracking"
  5.    ClientHeight    =   4110
  6.    ClientLeft      =   1380
  7.    ClientTop       =   1230
  8.    ClientWidth     =   7545
  9.    Height          =   4800
  10.    Icon            =   TTRAK.FRX:0000
  11.    Left            =   1320
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   4110
  15.    ScaleWidth      =   7545
  16.    Top             =   600
  17.    Width           =   7665
  18.    Begin CommandButton printbtn 
  19.       Caption         =   "Print"
  20.       Height          =   315
  21.       Left            =   1950
  22.       TabIndex        =   18
  23.       Top             =   3675
  24.       Width           =   3540
  25.    End
  26.    Begin CommandButton exitbtn 
  27.       Caption         =   "EXIT"
  28.       Height          =   495
  29.       Left            =   840
  30.       TabIndex        =   6
  31.       Top             =   2880
  32.       Width           =   1575
  33.    End
  34.    Begin CommandButton delbtn 
  35.       Caption         =   "DELETE"
  36.       Height          =   495
  37.       Left            =   840
  38.       TabIndex        =   5
  39.       Top             =   2160
  40.       Width           =   1575
  41.    End
  42.    Begin CommandButton addbtn 
  43.       Caption         =   "ADD"
  44.       Default         =   -1  'True
  45.       Height          =   495
  46.       Left            =   840
  47.       TabIndex        =   4
  48.       Top             =   1440
  49.       Width           =   1575
  50.    End
  51.    Begin ComboBox project 
  52.       BackColor       =   &H0000FFFF&
  53.       ForeColor       =   &H00FF0000&
  54.       Height          =   300
  55.       Left            =   600
  56.       TabIndex        =   0
  57.       Text            =   " "
  58.       Top             =   720
  59.       Width           =   2415
  60.    End
  61.    Begin Frame Frame1 
  62.       BackColor       =   &H00C0C0C0&
  63.       Caption         =   "information"
  64.       Height          =   1695
  65.       Left            =   3720
  66.       TabIndex        =   8
  67.       Top             =   120
  68.       Width           =   3135
  69.       Begin TextBox who 
  70.          BackColor       =   &H0000FFFF&
  71.          ForeColor       =   &H00FF0000&
  72.          Height          =   285
  73.          Left            =   1680
  74.          TabIndex        =   3
  75.          Text            =   " "
  76.          Top             =   1200
  77.          Width           =   975
  78.       End
  79.       Begin TextBox workdate 
  80.          BackColor       =   &H0000FFFF&
  81.          ForeColor       =   &H00FF0000&
  82.          Height          =   285
  83.          Left            =   1680
  84.          TabIndex        =   2
  85.          Text            =   " "
  86.          Top             =   840
  87.          Width           =   975
  88.       End
  89.       Begin TextBox hours 
  90.          BackColor       =   &H0000FFFF&
  91.          ForeColor       =   &H00FF0000&
  92.          Height          =   285
  93.          Left            =   1680
  94.          TabIndex        =   1
  95.          Text            =   " "
  96.          Top             =   480
  97.          Width           =   975
  98.       End
  99.       Begin Label Label4 
  100.          BackColor       =   &H00C0C0C0&
  101.          Caption         =   "Who"
  102.          Height          =   255
  103.          Left            =   480
  104.          TabIndex        =   11
  105.          Top             =   1200
  106.          Width           =   615
  107.       End
  108.       Begin Label Label3 
  109.          BackColor       =   &H00C0C0C0&
  110.          Caption         =   "Date"
  111.          Height          =   255
  112.          Left            =   480
  113.          TabIndex        =   10
  114.          Top             =   840
  115.          Width           =   615
  116.       End
  117.       Begin Label Label2 
  118.          BackColor       =   &H00C0C0C0&
  119.          Caption         =   "Hours"
  120.          Height          =   255
  121.          Left            =   480
  122.          TabIndex        =   9
  123.          Top             =   480
  124.          Width           =   735
  125.       End
  126.    End
  127.    Begin Label tothours 
  128.       BackColor       =   &H0000FFFF&
  129.       BorderStyle     =   1  'Fixed Single
  130.       Caption         =   " "
  131.       ForeColor       =   &H000000FF&
  132.       Height          =   375
  133.       Left            =   5520
  134.       TabIndex        =   15
  135.       Top             =   3000
  136.       Width           =   1215
  137.    End
  138.    Begin Label Label5 
  139.       BackColor       =   &H00C0C0C0&
  140.       Caption         =   "Total Hours"
  141.       FontBold        =   -1  'True
  142.       FontItalic      =   0   'False
  143.       FontName        =   "MS Serif"
  144.       FontSize        =   13.5
  145.       FontStrikethru  =   0   'False
  146.       FontUnderline   =   0   'False
  147.       Height          =   375
  148.       Left            =   3600
  149.       TabIndex        =   12
  150.       Top             =   3000
  151.       Width           =   1695
  152.    End
  153.    Begin Label totentry 
  154.       BackColor       =   &H0000FFFF&
  155.       BorderStyle     =   1  'Fixed Single
  156.       Caption         =   " "
  157.       ForeColor       =   &H000000FF&
  158.       Height          =   375
  159.       Left            =   5520
  160.       TabIndex        =   17
  161.       Top             =   2520
  162.       Width           =   1215
  163.    End
  164.    Begin Label Label7 
  165.       BackColor       =   &H00C0C0C0&
  166.       Caption         =   "Total Entries"
  167.       FontBold        =   -1  'True
  168.       FontItalic      =   0   'False
  169.       FontName        =   "MS Serif"
  170.       FontSize        =   13.5
  171.       FontStrikethru  =   0   'False
  172.       FontUnderline   =   0   'False
  173.       Height          =   375
  174.       Left            =   3600
  175.       TabIndex        =   16
  176.       Top             =   2520
  177.       Width           =   1815
  178.    End
  179.    Begin Label lastdate 
  180.       BackColor       =   &H0000FFFF&
  181.       BorderStyle     =   1  'Fixed Single
  182.       Caption         =   " "
  183.       ForeColor       =   &H000000FF&
  184.       Height          =   375
  185.       Left            =   5520
  186.       TabIndex        =   14
  187.       Top             =   2040
  188.       Width           =   1215
  189.    End
  190.    Begin Label Label6 
  191.       BackColor       =   &H00C0C0C0&
  192.       Caption         =   "Last Entry"
  193.       FontBold        =   -1  'True
  194.       FontItalic      =   0   'False
  195.       FontName        =   "MS Serif"
  196.       FontSize        =   13.5
  197.       FontStrikethru  =   0   'False
  198.       FontUnderline   =   0   'False
  199.       Height          =   375
  200.       Left            =   3600
  201.       TabIndex        =   13
  202.       Top             =   2025
  203.       Width           =   1575
  204.    End
  205.    Begin Label Label1 
  206.       BackColor       =   &H00C0C0C0&
  207.       Caption         =   "Project"
  208.       FontBold        =   -1  'True
  209.       FontItalic      =   0   'False
  210.       FontName        =   "MS Serif"
  211.       FontSize        =   18
  212.       FontStrikethru  =   0   'False
  213.       FontUnderline   =   0   'False
  214.       Height          =   495
  215.       Left            =   960
  216.       TabIndex        =   7
  217.       Top             =   120
  218.       Width           =   1335
  219.    End
  220.    Begin Menu about 
  221.       Caption         =   "&About..."
  222.    End
  223. Dim savproj As String
  224. Dim savhours As Long
  225. Dim recnbr As Long
  226. Sub about_Click ()
  227.     ttrakabt.Show
  228. End Sub
  229. Sub addbtn_Click ()
  230.     If project.text = "" Then
  231.         rc = MsgBox("Must enter Project Name", 48, "Warning")
  232.         Exit Sub
  233.     End If
  234.     If Get_Header() = PXERR_RECNOTFOUND Then
  235.        Create_Header 1
  236.     End If
  237.     lValue = Val(hours.text)
  238.     savhours = savhours + lValue
  239.     recnbr = recnbr + 1
  240.     Put_Header savhours, recnbr
  241.     Put_Record
  242.     tothours.caption = Str$(savhours)
  243.     lastdate.caption = workdate.text
  244.     totentry.caption = Str$(recnbr)
  245. End Sub
  246. Sub Create_Header (addflag As Integer) 'if 1 then add to project list
  247.         aValue = project.text
  248.         PutField ttrakRec, 1, "A"
  249.         lValue = 0
  250.         PutField ttrakRec, 2, "N"
  251.         aValue = "HDR"
  252.         PutField ttrakRec, 5, "A"
  253.         lValue = 0
  254.         PutField ttrakRec, 4, "N"
  255.         recnbr = 0
  256.         lValue = 0
  257.         PutField ttrakRec, 6, "N"
  258.         rc = PXRecAppend(ttrakTbl, ttrakRec)
  259.         PXError
  260.         If addflag = 1 Then
  261.             newproj$ = project.text
  262.             project.AddItem newproj$
  263.         End If
  264. End Sub
  265. Sub delbtn_Click ()
  266.     Dim dkey1 As String * 20
  267.     Dim dkey2 As Integer
  268.     dkey1 = RTrim$(project.text)
  269.     rc = PXPutAlpha(ttrakRec, 1, dkey1)
  270.     PXError
  271.     rc = PXSrchKey(ttrakTbl, ttrakRec, 1, SEARCHFIRST)
  272.     Do While rc <> PXERR_RECNOTFOUND And rc <> PXERR_ENDOFTABLE
  273.         rc = PXRecGet(ttrakTbl, ttrakRec)
  274.         PXError
  275.         rc = PXRecDelete(ttrakTbl)
  276.         PXError
  277.         rc = PXPutAlpha(ttrakRec, 1, dkey1)
  278.         rc = PXSrchKey(ttrakTbl, ttrakRec, 1, SEARCHFIRST)
  279.     Loop
  280.     hours.text = ""
  281.     workdate.text = ""
  282.     who.text = ""
  283.     lastdate.caption = ""
  284.     tothours.caption = ""
  285.     totentry.caption = ""
  286.     remove% = project.listindex
  287.     project.RemoveItem remove%
  288.     project.Refresh
  289. End Sub
  290. Sub exitbtn_Click ()
  291.     rc = PXTblClose(ttrakTbl)
  292.     rc = PXRecBufClose(ttrakRec)
  293.     rc = PXExit
  294.     End
  295. End Sub
  296. Sub Form_Load ()
  297.     If loadFlag <> PX_LOADED Then
  298.         PXInit "timetrak", PXSHARED
  299.         PXError
  300.         loadFlag = PX_LOADED
  301.     End If
  302.     tindex = 0
  303.     savproj = ""
  304. '   PXOpen "timetrak", ttrakTbl, ttrakRec
  305.     PXOpen DBPATH + "timetrak", ttrakTbl, ttrakRec
  306. '    Do While project.listcount
  307. '        project.RemoveItem 0
  308. '    Loop
  309.     rc = PXRecFirst(ttrakTbl)
  310.     PXError
  311.     rc = PXRecGet(ttrakTbl, ttrakRec)
  312.     PXError
  313.     Do Until rc <> PXSUCCESS
  314.         GetField ttrakRec, 1, "A"
  315.         If returnFld <> savproj Then
  316.             project.AddItem returnFld
  317.             savproj = returnFld
  318.         End If
  319.         PXNext ttrakTbl, ttrakRec
  320.     Loop
  321. End Sub
  322. Function Get_Header () As Integer
  323.     Dim key1 As String * 20
  324.     Dim key2 As Integer
  325.     key1 = project.text
  326.     rc = PXPutAlpha(ttrakRec, 1, key1)
  327.     PXError
  328.     key2 = 0
  329.     rc = PXPutShort(ttrakRec, 2, key2)
  330.     PXError
  331.     rc = PXSrchKey(ttrakTbl, ttrakRec, 2, SEARCHFIRST)
  332.     If rc = PXERR_RECNOTFOUND Then
  333.         Get_Header = rc
  334.     Else
  335.         PXError
  336.         rc = PXRecGet(ttrakTbl, ttrakRec)
  337.         Get_Header = rc
  338.         GetField ttrakRec, 6, "N"
  339.         recnbr = lValue
  340.         GetField ttrakRec, 4, "N"
  341.         savhours = lValue
  342.     End If
  343. End Function
  344. Sub printbtn_Click ()
  345.     projectName = project.text
  346.     printselect.Show
  347. End Sub
  348. Sub project_Change ()
  349.     savhours = 0
  350.     recnbr = 0
  351. End Sub
  352. Sub project_Click ()
  353.     hours.text = ""
  354.     who.text = ""
  355.     workdate.text = ""
  356.     savhours = 0
  357.     recnbr = 0
  358.     lastdate.caption = ""
  359.     tothours.caption = ""
  360.     totentry.caption = ""
  361.     If Get_Header() = PXERR_RECNOTFOUND Then
  362.         rc = MsgBox("No Header Rec. Create one?", 49, "Get Header")
  363.         If rc <> MBOK Then
  364.             Exit Sub
  365.         End If
  366.         Create_Header 0
  367.     End If
  368.     GetField ttrakRec, 3, "D"
  369.     lastdate.caption = returnFld
  370.     GetField ttrakRec, 4, "N"
  371.     tothours.caption = returnFld
  372.     savhours = Val(returnFld)
  373.     totentry.caption = Str$(recnbr)
  374. End Sub
  375. Sub Put_Header (hrs&, rnbr&)
  376.     vDate$ = workdate.text
  377.     If Gen_Date(vDate$) = 0 Then
  378.         PutField ttrakRec, 3, "D"
  379.     Else
  380.         rc = MsgBox("Invalid Date", 49, "Date Check")
  381.         If rc <> MBOK Then
  382.             Exit Sub
  383.         End If
  384.     End If
  385.     lValue = hrs
  386.     PutField ttrakRec, 4, "N"
  387.     aValue = "HDR"
  388.     PutField ttrakRec, 5, "A"
  389.     lValue = rnbr
  390.     PutField ttrakRec, 6, "N"
  391.     rc = PXRecUpdate(ttrakTbl, ttrakRec)
  392.     PXError
  393. End Sub
  394. Sub Put_Record ()
  395.     aValue = project.text
  396.     PutField ttrakRec, 1, "A"
  397.     lValue = recnbr
  398.     PutField ttrakRec, 2, "N"
  399.     vDate$ = workdate.text
  400.     If Gen_Date(vDate$) = 0 Then
  401.         PutField ttrakRec, 3, "D"
  402.     Else
  403.         rc = MsgBox("Invalid Date", 49, "Date Check")
  404.         If rc <> MBOK Then
  405.             Exit Sub
  406.         End If
  407.     End If
  408.     lValue = Val(hours.text)
  409.     PutField ttrakRec, 4, "N"
  410.     aValue = who.text
  411.     PutField ttrakRec, 5, "A"
  412.     lValue = recnbr
  413.     PutField ttrakRec, 6, "N"
  414.     rc = PXRecAppend(ttrakTbl, ttrakRec)
  415.     PXError
  416. End Sub
  417.