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

Public Sub DisplaySem(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 Semester.ID, Semester.SemesterName" & _
           " From Semester" & _
           " Where Semester.SemesterName like '" & SearchValue & "%'" & _
           " GROUP BY Semester.ID, Semester.SemesterName" & _
           " ORDER BY Semester.ID;"
Else
    msql = " SELECT Semester.ID, Semester.SemesterName" & _
           " From Semester" & _
           " GROUP BY Semester.ID, Semester.SemesterName" & _
           " ORDER BY Semester.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(Semester.ID) AS MaxOfID" & _
" FROM Semester;"
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


