VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsSchoolYear"
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 AddSY(ID As String, SY As String)
If rs.State = adStateOpen Then rs.Close
msql = " Select * From SchoolYear 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
    !SchoolYear = SY
    .Update
End With
MsgBox "New entry successfully saved to the record.", vbInformation
End Sub
Public Sub UpdateSY(ID As String, SY As String, OldID As String)
If rs.State = adStateOpen Then rs.Close
msql = " Update SchoolYear set id='" & ID & "',Schoolyear='" & SY & "' Where id='" & OldID & "'"
rs.Open msql, conn
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Public Sub DeleteSY(ID As String)
If rs.State = adStateOpen Then rs.Close
msql = " Delete * From SchoolYear Where ID='" & ID & "'"
rs.Open msql, conn
MsgBox "Record(s) Deleted", vbInformation, ""
End Sub

Public Sub DisplaySY(lstSY As ListView, SearchValue As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
    msql = " SELECT SchoolYear.ID, SchoolYear.SchoolYear" & _
           " From SchoolYear" & _
           " Where SchoolYear.SchoolYear like '" & SearchValue & "%'" & _
           " GROUP BY SchoolYear.ID, SchoolYear.SchoolYear" & _
           " ORDER BY SchoolYear.ID;"
Else
    msql = " SELECT SchoolYear.ID, SchoolYear.SchoolYear " & _
           " From SchoolYear" & _
           " GROUP BY SchoolYear.ID, SchoolYear.SchoolYear" & _
           " ORDER BY SchoolYear.ID;"
   End If
   rs.Open msql, conn
   lstSY.ListItems.Clear
   Do While Not rs.EOF
    a = a + 1
        Set lstItem = lstSY.ListItems.Add(, , a)
            lstItem.SubItems(1) = rs(0).Value
            lstItem.SubItems(2) = rs(1).Value
            rs.MoveNext
            Loop
            


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

End Function
