VB 6 Water

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 85

Forms:

AccountsFrm

Code:

Option Explicit
Dim clsData As New clsUsers
Dim OldID As String

Private Sub cmdClose_Click()


Unload Me
End Sub

Private Sub cmdAdd_Click()


'If rAdd = False Then MsgBox "Access Denied. The operation is not allowed", vbCritical,
"Restriction": Exit Sub
If cmdAdd.Caption = "&Add" Then
cmdAdd.Caption = "&Save"
Lockfalse
Clear
Else
If ValidateEntry = False Then
cmdAdd.Caption = "&Add"
txtUser.SetFocus
Lockfalse
clsData.AddUser txtUser, txtpass, cbotype.Text
Clear
Unload Me
AccountsFrm.Show 1, MainFrm
End If
End If
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdDelete_Click()


'If rDelete = False Then MsgBox "Access Denied. The operation is not allowed",
vbCritical, "Restriction": Exit Sub
If txtUser = "" Then Exit Sub
If txtUser = CurrentUser Then
MsgBox "Can't delete your own profile.", vbCritical, ""
Else
If vbYes = MsgBox("Are you sure you want to delete this user" & vbCrLf &
"Username: " & OldID, vbQuestion + vbYesNo, "") Then
clsData.DeleteUser txtUser
End If
End If
Unload Me
AccountsFrm.Show 1, MainFrm
End Sub

Private Sub cmdEdit_Click()


Lockfalse
txtUser.SetFocus
End Sub

Private Sub cmdUpdate_Click()


'If rUpdate = False Then MsgBox "Access Denied. The operation is not allowed",
vbCritical, "Restriction": Exit Sub
If ValidateEntry = False Then
clsData.UpdateUser txtUser, txtpass, cbotype, OldID
Unload Me
AccountsFrm.Show 1, MainFrm
End If
End Sub

Private Sub Form_Activate()


Set clsData = New clsUsers
clsData.DisplayUsers lstUser
If MainFrm.Tag <> "admin" Then
cmdDelete.Enabled = False
Else
cmdDelete.Enabled = True
End If
End Sub

Public Sub Lockfalse()


txtUser.Locked = False
txtpass.Locked = False
txtVerify.Locked = False
cbotype.Locked = False
End Sub

Public Sub Clear()


txtUser = ""
txtpass = ""
txtVerify = ""
cbotype.ListIndex = 0

End Sub
Public Function ValidateEntry() As Boolean
ValidateEntry = True
If Trim(txtUser) = "" Then
MsgBox "Please enter username", vbInformation, ""
Exit Function
ElseIf Trim(txtpass) <> Trim(txtVerify) Then
MsgBox "Password mismatch.", vbInformation, ""
Exit Function
End If
ValidateEntry = False
End Function
Private Sub lstUser_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim a As Boolean, b As Boolean, C As Boolean, d As Boolean
OldID = Item.ListSubItems(1).Text
txtUser = Item.ListSubItems(1).Text
txtpass = Item.ListSubItems(5).Text
txtVerify = Item.ListSubItems(5).Text
cbotype.Text = Item.ListSubItems(2).Text
clsData.GetUserPrivileges txtUser, UserTitle

End Sub
Private Sub OK_Click()
Unload Me
End Sub

Gen. Dec.
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


DataBackup
End Sub

Private Sub Dir1_Change()


Dir1_Click
End Sub

Private Sub Dir1_Click()


On Error GoTo hell:
File1.Path = Dir1.Path
txtBackupPath = Dir1.Path
Exit Sub
hell:
MsgBox " Error drive is not accessible", vbInformation, ""
Drive1.Drive = "c:"
End Sub

Private Sub Drive1_Change()


On Error GoTo heaven
Dir1.Path = Drive1.Drive
Exit Sub
heaven:
MsgBox " Error drive is not accessible", vbInformation, ""
Drive1.Drive = "c:"
End Sub
Sub DataBackup()
Dim FS As New FileSystemObject, a As Integer
ProgressBar1.Value = 0
FS.CopyFile App.Path & "\data.mdb", txtBackupPath & "\Data" & File1.ListCount & ".bac",
True
For a = 1 To 10
DoEvents
Sleep 500
ProgressBar1 = ProgressBar1 + 10
'BackupFrm.Height = 6240
Next
Set FS = Nothing
MsgBox "Backup successful", vbInformation, ""
'BackupFrm.Height = 5520
ProgressBar1.Value = 0
Exit Sub
End Sub

Private Sub jcbutton1_Click()


Unload Me
BackupFrm.Show 1, MainFrm
End Sub
Gen. Dec
Dim clsData As New clsBilling

Private Sub cmdAdd_Click()


If cmdAdd.Caption = "&New Billing" Then
cmdAdd.Caption = "&Save"
Clear
txtBID.SetFocus
Else
If ValidateEntry = False Then
cmdAdd.Caption = "&New Billing"
txtBID.SetFocus
clsData.AddBilling txtInstallID, txtBID, txtLname, txtfname, txtmname, txtAdd,
txtCon, DTPicker2.Value, txtMeterno, DTPicker1.Value, DTPicker3.Value, txtPrevious,
txtPresent, txtConsumption, txtBillAmount, DTPicker4.Value, DTPicker5.Value, "Unpaid"
Clear
Unload Me
BillingFrm.Show 1, MainFrm
End If
End If
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub
Private Function ValidateEntry() As Boolean
ValidateEntry = True
If Trim(txtBID) = "" Then
MsgBox "All fields are required.", vbInformation, ""
Exit Function
ElseIf Trim(txtMeterno) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtMeterno.SetFocus
Exit Function
ElseIf Not IsNumeric(txtPrevious) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
txtPrevious = ""
txtPrevious.SetFocus
Exit Function
ElseIf Not IsNumeric(txtPresent) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
txtPresent = ""
txtPresent.SetFocus
Exit Function
ElseIf Not IsNumeric(txtBillAmount) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
txtBillAmount = ""
txtBillAmount.SetFocus
Exit Function
ElseIf txtConsumption.Text <= 0 Then
MsgBox "Value of consumtion cannot be negative or equal to zero.Please check the
previous reading and present reading.", vbInformation, ""
txtConsumption.SetFocus
Exit Function
End If
ValidateEntry = False
End Function
Public Sub Clear()
txtInstallID = clsData.GetBillID
txtBID = ""
txtLname = ""
txtfname = ""
txtmname = ""
txtCon = ""
txtAdd = ""
txtMeterno = ""
txtPrevious = "0.00"
txtPresent = "0.00"
txtBillAmount = "0.00"
End Sub

Private Sub cmdDelete_Click()


If vbYes = MsgBox("Delete selected item?", vbQuestion + vbYesNo, "") Then
clsData.DeleteBilling lstBilling.SelectedItem.ListSubItems(1).Text

End If
Unload Me
BillingFrm.Show 1, MainFrm
End Sub

Private Sub cmdSearch_Click()


On Error Resume Next
SearchClientForBillingFrm.Show 1
txtBID = TempClientID
txtLname = TempLname
txtfname = TempFname
txtmname = TempMname
txtAdd = TempAddress
txtCon = TempContact
DTPicker2.Value = TempDateInstall
txtMeterno = TempMeterNo
End Sub

Private Sub DTPicker1_Change()


DTPicker1_Click
End Sub
Private Sub DTPicker1_Click()
DTPicker3.Value = DTPicker1.Value + 30
End Sub

Private Sub Form_Load()


txtInstallID = clsData.GetBillID
clsData.DisplayBilling lstBilling, ""
'cboMonth.ListIndex = 0
If MainFrm.Tag <> "admin" Then
cmdDelete.Enabled = False
Else
cmdDelete.Enabled = True
End If
DTPicker1.Value = Date
DTPicker3.Value = Date
DTPicker4.Value = Date
DTPicker5.Value = Date
End Sub
Private Sub Text4_Change()
If Trim(Text4) = "" Then
clsData.DisplayBilling lstBilling, ""
Else
clsData.DisplayBilling lstBilling, Text4.Text
End If
End Sub
Private Sub txtBID_Change()
txtPrevious = clsData.MyGetPreviousReading(txtBID)
End Sub
Private Sub txtConsumption_Change()
On Error Resume Next
txtBillAmount = Format(txtConsumption.Text * txtPrice, "##,##0.00")
End Sub
Private Sub txtPresent_Change()
On Error Resume Next
txtConsumption = Format(txtPresent.Text - txtPrevious, "##,##0.00")
End Sub
Private Sub txtPrevious_Change()
On Error Resume Next
txtConsumption = Format(txtPresent.Text - txtPrevious, "##,##0.00")
End Sub

Gen. Dec

Dim clsData As New clsClient


Dim OldID As String

Private Sub cmdAdd_Click()


If cmdAdd.Caption = "&Add" Then
cmdAdd.Caption = "&Save"
Clear
Lockfalse
txtLname.SetFocus
Else
If ValidateEntry = False Then
cmdAdd.Caption = "&Add"
Lockfalse
txtLname.SetFocus
clsData.AddClient txtBID, txtLname, txtfname, txtmname, txtAdd, txtCon, txtStatus
Clear
Unload Me
ClientFrm.Show 1, MainFrm
End If
End If
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdDelete_Click()

If vbYes = MsgBox("Delete selected item?", vbQuestion + vbYesNo, "") Then


clsData.DeleteClient txtBID

End If
Unload Me
ClientFrm.Show 1, MainFrm
End Sub
Private Sub cmdEdit_Click()
Lockfalse
End Sub
Private Sub cmdUpdate_Click()
If ValidateEntry = False Then
clsData.UpdateClient txtBID, txtLname, txtfname, txtmname, txtAdd, txtCon,
txtStatus, OldID
Unload Me
ClientFrm.Show 1, MainFrm
End If
End Sub

Private Sub Form_Load()


clsData.DisplayClients lstClient, ""
txtBID = clsData.GetID
If MainFrm.Tag <> "admin" Then
cmdDelete.Enabled = False
Else
cmdDelete.Enabled = True
End If
End Sub
Private Sub jcbutton3_Click()
Unload Me
ClientFrm.Show 1, MainFrm
End Sub
Private Sub lstClient_ItemClick(ByVal Item As MSComctlLib.ListItem)
OldID = Item.ListSubItems(1).Text
txtBID = Item.ListSubItems(1).Text
txtLname = Item.ListSubItems(2).Text
txtfname = Item.ListSubItems(3).Text
txtmname = Item.ListSubItems(4).Text
txtAdd = Item.ListSubItems(5).Text
txtCon = Item.ListSubItems(6).Text
txtStatus = Item.ListSubItems(7).Text
End Sub

Private Sub Text4_Change()


If Trim(Text4) = "" Then
clsData.DisplayClients lstClient, ""
Clear
Else
clsData.DisplayClients lstClient, Text4.Text
Clear
End If
End Sub
Public Sub Clear()
txtBID = clsData.GetID
txtLname = ""
txtfname = ""
txtmname = ""
txtCon = ""
txtAdd = ""
txtStatus = "Not Installed"
End Sub
Public Sub Lockfalse()
txtLname.Locked = False
txtfname.Locked = False
txtmname.Locked = False
txtCon.Locked = False
txtAdd.Locked = False
End Sub
Private Function ValidateEntry() As Boolean
ValidateEntry = True
If Trim(txtBID) = "" Then
MsgBox "All fields are required.", vbInformation, ""
Exit Function
ElseIf Trim(txtLname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtLname.SetFocus
Exit Function
ElseIf Trim(txtfname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtfname.SetFocus
Exit Function
ElseIf Trim(txtmname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtAuthor.SetFocus
Exit Function
ElseIf Not IsNumeric(txtCon) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
txtCon.SetFocus
Exit Function
ElseIf Trim(txtAdd) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtAdd.SetFocus
Exit Function
End If
ValidateEntry = False
End Function

Gen. Dec.
Option Explicit
Dim Setup As New clsCompany

Private Sub cmdEdit_Click()


If cmdEdit.Caption = "&Edit" Then
cmdEdit.Caption = "&Update"
ComName.Locked = False
Loc.Locked = False
Contact.Locked = False
tin.Locked = False
Else
If ValidateEntry = False Then
cmdEdit.Caption = "&Edit"
Setup.UpdateSetup ComName, Loc, Contact, tin
ComName.Locked = False
Loc.Locked = False
Contact.Locked = False
tin.Locked = False
Unload Me
End If
End If
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()

End Sub

Private Sub Form_Activate()


Setup.Setup ComName, Loc, Contact, tin
End Sub
Private Function ValidateEntry() As Boolean
ValidateEntry = True
If Trim(ComName) = "" Then
MsgBox "Don't leave the field blank", vbInformation, ""
ComName = ""
ComName.SetFocus
Exit Function
ElseIf Trim(Loc) = "" Then
MsgBox "Don't leave the field blank", vbInformation, ""
Loc = ""
Loc.SetFocus
Exit Function
ElseIf Trim(Contact) = "" Then
MsgBox "Don't leave the field blank", vbInformation, ""
Contact = ""
Contact.SetFocus
Exit Function
ElseIf Trim(tin) = "" Then
MsgBox "Don't leave the field blank", vbInformation, ""
tin = ""
tin.SetFocus
Exit Function
End If
ValidateEntry = False

End Function
Gen. Dec

Dim clsData As New DisConnect

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdConnect_Click()


If Trim(txtBID) = "" Then
MsgBox "Please enter client Information", vbInformation, ""
Else
clsData.UpdateConnect txtInstallID
clsData.AddConnectHistory txtBID, txtLname, txtfname, txtmname, txtAdd, txtCon,
Date, "Connected"
Unload Me
ConnectFrm.Show 1
End If
End Sub
Private Sub cmdDisconnect_Click()
If Trim(txtBID) = "" Then
MsgBox "Please enter client Information", vbInformation, ""
Else
clsData.UpdateDisConnect txtInstallID
clsData.AddDisConnectHistory txtBID, txtLname, txtfname, txtmname, txtAdd, txtCon,
Date, "Disconnected"
Unload Me
ConnectFrm.Show 1
End If
End Sub

Private Sub cmdHistory_Click()


Unload Me
ConnectionHistoryFrm.Show 1
End Sub

Private Sub Form_Load()


txtInstallID = clsData.GetConnectID
clsData.DisplayConnect lstConnect, ""
End Sub
Private Sub lstConnect_ItemClick(ByVal Item As MSComctlLib.ListItem)
txtInstallID = Item.ListSubItems(1).Text
txtBID = Item.ListSubItems(2).Text
txtLname = Item.ListSubItems(3).Text
txtfname = Item.ListSubItems(4).Text
txtmname = Item.ListSubItems(5).Text
txtAdd = Item.ListSubItems(6).Text
txtCon = Item.ListSubItems(7).Text
DTPicker2.Value = Item.ListSubItems(8).Text
txtMeterno = Item.ListSubItems(9).Text
End Sub
Gen. Dec

Dim clsData As New DisConnect


Private Sub cmdCancel_Click()
Unload Me
ConnectFrm.Show 1
End Sub
Private Sub Form_Load()
clsData.DisplayHistory lstConnectionHistory, ""
End Sub
Private Sub Text4_Change()
If Trim(Text4) = "" Then
clsData.DisplayHistory lstConnectionHistory, ""
Else
clsData.DisplayHistory lstConnectionHistory, Text4.Text
End If
End Sub
Gen. Dec

Dim clsData As New clsInstall


Dim clsClient As New clsClient
Dim OldID As String

Private Sub cmdAdd_Click()


If cmdAdd.Caption = "&Add" Then
cmdAdd.Caption = "&Save"
Clear
Lockfalse
Else
If ValidateEntry = False Then
cmdAdd.Caption = "&Add"
Lockfalse
txtBID.SetFocus
clsData.AddInstall txtInstallID, txtBID, txtLname, txtfname, txtmname, txtAdd,
txtCon, DTPicker2.Value, txtMeterno
clsData.AddDisConnect txtInstallID, txtBID, txtLname, txtfname, txtmname, txtAdd,
txtCon, DTPicker2.Value, Text1.Text
clsData.PrintNotice txtBID
clsClient.SetClientInstall txtBID
Clear
'Unload Me
'InstallFrm.Show 1, MainFrm
End If
End If
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdDelete_Click()


If vbYes = MsgBox("Delete selected item?", vbQuestion + vbYesNo, "") Then
clsData.DeleteInstall txtInstallID
End If
Unload Me
InstallFrm.Show 1, MainFrm
End Sub
Private Sub cmdEdit_Click()
Lockfalse
End Sub

Private Sub cmdSearch_Click()


SearchClientForInstallFrm.Show 1
txtBID = TempClientID
txtLname = TempLname
txtfname = TempFname
txtmname = TempMname
txtAdd = TempAddress
txtCon = TempContact
End Sub

Private Sub cmdUpdate_Click()


If ValidateEntry = False Then
clsData.UpdateInstall txtInstallID, txtBID, txtLname, txtfname, txtmname, txtAdd,
txtCon, DTPicker2.Value, txtMeterno, OldID
Unload Me
InstallFrm.Show 1, MainFrm
End If
End Sub
Private Sub Form_Load()
clsData.DisplayInstallation lstInstall, ""
txtInstallID = clsData.GetInstallID
If MainFrm.Tag <> "admin" Then
cmdDelete.Enabled = False
Else
cmdDelete.Enabled = True
End If
End Sub
Public Sub Clear()
txtInstallID = clsData.GetInstallID
txtBID = ""
txtLname = ""
txtfname = ""
txtmname = ""
txtCon = ""
txtAdd = ""
txtMeterno = ""
DTPicker2.Value = Date
End Sub
Public Sub Lockfalse()
txtBID.Locked = False
txtLname.Locked = False
txtfname.Locked = False
txtmname.Locked = False
txtCon.Locked = False
txtAdd.Locked = False
txtMeterno.Locked = False
End Sub
Private Function ValidateEntry() As Boolean
ValidateEntry = True
If Trim(txtBID) = "" Then
MsgBox "All fields are required.", vbInformation, ""
Exit Function
ElseIf Trim(txtLname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtLname.SetFocus
Exit Function
ElseIf Trim(txtfname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtfname.SetFocus
Exit Function
ElseIf Trim(txtmname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtAuthor.SetFocus
Exit Function
ElseIf Not IsNumeric(txtCon) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
txtCon.SetFocus
Exit Function
ElseIf Trim(txtAdd) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtAdd.SetFocus
Exit Function
ElseIf Trim(txtMeterno) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtMeterno.SetFocus
Exit Function
End If
ValidateEntry = False
End Function

Private Sub lstInstall_ItemClick(ByVal Item As MSComctlLib.ListItem)


OldID = Item.ListSubItems(1).Text
txtInstallID = Item.ListSubItems(1).Text
txtBID = Item.ListSubItems(2).Text
txtLname = Item.ListSubItems(3).Text
txtfname = Item.ListSubItems(4).Text
txtmname = Item.ListSubItems(5).Text
txtAdd = Item.ListSubItems(6).Text
txtCon = Item.ListSubItems(7).Text
DTPicker2.Value = Item.ListSubItems(8).Text
txtMeterno = Item.ListSubItems(9).Text
End Sub

Private Sub Text4_Change()


If Trim(Text4) = "" Then
clsData.DisplayInstallation lstInstall, ""
Clear
Else
clsData.DisplayInstallation lstInstall, Text4.Text
Clear
End If
End Sub
Gen. Dec

Dim clsData As New clsUsers


Private Sub cmdCancel_Click()
Unload Me
LoginSuccess = False
End Sub
Private Sub cmdOk_Click()
Dim msg As String
If cboUser.ListCount = 0 Then Unload Me: CurrentUser = "admin"
If cboUser.Text <> "" Then
Set clsData = New clsUsers
If True = clsData.Login(cboUser.Text, txtpass, msg) Then
DoEvents
CurrentUser = cboUser
userlog = clsData.UserLoginTime(CurrentUser, Time())
clsData.GetUserPrivileges cboUser, UserTitle
Unload Me
MainFrm.Show
Else
CurrentUser = ""
MsgBox msg, vbCritical, ""
txtpass = ""
End If
Set clsData = Nothing
End If
End Sub
Private Sub Form_Activate()
cboUser.SetFocus
cboUser.Text = "webgeekresources"
End Sub
Private Sub Form_Load()
Set clsData = New clsUsers
If clsData.GetUsers(cboUser) = False Then Load Me
Set clsData = Nothing
End Sub
Private Sub txtPass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdOk_Click
End If
End Sub

Gen. Dec

'#######################################
'# #
'# ACP Ribbon 2007 #
'# by #
'# adrianopaladini@gmail.com #
'# #
'# #
'# Visual from Office 2007 Beta 2 TR #
'# #
'# Please Dont Remove Author Info! #
'# #
'#######################################

'------------------------------------------------
' TO DO:
'
' A) Update when Resize, resolve flicks
' B) Optimize Code
' C) Insert Mini Buttons, Combos and Checkbox on Each Categories
' D) Option to Show Menu Under the Ribbon and Hide Ribbon
' E) Make Menu
' F) Option to user customize the menu
' G) Group Tabs
' H) Add Comment to All code
' I) FINISHED this project!
'
'------------------------------------------------

'------------------------------------------------
' Bugs:
'
' Please report to:
'
' adrianopaladini@gmail.com
'
'------------------------------------------------
Private Sub Form_Load()
GetWatermark
GetnumTry
GetcurTry
UpdateTry
Timer2.Enabled = True
'# SET Theme
ACPRibbon1.Theme = 0 ' 0 - Black
' 1 - Blue
' 2 - Silver

'# Set ImageList to use for icons


ACPRibbon1.ImageList = ImageList1

'# Set Circle Menu Button Picture with Index of image on imagelist
ACPRibbon1.Icon = 2

'# Show Caption of Form


ACPRibbon1.Caption = Me.Caption

'# Show Button to Customize Menu


'ACPRibbon1.ShowCustomMenu = True

'# Add TopButtons --- ID - Capt. - Icons


'ACPRibbon1.AddTopButton "1", "New", 2
'ACPRibbon1.AddTopButton "2", "Open", 3
'ACPRibbon1.AddTopButton "3", "Print", 4
'ACPRibbon1.AddTopButton "3", "Save", 5

'# Add Tabs --- ID - Caption


ACPRibbon1.AddTab "1", "Home"
ACPRibbon1.AddTab "2", "Transaction"
ACPRibbon1.AddTab "3", "Database"
'ACPRibbon1.AddTab "4", "New Tab"
'ACPRibbon1.AddTab "5", "WOW"

'# Add Cats --- ID - Tab - Caption - ShowDialogButton


ACPRibbon1.AddCat "1", "1", "Shutdown", False
ACPRibbon1.AddCat "2", "1", "System", False
ACPRibbon1.AddCat "3", "2", "Client", False
ACPRibbon1.AddCat "4", "2", "Install-Dis/Connect", False
ACPRibbon1.AddCat "5", "2", "Billing", False
ACPRibbon1.AddCat "6", "2", "Records", False
ACPRibbon1.AddCat "7", "3", "Users", False
ACPRibbon1.AddCat "8", "3", "Database", False
ACPRibbon1.AddCat "9", "3", "Company", False

'# Add Button --- ID - Cat - Capt. - Icons - More Arrow - ToolTip
ACPRibbon1.AddButton "1", "1", "Log-out", 1, False, "Log-out"
ACPRibbon1.AddButton "2", "2", "System", 2
ACPRibbon1.AddButton "2", "2", "Author", 7
ACPRibbon1.AddButton "3", "1", "Exit", 10
ACPRibbon1.AddButton "4", "3", "Client", 6
ACPRibbon1.AddButton "5", "4", "Installation", 5
ACPRibbon1.AddButton "6", "4", "Dis/Connect", 4
ACPRibbon1.AddButton "7", "5", "Billing", 3
ACPRibbon1.AddButton "8", "5", "Payment", 8
ACPRibbon1.AddButton "9", "6", "Service Records", 9
ACPRibbon1.AddButton "10", "6", "Statement of Accounts", 8
ACPRibbon1.AddButton "11", "7", "User Accounts", 11
ACPRibbon1.AddButton "12", "8", "Data Backup", 12
ACPRibbon1.AddButton "13", "8", "Data Restore", 13
ACPRibbon1.AddButton "14", "9", "Company Setup", 14
ACPRibbon1.AddButton "15", "6", "Monthly Report", 15
'# Repaint Ribbon
ACPRibbon1.Refresh

End Sub

Private Sub Form_Resize()

'# this procedure will resize the ribbon


ACPRibbon1.Resize

End Sub

Private Sub ACPRibbon1_MainMenuClick()

'# This Event occurs on click in Main Button Menu


frmSplash.Show 1

End Sub

Private Sub ACPRibbon1_CustomClick()

'# This Event occurs on click in Custom Button Menu


'MsgBox "Custom Click"

End Sub

Private Sub ACPRibbon1_MenuClick(ByVal ID As String, ByVal Caption As String)

'# This Event occurs when click on each Menu Button

End Sub
Private Sub ACPRibbon1_TabClick(ByVal ID As String, ByVal Caption As String)

'# This Event occurs when click on each tab


'MsgBox "TabSelected: " & ID & "--" & Caption

End Sub

Private Sub ACPRibbon1_CatClick(ByVal ID As String, ByVal Caption As String)

'# This Event occurs when click on each ShowDialogButton for each Categorie
'MsgBox "ShowDialogClick: " & ID & "--" & Caption

End Sub

Private Sub ACPRibbon1_ButtonClick(ByVal ID As String, ByVal Caption As String)

'# This Event occurs when click on each Button


'MsgBox "ButtonClick: " & ID & "--" & Caption

Select Case Caption


Case "Log-out"
If MsgBox("Are you sure you want to log-out", vbQuestion + vbYesNo, "Log_Out") =
vbYes Then LoginFrm.Show 1
Case "Exit"
If MsgBox("Are you sure you want to exit", vbQuestion + vbYesNo, "Exit") = vbYes
Then End
Case "User Accounts"
AccountsFrm.Show 1
Case "Company Setup"
CompanyFrm.Show 1
Case "Data Backup"
BackupFrm.Show 1
Case "Data Restore"
RestoreFrm.Show 1
Case "Client"
ClientFrm.Show 1
Case "Installation"
InstallFrm.Show 1
Case "Dis/Connect"
ConnectFrm.Show 1
Case "Billing"
BillingFrm.Show 1
Case "Payment"
PaymentFrm.Show 1
Case "System"
frmSplash.Show 1
Case "Author"
AuthorFrm.Show 1
Case "Service Records"
ServiceRecFrm.Show 1
Case "Statement of Accounts"
StatementOfAccountsFrm.Show 1
Case "Monthly Report"
MonthlyFrm.Show 1
End Select
End Sub

Private Sub Timer2_Timer()


If Val(txtcurTry) >= Val(txtnumtry) Then
Unload Me
DeveloperFrm.Show
End If
End Sub
Sub GetnumTry()
Dim msql As String
If rs.State = adStateOpen Then rs.Close
msql = "select numoftry from tblsecure"
rs.Open msql, conn
txtnumtry = rs(0).Value
End Sub
Sub GetcurTry()
Dim msql As String
If rs.State = adStateOpen Then rs.Close
msql = "select currenttry from tblsecure"
rs.Open msql, conn
txtcurTry = rs(0).Value
End Sub
Sub GetWatermark()
Dim msql As String
If rs.State = adStateOpen Then rs.Close
msql = "select logowatermark from tblsecure"
rs.Open msql, conn
Label6.Caption = rs(0).Value
End Sub
Sub UpdateTry()
Dim msql As String
If rs.State = adStateOpen Then rs.Close
msql = "update tblsecure set currenttry='" & Val(txtcurTry.Text) + 1 & "'"
rs.Open msql, conn
'txtnumtry = myrs(0).Value
End Sub
Gen. Dec.
Dim clsData As New clsMonthy
Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdOk_Click()


If lstInstall.ListItems.Count <= 0 Then
MsgBox "No Data to print.", vbInformation, ""
Else
clsData.PrintRecord DTPicker1.Value, DTPicker3.Value, lblTotal.Caption
End If

End Sub

Private Sub DTPicker1_Change()


DTPicker1_Click
clsData.DisplayRecord lstInstall, DTPicker1.Value, DTPicker3.Value
ComputeTotal
End Sub
Private Sub DTPicker1_Click()
DTPicker3.Value = DTPicker1.Value + 30
End Sub
Private Sub Form_Load()
clsData.DisplayRecord lstInstall, DTPicker1.Value, DTPicker3.Value
DTPicker1.Value = Date
DTPicker3.Value = Date
End Sub

Function ComputeTotal() As String


Dim a As Integer, b As Integer, sTotal As Currency
a = lstInstall.ListItems.Count
For b = 1 To a
sTotal = Val(sTotal) + lstInstall.ListItems(b).SubItems(6)
Next
lblTotal.Caption = Format(sTotal, "##,##0.00")
End Function

Gen. Dec
Dim clsPrint As New clsPrint
Dim clsData As New clsPayment
Dim clsBill As New clsBilling

Private Sub cmdAdd_Click()


If ValidateEntry = False Then

clsData.AddInvoice txtInstallID, txtBID, txtLname, txtfname, txtmname, txtAdd,


txtCon, lblBillID.Caption, lblBillDate.Caption, lblDueDate.Caption, Text3, txtBillAmount,
txttendered, txtChange, lblCashier.Caption, Date
clsPrint.PrintInvoice txtInstallID, txtBID, txtLname, txtfname, txtmname, txtAdd,
lblBillDate.Caption, lblDueDate.Caption, txtPresent, txtPrevious, txtConsumption,
txtBillAmount, txttendered, txtChange, lblCashier.Caption, lblFrom.Caption, lblTo.Caption
clsBill.UpdateBillingPaid txtInstallID
'Clear
Unload Me
PaymentFrm.Show 1, MainFrm
End If
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdSearch_Click()


SearchClientForPaymentFrm.Show 1
txtBID = TempClientID
txtLname = TempLname
txtfname = TempFname
txtmname = TempMname
txtAdd = TempAddress
txtCon = TempContact
lblBillID.Caption = TempBillID
lblBillDate.Caption = TempBillDate
lblDueDate = TempDueDate
txtAmount = TempBillAmount
txtConsumption = TempConsumption
txtPresent = TempPresentReading
txtPrevious = TempPreviousReading
lblFrom.Caption = TempPeriodFrom
lblTo.Caption = TempPeriodTo
'lblMonth.Caption = TempMonth
End Sub

Private Sub Form_Load()


txtInstallID = clsData.GetORID
lblCashier.Caption = CurrentUser
End Sub
Public Sub Clear()
txtInstallID = clsData.GetORID
txtLname = ""
txtfname = ""
txtmname = ""
txtCon = ""
txtAdd = ""
txtBID = ""
End Sub
Private Function ValidateEntry() As Boolean
ValidateEntry = True
If Trim(txtBID) = "" Then
MsgBox "All fields are required.", vbInformation, ""
Exit Function
ElseIf Trim(txtLname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtLname.SetFocus
Exit Function
ElseIf Trim(txtfname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtfname.SetFocus
Exit Function
ElseIf Trim(txtmname) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtAuthor.SetFocus
Exit Function
ElseIf Not IsNumeric(txtCon) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
txtCon.SetFocus
Exit Function
ElseIf Not IsNumeric(Text3) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
Text3.SetFocus
Exit Function
ElseIf Not IsNumeric(txttendered) Then
MsgBox "Please enter a numeric value.", vbInformation, ""
txttendered.SetFocus
Exit Function
ElseIf Trim(txtAdd) = "" Then
MsgBox "All fields are required.", vbInformation, ""
txtAdd.SetFocus
Exit Function
ElseIf txtChange.Text < 0 Then
MsgBox "Insufficient payment.", vbInformation, ""
txttendered.SetFocus
Exit Function
End If
ValidateEntry = False
End Function

Private Sub Text3_Change()


On Error Resume Next
txtBillAmount = Format(txtAmount.Text + Val(Text3), "##,##0.00")
End Sub

Private Sub txtAmount_Change()


On Error Resume Next
txtBillAmount = Format(txtAmount.Text + Val(Text3), "##,##0.00")
End Sub

Private Sub txtBillAmount_Change()


On Error Resume Next
Label16.Caption = txtBillAmount.Text
txtChange = Format(txttendered.Text - txtBillAmount.Text, "##,##0.00")
End Sub

Private Sub txttendered_Change()


On Error Resume Next
txtChange = Format(txttendered.Text - txtBillAmount.Text, "##,##0.00")
End Sub

Gen. Dec

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdOk_Click()


RestoreData
End Sub

Private Sub Dir1_Change()


On Error GoTo hell1
File1.Path = Dir1.Path
Exit Sub
hell1:
MsgBox " Error drive is not accessible", vbInformation, ""
Drive1.Drive = "c:"
End Sub

Private Sub Drive1_Change()


On Error GoTo hell2
Dir1.Path = Drive1.Drive
Exit Sub
hell2:
MsgBox " Error drive is not accessible", vbInformation, ""
Drive1.Drive = "c:"
End Sub

Private Sub File1_Click()


txtBackupPath = File1.Path & "\" & File1.FileName
End Sub
Sub RestoreData()
Dim FS As New FileSystemObject, a As Integer
If Trim(txtBackupPath) = "" Then MsgBox "Please choose filename of database you want
to restore.", vbInformation, "": Exit Sub
ProgressBar1.Value = 0
FS.CopyFile txtBackupPath, App.Path & "\Data.mdb", True
For a = 1 To 10
DoEvents
Sleep 500
ProgressBar1 = ProgressBar1 + 10
'RestoreFrm.Height = 6240
Next
MsgBox "Restore successful", vbInformation, ""
Set FS = Nothing
'RestoreFrm.Height = 5520
ProgressBar1.Value = 0
Exit Sub
End Sub

Private Sub Image6_Click()

End Sub

Private Sub jcbutton1_Click()


Unload Me
RestoreFrm.Show 1, MainFrm
End Sub
Gen. Dec
Dim clsData As New clsInstall

Private Sub cmdAdd_Click()


If lstInstall.ListItems.Count > 0 Then lstInstall_DblClick
Unload Me
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub
Private Sub Form_Load()
clsData.DisplayInstallation lstInstall, ""
End Sub
Private Sub lstInstall_DblClick()
TempClientID = lstInstall.SelectedItem.ListSubItems(2)
TempLname = lstInstall.SelectedItem.ListSubItems(3)
TempFname = lstInstall.SelectedItem.ListSubItems(4)
TempMname = lstInstall.SelectedItem.ListSubItems(5)
TempAddress = lstInstall.SelectedItem.ListSubItems(6)
TempContact = lstInstall.SelectedItem.ListSubItems(7)
TempDateInstall = lstInstall.SelectedItem.ListSubItems(8)
TempMeterNo = lstInstall.SelectedItem.ListSubItems(9)
Unload Me
End Sub

Private Sub Text4_Change()


If Trim(Text4) = "" Then
clsData.DisplayInstallation lstInstall, ""
Else
clsData.DisplayInstallation lstInstall, Text4.Text
End If
End Sub

Gen. Dec
Dim clsData As New clsClient

Private Sub cmdAdd_Click()


If lstClient.ListItems.Count > 0 Then lstClient_DblClick
Unload Me
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub Form_Load()


clsData.DisplayClientsNotInstalled lstClient, ""
End Sub

Private Sub lstClient_DblClick()


TempClientID = lstClient.SelectedItem.ListSubItems(1)
TempLname = lstClient.SelectedItem.ListSubItems(2)
TempFname = lstClient.SelectedItem.ListSubItems(3)
TempMname = lstClient.SelectedItem.ListSubItems(4)
TempAddress = lstClient.SelectedItem.ListSubItems(5)
TempContact = lstClient.SelectedItem.ListSubItems(6)
Unload Me
End Sub

Private Sub Text4_Change()


If Trim(Text4) = "" Then
clsData.DisplayClientsNotInstalled lstClient, ""
Else
clsData.DisplayClientsNotInstalled lstClient, Text4.Text
End If
End Sub
Gen. Dec
Dim clsData As New clsBilling

Private Sub cboMonth_Click()


clsData.DisplayBillingUnpaid lstInstall, Text4.Text
End Sub

Private Sub cmdAdd_Click()


If lstInstall.ListItems.Count > 0 Then lstInstall_DblClick
Unload Me
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub Form_Load()


clsData.DisplayBillingUnpaid lstInstall, ""
'cboMonth.ListIndex = 0
End Sub

Private Sub lstInstall_DblClick()


On Error Resume Next
TempBillID = lstInstall.SelectedItem.ListSubItems(1)
TempClientID = lstInstall.SelectedItem.ListSubItems(2)
TempLname = lstInstall.SelectedItem.ListSubItems(3)
TempFname = lstInstall.SelectedItem.ListSubItems(4)
TempMname = lstInstall.SelectedItem.ListSubItems(5)
TempAddress = lstInstall.SelectedItem.ListSubItems(6)
TempContact = lstInstall.SelectedItem.ListSubItems(7)
TempPreviousReading = lstInstall.SelectedItem.ListSubItems(12)
TempPresentReading = lstInstall.SelectedItem.ListSubItems(13)
TempConsumption = lstInstall.SelectedItem.ListSubItems(14)
TempBillAmount = lstInstall.SelectedItem.ListSubItems(15)
TempBillDate = lstInstall.SelectedItem.ListSubItems(16)
TempDueDate = lstInstall.SelectedItem.ListSubItems(17)
TempMonth = lstInstall.SelectedItem.ListSubItems(18)
TempMeterNo = lstInstall.SelectedItem.ListSubItems(9)
TempPeriodFrom = lstInstall.SelectedItem.ListSubItems(10)
TempPeriodTo = lstInstall.SelectedItem.ListSubItems(11)
Unload Me
End Sub

Private Sub Text4_Change()


If Trim(Text4) = "" Then
clsData.DisplayBillingUnpaid lstInstall, ""
Else
clsData.DisplayBillingUnpaid lstInstall, Text4.Text
End If
End Sub
Gen. Dec
Dim clsData As New clsService

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub cmdPrint_Click()


If Trim(txtBID) = "" Then
MsgBox "Please enter client Information", vbInformation, ""
Else
clsData.PrintServiceRecord txtBID, txtLname, txtAdd, DTPicker2.Value, txtMeterno
End If
End Sub

Private Sub cmdSearch_Click()


On Error Resume Next
SearchClientForBillingFrm.Show 1
txtBID = TempClientID
txtLname = TempLname & ", " & TempFname & " " & TempMname
txtAdd = TempAddress
txtCon = TempContact
DTPicker2.Value = TempDateInstall
txtMeterno = TempMeterNo
End Sub

Private Sub txtBID_Change()


If Trim(txtBID) = "" Then
clsData.DisplayService lstService, ""
Else
clsData.DisplayService lstService, txtBID.Text
End If
End Sub

Gen. Dec
Dim clsData As New clsStatementAccounts
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdPrint_Click()
If Trim(txtBID) = "" Then
MsgBox "Please enter client Information", vbInformation, ""
Else
clsData.PrintAccounts txtBID, txtLname, txtAdd, Date, txtMeterno, txtDueDate,
lblTotal.Caption
End If
End Sub

Private Sub cmdSearch_Click()


SearchClientForPaymentFrm.Show 1
txtBID = TempClientID
txtLname = TempLname & ", " & TempFname & " " & TempMname
txtAdd = TempAddress
lblDueDate = TempDueDate
txtMeterno = TempMeterNo
txtDueDate = TempDueDate
End Sub

Private Sub txtBID_Change()


If Trim(txtBID) = "" Then
clsData.GetAccounts lstService, ""
Else
clsData.GetAccounts lstService, txtBID.Text
ComputeTotal
End If
End Sub
Private Sub ComputeTotal()
Dim a As Integer, b As Integer, sTotal As Currency
a = lstService.ListItems.Count
For b = 1 To a
sTotal = Val(sTotal) + CCur(lstService.ListItems(b).SubItems(7))
Next
lblTotal = Format(sTotal, "##,##0.00")
End Sub

Modules:

DBconnect
Public rs As New ADODB.Recordset
Public conn As New ADODB.Connection
Public sql As String
Public ConString As String
Public CurrentUser As String
Public LoginSuccess As Boolean
Public UserTitle As String
Public userlog As Integer
Public TempClientID As String
Public TempLname As String
Public TempFname As String
Public TempMname As String
Public TempAddress As String
Public TempContact As String
Public TempDateInstall As String
Public TempMeterNo As String
Public TempBillID As String
Public TempBillDate As String
Public TempDueDate As String
Public TempBillAmount As String
Public TempConsumption As String
Public TempPresentReading As String
Public TempPreviousReading As String
Public TempPeriodFrom As String
Public TempPeriodTo As String
Public TempMonth As String
Sub Main()
'ConString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=" &
App.Path & "\Data.mdb;Jet OLEDB:Database Password="
ConString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=" &
App.Path & "\Data.db;Jet OLEDB:Database Password=webgeekbilling"
conn.Open ConString
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
End With
LoginFrm.Show
'MainFrm.Show
'Form1.Show
End Sub
Class Module

clsBilling

Function GetBillID() As String


If rs.State = adStateOpen Then rs.Close
sql = " SELECT Max(Billing.BillingID) AS MaxOfBillingID" & _
" FROM Billing;"
rs.Open sql, conn
If IsNull(rs(0).Value) Then
GetBillID = Format(1, "00000")
Else
GetBillID = Format(rs(0).Value + 1, "00000")
End If

End Function
Sub AddBilling(BillingID As String, ClientID As String, Lname As String, Fname As String,
Mname As String, Address As String, Contact As String, DateInstalled As String, MeterNo
As String, PeriodFrom As String, PeriodTo As String, PreviousReading As String,
PresentReading As String, Consumption As String, BillAmount As String, BillDate As
String, DueDate As String, Paid As String)
If rs.State = adStateOpen Then rs.Close
sql = "Select * From Billing Where BillingID='" & BillingID & "'"
rs.Open sql, conn
If rs.RecordCount >= 1 Then
MsgBox "Duplicate ID Found.Please enter another ID.", vbInformation, ""
Exit Sub
End If
With rs
.AddNew
!BillingID = BillingID
!ClientID = ClientID
!Lname = StrConv(Lname, vbProperCase)
!Fname = StrConv(Fname, vbProperCase)
!Mname = StrConv(Mname, vbProperCase)
!Address = Address
!Contact = Contact
!DateInstalled = DateInstalled
!MeterNo = MeterNo
!PeriodFrom = PeriodFrom
!PeriodTo = PeriodTo
!PreviousReading = PreviousReading
!PresentReading = PresentReading
!Consumption = Consumption
!BillAmount = BillAmount
!BillDate = BillDate
!DueDate = DueDate
!Paid = Paid
.Update
End With
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub DeleteBilling(BillingID As String)
If rs.State = adStateOpen Then rs.Close
sql = "Delete * From Billing Where BillingID='" & BillingID & "'"
rs.Open sql, conn
MsgBox "Record(s) Deleted", vbInformation, ""
End Sub
Sub DisplayBilling(lstBilling As ListView, SearchValue As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.Lname, Billing.Fname,
Billing.Mname, Billing.Address, Billing.Contact, Billing.DateInstalled, Billing.MeterNo,
Billing.PeriodFrom, Billing.PeriodTo, Billing.PreviousReading, Billing.PresentReading,
Billing.Consumption, Billing.BillAmount, Billing.BillDate, Billing.DueDate" & _
" From Billing" & _
" Where Billing.Lname like '" & SearchValue & "%'" & _
" ORDER BY Billing.BillingID, Billing.Lname;"
Else
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.Lname, Billing.Fname,
Billing.Mname, Billing.Address, Billing.Contact, Billing.DateInstalled, Billing.MeterNo,
Billing.PeriodFrom, Billing.PeriodTo, Billing.PreviousReading, Billing.PresentReading,
Billing.Consumption, Billing.BillAmount, Billing.BillDate, Billing.DueDate" & _
" From Billing" & _
" ORDER BY Billing.BillingID, Billing.Lname;"
End If
rs.Open sql, conn
lstBilling.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstBilling.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
lstItem.SubItems(7) = rs(6).Value
lstItem.SubItems(8) = rs(7).Value
lstItem.SubItems(9) = rs(8).Value
lstItem.SubItems(10) = rs(9).Value
lstItem.SubItems(11) = rs(10).Value
lstItem.SubItems(12) = rs(11).Value
lstItem.SubItems(13) = rs(12).Value
lstItem.SubItems(14) = rs(13).Value
lstItem.SubItems(15) = rs(14).Value
lstItem.SubItems(16) = rs(15).Value
lstItem.SubItems(17) = rs(16).Value
'lstItem.SubItems(18) = rs(17).Value
rs.MoveNext
Loop
End Sub

Sub DisplayBillingUnpaid(lstBilling As ListView, SearchValue As String)


Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.Lname, Billing.Fname,
Billing.Mname, Billing.Address, Billing.Contact, Billing.DateInstalled, Billing.MeterNo,
Billing.PeriodFrom, Billing.PeriodTo, Billing.PreviousReading, Billing.PresentReading,
Billing.Consumption, Billing.BillAmount, Billing.BillDate, Billing.DueDate,Billing.Paid" & _
" From Billing" & _
" Where Billing.Lname like '" & SearchValue & "%' and Billing.Paid='Unpaid'" &
_
" ORDER BY Billing.BillingID, Billing.Lname;"
Else
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.Lname, Billing.Fname,
Billing.Mname, Billing.Address, Billing.Contact, Billing.DateInstalled, Billing.MeterNo,
Billing.PeriodFrom, Billing.PeriodTo, Billing.PreviousReading, Billing.PresentReading,
Billing.Consumption, Billing.BillAmount, Billing.BillDate, Billing.DueDate,Billing.Paid" & _
" From Billing" & _
" Where Billing.Paid='Unpaid'" & _
" ORDER BY Billing.BillingID, Billing.Lname;"
End If
rs.Open sql, conn
lstBilling.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstBilling.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
lstItem.SubItems(7) = rs(6).Value
lstItem.SubItems(8) = rs(7).Value
lstItem.SubItems(9) = rs(8).Value
lstItem.SubItems(10) = rs(9).Value
lstItem.SubItems(11) = rs(10).Value
lstItem.SubItems(12) = rs(11).Value
lstItem.SubItems(13) = rs(12).Value
lstItem.SubItems(14) = rs(13).Value
lstItem.SubItems(15) = rs(14).Value
lstItem.SubItems(16) = rs(15).Value
lstItem.SubItems(17) = rs(16).Value
lstItem.SubItems(18) = rs(17).Value
rs.MoveNext
Loop
End Sub
Sub UpdateBillingPaid(BillingID As String)
If rs.State = adStateOpen Then rs.Close
sql = "Update Billing set Billing.Paid='Paid' Where BillingID='" & BillingID & "'"
rs.Open sql, conn
End Sub

Function MyGetPreviousReading(ClientID As String) As String


If rs.State = adStateOpen Then rs.Close
sql = " SELECT Max(Billing.PresentReading) AS MaxOfPresentReading" & _
" FROM Billing" & _
" Where Billing.ClientID='" & ClientID & "'"
rs.Open sql, conn
If IsNull(rs(0).Value) Then
MyGetPreviousReading = "0.00"
Else
MyGetPreviousReading = rs(0).Value
End If

End Function
Function GetPreviousReading() As String
If rs.State = adStateOpen Then rs.Close
sql = " SELECT Max(Billing.PresentReading) AS MaxOfPresentReading" & _
" FROM Billing;"
rs.Open sql, conn
If IsNull(rs(0).Value) Then
GetPreviousReading = "0.00"
Else
GetPreviousReading = rs(0).Value
End If

End Function

clsClient
Dim mrs As New ADODB.Recordset
Dim msql As String
Sub AddClient(cID As String, Lname As String, Fname As String, Mname As String,
Address As String, Contact As String, Status As String)
If rs.State = adStateOpen Then rs.Close
sql = "Select * from Client Where ClientID='" & ID & "'"
rs.Open sql, conn
If rs.RecordCount >= 1 Then
MsgBox "Duplicate ID Found.Please enter another ID.", vbInformation, ""
Exit Sub
End If
With rs
.AddNew
!ClientID = cID
!Lname = StrConv(Lname, vbProperCase)
!Fname = StrConv(Fname, vbProperCase)
!Mname = StrConv(Mname, vbProperCase)
!Address = Address
!Contact = Contact
!Status = Status
.Update
End With
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub UpdateClient(cID As String, Lname As String, Fname As String, Mname As String,
Address As String, Contact As String, Status As String, OldID As String)
If rs.State = adStateOpen Then rs.Close
sql = "Update Client set Client.ClientID='" & cID & "', Client.Lname='" &
StrConv(Lname, vbProperCase) & "',Client.Fname='" & StrConv(Fname, vbProperCase)
& "',Client.Mname='" & StrConv(Mname, vbProperCase) & "',Client.Address='" &
StrConv(Address, vbProperCase) & "',Client.Contact='" & Contact & "', Client.Status='"
& Status & "' Where Client.ClientID='" & OldID & "'"
rs.Open sql, conn
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub DeleteClient(cID As String)
If rs.State = adStateOpen Then rs.Close
sql = " Delete * From Client Where ClientID='" & cID & "'"
rs.Open sql, conn
MsgBox "Record(s) Deleted", vbInformation, ""
End Sub
Function GetID() As String
If rs.State = adStateOpen Then rs.Close
sql = " SELECT Max(Client.ClientID) AS MaxOfClientID" & _
" FROM Client;"
rs.Open sql, conn
If IsNull(rs(0).Value) Then
GetID = Format(1, "00000")
Else
GetID = Format(rs(0).Value + 1, "00000")
End If
End Function
Sub DisplayClients(lstClient As ListView, SearchValue As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
sql = " SELECT Client.ClientID, Client.Lname, Client.Fname, Client.Mname,
Client.Address, Client.Contact,Client.Status" & _
" From Client" & _
" Where Client.Lname like '" & SearchValue & "%'" & _
" ORDER BY Client.Lname;"
Else
sql = " SELECT Client.ClientID, Client.Lname, Client.Fname, Client.Mname,
Client.Address, Client.Contact,Client.Status" & _
" From Client" & _
" ORDER BY Client.Lname;"
End If
rs.Open sql, conn
lstClient.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstClient.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
lstItem.SubItems(7) = rs(6).Value
rs.MoveNext
Loop
End Sub

Sub SetClientInstall(ClientID As String)


If rs.State = adStateOpen Then rs.Close
sql = "Update Client set Client.Status='Installed' Where ClientID='" & ClientID & "'"
rs.Open sql, conn
End Sub
Sub DisplayClientsNotInstalled(lstClient As ListView, SearchValue As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
sql = " SELECT Client.ClientID, Client.Lname, Client.Fname, Client.Mname,
Client.Address, Client.Contact,Client.Status" & _
" From Client" & _
" Where Client.Lname like '" & SearchValue & "%' and Client.Status='Not
Installed'" & _
" ORDER BY Client.Lname;"
Else
sql = " SELECT Client.ClientID, Client.Lname, Client.Fname, Client.Mname,
Client.Address, Client.Contact,Client.Status" & _
" From Client" & _
" Where Client.Status='Not Installed'" & _
" ORDER BY Client.Lname;"
End If
rs.Open sql, conn
lstClient.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstClient.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
lstItem.SubItems(7) = rs(6).Value
rs.MoveNext
Loop
End Sub

clsCompany
Dim mrs As New ADODB.Recordset
Dim msql As String
Sub Setup(txtCname As TextBox, txtLocation As TextBox, txtContact As TextBox, txtTIN
As TextBox)
If mrs.State = adStateOpen Then mrs.Close
msql = "SELECT * FROM CompanySetup"
mrs.Open msql, conn
txtCname = IIf(IsNull(mrs(1).Value), "", mrs(1).Value)
txtLocation = IIf(IsNull(mrs(2).Value), "", mrs(2).Value)
txtContact = IIf(IsNull(mrs(3).Value), "", mrs(3).Value)
txtTIN = IIf(IsNull(mrs(4).Value), "", mrs(4).Value)
End Sub
Sub UpdateSetup(txtCname As TextBox, txtLocation As TextBox, txtContact As TextBox,
txtTIN As TextBox)
If mrs.State = adStateOpen Then mrs.Close
msql = "UPDATE CompanySetup SET CompanySetup.CName='" & txtCname & "',
CompanySetup.Loc='" & txtLocation & "',CompanySetup.Contact='" & txtContact &
"',CompanySetup.TIN='" & txtTIN & "' WHERE (((CompanySetup.Index)=1));"
mrs.Open msql, conn
MsgBox "Setup Updated!.", vbInformation, ""
End Sub
ClsInstall
Dim mrs As New ADODB.Recordset
Dim msql As String
Sub AddInstall(InstallID As String, ClientID As String, Lname As String, Fname As String,
Mname As String, Address As String, Contact As String, InstallDate As String, MeterNo
As String)
If rs.State = adStateOpen Then rs.Close
sql = "Select * From Installation Where InstallID='" & InstallID & "'"
rs.Open sql, conn
If rs.RecordCount >= 1 Then
MsgBox "Duplicate ID Found.Please enter another ID.", vbInformation, ""
Exit Sub
End If
With rs
.AddNew
!InstallID = InstallID
!ClientID = ClientID
!Lname = StrConv(Lname, vbProperCase)
!Fname = StrConv(Fname, vbProperCase)
!Mname = StrConv(Mname, vbProperCase)
!Address = Address
!Contact = Contact
!InstallDate = InstallDate
!MeterNo = MeterNo
.Update
End With
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub UpdateInstall(InstallID As String, ClientID As String, Lname As String, Fname As
String, Mname As String, Address As String, Contact As String, InstallDate As String,
MeterNo As String, OldID As String)
If rs.State = adStateOpen Then rs.Close
sql = "Update Installation set Installation.InstallID='" & InstallID &
"',Installation.ClientID='" & ClientID & "', Installation.Lname='" & StrConv(Lname,
vbProperCase) & "',Installation.Fname='" & StrConv(Fname, vbProperCase) &
"',Installation.Mname='" & StrConv(Mname, vbProperCase) & "',Installation.Address='"
& StrConv(Address, vbProperCase) & "',Installation.Contact='" & Contact &
"',Installation.InstallDate='" & InstallDate & "',Installation.MeterNo='" & MeterNo & "'
Where Installation.InstallID='" & OldID & "'"
rs.Open sql, conn
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub DeleteInstall(InstallID As String)
If rs.State = adStateOpen Then rs.Close
sql = "Delete * From Installation Where InstallID='" & InstallID & "'"
rs.Open sql, conn
MsgBox "Record(s) Deleted", vbInformation, ""
End Sub
Function GetInstallID() As String
If rs.State = adStateOpen Then rs.Close
sql = " SELECT Max(Installation.InstallID) AS MaxOfInstallID" & _
" FROM Installation;"
rs.Open sql, conn
If IsNull(rs(0).Value) Then
GetInstallID = Format(1, "00000")
Else
GetInstallID = Format(rs(0).Value + 1, "00000")
End If
End Function
Sub DisplayInstallation(lstInstall As ListView, SearchValue As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
sql = " SELECT Installation.InstallID, Installation.ClientID, Installation.Lname,
Installation.Fname, Installation.Mname, Installation.Address, Installation.Contact,
Installation.InstallDate, Installation.MeterNo" & _
" From Installation" & _
" Where Installation.Lname like '" & SearchValue & "%'" & _
" ORDER BY Installation.InstallID, Installation.Lname;"
Else
sql = " SELECT Installation.InstallID, Installation.ClientID, Installation.Lname,
Installation.Fname, Installation.Mname, Installation.Address, Installation.Contact,
Installation.InstallDate, Installation.MeterNo" & _
" From Installation" & _
" ORDER BY Installation.InstallID, Installation.Lname;"
End If
rs.Open sql, conn
lstInstall.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstInstall.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
lstItem.SubItems(7) = rs(6).Value
lstItem.SubItems(8) = rs(7).Value
lstItem.SubItems(9) = rs(8).Value
rs.MoveNext
Loop
End Sub
Sub AddDisConnect(DisConnectID As String, ClientID As String, Lname As String, Fname
As String, Mname As String, Address As String, Contact As String, DisConnectDate As
String, sType As String)
If rs.State = adStateOpen Then rs.Close
sql = "Select * From MyConnect"
rs.Open sql, conn
With rs
.AddNew
!DisConnectID = DisConnectID
!ClientID = ClientID
!Lname = StrConv(Lname, vbProperCase)
!Fname = StrConv(Fname, vbProperCase)
!Mname = StrConv(Mname, vbProperCase)
!Address = Address
!Contact = Contact
!DateRec = InstallDate
!sType = sType
.Update
End With
'MsgBox "Record(s) Updated", vbInformation, ""
End Sub

Public Sub PrintNotice(ClientID As String)


If rs.State = adStateOpen Then rs.Close
sql = " SELECT Installation.InstallID, Installation.ClientID, Installation.Lname,
Installation.Fname, Installation.Mname, Installation.Address, Installation.Contact,
Installation.InstallDate, Installation.MeterNo" & _
" From Installation" & _
" Where Installation.ClientID like '" & ClientID & "%'" & _
" ORDER BY Installation.InstallID, Installation.Lname;"
rs.Open sql, conn

Set rptInstallation.DataSource = rs

rptInstallation.Sections("Section2").Controls.Item("lblName").Caption =
rs(2).Value & " " & rs(3).Value & ", " & rs(4).Value
rptInstallation.Show 1
End Sub

clsMonthly

Sub DisplayRecord(lstRecord As ListView, DateFrom As String, DateTo As String)


Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
'sql=" SELECT Invoice.InvoiceID, Invoice.ClientID, [Lname]& " " & [Fname] & ", " &
[Mname] AS Name, Invoice.BillID, Invoice.BillDate, Invoice.BillAmount, Invoice.DateRec "
&_
" From Invoice" & _
" Where Invoice.DateRec >=#" & DateFrom & "# and Invoice.DateRec <=#" &
DateTo & "#" & _
" GROUP BY Invoice.InvoiceID, Invoice.ClientID, [Lname]+" "+[Fname]+", "+[Mname],
Invoice.BillID, Invoice.BillDate, Invoice.BillAmount, Invoice.DateRec;

sql = " SELECT Invoice.InvoiceID, Invoice.ClientID, Invoice.Lname, Invoice.Fname,


Invoice.Mname, Invoice.BillID, Invoice.BillDate, Invoice.BillAmount, Invoice.DateRec" & _
" From Invoice" & _
" Where Invoice.DateRec >=#" & DateFrom & "# and Invoice.DateRec <=#" &
DateTo & "#" & _
" GROUP BY Invoice.InvoiceID, Invoice.ClientID, Invoice.Lname, Invoice.Fname,
Invoice.Mname, Invoice.BillID, Invoice.BillDate, Invoice.BillAmount, Invoice.DateRec;"
rs.Open sql, conn
lstRecord.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstRecord.ListItems.Add(, , a)
lstItem.SubItems(1) = rs(0).Value
lstItem.SubItems(2) = rs(1).Value
lstItem.SubItems(3) = rs(2).Value & " " & rs(3).Value & ", " & rs(4).Value
lstItem.SubItems(4) = rs(5).Value
lstItem.SubItems(5) = rs(6).Value
lstItem.SubItems(6) = rs(7).Value
'lstItem.SubItems(7) = rs(8).Value
rs.MoveNext
Loop
End Sub

Sub PrintRecord(DateFrom As String, DateTo As String, lblTotal As String)


If rs.State = adStateOpen Then rs.Close
sql = " SELECT Invoice.InvoiceID, Invoice.ClientID, Invoice.Lname, Invoice.Fname,
Invoice.Mname, Invoice.BillID, Invoice.BillDate, Invoice.BillAmount, Invoice.DateRec" & _
" From Invoice" & _
" Where Invoice.DateRec >=#" & DateFrom & "# and Invoice.DateRec <=#" &
DateTo & "#" & _
" GROUP BY Invoice.InvoiceID, Invoice.ClientID, Invoice.Lname, Invoice.Fname,
Invoice.Mname, Invoice.BillID, Invoice.BillDate, Invoice.BillAmount, Invoice.DateRec;"
rs.Open sql, conn

Set rptMonthly.DataSource = rs
rptMonthly.Sections("Section2").Controls.Item("lblDateFrom").Caption = DateFrom
rptMonthly.Sections("Section2").Controls.Item("lblDateTo").Caption = DateTo
rptMonthly.Sections("Section5").Controls.Item("lblTotal").Caption = lblTotal

rptMonthly.Show 1
End Sub

clspayment

Function GetORID() As String


If rs.State = adStateOpen Then rs.Close
sql = " SELECT Max(Invoice.InvoiceID) AS MaxOfInvoiceID" & _
" FROM Invoice;"
rs.Open sql, conn
If IsNull(rs(0).Value) Then
GetORID = Format(1, "00000")
Else
GetORID = Format(rs(0).Value + 1, "00000")
End If
End Function
Sub AddInvoice(InvoiceID As String, ClientID As String, Lname As String, Fname As
String, Mname As String, Address As String, Contact As String, BillID As String, BillDate
As String, DueDate As String, Penalty As String, BillAmount As String, Tendered As
String, Change As String, Cashier As String, DateRec As String)
If rs.State = adStateOpen Then rs.Close
sql = "Select * From Invoice Where InvoiceID='" & InvoiceID & "'"
rs.Open sql, conn
If rs.RecordCount >= 1 Then
MsgBox "Duplicate ID Found.Please enter another ID.", vbInformation, ""
Exit Sub
End If
With rs
.AddNew
!InvoiceID = InvoiceID
!ClientID = ClientID
!Lname = StrConv(Lname, vbProperCase)
!Fname = StrConv(Fname, vbProperCase)
!Mname = StrConv(Mname, vbProperCase)
!Address = Address
!Contact = Contact
!BillID = BillID
!BillDate = BillDate
!DueDate = DueDate
!Penalty = Penalty
!BillAmount = BillAmount
!Tendered = Tendered
!Change = Change
!Cashier = Cashier
!DateRec = DateRec
.Update
End With
End Sub

clsPrint
Dim mrs As New ADODB.Recordset
Dim msql As String
Sub PrintInvoice(InvoiceID As String, ClientID As String, Lname As String, Fname As
String, Mname As String, Address As String, BillDate As String, DueDate As String,
PresentReading As String, PreviousReading As String, Consumption As String, sTotal As
String, Tendered As String, Change As String, Cashier As String, PeriodFrom As String,
PeriodTo As String)
Dim rst As New ADODB.Recordset
If mrs.State = adStateOpen Then mrs.Close

msql = " SELECT Invoice.InvoiceID, Invoice.ClientID, Invoice.Lname, Invoice.Fname,


Invoice.Mname, Invoice.BillDate, Invoice.DueDate, Invoice.BillAmount, Invoice.Tendered,
Invoice.Change, Invoice.Cashier" & _
" FROM Invoice"

mrs.Open msql, conn

Set rptResibo.DataSource = mrs

If rst.State = adStateOpen Then rst.Close


rst.Open "SELECT * FROM CompanySetup where Index=1", conn

rptResibo.Sections("Section4").Controls.Item("lblCName").Caption = rst(1).Value
rptResibo.Sections("Section4").Controls.Item("lblLocation").Caption = rst(2).Value
rptResibo.Sections("Section4").Controls.Item("lblContact").Caption = rst(3).Value
rptResibo.Sections("Section4").Controls.Item("lblTIN").Caption = rst(4).Value
rptResibo.Sections("Section4").Controls.Item("lblInvoice").Caption = InvoiceID
rptResibo.Sections("Section2").Controls.Item("lblClientID").Caption = ClientID
rptResibo.Sections("Section2").Controls.Item("lblName").Caption = Lname & ", " &
Fname & " " & Mname
rptResibo.Sections("Section2").Controls.Item("lblAddress").Caption = Address
rptResibo.Sections("Section2").Controls.Item("lblBillDate").Caption = BillDate
rptResibo.Sections("Section2").Controls.Item("lblDueDate").Caption = DueDate
rptResibo.Sections("Section2").Controls.Item("lblPresentReading").Caption =
PresentReading
rptResibo.Sections("Section2").Controls.Item("lblPreviousReading").Caption =
PreviousReading
rptResibo.Sections("Section2").Controls.Item("lblConsumption").Caption =
Consumption
rptResibo.Sections("Section5").Controls.Item("lblTotal").Caption = sTotal
rptResibo.Sections("Section5").Controls.Item("lblTendered").Caption = Tendered
rptResibo.Sections("Section5").Controls.Item("lblChange").Caption = Change
rptResibo.Sections("Section5").Controls.Item("lblCashier").Caption = Cashier
rptResibo.Sections("Section4").Controls.Item("lblMonth").Caption = PeriodFrom
rptResibo.Sections("Section4").Controls.Item("Label14").Caption = PeriodTo
rptResibo.Show 1
Set rst = Nothing
End Sub

clsService

Sub DisplayService1(lstService As ListView, ClientID As String)


Dim lstItem As ListItem, a As Integer
Dim rsInvoice As New ADODB.Recordset
If rs.State = adStateOpen Then rs.Close
If ClientID <> "" Then
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading,
Billing.Consumption,Billing.Paid" & _
" FROM Billing" & _
" Where Billing.ClientID like '" & ClientID & "' and Billing.Paid='Paid'"
Else
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading,
Billing.Consumption,Billing.Paid" & _
" FROM Billing"
End If
If rsInvoice.State = adStateOpen Then rsInvoice.Close
rsInvoice.Open " SELECT Invoice.ClientID, Invoice.BillAmount, Invoice.InvoiceID,
Invoice.DateRec" & _
" FROM Invoice" & _
" Where Invoice.ClientID='" & ClientID & "'", conn
rs.Open sql, conn
lstService.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstService.ListItems.Add(, , a)
lstItem.SubItems(1) = rs(2).Value
lstItem.SubItems(2) = rs(3).Value
lstItem.SubItems(3) = rs(4).Value
lstItem.SubItems(4) = rs(5).Value
lstItem.SubItems(5) = rs(6).Value
lstItem.SubItems(6) = rsInvoice(1).Value
lstItem.SubItems(7) = rsInvoice(2).Value
lstItem.SubItems(8) = rsInvoice(3).Value
'lstItem.SubItems(8) = rs(8).Value
rs.MoveNext
Loop
End Sub

Sub PrintServiceRecord(ClientID As String, txtName As String, txtAddress As String,


txtDateInstall As String, txtMeterno As String)
Dim rsInvoice As New ADODB.Recordset
If rs.State = adStateOpen Then rs.Close
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.Paid, Invoice.BillAmount, Invoice.InvoiceID,Invoice.DateRec" & _
" FROM Billing INNER JOIN Invoice ON Billing.BillingID = Invoice.InvoiceID " &
_
" Where Billing.ClientID like '" & ClientID & "' and Billing.Paid='Paid'" & _
" GROUP BY Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.Paid, Invoice.BillAmount, Invoice.InvoiceID,Invoice.DateRec"
rs.Open sql, conn

Set rptService.DataSource = rs

'If rsInvoice.State = adStateOpen Then rsInvoice.Close


'rsInvoice.Open " SELECT Invoice.ClientID, Invoice.BillAmount, Invoice.InvoiceID,
Invoice.DateRec" & _
' " FROM Invoice" & _
' " Where Invoice.ClientID='" & ClientID & "'", conn

On Error Resume Next


rptService.Sections("Section2").Controls.Item("lblClientID").Caption = rs(0).Value
rptService.Sections("Section2").Controls.Item("lblName").Caption = txtName
rptService.Sections("Section2").Controls.Item("lblAddress").Caption = txtAddress
rptService.Sections("Section2").Controls.Item("lblDate").Caption = txtDateInstall
rptService.Sections("Section2").Controls.Item("lblMeterNo").Caption = txtMeterno
rptService.Sections("Section1").Controls.Item("Text5").Caption =
rsInvoice(1).Value
rptService.Sections("Section1").Controls.Item("Text6").Caption =
rsInvoice(2).Value
rptService.Sections("Section1").Controls.Item("Text7").Caption =
rsInvoice(3).Value
rptService.Show 1
End Sub
Sub DisplayService(lstService As ListView, ClientID As String)
Dim lstItem As ListItem, a As Integer
Dim rsInvoice As New ADODB.Recordset
If rs.State = adStateOpen Then rs.Close
If ClientID <> "" Then
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.Paid, Invoice.BillAmount, Invoice.InvoiceID,Invoice.DateRec" & _
" FROM Billing INNER JOIN Invoice ON Billing.BillingID = Invoice.InvoiceID " &
_
" Where Billing.ClientID like '" & ClientID & "' and Billing.Paid='Paid'" & _
" GROUP BY Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.Paid, Invoice.BillAmount, Invoice.InvoiceID,Invoice.DateRec"
Else
sql = " SELECT Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.Paid, Invoice.BillAmount, Invoice.InvoiceID,Invoice.DateRec" & _
" FROM Billing INNER JOIN Invoice ON Billing.BillingID = Invoice.InvoiceID " &
_
" GROUP BY Billing.BillingID, Billing.ClientID, Billing.PeriodFrom,
Billing.PeriodTo, Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.Paid, Invoice.BillAmount, Invoice.InvoiceID,Invoice.DateRec"
End If
'If rsInvoice.State = adStateOpen Then rsInvoice.Close
' rsInvoice.Open " SELECT Invoice.ClientID, Invoice.BillAmount, Invoice.InvoiceID,
Invoice.DateRec" & _
' " FROM Invoice" & _
' " Where Invoice.ClientID='" & ClientID & "'", conn
rs.Open sql, conn
lstService.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstService.ListItems.Add(, , a)
lstItem.SubItems(1) = rs(2).Value
lstItem.SubItems(2) = rs(3).Value
lstItem.SubItems(3) = rs(4).Value
lstItem.SubItems(4) = rs(5).Value
lstItem.SubItems(5) = rs(6).Value
lstItem.SubItems(6) = rs(8).Value
lstItem.SubItems(7) = rs(9).Value
lstItem.SubItems(8) = rs(10).Value
'lstItem.SubItems(8) = rs(8).Value
rs.MoveNext
Loop
End Sub

clsStatementAccounts
Public Sub GetAccounts(lstAccounts As ListView, ClientID As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If ClientID <> "" Then
sql = " SELECT Billing.ClientID, Billing.PeriodFrom, Billing.PeriodTo,
Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.BillAmount,Billing.Paid" & _
" From Billing" & _
" Where Billing.ClientID='" & ClientID & "' and Billing.Paid='Unpaid' " & _
" ORDER BY Billing.ClientID;"
Else
sql = " SELECT Billing.ClientID, Billing.PeriodFrom, Billing.PeriodTo,
Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.BillAmount,Billing.Paid" & _
" From Billing" & _
" Where Billing.Paid='Unpaid' " & _
" ORDER BY Billing.ClientID;"
End If
rs.Open sql, conn
lstAccounts.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstAccounts.ListItems.Add(, , a)
lstItem.SubItems(1) = rs(1).Value
lstItem.SubItems(2) = rs(2).Value
lstItem.SubItems(3) = rs(3).Value
lstItem.SubItems(4) = rs(4).Value
lstItem.SubItems(5) = rs(5).Value
lstItem.SubItems(6) = rs(6).Value
lstItem.SubItems(7) = rs(6).Value
rs.MoveNext
Loop
End Sub

Sub PrintAccounts(ClientID As String, txtName As String, txtAddress As String, txtDate


As String, txtMeterno As String, txtDueDate As String, txtTotal As String)
If rs.State = adStateOpen Then rs.Close
sql = " SELECT Billing.ClientID, Billing.PeriodFrom, Billing.PeriodTo,
Billing.PresentReading, Billing.PreviousReading, Billing.Consumption,
Billing.BillAmount,Billing.Paid" & _
" From Billing" & _
" Where Billing.ClientID='" & ClientID & "' and Billing.Paid='Unpaid' " & _
" ORDER BY Billing.ClientID;"
rs.Open sql, conn

Set rptStatement.DataSource = rs

rptStatement.Sections("Section2").Controls.Item("lblClientID").Caption =
rs(0).Value
rptStatement.Sections("Section2").Controls.Item("lblName").Caption = txtName
rptStatement.Sections("Section2").Controls.Item("lblAddress").Caption =
txtAddress
rptStatement.Sections("Section2").Controls.Item("lblDate").Caption = txtDate
rptStatement.Sections("Section2").Controls.Item("lblMeterNo").Caption =
txtMeterno
rptStatement.Sections("Section5").Controls.Item("lblDueDate").Caption =
txtDueDate
rptStatement.Sections("Section5").Controls.Item("lblTotal").Caption = txtTotal

rptStatement.Show 1
End Sub

Clsusers
Dim mrs As New ADODB.Recordset
Dim msql As String
Sub DisplayUsers(lstUsers As ListView)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
sql = "Select * From Accounts Where Hidden <> True Order By Username"
rs.Open sql, conn
lstUsers.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstUsers.ListItems.Add(, , a)
lstItem.SubItems(1) = rs(0).Value
lstItem.SubItems(2) = rs(2).Value
lstItem.SubItems(5) = rs(1).Value
rs.MoveNext
Loop
End Sub
Function GetUsers(cboUser As ComboBox) As Boolean
'On Error GoTo hell
If rs.State = adStateOpen Then rs.Close
sql = "Select * From Accounts Order by Username"
rs.Open sql, conn
If Not (rs.EOF And rs.BOF) Then
cboUser.Clear
Do While Not rs.EOF
GetUsers = True
cboUser.AddItem rs.Fields(0).Value
rs.MoveNext
cboUser.ListIndex = 0
Loop
End If
Exit Function
'hell:
'MsgBox Err.Description, vbCritical, ""
End Function
Public Function Login(Username As String, Password As String, msg As String) As
Boolean
If rs.State = adStateOpen Then rs.Close
sql = "Select * From accounts where username='" & Username & "'"
rs.Open sql, conn
If (rs.EOF And rs.BOF) Then
DoEvents
msg = "The system cannot log you on.Please enter valid username and password."
Login = False
Else
If rs.Fields(1).Value = Password Or rs.Fields(1).Value = "empty" Then
DoEvents
Login = True
MainFrm.Tag = rs.Fields(2).Value
ElseIf IsNull(rs.Fields(0).Value) Then
DoEvents
Login = True
Else
Login = False
msg = "Incorrect password"
End If
End If
End Function
Sub AddUser(Username As String, Password As String, AccountType As String)
'Dim mAdd As Boolean, mUpdate As Boolean, mDelete As Boolean, mPrint As Boolean
'mAdd = IIf(chkAdd.Value = 1, True, False)
'mUpdate = IIf(chkUpdate.Value = 1, True, False)
'mDelete = IIf(chkDel.Value = 1, True, False)
'mPrint = IIf(chkPrint.Value = 1, True, False)
If rs.State = adStateOpen Then rs.Close
sql = "Select * From Accounts Where username='" & Username & "'"
rs.Open sql, conn
If rs.RecordCount >= 1 Then
MsgBox "Duplicate username found.Please enter another username.",
vbInformation, ""
Exit Sub
End If
With rs
.AddNew
!Username = Username
!Password = Password
!AccountType = AccountType
'!Add = mAdd
'!Delete = mDel
'!Update = mUpdate
'!Print = mPrint
.Update
End With
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub UpdateUser(Username As String, Password As String, AccountType As String,
OldUser As String)
'Dim mAdd As Boolean, mUpdate As Boolean, mDelete As Boolean, mPrint As Boolean
'mAdd = IIf(chkAdd.Value = 1, True, False)
'mUpdate = IIf(chkUpdate.Value = 1, True, False)
'mDelete = IIf(chkDel.Value = 1, True, False)
'mPrint = IIf(chkPrint.Value = 1, True, False)
If rs.State = adStateOpen Then rs.Close
sql = "UPDATE Accounts SET Accounts.UserName='" & Username & "',
Accounts.Password='" & Password & "', Accounts.AccountType='" & AccountType & "'
WHERE (Accounts.UserName)='" & OldUser & "';"
rs.Open sql, conn
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub DeleteUser(Username As String)
If rs.State = adStateOpen Then rs.Close
sql = "Delete * From Accounts Where username='" & Username & "'"
rs.Open sql, conn
MsgBox "Record(s) Updated", vbInformation, ""
End Sub
Sub GetUserPrivileges(Username As String, AccountType As String)
If rs.State = adStateOpen Then rs.Close
sql = " SELECT Accounts.AccountType" & _
" FROM Accounts" & _
" Where username='" & Username & "'"
rs.Open sql, conn
AccountType = rs!AccountType
End Sub
Sub Initialize()
With mrs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
End With
End Sub
Function UserLoginTime(Username As String, LoginTime As Date) As Integer
If rs.State = adStateOpen Then rs.Close
sql = " Select * From Userlog"
rs.Open sql, conn
With rs
.AddNew
!Username = Username
!LoginTime = LoginTime
.Update
End With
UserLoginTime = rs(0).Value
End Function
Function UserLogoutTime(Index As Integer, LogOutTime As String) As Integer
If rs.State = adStateOpen Then rs.Close
sql = " Update Userlog set Userlog.LogoutTime=#" & LogOutTime & "# Where
(userlog.logid)= " & Index & ""
rs.Open sql, conn
End Function
Sub DisplayUserLog(lstLog As ListView, mDate As Date)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
sql = " Select * From Userlog Where (Userlog.Date)=#" & mDate & "#"
rs.Open sql, conn
lstLog.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstLog.ListItems.Add(, , a, 1, 1)
lstItem.SubItems(1) = rs(1).Value
lstItem.SubItems(2) = rs(2).Value
If IsNull(rs(3).Value) Then
lstItem.SubItems(3) = ""
Else
lstItem.SubItems(3) = rs(3).Value
End If
lstItem.SubItems(4) = rs(4).Value
rs.MoveNext
Loop
End Sub

Disconnect
Dim mrs As New ADODB.Recordset
Dim msql As String
Sub DisplayConnect(lstConnect As ListView, SearchValue As String)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
sql = " SELECT MyConnect.DisConnectID, MyConnect.ClientID, MyConnect.Lname,
MyConnect.Fname, MyConnect.Mname, MyConnect.Address, MyConnect.Contact,
MyConnect.DateRec, MyConnect.sType" & _
" From MyConnect" & _
" Where MyConnect.Lname like '" & SearchValue & "%'" & _
" ORDER BY MyConnect.DisConnectID, MyConnect.Lname;"
Else
sql = " SELECT MyConnect.DisConnectID, MyConnect.ClientID, MyConnect.Lname,
MyConnect.Fname, MyConnect.Mname, MyConnect.Address, MyConnect.Contact,
MyConnect.DateRec, MyConnect.sType" & _
" From MyConnect" & _
" ORDER BY MyConnect.DisConnectID, MyConnect.Lname;"
End If
rs.Open sql, conn
lstConnect.ListItems.Clear
Do While Not rs.EOF
a=a+1
Set lstItem = lstConnect.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
lstItem.SubItems(7) = rs(6).Value
lstItem.SubItems(8) = rs(7).Value
lstItem.SubItems(9) = rs(8).Value
rs.MoveNext
Loop
End Sub
Sub UpdateConnect(ConnectID As String)
If rs.State = adStateOpen Then rs.Close
sql = "Update MyConnect set Myconnect.sType='Connected' Where
Myconnect.DisConnectID='" & ConnectID & "'"
rs.Open sql, conn
MsgBox "Client Connected", vbInformation, ""
End Sub
Sub UpdateDisConnect(ConnectID As String)
If rs.State = adStateOpen Then rs.Close
sql = "Update MyConnect set Myconnect.sType='Disconnected' Where
Myconnect.DisConnectID='" & ConnectID & "'"
rs.Open sql, conn
MsgBox "Client Disconnected", vbInformation, ""
End Sub
Function GetConnectID() As String
If rs.State = adStateOpen Then rs.Close
sql = " SELECT Max(MyConnect.DisConnectID) AS MaxOfDisConnectID" & _
" FROM MyConnect;"
rs.Open sql, conn
If IsNull(rs(0).Value) Then
GetConnectID = Format(1, "00000")
Else
GetConnectID = Format(rs(0).Value + 1, "00000")
End If
End Function
Sub AddConnectHistory(ClientID As String, Lname As String, Fname As String, Mname
As String, Address As String, Contact As String, DateRec As String, sType As String)
If rs.State = adStateOpen Then rs.Close
sql = " Select * From MyConnectHistory"
rs.Open sql, conn
With rs
.AddNew
!ClientID = ClientID
!Lname = StrConv(Lname, vbProperCase)
!Fname = StrConv(Fname, vbProperCase)
!Mname = StrConv(Mname, vbProperCase)
!Address = Address
!Contact = Contact
!DateRec = DateRec
!sType = sType
.Update
End With
End Sub
Sub AddDisConnectHistory(ClientID As String, Lname As String, Fname As String,
Mname As String, Address As String, Contact As String, DateRec As String, sType As
String)
If rs.State = adStateOpen Then rs.Close
sql = " Select * From MyConnectHistory"
rs.Open sql, conn
With rs
.AddNew
!ClientID = ClientID
!Lname = StrConv(Lname, vbProperCase)
!Fname = StrConv(Fname, vbProperCase)
!Mname = StrConv(Mname, vbProperCase)
!Address = Address
!Contact = Contact
!DateRec = DateRec
!sType = sType
.Update
End With
End Sub
Sub DisplayHistory(lstConnectionHistory As ListView, SearchValue As String)
Dim lstItem As ListItem
If rs.State = adStateOpen Then rs.Close
If SearchValue <> "" Then
sql = " SELECT MyConnectHistory.DisConnectID, MyConnectHistory.ClientID,
MyConnectHistory.Lname, MyConnectHistory.Fname, MyConnectHistory.Mname,
MyConnectHistory.Address, MyConnectHistory.Contact, MyConnectHistory.DateRec,
MyConnectHistory.sType" & _
" From MyConnectHistory" & _
" Where MyConnectHistory.Lname like '" & SearchValue & "%'" & _
" ORDER BY MyConnectHistory.DisConnectID, MyConnectHistory.Lname;"
Else
sql = " SELECT MyConnectHistory.DisConnectID, MyConnectHistory.ClientID,
MyConnectHistory.Lname, MyConnectHistory.Fname, MyConnectHistory.Mname,
MyConnectHistory.Address, MyConnectHistory.Contact, MyConnectHistory.DateRec,
MyConnectHistory.sType" & _
" From MyConnectHistory" & _
" ORDER BY MyConnectHistory.DisConnectID, MyConnectHistory.Lname;"
End If
rs.Open sql, conn
lstConnectionHistory.ListItems.Clear
Do While Not rs.EOF
Set lstItem = lstConnectionHistory.ListItems.Add(, , rs(0).Value)
lstItem.SubItems(1) = rs(1).Value
lstItem.SubItems(2) = rs(2).Value
lstItem.SubItems(3) = rs(3).Value
lstItem.SubItems(4) = rs(4).Value
lstItem.SubItems(5) = rs(5).Value
lstItem.SubItems(6) = rs(6).Value
lstItem.SubItems(7) = rs(7).Value
lstItem.SubItems(8) = rs(8).Value
rs.MoveNext
Loop

End Sub

You might also like