VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsStudents"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim mrs As New ADODB.Recordset
Dim msql As String
Public Sub AddFaculty(ID As String, Lname As String, Fname As String, Mname As String, Address As String, Contact As String)
If rs.State = adStateOpen Then rs.Close
msql = "Select * From Faculty Where ID='" & ID & "'"
rs.Open msql, conn
If rs.RecordCount >= 1 Then
MsgBox "Duplicate ID.Please enter valid ID number.", vbCritical, ""
Exit Sub
End If
With rs
    .AddNew
    !ID = ID
    !Lname = Lname
    !Fname = Fname
    !Mname = Mname
    !Address = Address
    !Contact = Contact
    .Update
End With
MsgBox "New Student entry successfully saved to the record.", vbInformation
End Sub
Public Sub UpdateFaculty(ID As String, Lname As String, Fname As String, Mname As String, Address As String, Contact As String, OldID As String)
If rs.State = adStateOpen Then rs.Close
msql = " Update Faculty Set ID='" & ID & "',Lname='" & Lname & "',Fname='" & Fname & "',Mname='" & Mname & "',Address='" & Address & "',Contact='" & Contact & "' Where ID='" & OldID & "'"
rs.Open msql, conn
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Public Sub DeleteFaculty(ID As String)
If rs.State = adStateOpen Then rs.Close
msql = "Delete * From Faculty Where ID='" & ID & "'"
rs.Open msql, conn
MsgBox "Record(s) Deleted", vbInformation, ""
End Sub

Public Sub DisplayFacInfo(lstStud As ListView, SearchValue As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
msql = " SELECT Faculty.ID, Faculty.Lname, Faculty.Fname, Faculty.Mname, Faculty.Address, Faculty.Contact" & _
       " From Faculty" & _
       " Where Faculty.Lname like '" & SearchValue & "%'" & _
       " GROUP BY Faculty.ID, Faculty.Lname, Faculty.Fname, Faculty.Mname, Faculty.Address, Faculty.Contact" & _
       " ORDER BY Faculty.ID, Faculty.Lname;"
Else
msql = " SELECT Faculty.ID, Faculty.Lname, Faculty.Fname, Faculty.Mname, Faculty.Address, Faculty.Contact" & _
       " From Faculty" & _
       " GROUP BY Faculty.ID, Faculty.Lname, Faculty.Fname, Faculty.Mname, Faculty.Address, Faculty.Contact" & _
       " ORDER BY Faculty.ID, Faculty.Lname;"
End If
rs.Open msql, conn
lstStud.ListItems.Clear
Do While Not rs.EOF
a = a + 1
    Set lstItem = lstStud.ListItems.Add(, , a)
        lstItem.SubItems(1) = rs(0).Value
        lstItem.SubItems(2) = rs(1).Value
        lstItem.SubItems(3) = rs(2).Value
        lstItem.SubItems(4) = rs(3).Value
        lstItem.SubItems(5) = rs(4).Value
        lstItem.SubItems(6) = rs(5).Value
        rs.MoveNext
        Loop
End Sub

Public Function GetID() As String
If rs.State = adStateOpen Then rs.Close
msql = " SELECT Max(Faculty.ID) AS MaxOfID " & _
     " FROM Faculty;"
rs.Open msql, conn
If IsNull(rs(0).Value) Then
GetID = Format(1, "000000")
Else
GetID = Format(rs(0).Value + 1, "000000")
End If
End Function


