frmAdd.frm

 VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmAdd
   BackColor       =   &H8000000E&
   Caption         =   "Student Record"
   ClientHeight    =   6135
   ClientLeft      =   5010
   ClientTop       =   3135
   ClientWidth     =   9540
   LinkTopic       =   "Form1"
   Moveable        =   0   'False
   ScaleHeight     =   6135
   ScaleWidth      =   9540
   StartUpPosition =   2  'CenterScreen
   Begin MSComDlg.CommonDialog CommonDialog1
      Left            =   5400
      Top             =   3000
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      DefaultExt      =   ".jpg"
      DialogTitle     =   "Save File from Database as....."
      Filter          =   "Picture Files (*.jpg,*.bmp,*.wmf,*.emf)|*.jpg;*.bmp;*.wmf;*.emf|All files (*.*)|*.*"
   End
   Begin VB.CommandButton cmdPicSave
      Height          =   375
      Left            =   6480
      Style           =   1  'Graphical
      TabIndex        =   25
      ToolTipText     =   "Save Picture in a file..."
      Top             =   4440
      Width           =   495
   End
   Begin VB.CommandButton cmdPicInsert
      Height          =   375
      Left            =   6480
      Style           =   1  'Graphical
      TabIndex        =   24
      ToolTipText     =   "Browse for a picture to store in the database..."
      Top             =   3720
      Width           =   495
   End
   Begin VB.CommandButton cmdPicShow
      Height          =   375
      Left            =   6480
      Style           =   1  'Graphical
      TabIndex        =   23
      ToolTipText     =   "View Picture"
      Top             =   4080
      Width           =   495
   End
   Begin VB.Timer Timer2
      Interval        =   5
      Left            =   2760
      Top             =   5520
   End
   Begin VB.Timer Timer1
      Interval        =   1
      Left            =   2280
      Top             =   5520
   End
   Begin MSAdodcLib.Adodc Adodc1
      Height          =   330
      Left            =   600
      Top             =   7320
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Arjay Folder\downloads\New\viray.mdb;Persist Security Info=False"
      OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Arjay Folder\downloads\New\viray.mdb;Persist Security Info=False"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "tblViray"
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton cmdUpdate
      Height          =   615
      Index           =   2
      Left            =   7800
      Picture         =   "frmAdd.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   19
      Top             =   5160
      Width           =   615
   End
   Begin VB.CommandButton cmdClose
      Cancel          =   -1  'True
      Height          =   615
      Left            =   8640
      Picture         =   "frmAdd.frx":04FF
      Style           =   1  'Graphical
      TabIndex        =   18
      Top             =   5160
      Width           =   615
   End
   Begin VB.TextBox txtCN
      Height          =   285
      Left            =   2160
      TabIndex        =   17
      Top             =   4560
      Width           =   3255
   End
   Begin VB.TextBox txtAdd
      Height          =   855
      Left            =   1320
      MultiLine       =   -1  'True
      TabIndex        =   16
      Top             =   3600
      Width           =   3975
   End
   Begin MSComCtl2.DTPicker DTDOB
      Height          =   255
      Left            =   1800
      TabIndex        =   15
      Top             =   3240
      Width           =   2415
      _ExtentX        =   4260
      _ExtentY        =   450
      _Version        =   393216
      Format          =   16449537
      CurrentDate     =   40171
   End
   Begin VB.ComboBox cmbYear
      Height          =   315
      Left            =   4320
      TabIndex        =   14
      Top             =   2640
      Width           =   1095
   End
   Begin VB.ComboBox cmbCourse
      Height          =   315
      Left            =   960
      TabIndex        =   13
      Top             =   2640
      Width           =   1455
   End
   Begin VB.TextBox txtMI
      Height          =   285
      Left            =   5280
      MaxLength       =   2
      TabIndex        =   12
      Top             =   1680
      Width           =   615
   End
   Begin VB.TextBox txtFN
      Height          =   285
      Left            =   2760
      TabIndex        =   11
      Top             =   1680
      Width           =   2415
   End
   Begin VB.TextBox txtLN
      Height          =   285
      Left            =   240
      TabIndex        =   10
      Top             =   1680
      Width           =   2415
   End
   Begin VB.TextBox txtSN
      Height          =   285
      Left            =   2160
      TabIndex        =   9
      Top             =   1200
      Width           =   1215
   End
   Begin Viray.Photo Photo1
      Height          =   2535
      Left            =   6000
      TabIndex        =   26
      Top             =   1080
      Width           =   3255
      _ExtentX        =   5741
      _ExtentY        =   6165
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Save Picture"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   12
      Left            =   7080
      TabIndex        =   29
      Top             =   4560
      Width           =   1695
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Browse Picture"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   11
      Left            =   7080
      TabIndex        =   28
      Top             =   3840
      Width           =   1695
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "View Picture"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   1
      Left            =   7080
      TabIndex        =   27
      Top             =   4200
      Width           =   1695
   End
   Begin VB.Image Image1
      Height          =   555
      Left            =   240
      Picture         =   "frmAdd.frx":090C
      Top             =   240
      Width           =   540
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "New Blank Database "
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   15.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   1200
      TabIndex        =   22
      Top             =   240
      Width           =   3375
   End
   Begin VB.Label Label2
      BackColor       =   &H8000000E&
      Caption         =   "Save"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   0
      Left            =   7920
      TabIndex        =   21
      Top             =   5760
      Width           =   495
   End
   Begin VB.Label Label2
      BackColor       =   &H8000000E&
      Caption         =   "Cancel"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   1
      Left            =   8640
      TabIndex        =   20
      Top             =   5760
      Width           =   615
   End
   Begin VB.Line Line2
      X1              =   240
      X2              =   9360
      Y1              =   5040
      Y2              =   5040
   End
   Begin VB.Line Line1
      X1              =   240
      X2              =   9360
      Y1              =   960
      Y2              =   960
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Student Number:"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   10
      Left            =   240
      TabIndex        =   8
      Top             =   1200
      Width           =   1695
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "LastName"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   9
      Left            =   960
      TabIndex        =   7
      Top             =   2040
      Width           =   1095
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "First Name"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   8
      Left            =   3480
      TabIndex        =   6
      Top             =   2040
      Width           =   975
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "MI"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   7
      Left            =   5400
      TabIndex        =   5
      Top             =   2040
      Width           =   375
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Course"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   6
      Left            =   240
      TabIndex        =   4
      Top             =   2640
      Width           =   735
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Year Level"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   5
      Left            =   3000
      TabIndex        =   3
      Top             =   2640
      Width           =   1095
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Date of Birth"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   4
      Left            =   240
      TabIndex        =   2
      Top             =   3240
      Width           =   1335
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Address"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   3
      Left            =   240
      TabIndex        =   1
      Top             =   3600
      Width           =   855
   End
   Begin VB.Label Label1
      BackStyle       =   0  'Transparent
      Caption         =   "Contact Number"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   2
      Left            =   240
      TabIndex        =   0
      Top             =   4560
      Width           =   1695
   End
End
Attribute VB_Name = "frmAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim RS As New ADODB.Recordset
Dim cn As New ADODB.Connection
Private WithEvents ctrl As TextBox
Attribute ctrl.VB_VarHelpID = -1
Private WithEvents ctr  As ComboBox
Attribute ctr.VB_VarHelpID = -1
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdPicInsert_Click()
Photo1.OpenPhotoFile
End Sub
Private Sub cmdPicSave_Click()
On Error GoTo hell
    cmdlg.ShowSave
    If cmdlg.Filename <> "" Then
        SavePicture Photo1.Picture, cmdlg.Filename
    End If
hell:

End Sub

Private Sub cmdPicShow_Click()
On Error Resume Next
        Kill "tmp.jpg"
        SavePicture Photo1.Picture, "tmp.jpg"
        ShellEx "tmp.jpg"
End Sub

Private Sub cmdUpdate_Click(Index As Integer)
Dim RS As New ADODB.Recordset
If checker = True Then
RS.Open "Select* from tblViray", cn, adOpenDynamic, adLockPessimistic
RS.AddNew
    RS("SN") = txtSN.Text
    RS("LN") = txtLN.Text
    RS("FN") = txtFN.Text
    RS("MI") = txtMI.Text
    RS("COURSE") = cmbCourse.Text
    RS("YEARLEV") = cmbYear.Text
    RS("DOB") = DTDOB.Value
    RS("ADD") = txtAdd.Text
    RS("CN") = txtCN.Text
    Photo1.SavePhoto RS.Fields("Picture")
RS.Update
MsgBox "RecordSaved!"
Locker

End If
End Sub
Private Sub Locker()
txtSN.Locked = True
txtLN.Locked = True
txtFN.Locked = True
txtMI.Locked = True
cmbCourse.Locked = True
cmbYear.Locked = True
txtAdd.Locked = True
txtCN.Locked = True
End Sub


Private Sub Form_Load()
On Error Resume Next
AnimateForm Me, aLoad, aMedium
Set RS = New ADODB.Recordset
RS.AddNew
    RS("SN") = txtSN.Text
    RS("LN") = txtLN.Text
    RS("FN") = txtFN.Text
    RS("MI") = txtMI.Text
    RS("COURSE") = cmbCourse.Text
    RS("YEARLEV") = cmbYear.Text
    RS("DOB") = DTDOB.Value
    RS("ADD") = txtAdd.Text
    RS("CN") = txtCN.Text
    Photo1.SavePhoto RS.Fields("Picture")
Timer1.Enabled = True
Timer2.Enabled = True
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Viray.mdb;"
With RS
        .ActiveConnection = cn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Source = "select * from tblViray"
        .Open
End With
If Len(RS!Picture) > 0 Then
            Photo1.LoadPhoto RS!Picture
        End If


        With RS
            If .RecordCount < 1 Then
                txtcount.Text = 0
            Else
                txtcount.Text = .AbsolutePosition
            End If
            lblmax.Caption = .RecordCount
        End With

End Sub

Private Sub Form_Unload(Cancel As Integer)
AnimateForm Me, aUnload, aMedium
End Sub

Private Sub Timer1_Timer()
cmbCourse.AddItem ("BSIT")
cmbCourse.AddItem ("BSHRM")
cmbCourse.AddItem ("BSEd")
cmbCourse.AddItem ("HRS")
cmbCourse.AddItem ("ICT")
cmbCourse.AddItem ("Caregivimg")

cmbYear.AddItem ("1st")
cmbYear.AddItem ("2nd")
cmbYear.AddItem ("3rd")
cmbYear.AddItem ("4th")

Timer1.Enabled = False
End Sub

Function checker() As Boolean
Dim X
For Each X In Me
    If TypeOf X Is TextBox Then
        If X.Text = "" Then
            MsgBox ("insuficient data!")
            X.SetFocus
            checker = False
            Exit Function
        End If
    ElseIf TypeOf X Is ComboBox Then
        If X.Text = "" Then
            MsgBox ("insuficient data!")
            X.SetFocus
            checker = False
            Exit Function
        End If
    End If
Next
checker = True
End Function


Private Sub Timer2_Timer()
If TypeOf Me.ActiveControl Is TextBox Then
    Set ctrl = Me.ActiveControl
   Me.ActiveControl.BackColor = &H80C0FF
ElseIf TypeOf Me.ActiveControl Is ComboBox Then
    Set ctr = Me.ActiveControl
   Me.ActiveControl.BackColor = &H80C0FF
End If
End Sub
Private Sub ctrl_LostFocus()
    ctrl.BackColor = vbWhite
End Sub
Private Sub ctr_LostFocus()
    ctr.BackColor = vbWhite
End Sub



Private Sub txtAdd_Change()
SendKeys "{end}"
txtAdd.Text = StrConv(txtAdd.Text, vbProperCase)

End Sub

Private Sub txtCN_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
    Case 48 To 57
    Case 13
    Case 8
    Case Else
        KeyAscii = 0
End Select
End Sub

Private Sub txtFN_Change()
SendKeys "{end}"
txtFN.Text = StrConv(txtFN.Text, vbProperCase)

End Sub

Private Sub txtFN_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
    Case 97 To 122
    Case 65 To 90
    Case 32
    Case 8
    Case Else
        KeyAscii = 0
End Select
End Sub

Private Sub txtLN_Change()
SendKeys "{end}"
txtLN.Text = StrConv(txtLN.Text, vbProperCase)

End Sub

Private Sub txtLN_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
    Case 97 To 122
    Case 65 To 90
    Case 32
    Case 8
    Case Else
        KeyAscii = 0
End Select
End Sub


Private Sub txtMI_Change()
SendKeys "{end}"
txtMI.Text = StrConv(txtMI.Text, vbProperCase)

End Sub

Private Sub txtMI_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
    Case 97 To 122
    Case 65 To 90
    Case 32
    Case 8
    Case Else
        KeyAscii = 0
End Select
End Sub



Private Sub txtSN_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
    Case 48 To 57
    Case 13
    Case 8
    Case Else
        KeyAscii = 0
End Select
End Sub

Project Homepage: