VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsDay"
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 AddDay(ID As String, DayName As String, DayInitial As String)
If rs.State = adStateOpen Then rs.Close
msql = " Select * from MyDay 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
    !DayName = DayName
    !DayInitial = DayInitial
    .Update
End With
MsgBox "New entry successfully saved to the record.", vbInformation
End Sub
Public Sub UpdateDay(ID As String, DayName As String, DayInitial As String, OldID As String)
If rs.State = adStateOpen Then rs.Close
msql = " Update MyDay set id='" & ID & "',DayName='" & DayName & "',DayInitial='" & DayInitial & "' Where id='" & OldID & "'"
rs.Open msql, conn
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Public Sub DeleteDay(ID As String)
If rs.State = adStateOpen Then rs.Close
msql = " Delete * From MyDay Where ID='" & ID & "'"
rs.Open msql, conn
MsgBox "Record(s) Deleted", vbInformation, ""
End Sub
Public Sub DisplayDay(lstDay As ListView)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close

    msql = " SELECT MyDay.ID, MyDay.DayName, MyDay.DayInitial" & _
           " From MyDay" & _
    " GROUP BY MyDay.ID, MyDay.DayName, MyDay.DayInitial " & _
    " ORDER BY MyDay.ID;"
 rs.Open msql, conn
   lstDay.ListItems.Clear
   Do While Not rs.EOF
    a = a + 1
        Set lstItem = lstDay.ListItems.Add(, , a)
            lstItem.SubItems(1) = rs(0).Value
            lstItem.SubItems(2) = rs(1).Value
            lstItem.SubItems(3) = rs(2).Value
            rs.MoveNext
            Loop
End Sub

Function GetID() As String
If rs.State = adStateOpen Then rs.Close
msql = " SELECT Max(MyDay.ID) AS MaxOfID" & _
" FROM MyDay;"
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



