Professional Documents
Culture Documents
VB 6 Water
VB 6 Water
VB 6 Water
AccountsFrm
Code:
Option Explicit
Dim clsData As New clsUsers
Dim OldID As String
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)
End If
Unload Me
BillingFrm.Show 1, MainFrm
End Sub
Gen. Dec
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
Gen. Dec.
Option Explicit
Dim Setup As New clsCompany
End Sub
End Function
Gen. Dec
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 Circle Menu Button Picture with Index of image on imagelist
ACPRibbon1.Icon = 2
'# 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
End Sub
End Sub
End Sub
End Sub
Private Sub ACPRibbon1_TabClick(ByVal ID As String, ByVal Caption As String)
End Sub
'# This Event occurs when click on each ShowDialogButton for each Categorie
'MsgBox "ShowDialogClick: " & ID & "--" & Caption
End Sub
End Sub
Gen. Dec
Dim clsPrint As New clsPrint
Dim clsData As New clsPayment
Dim clsBill As New clsBilling
Gen. Dec
End Sub
Gen. Dec
Dim clsData As New clsClient
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
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
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
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
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
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
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
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
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
Set rptService.DataSource = rs
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
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