Professional Documents
Culture Documents
Connection
Global rs As New ADODB.Recordset
End Sub
Option Explicit
Dim Msg As String
Sub load_list()
Datcon
With rs
If .State = adStateOpen Then
.Close
End If
.Open "SELECT * FROM ssection order by ssection.level", cn, adOpenKeyset,
adLockOptimistic
If .EOF = True Then
On Error Resume Next
lstSection.ListItems.clear
Exit Sub
End If
lstSection.ListItems.clear
Do While .EOF = False
On Error Resume Next
lstSection.ListItems.Add , , , , 1
lstSection.ListItems(lstSection.ListItems.Count).SubItems(1) = ![sec]
lstSection.ListItems(lstSection.ListItems.Count).SubItems(2) = ![Level]
.MoveNext
Loop
End With
End Sub
End Sub
With rs
If .State = adStateOpen Then
.Close
End If
Msg = MsgBox("Do you want to delete this section?", vbQuestion + vbYesNo)
If Msg = vbYes Then
.Open "delete *from ssection where sec = '" & txtSection.Text & "'", cn,
adOpenKeyset, adLockOptimistic
MsgBox " Section has been deleted", vbInformation
load_list
Else
Exit Sub
End If
End With
clear
disable
btnDelete.Enabled = False
btnUpdate.Enabled = False
btnSaveu.Enabled = False
End Sub
Datcon
With rs
If .State = adStateOpen Then
.Close
End If
.Open "Select * from ssection where sec ='" & txtSection.Text & "'", cn,
adOpenKeyset, adLockOptimistic
Else
.AddNew
!sec = txtSection.Text
!Level = cbxLevel.Text
.Update
MsgBox "New section has been added!", vbInformation
btnAdd.Visible = True
btnAdd.Enabled = True
btnDelete.Enabled = False
btnUpdate.Enabled = False
btnSaveu.Enabled = False
load_list
clear
disable
End If
End With
End Sub
With rs
If .State = adStateOpen Then
.Close
End If
.Open "select * from ssection where sec='" & txtSection.Text & "'", cn,
adOpenKeyset, adLockOptimistic
Else
Msg = MsgBox("Do you want to update this section?", vbQuestion + vbYesNo)
If Msg = vbYes Then
If .EOF Then
On Error Resume Next
End If
.Update
!sec = txtSection.Text
!Level = cbxLevel.Text
.Update
Else
Exit Sub
End If
End If
End With
End Sub
Sub choices()
Datcon
With rs
If .State = adStateOpen Then
.Close
End If
Case 0
mousex = X
mousey = y
Case 1
Me.Left = Me.Left + (X - mousex)
Me.Top = Me.Top + (y - mousey)
End Select
End Sub
btnDelete.Enabled = True
btnUpdate.Enabled = True
btnSaveu.Enabled = True
End Sub
Sub enable()
txtSection.Enabled = True
End Sub
Sub disable()
txtSection.Enabled = False
End Sub
Sub clear()
txtSection.Text = ""
cbxLevel.Text = ""
End Sub
Sub sort()
Datcon
With rs
If .State = adStateOpen Then
.Close
End If
.Open "select*from ssection where level='" & cbxLevel.Text & "'", cn, adOpenKeyset,
adLockOptimistic
If .EOF = True Then
On Error Resume Next
lstSection.ListItems.clear
Exit Sub
End If
lstSection.ListItems.clear
Do While .EOF = False
On Error Resume Next
lstSection.ListItems.Add , , , , 1
lstSection.ListItems(lstSection.ListItems.Count).SubItems(1) = ![sec]
lstSection.ListItems(lstSection.ListItems.Count).SubItems(2) = ![Level]
.MoveNext
Loop
End With
End Sub
End Sub
Sub box()
Datcon
Dim Getdoc As String
With rs
If .State = adStateOpen Then
.Close
End If
.Open " SELECT Max(sid.idnum) AS MaxOfidnum" & _
" FROM sid;", cn, adOpenKeyset, adLockOptimistic
If IsNull(rs(0).Value) Then
Getdoc = Format(1, "00000")
Else
Getdoc = Format(rs(0).Value + 1, "00000")
End If
lblDoc.Caption = "MDCS- EF-" & Getdoc
End With
End Sub