Final

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

ELECTRICITY BILLING SYSTEM

PROJECT REPORT
ON
ELECTRICITY BILLING SYSTEM

SUBMITTED IN PARTIAL FULFILMENT FOR AWARD


OF THE DEGREE OF

BACHELOR IN COMPUTER APPLICATION

SESSION: 2013-2016

ARCADE BUSINESS COLLEGE


SUBMITTED BY:-
NAME: - REGESTRATION NO. :-

CHANDRA PRAKASH 1320400058


PRINCE 1320400135
JITENDRA KUMAR VERMA 1320400088
ELECTRICITY BILLING SYSTEM

ACKNOWLEDGEMENT

I take this opportunity to express my sincere thanks and deep gratitude


towards “Mr. Sukesh Kumar” for her valuable guidance and co-
operation in carrying out this Project successfully. Development of
project like “ELECTRICITY BILLING SYSTEM” in Visual Basic 6.0 is not a
too much difficult task but fairly a puzzle one.
This language teaches so much about database
programming and new Visual Basic 6.0.This project is a part of our BCA
course. I have developed this project with the help of Faculty members
of my Institute ARCADE BUSINESS COLLEGE, PATNA, BIHAR and as such
I am extremely grateful to all of them. I am obliged to my project guide
“Mr. Sukesh Kumar”.

Thanking You,
CHANDRA PRAKASH
ELECTRICITY BILLING SYSTEM

DECLARATION

I, Mr. CHANDRA PRAKASH hereby declare that this project is the record
of authentic work carried out by me during the academic year 2013 –
2016 and has not been submitted to any other University or Institute
towards the award of any degree.

ChandraPrakash
Name of the Student
ELECTRICITY BILLING SYSTEM

TABLE OF CONTENTS
TITLE PAGE NO
1 System Introduction 1

2 Problems in Existing System 2-3

3 Proposed System 4-5

4 Feasibility Study 6-7

5 Hardware And Software Environment 8

6 About Front End 9-11

7 About Back End 12-15

8 Scope of the Project 16

9 Achievement of the System 17

10 User Requirements 18-20

11 Entity Relationship Diagram 21-22

12 Data Flow Diagram 23-27

13 Module Descriptions 28-35

14 Table Specifications 36-43

15 Input Screen 44-70

16 Coding 71-275

17 Output Screen 276-284


ELECTRICITY BILLING SYSTEM

TITLE PAGE NO
18 Test Procedures and Implementation 285-297

19 Menu Tree 298-299

20 User Manual 300-307

21 Time Frame 308

22 Job Distributions 309

23 Future Scopes 310-311

24 Drawbacks 312

25 Conclusion 313

26 Bibliography 314
ELECTRICITY BILLING SYSTEM

SYSTEM INTRODUCTION

This project “Electricity Billing System” aim is to generate electricity


bill with all the charges and penalty automatically. Existing system is
manual system and the manual system is extremely laborious. It makes
the process more difficult and hard.

The aim of our project is to develop a partially computerize work


performed in the Electricity Board like generating monthly bill, record
unit of energy, store record of the customer etc.

Thus project is developed as per seeing the increasing


requirement to speed up the work; hence the proposed system is to
reduce manual work, improving work efficiency, saving time and to
provide greater flexibility.

We use Visual Basic 6.0 as front end and Oracle 10g as back end for
developing our project.

1
ELECTRICITY BILLING SYSTEM

PROBLEMS IN EXISTING SYSTEM

The old manual system was suffering from a series of drawbacks.


Since whole of the system was to be maintained with hands and
managed by pen and paper, the process of keeping, maintaining and
retrieving of information was very difficult and tedious job. The records
were never used to be in systematic order. The other problem was find
a particular information and to update these records. Actually existing
system is quite laborious as system is quite laborious as one has to
enter same information at three different places.

Major Drawbacks:
1. The existing system is assumed to be manual billing system and
hence all the operations are assumed to be done manually by pen and
paper works.Thus there are chances of error in processing.

2. The basic and major drawbacks in the existing system are the speed
of retrieval of data from files, which leads to delay.

3. There are of plenty of chances of duplicity of data and information.

4. Updating is very tedious job.

5. Uses of hardcopy are not safe always.

6. There is no central database from where one can get different


statically data at one place.

2
ELECTRICITY BILLING SYSTEM

7. Large amount of store space is needed to store the data.

8. Less accuracy.

9. Difficult to maintain database.

10. It reduces feasibility and is less reliable.

Thus above facts, figures and drawbacks clearly indicate that


there is need for computerization and thus decided to computerize the
“ELECTRICITY BILLING SYSTEM”.

3
ELECTRICITY BILLING SYSTEM

PROPOSED SYSTEM

The project is proposed to overcome the drawbacks of existing system.

This project is developed on the based on stand-alone


and centralized system architecture. Any system should have the ability
to provide error free filtered information after the processing the
require data. This system has been taken up with a view for developing
a more sophisticated system that can be easily handled by any kinds of
users.

It will automate all the process of Electricity Billing


System. We have computerized their department and database.

Key Features of Proposed System:


 Proposed system is highly user friendly.
 It maintains high accuracy and so there is no chance of error.
 Easy to use and maintain the system.
 It accesses the data very fast, so it is not time consuming.
 It is highly restricted to make duplicity.
 Complete control over the proposed system.
 It manage database in high efficient way.
 It centralized the database.
 In it a better GUI Interface is design to make attractive.

4
ELECTRICITY BILLING SYSTEM

 It provides high security means no one retrieved data before


authentication.
 It reduces the manual system work.
 User has complete control as it provides and accepts only
appropriate and valid data.
 Perfect generation of bills.
 Thus proposed system increases the overall performance.

5
ELECTRICITY BILLING SYSTEM

FEASIBILITYSTUDY
As we know each and every project needs to have a feasibility study for
the complete understandability of the project. We will consider three
types of feasibility study they are technical feasibility, operational
feasibility and economical feasibility.

Technical Feasibility:
This new system requires 6 fully trained people to run the system
perfectly. 1 Admin person to maintain database and 5persons to handle
the system interface and order making things.

As our existing system is purely manual, so we need a onetime


investment of Rs 4 Lacs for the purchase of 6 computers, 5 invoice
printers, a laser printer, AC and networking etc. It requires approx. 10
Lacks PA as a operating cost.

With the above details our system is technically feasible as after


investing 14 Lacs in a year, the company is still saving Rs 15 Lacs PA.

Operational Feasibility:
The new solution is feasible in all sense but operationally it is not.
The new system demands the expulsion of at least 15 people from the

6
ELECTRICITY BILLING SYSTEM

company. It creates an environment of joblessness and fear among the


employees. It can lead to an indefinite strike in the company also. So
the management must take corrective actions prior in advance in order
to start the further proceedings.

Econimical Feasibility:
The purpose of the economic feasibility assessment is to determine the
positive economic benefits to the organization that the proposed
system will provide.It includes quantification and identification of all
the benefits expected. This assessment typically involves a
cost/benefits analysis.

7
ELECTRICITY BILLING SYSTEM

HARDWARE ENVIRONMENT

 The application front-end will be design on Windows 7,


Itanium III processor @ 1.80 GHz speed, with 2GB RAM.

 The databases Oracle 10g work as back-end will be running


on Windows OS, Itanium III processor @ 1.80 GHz speed,
with 2GB RAM.

 Optical Mouse as a pointing device.

 PS2 keyboard is used.

 Color CRT monitor is used of 15.6’.

SOFTWARE ENVIRONMENT

 The application front end will be designed using Visual Basic


6.0.

 The database has been designed on Oracle 10g.

8
ELECTRICITY BILLING SYSTEM

ABOUTFRONTEND

MICROSOFT VISUAL BASIC 6.0

Over past few years visual basic 6.0 (front end) the relational data base
management system has been fine-tuning it is offering a large complex
application in the relational market. Visual basic 6.0 is a front end (i.e.
uses graphical user interface) visual basic 6.0 uses windows
environment. It may use any DBMS or RDBMS as a back-end through
ODBC (open database connectivity).

Visual Basic 6.0 is an enjoyable language due to its visual


environment. Building a windows program in Visual Basic requires
dragging and dropping graphic objects on to the screen from a toolbox.
Thus Visual Basic is the efficient GUI tools to develop some exciting
windows-based application.

Visual Basic 6.0 is much more than just a programming language.


The programming language forms the background of all that takes
place in a running Visual Basic program. The language is a secondary
consideration to the user interface. A windows program offers a high

9
ELECTRICITY BILLING SYSTEM

degree of user interaction using the graphical elements that forms the
objects on the window the user sees .If the user interface is not correct,
user will not like the program.

Visual Basic lets one add menus, text boxes, command buttons,
option buttons (for making exclusive choice), check boxes, list boxes,
scroll bars and file and directory boxes to black windows. One can use
Visual Basic to communicate with other applications, running under
windows. Visual Basic offers: More Internet features, better support
for data base development, more language feature to make
programming job easier.

Significance Features Of Visual Basic 6.0

 Visual Basic applications are event driven. Event driven means the
user is in Control of the application.
 Visual Basic supports the principle of object-oriented design.
 Visual Basic is a complete window application development
system.
 Data access features allow creating databases, front-end
applications andscalable server side components for most popular

10
ELECTRICITY BILLING SYSTEM

databasesformats includingMicrosoft SQL server and other


enterprise level databases.

 Active X technology allows using functionality provided by other


applications such as Microsoft Word, Microsoft Excel and other
applications and objects could be created using the Professional
Enterprise editions of Visual Basic.
 The Fast Track To Windows Development
 Friendly Environment
 Graphical User Interface
 Open Database Connectivity
 The finished applications are a true .exe files that uses a Visual
Basic virtual machine that can be freely distributed.
 Visual basic provides a GUI which and therefore screen looks
very attractive.
 Work on client / server computing model.
 Object Oriented programming approach.
 Visual basic provides several tool bars, which make working quick
and easy.
 It is front end and DBMS as a back end so it uses all the features of
RDBMS like referential integrity foreign key etc.
 It uses a micro help line, which visual basic uses to display starters
to display information through the session.

11
ELECTRICITY BILLING SYSTEM

ABOUT BACK END

ORACLE

Over the past several years, relational database management system


have become the most widely accepted way to manage data relational
system often benefits such as:

1. Easy access to all data.

2. Flexibility in storage and modeling.

3. Reduced data storage and redundancy.

4. Independence of physical storage & logical data designs.

5. A high-level data manipulation language (SQL).

6. Tables & table operations are well defined because relational


theory is founded in set theory, relational algebra & relational
calculus.

7. Program-Data Independence.

8. Minimal Data-Redundancy.
9. Data Consistency.
10. Data Sharing.

12
ELECTRICITY BILLING SYSTEM

11. Reduced Program Maintenance.

Points Related to Oracle


Database: -

A database is a set of data, organized for easy access. The


database is the actual data. It is the database that you will be accessing
when you need to retrieve data.

Data Dictionary:-

The data dictionary is a set of tables Access uses to maintain


information about the database. The data dictionary contains
information about tables, indexes, clusters, and so on.

DBA (Database Administrator): -

The DBA is the person responsible for the


operation, configuration, and performance of the database. The DBA is
charged with keeping the database operating smoothly, ensuring that
backups are done on a regular basis (and that the backups work), and
installing new software. Other responsibilities might includeplanning
for future expansion and disk space needs, creating databases and
table spaces, adding users and maintaining security, and monitoringthe

13
ELECTRICITY BILLING SYSTEM

database and retuning it asnecessary. Large installations might have


teams ofDBAs to keep thesystem running smoothly; alternatively, the
tasks might be segmented among the DBAs.

DBMS or RDBMS: -
The Database Management System is the software and
collection of tools that manages the database. Oracle software is the
DBMS. A Relational Database Management System is a DBMS that is
relational in nature. This means that the internal workings oracle data
in a relational manner. Oracle is an RDBMS.

Query:-

A query is a read-only transaction against a database. A


query is generated using the SELECT statement. Users generally
distinguish between queries and other transaction types because a
query does not change the data in the database.

Schema:-

A schema is a collection of objects associated with the


database.

14
ELECTRICITY BILLING SYSTEM

Oracle is a very effective DBMS tool which is generally used by all the
users. It is compatible with all types ofsystems & can be installed and
used as and when required.

15
ELECTRICITY BILLING SYSTEM

SCOPE OF THE PROJECT

The project is based on the automation of work perform in Electricity


Board that means we have tried to computerize various process of
Electricity Billing System.

The following are the major improvement of the new system over the
existing system.

 A fully menu driven user friendly computerized system has been


developed where the user can perform task like entering data,
deleting and updating the information with great ease.
 All the operations are carried automatically preventing a lot of
manual work.
 Data redundancy will be greatly reduced because this new system
is built using Visual Basic 6.0 as front end.
 Additional checks have also been incorporated into the system to
avoid duplications of data as far as possible.
 Maintenance of database as well as overall project will become
easy to handle.
 To store data in a centralized location to reduce redundancy and
increase consistency.

16
ELECTRICITY BILLING SYSTEM

MAIN ACHIEVEMENT OF THE SYSTEM

The project gives an overview of the “Electricity Billing


System”. After entering into the project, user is left with several
options via-

 The customer can take new connections.


 The user can view the existing lists of customers, which already
have electricity connections.
 The user can of course see bills and take billing statements.
 The user can also do several administrative works like managing
rates of electricity consumption,addition ormodification of
metered detail and customer entries.

It is a computerized system, which can be used very easily and


effectively by the administrator of the“Electricity Billing System”.

17
ELECTRICITY BILLING SYSTEM

USER REQUIREMENTS

FUNCTIONAL REQUIREMENTS

A.INPUT/OUTPUT

1. System shall have a form to accept the customer details.


2. System shall have a form to accept the meter details.
3. System shall have a form to accept consumed unit and
specified date details.
4. System shall provide search facility on customer id, customer
name, address, subdivision, on phase, tariff, status etc. to view
all records in a specified way.
5. System should provide facility for change in customer & meter
details.
6. System should maintain the status about the consumer who
paid the bill on time and who not paid it.

18
ELECTRICITY BILLING SYSTEM

B.PROCESSING

1. System should automatically generate customer id on the

basis of their sub-division.

2. System should automatically generate bill id and receipt id of


consumer.

3. System should generate all bills at a time.

C. ERROR HANDLING

1. Should report any errors on duplicate primary keys.

2. Should report any ‘Out of Range’ values on numeric fields

3. Should report any data type mismatches any field on the forms.

4. Should report on any ‘Invalid dates’

5. Should report any violation of authorization of rights

6. Should report any Invalid Login errors

19
ELECTRICITY BILLING SYSTEM

D. NON-FUNCTIONAL REQUIREMENTS

1. All user manuals should be provided in the necessary format


2. Application should support 5 simultaneous users.
3. Transaction should be completed within 1/5th of second
4. There will be backup procedure to maintain records.

20
ELECTRICITY BILLING SYSTEM

ENTITY RELATIONSHIP DIAGRAM

E-R model is explained as ERD(Entity Relationship Diagram).It is a


graphical representation of entities and their relationship within an
organization.It describes inter-related things of interest in a specific
domain of knowledge.An ER model is composed of entity types and
specifies relationships tha can exist between instances of those entity
types.It is a conceptual view of an organization according to which
database will design and processed through front end application.

In software engineering an ER model is commonly formed to represent


things that a business needs to remember in order to perform business
process.Consequently,the ER model becomes an abstract data model
that defines a data or information structure that can be implemented in

in a database, typically a relational database.

21
ELECTRICITY BILLING SYSTEM

22
ELECTRICITY BILLING SYSTEM

DATA FLOW DIAGRAM

A Data Flow Diagram (DFD) is a graphical representation of the “flow”


of data through an information system, modeling its process aspects.

A DFD is often used as a preliminary step to create an overview of the


system, which can later be elaborated.DFDs, can also be used for the
visualization of data processing (structured design).

A DFD shows what kind of information will be input to and output from
the system, where the dat will come from and go to, and where the
data will be stored.It does not show information about the timing of
process or information about whether processes will operate in
sequence or in parallel.

23
ELECTRICITY BILLING SYSTEM

ZERO LEVEL DFD

24
ELECTRICITY BILLING SYSTEM

FIRST LEVEL DFD

25
ELECTRICITY BILLING SYSTEM

SECOND LEVEL DFD

26
ELECTRICITY BILLING SYSTEM

27
ELECTRICITY BILLING SYSTEM

MODUE DESCRIPTION
1. Log in:
It provides safety and security to the system. After the
log in process, the rest of application is available to the user. Firstly user
has to register by providing user id and password. These user id and
password maintained in a database. Only authenticated person can log
in through the system.

2. Consumer management:
In this module there are many sub modules.
In it we can manage the customer information, consuming unit of
energy etc.

(a) New Consumer Entry


This system allows user to add new connection of consumer.
In it new consumer with his personal details and service (meter
and deposit) are managed. It generates a unique customer id
based on the division, subdivision, section and distribution to
which he belongs.

 It provides two types of connection-


(i) Domestic
(ii) Non-Domestic

28
ELECTRICITY BILLING SYSTEM

(b) Meter Entry:


In this sub-module we have to store
the meter related details. In it we have to store
previous consumed unit, previous reading, date and
current consumed unit, current reading, date and all
these details are added in the particular database and
fetch from database whenever be required.

(3)Edit:
In this module we have the facility to edit the
consumer and meter details.

(a)Consumer Record
In this if any changes occur with consumer details,
then we have the facility to modify it and again save it
into database with modified data and then after that
all the process is going to be executed according to
new modified records.

29
ELECTRICITY BILLING SYSTEM

(b)Meter Record:

In this sub-module if we have to modify the meter


records such as current consumed unit, date and reading
then we can modify it and saved tis modified record in
specified database.

(4)Billing:
In this module the final bill will be
generated for the entire consumer at a time and dispatched to their
mentioned address. In this bill id is generated automatically. For
generating the bill we have to use some charges to calculate and
producing of bill. These charges are as following:

(a) Energy Charge


This is the per unit
electricity charges. It depends on consumer that how
much they consume the unit of energy per month. The
consumed unit is multiplied to their respective charge.

(b) Fixed Charge


It depends on the connected
load that the utility provides you. It is calculated assum
of wattage of all appliances that you have at your
home. Fixed charge is different for single phase and

30
ELECTRICITY BILLING SYSTEM

triple phase. At least Rs55 is for single phase in


domestic and non-domestic both and Rs180 is for
single phase in non-domestic and Rs200 is for triple
phase in non-domestic and it is increased according to
increment of connected load.

(c) Energy Duty Tax


This is the
government tax for using electricity. Duty is applicable
per unit of electricity consumption and tax is applied
on the whole bill amount. Energy Duty Tax is 6% of
energy charges per month.

(d) Meter Rent


Rent for having meter at
your home. Rates are different for single phase
and three phase connection. Single phase meter
rent is 20 rupees and triple phase meter rent is
50 rupees per month.

(e) Delayed Payable Surcharge


DPS is Delayed Payable Surcharge which is
applied to the consumer if bill is not paid at
the given time.1.5% of total bill amount is
surcharged every month.

31
ELECTRICITY BILLING SYSTEM

(f) Rebate:
Rebate is also given to the consumer if
he pays the bill under the first given
date.10ps/unit is given to the entire
consumer; it means total consumed
unit of a single month is multiplied to
10ps every month.
(g) Dues:
If previous month bill is not paid then
dues is combined with the next month
bill.

(5).Payment
In this module the payment of bill is managed.

(a) Receipt:
The final receipt is generated at the
time when the consumer pays their monthly bill.

32
ELECTRICITY BILLING SYSTEM

(6)View
In this module we can search and view customer
records, meter details, bill details and receipt details
in a specified way.

(a)Consumr Details:
In this sub-module we can view all types of
customer and all of its records on different fields such
as on customer id, name, sub-division, meter no, tariff
etc. and also take print out of this.

(b)Bill Details:
In this sub-module we can view all previous bills
of all months of all consumers and take print out of this.

(c)Receipt Details:
In this sub-module we can view all the previous
receipt of all months of all consumers which is made at the
time of payment of bill. We can also take print out of this.

33
ELECTRICITY BILLING SYSTEM

(d)Status:
In this sub-module we can view all the consumer
records on the basis of their status, it means that which
consumer paid the bill and which is not in the specified given
month. We can take print out of it.

(e)Meter Details:
In this sub-module we can view the entire previous
consumed unit used by the consumer.We can view
particular consumer consumed unit and take print out of it.

(7)Administrator:
Handling databases is in the power of the admin person only. It
performs general and special purpose both type of work.

Update Fixed Charge:

In this sub module the administrator can change


the fixed charge if there is any change is going to be happened.

34
ELECTRICITY BILLING SYSTEM

Create user:
In this sub module the new user account is created by
the administrator and the user id and password is given to the
user to use it. The add command button is used to save all the
data record in the database. The reset command button is used to
clear all the data after processing and exit command button is
used to come back from that form

Modify User Details:


In this sub module the user details is modified by the
administrator. User record, user id and password is updated and
again save to the respected database. The update command
button is used to modify the user record. The reset command
button is used to clear all the data after processing and exit
command button is used to come back from that form.

35
ELECTRICITY BILLING SYSTEM

TABLE
SPECIFICATION

36
ELECTRICITY BILLING SYSTEM

LOGIN TABLE

Column Name Data Type Size Description


User_Name Varchar2 30 User name of Admin/Employee

User_ Id Varchar2 10 User Id of Admin/Employee

Password Varchar2 10 Password of Admin/Employee

User_Type Char 15 Type of User who login

EMPLOYEE DETAILS TABLE


Column Name Data Type Size Constraints Description
E_Id Varchar2 10 Primary Key Employee Identification
No.
E_Nm Varchar2 30 Not Null Employee Name

E_PhNo Number 10 Null Employee Phone Number

E_Email Varchar2 40 Null Employee Email Address

E_Add Varchar2 40 Not Null Employee Address

E_Dist Varchar2 15 Not Null Employee District

E_Pin Number 6 Not Null Employee Pin Code

E_Doj Date Auto Not Null Employee Date Of Joining

37
ELECTRICITY BILLING SYSTEM

CONSUMER DETAILS TABLE

Column Name Data Type Size Constraints Description


Cust_Id Varchar2 10 Primary Key Consumer Identification
No.
Cust_Name Varchar2 30 Not Null Consumer Name

Phone_No Number 12 Null Consumer Phone Number

Email_Id Varchar2 40 Null Consumer Email Address

Cust_Add Varchar2 40 Not Null Consumer Address

District Varchar2 15 Not Null Consumer District

P_Code Number 6 Not Null Consumer Pin Code

Division Varchar2 25 Not Null Consumer Division

Sub_Division Varchar2 25 Not Null Consumer Sub Division

METER DETAILS TABLE


Column Name Data Type Size Constraints Description
Cust_Id Varchar2 10 Foreign Key Consumer Identification
No.
M_No Number 8 Primary Key Consumer Meter No.

Phase Number 1 Not Null Phase of Consumer

Conn_Date Date Auto Not Null Connection Date

Supp_Section Varchar2 15 Not Null Supply Section of


Consumer
Tarrif Varchar2 15 Not Null Tariff Of Consumer

C_Load Number 2 Not Null Connection Load of


Consumer

38
ELECTRICITY BILLING SYSTEM

MEASURE DETAILS TABLE

Column Name Data Type Size Constraints Description


Cust_Id Varchar2 10 Foreign Key Consumer Identification
No.
M_No Number 8 Foreign Key Consumer Meter No.

E_Id Varchar2 10 Foreign Key Employee


Identification No.
P_Date Date Auto Not Null Previous Reading Date

P_Reading Number 6 Not Null Previous Reading

P_Unit Number 6 Not Null Previous Consumed Unit

C_Date Date Auto Not Null Current Reading Date

C_Reading Number 6 Not Null Current Reading

C_Unit Number 6 Not Null Current Unit Consumed

DOMESTIC CHARGE DETAILS TABLE


Column Name Data Type Size Constraints Description
D_upto100 Decimal 6,2 Not Null Domestic Unit Consumed
up to 100
D_upto200 Decimal 6,2 Not Null Domestic Unit Consumed
up to 200
D_upto300 Decimal 6,2 Not Null Domestic Unit
Consumed up to 300
D_above300 Decimal 6,2 Not Null Domestic Unit Consumed
above 300
D_DPS Decimal 6,2 Not Null Domestic Delayed
Payable Surcharge
D_ED Decimal 6,2 Not Null Domestic Electricity Duty

D_FC Decimal 6,2 Not Null Domestic Fixed


Charge(Phase 1)

39
ELECTRICITY BILLING SYSTEM

D_AKW Decimal 6,2 Not Null Domestic Additional


Kilowatt(Phase 1)
D_Mrent Decimal 6,2 Not Null Domestic Meter Rent
(Phase 1)
D_FC3 Decimal 6,2 Not Null Domestic Fixed Charge
(Phase 3)
D_AKW Decimal 6,2 Not Null Domestic Additional
kilowatt(Phase 3)
D_Mrent3 Decimal 6,2 Not Null Domestic Meter
Rent(Phase 3)
D_Rebate Decimal 6,2 Not Null Domestic Rebate Allowed

NON-DOMESTIC CHARGE DETAILS TABLE

Column Name Data Type Size Constraints Description


N_upto100 Decimal 6,2 Not Null Non-Domestic Unit
Consumed up to 100
N_upto200 Decimal 6,2 Not Null Non-Domestic Unit
Consumed up to 200
N_above200 Decimal 6,2 Not Null Non-Domestic Unit
Consumed above 200
N_DPS Decimal 6,2 Not Null Non-Domestic Delayed
Payable Surcharge
N_ED Decimal 6,2 Not Null Non-Domestic Electricity
Duty
N_FC Decimal 6,2 Not Null Non-Domestic Fixed
Charge(Phase 1)
N_AKW Decimal 6,2 Not Null Non-Domestic Additional
Kilowatt(Phase 1)
N_Mrent Decimal 6,2 Not Null Non-Domestic Meter
Rent
(Phase 1)
N_FC3 Decimal 6,2 Not Null Non-Domestic Fixed
Charge (Phase 3)
N_AKW Decimal 6,2 Not Null Non-Domestic Additional
kilowatt(Phase 3)
N_Mrent3 Decimal 6,2 Not Null Non-Domestic Meter
Rent(Phase 3)
N_Rebate Decimal 6,2 Not Null Non-Domestic Rebate
Allowed

40
ELECTRICITY BILLING SYSTEM

CALCULATE DETAILS TABLE

Column Name Data Type Size Constraints Description


E_Id Varchar2 10 Foreign Key Employee Identification
No
Cust_Id Varchar2 10 Foreign Key Consumer Identification
No
M_No Number 8 Foreign Key Consumer Meter No.

Energy_Charge Decimal 6,2 Not Null Energy Charge of


Consumed Unit
DPS_Cmonth Decimal 6,2 Not Null Delayed Payable
Surcharge
Fixed_Charge Decimal 6,2 Not Null Fixed Charge(Different
Rate for Different Phase)
Electrictiy_Duty Decimal 6,2 Not Null Electricity Duty Charge
(6% of Energy Charge)
Meter_Rent Decimal 6,2 Not Null Meter Rent(Different
Rate for Different Phase)
Total_Assesment Decimal 10,2 Not Null Total Sum Of all Charges

Rebate Decimal 6,2 Not Null Rebate Allowed


(10ps/unit)
Gross_Total Decimal 10,2 Not Null Final Amount with all
charges
Dues Decimal 10,2 Not Null Dues (if not paid last
month)
Month Varchar2 8 Not Null Month Of Bill Generation

C_Date Date Auto Not Null Current Reading Date

C_Reading Number 6 Not Null Current Reading

C_Unit Number 6 Not Null Current Consumed Unit

41
ELECTRICITY BILLING SYSTEM

BILL DETAILS TABLE

Column Name Data Type Size Constraints Description


E_Id Varchar2 10 Foreign Key Employee Identification
No
Cust_Id Varchar2 10 Foreign Key Consumer Identification
No
M_No Number 8 Foreign Key Consumer Meter No.

B_Id Number 20 Primary Key Bill Identification No. for


each Bill
B_Date Date Auto Not Null Date of Billing

Bill_Month Varchar2 8 Not Null Bill for respected Month

Gross_Total Decimal 10,2 Not Null Final Amount with all


charges
Date1 Date Auto Not Null First Payable Date

Date2 Date Auto Not Null Second Payable Date

Charge1 Decimal 10,2 Not Null Total Assessment with


no fine & with rebate
Charge2 Decimal 10,2 Not Null Total Assessment with no
fine & with no rebate
Charge3 Decimal 10,2 Not Null Total Assessment with
fine & no rebate
Status Varchar2 10 Not Null Status show that bill is
paid or not

PAYMENT DETAILS TABLE

Column Name Data Type Size Constraints Description


E_Id Varchar2 10 Foreign Key Employee Identification
No
Cust_Id Varchar2 10 Foreign Key Consumer Identification
No
M_No Number 8 Foreign Key Consumer Meter No.

B_Id Number 20 Foreign Key Bill Identification No. for


each bill

42
ELECTRICITY BILLING SYSTEM

R_No Number 20 Primary Key Receipt Number for each


Receipt
R_Date Date Auto Not Null Date of Payment Of Bill

Amount Decimal 10,2 Not Null Amount Paid by


Consumer
B_Month Varchar2 8 Not Null Bill for respected Month

Tot_Bill Decimal 10,2 Not Null Total Payable Amount

Dues Decimal 10,2 Not Null Dues(if total bill is not


paid)

43
ELECTRICITY BILLING SYSTEM

INPUT
SCREEN

44
ELECTRICITY BILLING SYSTEM

SPLASH SCREEN

45
ELECTRICITY BILLING SYSTEM

ADMINISTRATOR INFORMATION

46
ELECTRICITY BILLING SYSTEM

CREATE ADMINISTRATOR LOGIN ID

47
ELECTRICITY BILLING SYSTEM

LOGIN

48
ELECTRICITY BILLING SYSTEM

MULTIPLE DOCUMNT INTERFACE

49
ELECTRICITY BILLING SYSTEM

NEW CONSUMER ENTRY

50
ELECTRICITY BILLING SYSTEM

METER READING FORM

51
ELECTRICITY BILLING SYSTEM

BILL GENERATION

52
ELECTRICITY BILLING SYSTEM

ENERGY BILL IN GRID VIEW

53
ELECTRICITY BILLING SYSTEM

PAYMENT RECEIPT

54
ELECTRICITY BILLING SYSTEM

CREATE USER

55
ELECTRICITY BILLING SYSTEM

UPDATE USER INFORMATION

56
ELECTRICITY BILLING SYSTEM

CHANGE PASSWORD

57
ELECTRICITY BILLING SYSTEM

UPDATE CONSUMER RECORD

58
ELECTRICITY BILLING SYSTEM

UPDATE METER READING

59
ELECTRICITY BILLING SYSTEM

UPDATED BILL GENERATION

60
ELECTRICITY BILLING SYSTEM

UPDATE DOMESTIC CHARGES

61
ELECTRICITY BILLING SYSTEM

UPDATE NON-DOMESTIC CHARGES

62
ELECTRICITY BILLING SYSTEM

SEARCHING CONSUMER INFORMATION

63
ELECTRICITY BILLING SYSTEM

SEARCHING CONSUMED UNIT

64
ELECTRICITY BILLING SYSTEM

SEARCHING PREVIOUS BILL

65
ELECTRICITY BILLING SYSTEM

SEARCHING PREVIOUS RECEIPT

66
ELECTRICITY BILLING SYSTEM

SEARCHING PAID CONSUMER RECORD

67
ELECTRICITY BILLING SYSTEM

SEARCHING UNPAID CONSUMER RECORD

68
ELECTRICITY BILLING SYSTEM

VIEW DOMESTIC CHARGES

69
ELECTRICITY BILLING SYSTEM

VIEW NON-DOMESTIC CHARGES

70
ELECTRICITY BILLING SYSTEM

CODING

71
ELECTRICITY BILLING SYSTEM

SPLASH SCREEN

Dim n As Integer

Dim p As String

Dim c As ADODB.Connection

Dim r As ADODB.Recordset

Dim sql As String

Private Sub Timer1_Timer()

Timer1.Interval = 100

If n = 4 Then

n=1

Else

n=n+1

End If

Select Case n

Case 1:

Shape1.Visible = True

Shape2.Visible = False

Shape3.Visible = False

Case 2:

Shape1.Visible = True

Shape2.Visible = True

Shape3.Visible = False

Case 3:

72
ELECTRICITY BILLING SYSTEM

Shape1.Visible = True

Shape2.Visible = True

Shape3.Visible = True

Case 4:

Shape1.Visible = False

Shape2.Visible = False

Shape3.Visible = False

End Select

If ProgressBar1.value = 100 Then

Unload Me

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select count( user_id) from login"

Set r = c.Execute(sql)

If r.Fields(0) = 0 Then

frm_admininfo.Show

Else

frm_login.Show

End If

Else

ProgressBar1.value = ProgressBar1.value + 5

End If

End Sub

73
ELECTRICITY BILLING SYSTEM

ADMINISTRATOR INFORMATION

Dim str As String

Dim d As Date

Dim id As Integer

Private Sub cmd_cancel_Click()

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Administrator


Information") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub cmd_reset_Click()

txt_name.Text = ""

txt_phno.Text = ""

txt_email.Text = ""

txt_add.Text = ""

txt_dist.Text = ""

txt_pin.Text = ""

dtp_doj = Now

74
ELECTRICITY BILLING SYSTEM

End Sub

'Private Sub Form_Unload(Cancel As Integer)

'X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Administrator


Information") = vbYes

'If X = True Then

'Unload Me

'Else

'Cancel = 1

'End If

'End Sub

Private Sub txt_add_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_dist.SetFocus

End If

End Sub

Private Sub txt_add_LostFocus()

txt_add = UCase(Trim(txt_add))

End Sub

Private Sub txt_dist_LostFocus()

txt_dist = UCase(Trim(txt_dist))

End Sub

75
ELECTRICITY BILLING SYSTEM

Private Sub txt_email_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

dtp_doj.SetFocus

End If

End Sub

Private Sub txt_dist_KeyPress(KeyAscii As Integer)

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii <>
8 And KeyAscii <> 13 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_dist.SetFocus

ElseIf KeyAscii = 13 Then

txt_pin.SetFocus

End If

End Sub

Private Sub txt_email_LostFocus()

txt_email.Text = Trim(txt_email.Text)

End Sub

Private Sub txt_name_Change()

If Len(txt_name) >= 30 Then

X = MsgBox("LENGTH SHOULD NOT EXCEED THAN 30", vbCritical, "Error")

76
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub txt_name_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_name = UCase(Trim(txt_name.Text))

txt_add.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii
<> 8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_name.SetFocus

End If

End Sub

Private Sub txt_name_LostFocus()

txt_name.Text = Trim(txt_name.Text)

End Sub

Private Sub txt_phno_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_phno.SetFocus

End If

77
ELECTRICITY BILLING SYSTEM

If KeyAscii = 13 Then

txt_email.SetFocus

End If

End Sub

Private Sub txt_pin_KeyPress(KeyAscii As Integer)

If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_pin.SetFocus

End If

If KeyAscii = 13 Then

txt_phno.SetFocus

End If

End Sub

Private Sub cmd_add_click()

If txt_name.Text = "" And txt_phno.Text = "" And txt_email.Text = "" And txt_add.Text = ""
And txt_dist.Text = "" And txt_pin.Text = "" Then

X = MsgBox("PLEASE ENTER RECORD", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_name = "" Then

X = MsgBox("PLEASE ENTER NAME", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_add = "" Then

78
ELECTRICITY BILLING SYSTEM

X = MsgBox("PLEASE ENTER ADDRESS", vbCritical, "Error")

txt_add.SetFocus

ElseIf txt_dist = "" Then

X = MsgBox("PLEAE ENTER DISTRICT", vbCritical, "Error")

txt_dist.SetFocus

ElseIf txt_pin = "" Then

X = MsgBox("PLEASE ENTER PIN CODE", vbCritical, "Error")

txt_pin.SetFocus

Else

conn

str = Mid(txt_name, 1, 3) & 1

sql = "insert into employee values('" + str + "','" + txt_name.Text + "'," + txt_phno.Text +
",'" + txt_email.Text + "','" + txt_add.Text + "','" + txt_dist.Text + "'," + txt_pin.Text + ",'" +
Format(dtp_doj.value, "DD MMM YY") + "')"

Set r = c.Execute(sql)

X = MsgBox("RECORD SAVE", vbInformation, "Admin Info")

frm_admin.Show

frm_admin.txt_nm.Text = txt_name.Text

frm_admin.txt_uid.Text = str

Unload frm_admininfo

End If

End Sub

79
ELECTRICITY BILLING SYSTEM

CREATE ADMINISTRATOR

Dim c As ADODB.Connection

Dim r As ADODB.Recordset

Dim sql As String

Dim str As String

Private Sub cmd_ok_click()

If txt_nm.Text = "" And txt_uid.Text = "" And txt_pass.Text = "" Then

X = MsgBox("PLEASE ENTER ADMIN DETAIL", vbCritical, "Error")

txt_cpass.Text = ""

txt_nm.SetFocus

ElseIf txt_nm.Text = "" Then

X = MsgBox("PLEASE ENTER ADMIN NAME", vbCritical, "Error")

txt_pass.Text = ""

txt_cpass.Text = ""

txt_nm.SetFocus

Exit Sub

ElseIf txt_uid.Text = "" Then

X = MsgBox("PLEASE ENTER USER ID", vbCritical, "Error")

txt_pass.Text = ""

txt_cpass.Text = ""

txt_uid.SetFocus

Exit Sub

80
ELECTRICITY BILLING SYSTEM

ElseIf txt_pass.Text = "" Then

X = MsgBox("PLEASE RE-ENTER THE PASSWORD", vbCritical, "Error")

txt_cpass.Text = ""

txt_pass.SetFocus

Exit Sub

ElseIf txt_cpass.Text = "" Then

X = MsgBox("PLEASE RE-ENTER THE PASSWORD", vbCritical, "Error")

txt_pass.Text = ""

txt_cpass.Text = ""

txt_pass.SetFocus

Exit Sub

ElseIf txt_pass <> txt_cpass Then

X = MsgBox("PLEASE RE-ENTER THE PASSWORD", vbCritical, "Error")

txt_pass.Text = ""

txt_cpass.Text = ""

txt_pass.SetFocus

Exit Sub

Else

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "insert into login values('" + txt_nm.Text + "','" + txt_uid.Text + "','" + txt_pass.Text
+ "','ADMINISTRATOR')"

Set r = c.Execute(sql)

81
ELECTRICITY BILLING SYSTEM

X = MsgBox("ADMINISTRATOR SUCCESSFULLY CREATED", vbInformation + vbOKOnly,


"Administrator") = vbOK

Unload Me

Load frm_login

frm_login.Show

Exit Sub

End If

End Sub

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Create Administrator") =


vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_cpass_Change()

If Len(txt_pass) > 8 Then

X = MsgBox("PASSWORD LENGTH NOT EXCEDED THAN 8", vbCritical, "Error")

End If

82
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_pass_Change()

If Len(txt_pass) > 8 Then

X = MsgBox("PASSWORD LENGTH NOT EXCEDED THAN 8", vbCritical, "Error")

End If

End Sub

Private Sub txt_pass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cpass.SetFocus

End If

End Sub

Private Sub txt_uid_LostFocus()

txt_uid.Text = UCase(Trim(txt_uid.Text))

End Sub

Private Sub txt_cpass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Call cmd_ok_click

End If

End Sub

83
ELECTRICITY BILLING SYSTEM

Private Sub txt_uid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_pass.SetFocus

End If

End Sub

84
ELECTRICITY BILLING SYSTEM

LOGIN

Dim p As String

Dim c As ADODB.Connection

Dim r As ADODB.Recordset

Dim sql As String

Private Sub chk_showpass_Click()

If chk_showpass.value = 1 Then

txt_pass.PasswordChar = value

Else

txt_pass.PasswordChar = "*"

End If

cmd_ok.SetFocus

End Sub

Private Sub chk_showpass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If chk_showpass.value = 1 Then

chk_showpass.value = 0

Else

chk_showpass.value = 1

End If

Call chk_showpass_Click

85
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub cmd_cancel_Click()

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Electricity Billing


System") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub combo_uid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_pass.SetFocus

End If

End Sub

Private Sub combo_ltype_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If combo_ltype.Text = "" Then

Exit Sub

Else

combo_uid.SetFocus

86
ELECTRICITY BILLING SYSTEM

End If

End If

End Sub

Private Sub cmd_ok_click()

If combo_ltype.Text = "" And combo_uid.Text = "" And txt_pass.Text = "" Then

X = MsgBox("PLEASE ENTER THE DATA", vbCritical, "Error")

combo_ltype.SetFocus

ElseIf combo_uid.Text = "" Then

X = MsgBox("PLEASE SELECT A USER ID", vbCritical, "Error")

txt_pass.Text = ""

combo_uid.SetFocus

ElseIf txt_pass.Text = "" Then

X = MsgBox("PLEASE ENTER A PASSWORD", vbCritical, "Error")

txt_pass.SetFocus

Exit Sub

ElseIf combo_ltype.Text = "ADMINISTRATOR" And p = txt_pass.Text Then

MDIForm1.Administator.Visible = True

emp_id = combo_uid.Text

pass = txt_pass.Text

Unload Me

MDIForm1.Show

Exit Sub

ElseIf combo_ltype.Text = "EMPLOYEE" And p = txt_pass.Text Then

MDIForm1.Administator.Visible = False

87
ELECTRICITY BILLING SYSTEM

emp_id = combo_uid.Text

pass = txt_pass.Text

Unload Me

MDIForm1.Show

Exit Sub

Else

X = MsgBox("WRONG PASSWORD", vbCritical, "Error")

txt_pass.Text = ""

chk_showpass.value = 0

txt_pass.SetFocus

End If

End Sub

Private Sub combo_ltype_Click()

combo_uid.Clear

combo_uid.Enabled = True

txt_pass.Enabled = True

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select user_id from login where user_type='" + combo_ltype.Text + "'"

Set r = c.Execute(sql)

Do While Not r.EOF

combo_uid.AddItem Trim(r.Fields(0))

r.MoveNext

88
ELECTRICITY BILLING SYSTEM

Loop

End Sub

Private Sub Form_Load()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select distinct user_type from login"

Set r = c.Execute(sql)

Do While Not r.EOF

combo_ltype.AddItem Trim(r.Fields(0))

r.MoveNext

Loop

End Sub

Private Sub txt_pass_Change()

If Len(txt_pass) > 8 Then

X = MsgBox("PASSWORD LENGTH NOT EXCEDED THAN 8", vbCritical, "Error")

End If

End Sub

Private Sub txt_pass_gotfocus()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

89
ELECTRICITY BILLING SYSTEM

sql = "select password from login where user_id='" + combo_uid.Text + "'"

On Error GoTo X

Set r = c.Execute(sql)

p = r.Fields(0)

Exit Sub

X:

X = MsgBox("PLEASE SELECT USER ID", vbCritical, "Error")

combo_uid.SetFocus

End Sub

Private Sub txt_pass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Call cmd_ok_click

End If

End Sub

90
ELECTRICITY BILLING SYSTEM

MDI FORM

Private Sub New_User_Click()

frm_user.Show

End Sub

Private Sub Bill_Detail_Click()

frm_pbill.Show

End Sub

Private Sub Change_Password_Click()

frm_password.Show

End Sub

Private Sub Create_User_Click()

frm_user.Show

End Sub

Private Sub Current_bill_Click()

frm_bill.Show

End Sub

Private Sub Customer_Detail_Click()

frm_custview.Show

91
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub Customer_Record_Click()

frm_c_rec.Show

End Sub

Private Sub Domesic_Charge_Click()

frm_dcharge.Show

End Sub

Private Sub Domestic_Click()

frm_domestic.Show

End Sub

Private Sub Energy_Bill_Click()

frm_allbill.Show

End Sub

Private Sub Exit_Click()

Unload Me

End Sub

Private Sub ff_Click()

frm_allbill.Show

End Sub

92
ELECTRICITY BILLING SYSTEM

Private Sub Logout_Click()

X = MsgBox("ARE YOU SURE TO LOGOUT", vbQuestion + vbYesNo, "Electricity Billing


System") = vbYes

If X = True Then

MDIForm1.Hide

frm_login.Show

Else

Exit Sub

End If

End Sub

Private Sub M_reading_Click()

frm_updmeter.Show

End Sub

Private Sub MDIForm_Load()

Picture2.Left = -8650

End Sub

Private Sub MDIForm_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Electricity Billing


System") = vbYes

93
ELECTRICITY BILLING SYSTEM

If X = True Then

End

Else

Cancel = 1

End If

End Sub

Private Sub Meter_Reading_Click()

frm_meter.Show

End Sub

Private Sub New_Customer_Click()

frm_new.Show

End Sub

Private Sub Non_Domestic_Click()

frm_nondomestic.Show

End Sub

Private Sub NonDomestic_Charge_Click()

frm_ndcharge.Show

End Sub

Private Sub reading_Click()

frm_unit.Show

94
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub Receipt_Click()

frm_pay.Show

End Sub

Private Sub Receipt_Detail_Click()

frm_reciptview.Show

End Sub

Private Sub Status_Click()

Frm_status.Show

End Sub

Private Sub Timer1_Timer()

If Picture2.Left < 20500 Then

Picture2.Left = Picture2.Left + 30

Else

Picture2.Left = -8650

End If

End Sub

Private Sub Update_User_Click()

frm_userupdate.Show

End Sub

95
ELECTRICITY BILLING SYSTEM

NEW CONSUMER ENTRY

Public id As Integer

Public str As String

Private Sub cmd_add_click()

If txt_name = "" And txt_phno = "" And txt_add = "" And txt_dist = "" And txt_pin = "" Then

X = MsgBox("PLEASE ENTER CONSUMER RECORD", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_name = "" Then

X = MsgBox("PLEASE ENTER NAME", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_add = "" Then

X = MsgBox("PLEASE ENTER ADDRESS", vbCritical, "Error")

txt_add.SetFocus

ElseIf txt_dist = "" Then

X = MsgBox("PLEASE ENTER DISTRICT", vbCritical, "Error")

txt_dist.SetFocus

ElseIf txt_pin = "" Then

X = MsgBox("PLEASE ENTER PINCODE", vbCritical, "Error")

txt_pin.SetFocus

ElseIf combo_sdiv = "" Then

X = MsgBox("PLEASE SELECT SUB-DIVISON", vbCritical, "Error")

combo_sdiv.SetFocus

96
ELECTRICITY BILLING SYSTEM

ElseIf txt_mno = "" And Combo_phase = "" And txt_cdate = "" And Combo_ssec = "" And
Combo_ssec = "" And Combo_cload = "" Then

X = MsgBox("PLEASE ENTER METER DETAIL", vbCritical, "Error")

txt_mno.SetFocus

ElseIf txt_mno = "" Then

X = MsgBox("PLEASE ENTER METER NUMBER", vbCritical, "Error")

txt_mno.SetFocus

ElseIf Combo_phase = "" Then

X = MsgBox("PLEASE ENTER PHASE", vbCritical, "Error")

txt_phase.SetFocus

ElseIf Combo_ssec = "" Then

X = MsgBox("PLEASE ENTER SUPPLY SECTION", vbCritical, "Error")

Combo_ssec.SetFocus

ElseIf Combo_tarrif = "" Then

X = MsgBox("PLEASE ENTER TARRIF", vbCritical, "Error")

Combo_tarrif.SetFocus

ElseIf Combo_cload = "" Then

X = MsgBox("PLEASE ENTER CONNECTON LOAD", vbCritical, "Error")

Combo_cload.SetFocus

Else

conn

Set r = New ADODB.Recordset

If txt_phno.Text = "" And txt_eid.Text = "" Then

sql = " insert into customer values('" + txt_cid + "','" + txt_name + "',Null,Null,'" + txt_add
+ "','" + txt_dist + "'," + txt_pin + ",'" + txt_div + "','" + combo_sdiv + "')"

97
ELECTRICITY BILLING SYSTEM

ElseIf txt_phno = "" Then

sql = " insert into customer values('" + txt_cid + "','" + txt_name + "',Null,'" + txt_eid.Text
+ "','" + txt_add + "','" + txt_dist + "'," + txt_pin + ",'" + txt_div + "','" + combo_sdiv + "')"

ElseIf txt_eid = "" Then

sql = " insert into customer values('" + txt_cid + "','" + txt_name + "'," + txt_phno.Text +
",Null,'" + txt_add + "','" + txt_dist + "'," + txt_pin + ",'" + txt_div + "','" + combo_sdiv + "')"

Else

sql = " insert into customer values('" + txt_cid + "','" + txt_name + "'," + txt_phno.Text +
",'" + txt_eid.Text + "','" + txt_add + "','" + txt_dist + "'," + txt_pin + ",'" + txt_div + "','" +
combo_sdiv + "')"

End If

sql1 = "insert into meter values ('" + txt_cid + "'," + txt_mno + "," + Combo_phase + ",'" +
Format(dtp_cdate, "dd mmm yy") + "','" + Combo_ssec + "','" + Combo_tarrif + "'," +
Combo_cload + ")"

c.Execute (sql)

c.Execute (sql1)

X = MsgBox("RECORD SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "Consumer")


= vbOK

Call cmd_reset_Click

End If

Exit Sub

End Sub

Private Sub cmd_cancel_Click()

Unload Me

End Sub

98
ELECTRICITY BILLING SYSTEM

Private Sub cmd_reset_Click()

txt_cid.Text = ""

txt_name.Text = ""

txt_phno.Text = ""

txt_eid.Text = ""

txt_add.Text = ""

txt_dist.Text = ""

txt_pin.Text = ""

combo_sdiv.ListIndex = -1

txt_mno.Text = ""

Combo_phase.ListIndex = -1

dtp_cdate.value = Now

Combo_ssec.ListIndex = -1

Combo_tarrif.ListIndex = -1

Adodc1.Refresh

Call Form_Load

txt_name.SetFocus

End Sub

Private Sub Combo_cload_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

cmd_add.SetFocus

End If

End Sub

99
ELECTRICITY BILLING SYSTEM

Private Sub Combo_phase_Click()

Combo_cload.Clear

If Combo_phase = "" Then Exit Sub

If Combo_phase = 1 Then

For i = 1 To 7

Combo_cload.AddItem i

Next

ElseIf Combo_phase = 3 Then

For i = 5 To 10

Combo_cload.AddItem i

Next

End If

End Sub

Private Sub Combo_sdiv_Click()

If combo_sdiv.Text = "DARBHANGA" Then

str = "DBG"

ElseIf combo_sdiv.Text = "LAHERIASARAI" Then

str = "LRS"

End If

conn

Set r = New ADODB.Recordset

sql = "select max(to_number(substr(cust_id,4,length(cust_id)))) from customer where


division='" + txt_div.Text + "' and sub_division='" + combo_sdiv.Text + "'"

Set r = c.Execute(sql)

100
ELECTRICITY BILLING SYSTEM

If IsNull(r.Fields(0)) Then

txt_cid.Visible = True

txt_cid = str & 1

Else

id = r.Fields(0) + 1

txt_cid.Visible = True

txt_cid.Text = str & id

End If

End Sub

Private Sub combo_sdiv_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If txt_name = "" And txt_phno = "" And txt_add = "" And txt_dist = "" And txt_pin = "" Then

X = MsgBox("PLEASE ENTER CONSUMER RECORD", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_name = "" Then

X = MsgBox("PLEASE ENTER NAME", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_add = "" Then

X = MsgBox("PLEASE ENTER ADDRESS", vbCritical, "Error")

txt_add.SetFocus

ElseIf txt_dist = "" Then

X = MsgBox("PLEASE ENTER DISTRICT", vbCritical, "Error")

txt_dist.SetFocus

ElseIf txt_pin = "" Then

101
ELECTRICITY BILLING SYSTEM

X = MsgBox("PLEASE ENTER PIN CODE", vbCritical, "Error")

txt_pin.SetFocus

Else

Frame2.Enabled = True

txt_mno.SetFocus

End If

End If

End Sub

Private Sub Combo_sdiv_LostFocus()

Call combo_sdiv_KeyPress(13)

End Sub

Private Sub combo_ssec_GotFocus()

Combo_ssec.Clear

If combo_sdiv = "DARBHANGA" Then

Combo_ssec.AddItem "DONAR"

Combo_ssec.AddItem "BELA"

ElseIf combo_sdiv = "LAHERIASARAI" Then

Combo_ssec.AddItem "LAXMINAGAR"

Combo_ssec.AddItem "BENTA"

Combo_ssec.AddItem "PANDASARAI"

End If

End Sub

102
ELECTRICITY BILLING SYSTEM

Private Sub Combo_ssec_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Combo_tarrif.SetFocus

End If

End Sub

Private Sub combo_tarrif_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Combo_cload.SetFocus

End If

End Sub

Private Sub dtp_cdate_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Combo_ssec.SetFocus

End If

End Sub

Private Sub Form_Load()

txt_cid.Visible = False

txt_cid.Text = ""

dtp_cdate.value = Now()

txt_div.Text = "DARBHANGA"

Frame2.Enabled = False

103
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "New Consumer") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_add_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_dist.SetFocus

End If

End Sub

Private Sub txt_add_LostFocus()

txt_add = Trim(UCase(txt_add))

End Sub

Private Sub txt_dist_KeyPress(KeyAscii As Integer)

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii <>
8 And KeyAscii <> 32 And KeyAscii <> 13 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

104
ELECTRICITY BILLING SYSTEM

KeyAscii = 0

txt_dist.SetFocus

End If

If KeyAscii = 13 Then

txt_pin.SetFocus

End If

End Sub

Private Sub txt_dist_LostFocus()

txt_dist = Trim(UCase(txt_dist))

End Sub

Private Sub txt_eid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_add.SetFocus

ElseIf KeyAscii = 32 Then

KeyAscii = 0

End If

End Sub

Private Sub txt_eid_LostFocus()

txt_eid.Text = Trim(txt_eid.Text)

conn

sql = "select email_id from customer"

Set r = c.Execute(sql)

Do While Not r.EOF

105
ELECTRICITY BILLING SYSTEM

If r.Fields(0) = txt_eid.Text Then

X = MsgBox("EMAIL ALREADY EXIST", vbInformation + vbOKOnly, "Consumer") = vbOK

txt_eid.Text = ""

txt_eid.SetFocus

Exit Sub

Else

r.MoveNext

End If

Loop

End Sub

Private Sub txt_mno_LostFocus()

If Len(txt_mno) <> 8 And Len(txt_mno) <> 0 Then

X = MsgBox("PLEASE ENTER VALID METER NUMBER", vbCritical, "Error")

txt_mno.Text = ""

txt_mno.SetFocus

End If

conn

sql = "select m_no from meter"

Set r = c.Execute(sql)

Do While Not r.EOF

If r.Fields(0) = txt_mno.Text Then

X = MsgBox("METER NUMBER ALREADY EXIST", vbInformation + vbOKOnly,


"COnsumer") = vbOK

txt_mno.Text = ""

106
ELECTRICITY BILLING SYSTEM

txt_mno.SetFocus

Exit Sub

Else

r.MoveNext

End If

Loop

End Sub

Private Sub txt_name_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_phno.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii
<> 8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_name.SetFocus

End If

End Sub

Private Sub txt_mno_KeyPress(KeyAscii As Integer)

If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii
<> 13 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_mno.SetFocus

107
ELECTRICITY BILLING SYSTEM

ElseIf KeyAscii = 13 Then

Combo_phase.SetFocus

End If

End Sub

Private Sub txt_name_LostFocus()

txt_name.Text = UCase(Trim(txt_name.Text))

End Sub

Private Sub combo_phase_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

dtp_cdate.SetFocus

End If

End Sub

Private Sub txt_phno_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_phno.SetFocus

End If

If KeyAscii = 13 Then

txt_eid.SetFocus

End If

End Sub

108
ELECTRICITY BILLING SYSTEM

Private Sub txt_phno_LostFocus()

If Len(txt_phno) <> 10 And Len(txt_phno) <> 0 Then

X = MsgBox("PLEASE ENTER A VALID PHONE NUMBER", vbCritical, "Error")

txt_phno.Text = ""

txt_phno.SetFocus

Exit Sub

End If

conn

Set r = New ADODB.Recordset

sql = "select phone_no from customer"

Set r = c.Execute(sql)

Do While Not r.EOF

If r.Fields(0) = txt_phno.Text Then

X = MsgBox("PHONE NUMBER ALREADY EXIST", vbInformation + vbOKOnly,


"Consumer") = vbOK

txt_phno.Text = ""

txt_phno.SetFocus

Exit Sub

Else

r.MoveNext

End If

Loop

End Sub

109
ELECTRICITY BILLING SYSTEM

Private Sub txt_pin_KeyPress(KeyAscii As Integer)

If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_pin.SetFocus

End If

If KeyAscii = 13 Then

combo_sdiv.SetFocus

End If

End Sub

Private Sub txt_pin_LostFocus()

If Len(txt_pin) <> 6 And Len(txt_pin) <> 0 Then

X = MsgBox("PLEASE ENTER A VALID PIN CODE", vbCritical, "Error")

txt_pin.Text = ""

txt_pin.SetFocus

End If

End Sub

110
ELECTRICITY BILLING SYSTEM

METER READING

Dim d As Date

Private Sub cmd_add_click()

d = txt_pdate.Text

If dtp_cdate.value < d Then

X = MsgBox("PLEASE ENTER READING 25 DAYS AFTER FROM PREVIOUS READING


DATE", vbCritical)

dtp_cdate.SetFocus

Exit Sub

ElseIf dtp_cdate.value > Now Then

X = MsgBox("NOT A VALID DATE", vbCritical, "Error")

dtp_cdate.SetFocus

Exit Sub

End If

conn

sql = "insert into measure values('" + txt_eid.Text + "','" + txt_cid + "'," + txt_mno + ",'" +
Format(txt_pdate, "dd MMM yy") + "'," + txt_pread + "," + txt_punit + ",'" +
Format(dtp_cdate, "dd MMM yy") + "'," + txt_cread + "," + txt_cunit + ")"

Set r = c.Execute(sql)

X = MsgBox("RECORD SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "Meter


Reading") = vbOK

Call cmd_reset_Click

End Sub

111
ELECTRICITY BILLING SYSTEM

Private Sub cmd_cancel_Click()

Unload Me

End Sub

Private Sub cmd_reset_Click()

txt_cid = ""

txt_name = ""

txt_mno = ""

txt_phase = ""

txt_condate = ""

txt_div = ""

txt_sdiv = ""

txt_ssec = ""

txt_tarrif = ""

txt_eid.Text = ""

txt_pdate = ""

txt_pread = ""

txt_punit = ""

dtp_cdate.value = Now

txt_cread = ""

txt_cunit = ""

Adodc1.Refresh

txt_cid.SetFocus

End Sub

112
ELECTRICITY BILLING SYSTEM

Private Sub Form_Load()

dtp_cdate.value = Now

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Meter Reading") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cid = UCase(Trim(txt_cid))

conn

sql = "select max(c_date) from measure where cust_id='" + txt_cid.Text + "'"

On Error GoTo X

Set r = c.Execute(sql)

If Format(r.Fields(0), "MMM yyyy") = Format(Now, "MMM yyyy") Then

X = MsgBox("READING ALREADY ADDED", vbInformation + vbOKOnly, "Meter Reading")


= vbOK

txt_cid.Text = ""

113
ELECTRICITY BILLING SYSTEM

txt_cid.SetFocus

Exit Sub

End If

Set r = New ADODB.Recordset

sql = "select * from customer,meter where customer.cust_id='" + txt_cid.Text + "' and


meter.cust_id='" + txt_cid.Text + "'"

On Error GoTo X

Set r = c.Execute(sql)

txt_div.Text = r.Fields("DIVISION")

txt_name.Text = r.Fields("CUST_NAME")

txt_mno.Text = r.Fields("M_NO")

txt_phase.Text = r.Fields("phase")

txt_condate.Text = Format(r.Fields("conn_date"), "dd MMM yyyy")

txt_sdiv.Text = r.Fields("sub_division")

txt_ssec.Text = r.Fields("supp_section")

txt_tarrif.Text = r.Fields("tarrif")

txt_eid.Text = emp_id

dtp_cdate.Enabled = True

txt_cread.Enabled = True

dtp_cdate.SetFocus

sql = "select c_date,c_reading,c_unit from measure where cust_id='" + txt_cid.Text + "' and
c_date=(select max(c_date) from measure where cust_id='" + txt_cid.Text + "')"

On Error GoTo y

Set r = c.Execute(sql)

txt_pdate = Format(r.Fields(0), "dd MMM yyyy")

114
ELECTRICITY BILLING SYSTEM

txt_pread = r.Fields(1)

txt_punit = r.Fields(2)

Exit Sub

y:

sql = "select conn_date from meter where m_no=" + txt_mno + ""

Set r = c.Execute(sql)

txt_pdate = Format(r.Fields(0), "dd MMM yyyy")

txt_pread = 0

txt_punit = 0

Exit Sub

X:

X = MsgBox("CONSUMER DOES NOT EXIST", vbInformation, "Meter Reading") = vbOK

txt_cid.Text = ""

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

Private Sub txt_cread_Change()

If txt_cread.Text = "" Then

txt_cunit.Text = ""

Exit Sub

End If

115
ELECTRICITY BILLING SYSTEM

txt_cunit = Val(txt_cread) - Val(txt_pread)

End Sub

Private Sub txt_cread_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If txt_cread.Text = "" Then Exit Sub

cmd_add.SetFocus

End If

End Sub

Private Sub txt_cread_LostFocus()

If txt_cread.Text = "" Then

Exit Sub

ElseIf Val(txt_pread) > Val(txt_cread) Then

X = MsgBox("PLEASE ENTER CORRECT READING", vbCritical, "Error")

txt_cread.Text = ""

txt_cread.SetFocus

txt_cunit.Text = ""

Else

Call txt_cread_KeyPress(13)

End If

End Sub

116
ELECTRICITY BILLING SYSTEM

ENERGY BILL

Dim r8 As ADODB.Recordset

Dim r2 As ADODB.Recordset

Dim r3 As ADODB.Recordset

Dim r4 As ADODB.Recordset

Dim r5 As ADODB.Recordset

Dim id As Integer

Dim r11 As ADODB.Recordset

Dim r12 As ADODB.Recordset

Dim r13 As ADODB.Recordset

Dim r14 As ADODB.Recordset

Dim mm As String

Dim i As Integer

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_exit1_Click()

Unload Me

End Sub

117
ELECTRICITY BILLING SYSTEM

Private Sub cmd_first_Click()

If Adodc1.Recordset.EOF Or Adodc1.Recordset.BOF = True Then Exit Sub

Adodc1.Recordset.MoveFirst

Call ado

End Sub

Private Sub cmd_last_Click()

If Adodc1.Recordset.EOF Or Adodc1.Recordset.BOF = True Then Exit Sub

Adodc1.Recordset.MoveLast

Call ado

End Sub

Private Sub cmd_next_Click()

On Error GoTo X

Adodc1.Recordset.MoveNext

If Adodc1.Recordset.EOF Or Adodc1.Recordset.BOF = True Then Exit Sub

Call ado

Exit Sub

X:

X = MsgBox(" LAST RECORD", vbInformation + vbOKOnly, "Energy Bill") = vbOK

End Sub

Private Sub cmd_previous_Click()

On Error GoTo X

Adodc1.Recordset.MovePrevious

118
ELECTRICITY BILLING SYSTEM

If Adodc1.Recordset.EOF Or Adodc1.Recordset.BOF = True Then Exit Sub

Call ado

Exit Sub

X:

X = MsgBox("FIRST RECORD", vbInformation + vbOKOnly, "Energy Bill") = vbOK

End Sub

Private Sub cmd_print_Click()

If DataEnvironment1.rsCommand2.State = 1 Then DataEnvironment1.rsCommand2.Close

DataReport2.Show

cmd_reset.Enabled = True

End Sub

Private Sub cmd_reset_Click()

txt_bid.Text = ""

txt_div.Text = ""

txt_eid.Text = ""

txt_bdate.Text = ""

txt_bmonth.Text = ""

txt_cid.Text = ""

txt_sdiv.Text = ""

txt_ddate.Text = ""

txt_ename.Text = ""

txt_eadd.Text = ""

txt_ephone.Text = ""

119
ELECTRICITY BILLING SYSTEM

txt_name.Text = ""

txt_add.Text = ""

txt_c1.Text = ""

txt_c2.Text = ""

txt_c3.Text = ""

lbl_d1.Caption = "DATE1"

lbl_d2.Caption = "DATE2"

lbl_d3.Caption = "DATE3"

txt_mno.Text = ""

txt_tarrif.Text = ""

txt_phase.Text = ""

txt_cload.Text = ""

txt_pdate.Text = ""

txt_pread.Text = ""

txt_punit.Text = ""

txt_cdate.Text = ""

txt_cread.Text = ""

txt_cunit.Text = ""

txt_ech.Text = ""

txt_dpscurr.Text = ""

txt_fxdch.Text = ""

txt_ed.Text = ""

txt_mrent.Text = ""

txt_tass.Text = ""

txt_dues.Text = ""

120
ELECTRICITY BILLING SYSTEM

txt_gtot.Text = ""

txt_rebate.Text = ""

txt_rno.Text = ""

txt_date.Text = ""

txt_amt.Text = ""

Call Form_Load

End Sub

Private Sub cmd_reset1_Click()

conn

Adodc2.RecordSource = "select * from customer c,meter m,measure re,calculate ca,bill b


where c.cust_id=m.cust_id and re.cust_id=c.cust_id and re.c_reading in (select c_reading
from measure where to_char(c_date,'MON')='" & UCase(Format(Now, "MMM")) & "' And
to_char(c_date,'YYYY')='" & Format(Now, "YYYY") & "') and c.cust_id in (select cust_id
from measure where to_char(c_date,'MON')='" & UCase(Format(Now, "MMM")) & "' And
to_char(c_date,'YYYY')='" & Format(Now, "YYYY") & "') and re.c_reading=ca.c_reading and
ca.month=b.bill_month and c.cust_id=ca.cust_id and c.cust_id=b.cust_id"

Adodc2.Refresh

Set DataGrid1.DataSource = Adodc2

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

121
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

DataGrid1.Columns(15).Caption = "READING DATE"

DataGrid1.Columns(16).Caption = "READING"

DataGrid1.Columns(17).Caption = "UNIT"

DataGrid1.Columns(18).Caption = "BILL NO."

DataGrid1.Columns(19).Caption = "BILL MONTH"

DataGrid1.Columns(20).Caption = "BILL DATE"

DataGrid1.Columns(21).Caption = "ENERGY CHARGE"

DataGrid1.Columns(22).Caption = "DPS"

DataGrid1.Columns(23).Caption = "FIXED CHARGE"

DataGrid1.Columns(24).Caption = "ELECTRICITY DUTY"

DataGrid1.Columns(25).Caption = "METER RENT"

DataGrid1.Columns(26).Caption = "TOTAL"

DataGrid1.Columns(27).Caption = "REBAIT"

DataGrid1.Columns(28).Caption = "GROSS TOTAL"

DataGrid1.Columns(29).Caption = "DUES"

DataGrid1.Columns(30).Caption = "PAYBLE UPTO"

DataGrid1.Columns(31).Caption = "CHARGE"

DataGrid1.Columns(32).Caption = "PAYBLE UPTO"

DataGrid1.Columns(33).Caption = "CHARGE"

DataGrid1.Columns(34).Caption = "CHARGE"

DataGrid1.Columns(35).Caption = "STATUS"

122
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub cmd_save_click()

conn

sql = "delete from temp"

c.Execute (sql)

sql = "select * from measure where to_char(c_date,'MON')='" & UCase(Format(Now,


"MMM")) & "' And to_char(c_date,'YYYY')='" & Format(Now, "YYYY") & "' ORDER BY
CUST_ID"

Set r = c.Execute(sql)

Set r3 = New ADODB.Recordset

sql = "select * from employee where e_id='" + emp_id + "'"

Set r3 = c.Execute(sql)

Do While Not r.EOF

Set r1 = New ADODB.Recordset

sql = "select * from customer,meter where customer.cust_id='" + r.Fields(1) + "' and


meter.cust_id='" + r.Fields(1) + "' and customer.cust_id=meter.cust_id"

Set r1 = c.Execute(sql)

'============================ CHECK BILL GENERATION


================================

Set r11 = New ADODB.Recordset

Set r12 = New ADODB.Recordset

123
ELECTRICITY BILLING SYSTEM

sql = "select max(c_reading) from calculate where cust_id='" + r1.Fields(0) + "'"

Set r11 = c.Execute(sql)

sql = "select max(c_reading) from measure where cust_id='" + r1.Fields(0) + "'"

Set r12 = c.Execute(sql)

If IsNull(r11.Fields(0)) Then GoTo next1 '-------------- if bill is not generted (1st time)

If IsNull(r12.Fields(0)) Then 'GoTo next1 '-------------- if new customer

X = MsgBox(" NEW CONSUMER", vbInformation + vbOKOnly, "Energy Bill") = vbOK

GoTo xx

End If

If r12.Fields(0) = r11.Fields(0) Then

GoTo xx

End If

'===================================================
========================================

'================= CHECK NEW CUSTOMER


=====================

next1:

'===================================================
=== DUES/RECEIPT DETAIL ENTRY ==============================

Set r13 = New ADODB.Recordset

124
ELECTRICITY BILLING SYSTEM

Set r14 = New ADODB.Recordset

sql = "select * FROM bill where B_ID=(SELECT MAX(B_ID) FROM BILL WHERE CUST_ID=
'" + r1.Fields(0) + "')"

Set r13 = c.Execute(sql)

sql = "select * from payment where b_id=(select max(b_id) from payment where
cust_id='" + r1.Fields(0) + "')"

Set r14 = c.Execute(sql)

'============================== FIRST TIME RECEIPT DETAIL


====================

If r13.BOF Or r13.EOF Then

rno = "XXXXX"

pdate = "XXXXX"

amt = "XXXXX"

dues = 0

GoTo n1

End If

'===================================================
============================

'

'========================= IF NO ANY PREVIOUS RECEIPT DETAIL(2ND


TIME BILL AND NO PAYMENT) ======================

If r14.BOF Or r14.EOF Then

rno = "XXXXX"

pdate = "XXXXX"

amt = "XXXXX"

125
ELECTRICITY BILLING SYSTEM

dues = r13.Fields("gross_total")

GoTo n1

End If

'===================================================
====================================================
=====

'====================================== PREVIOUS RECEIPT


DETAIL ===================

rno = r14.Fields("r_no")

pdate = r14.Fields("r_date")

amt = r14.Fields("amount")

'===================================================
===============================

If IsNull(r14.Fields("b_id")) Then

bid = 0

Else

bid = r14.Fields("b_id")

End If

'========================== Dues Calculation


=======================================

If r13.Fields("b_id") <> bid Then

dues = r13.Fields("gross_total") + r14.Fields("dues")

Else

126
ELECTRICITY BILLING SYSTEM

dues = r14.Fields("dues")

End If

'============================= DUES/RECEIPT DETAIL END


==================================

'============================ INFORMATION ENTRY


====================================

n1:

' ======================== CUSTOMER INFORMATION


===============================

'=================================== CALCULATION
====================================================

'===================================================
=== DOMESTIC CALCULATION
=====================================

Set r2 = New ADODB.Recordset

If r1.Fields("tarrif") = "DOMESTIC" Then

sql = "select * from domestic"

Set r2 = c.Execute(sql)

If (r.Fields("c_unit") < 101) Then

e_charge = (r2.Fields("d_upto100") * r.Fields("c_unit"))

ElseIf (r.Fields("c_unit") < 201) Then

e_charge = (r2.Fields("d_upto200") * r.Fields("c_unit"))

ElseIf (r.Fields("c_unit") < 301) Then

e_charge = (r2.Fields("d_upto300") * r.Fields("c_unit"))

Else

127
ELECTRICITY BILLING SYSTEM

e_charge = (r2.Fields("d_above300") * r.Fields("c_unit"))

End If

e_duty = (e_charge * r2.Fields("d_ed") / 100)

rebate = (r.Fields("c_unit") * r2.Fields("d_rebate") / 100)

dps_current = (dues * r2.Fields("d_dps") / 100)

p = r2.Fields("d_dps")

For i = 1 To 10

'========================== IF PHASE=1 AND CONNECTION LOAD


CALCULATION =============================

If r1.Fields("phase") = 1 And r1.Fields("c_load") = i Then

fixed = (r2.Fields("d_fc") + (r2.Fields("d_akw") * (i - 1)))

rent = r2.Fields("d_mrent")

ElseIf r1.Fields("phase") = 3 And r1.Fields("c_load") = i Then

'===================================================
================================================

'========================== IF PHASE=3 AND CONNECTION LOAD


CALCULATION =============================

fixed = (r2.Fields("d_fc3") + (r2.Fields("d_akw3") * (i - 1)))

rent = r2.Fields("d_mrent3")

End If

'===================================================
==================================================

Next

128
ELECTRICITY BILLING SYSTEM

'================================= DOMESTIC CALCULATION END


===================================================

'=================================================
NON-DOMESTIC CALCULATION
====================================

ElseIf r1.Fields("tarrif") = "NON-DOMESTIC" Then

Set r2 = New ADODB.Recordset

sql1 = "select * from non_domestic"

Set r2 = c.Execute(sql1)

If (r.Fields("c_unit") < 101) Then

e_charge = (r2.Fields("n_upto100") * r.Fields("c_unit"))

ElseIf (r.Fields("c_unit") < 201) Then

e_charge = (r2.Fields("n_upto200") * r.Fields("c_unit"))

Else

e_charge = (r2.Fields("d_above200") * r.Fields("c_unit"))

End If

e_duty = (e_charge * r2.Fields("n_ed") / 100)

rebate = (r.Fields("c_unit") * r2.Fields("n_rebate") / 100)

dps_current = (dues * r2.Fields("n_dps") / 100)

p = r2.Fields("n_dps")

For i = 1 To 10

'=========================== IF PHASE=1 AND CONNECTION LOAD


CALCULATION ==============================

If r1.Fields("phase") = 1 And r1.Fields("c_load") = i Then

fixed = (r2.Fields("n_fc") + (r2.Fields("n_akw") * (i - 1)))

129
ELECTRICITY BILLING SYSTEM

rent = r2.Fields("n_mrent")

'===================================================
====================================================
===========

'======================================== IF PHASE =3 AND


CONNECTION LOAD CALCULATION
=================================

ElseIf r1.Fields("phase") = 3 And r1.Fields("c_load") = i Then

fixed = (r2.Fields("n_fc3") + (r2.Fields("n_akw3") * (i - 1)))

rent = r2.Fields("n_mrent3")

End If

'===================================================
====================================================
================

Next

End If

'===================================== NON-DOMESTIC
CALCULATION END ======================================

'===================================== TOTAL AND GROSS


TOTAL CALCULATE ==================================

total = Val(e_charge) + Val(dps_current) + Val(fixed) + Val(e_duty) + Val(rent)

gross_total = Val(total) + Val(dues)

c1 = gross_total - rebate

c2 = gross_total

c3 = gross_total + (gross_total * p / 100)

130
ELECTRICITY BILLING SYSTEM

d1 = Now + 14

d2 = Now + 21

Set r5 = New ADODB.Recordset

sql = "select max(b_id) from bill"

Set r5 = c.Execute(sql)

If IsNull(r5.Fields(0)) Then

bid = 1

Else

id = r5.Fields(0) + 1

bid = id

End If

sql = "insert into calculate values('" & emp_id & "','" & r1.Fields("cust_id") & "'," &
r1.Fields("m_no") & "," & e_charge & "," & dps_current & "," & fixed & "," & e_duty & "," &
rent & "," & total & "," & rebate & "," & gross_total & "," & dues & ",'" &
UCase(Format(r.Fields("p_date"), "MMM yyyy")) & "','" & Format(r.Fields("c_date"), "dd
MMM yyyy") & "'," & r.Fields("c_reading") & "," & r.Fields("c_unit") & ")"

c.Execute (sql)

sql = "insert into bill values('" & emp_id & "','" & r1.Fields("cust_id") & "'," &
r1.Fields("m_no") & "," & bid & ",'" & Format(Now, "dd MMM yyyy") & "','" &
UCase(Format(r.Fields("p_date"), "MMM yyyy")) & "'," & gross_total & ",'" & Format(d1,
"dd MMM yyyy") & "','" & Format(d2, "dd MMM yyyy") & "'," & c1 & "," & c2 & "," & c3 &
",'UN PAID')"

c.Execute (sql)

131
ELECTRICITY BILLING SYSTEM

mm = UCase(Format(r.Fields("p_date"), "MMM yyyy"))

sql = "insert into temp values(" & bid & ",'" & Format(Now, "dd MMM yyyy") & "','" & mm &
"','" & Format(d1, "dd MMM yyyy") & "', '" & r1.Fields("cust_id") & "','" &
r1.Fields("cust_name") & "','" & r1.Fields("cust_add") & "','" & r1.Fields("division") & "','" &
r1.Fields("sub_division") & "'," & r1.Fields("m_no") & ",'" & r1.Fields("tarrif") & "'," &
r1.Fields("phase") & ",'" & r1.Fields("c_load") & "','" & emp_id & "','" & r3.Fields("e_nm") &
"','" & r3.Fields("e_add") & "'," & r3.Fields("e_phno") & ",'" & Format(r.Fields("p_date"), "dd
MMM yyyy") & "'," & r.Fields("p_reading") & "," & r.Fields("p_unit") & ",'" &
Format(r.Fields("c_date"), "dd MMM yyyy") & "'," & r.Fields("c_reading") & "," &
r.Fields("c_unit") & "," & dues & "," & e_charge & "," & dps_current & "," & fixed & "," &
e_duty & "," & rent & "," & total & "," & rebate & "," & gross_total & ",'" & Format(d1, "dd
MMM yyyy") & "','" & Format(d2, "dd MMM yyyy") & "'," & c1 & "," & c2 & "," & c3 & ",'" &
rno & "','" & pdate & "','" & amt & "')"

c.Execute (sql)

Adodc1.Refresh

Call ado

cmd_print.Enabled = True

cmd_first.Enabled = True

cmd_last.Enabled = True

cmd_previous.Enabled = True

cmd_next.Enabled = True

cmd_reset.Enabled = False

cmd_save.Enabled = False

a=1

xx:

r.MoveNext

132
ELECTRICITY BILLING SYSTEM

Loop

If a <> 1 Then

X = MsgBox("BILL ALREADY GENERATED", vbInformation + vbOKOnly, "Enrgy Bill") =


vbOK

End If

End Sub

Public Sub ado()

txt_bid.Text = Adodc1.Recordset.Fields("bill_id")

txt_div.Text = Adodc1.Recordset.Fields("div")

txt_eid.Text = Adodc1.Recordset.Fields("e_id")

txt_bdate.Text = Adodc1.Recordset("bdate")

txt_bmonth.Text = Adodc1.Recordset.Fields("bmonth")

txt_cid.Text = Adodc1.Recordset.Fields("c_id")

txt_sdiv.Text = Adodc1.Recordset.Fields("sdiv")

txt_ddate.Text = Adodc1.Recordset.Fields("due_date")

txt_ename.Text = Adodc1.Recordset.Fields("e_name")

txt_eadd.Text = Adodc1.Recordset.Fields("e_add")

txt_ephone.Text = Adodc1.Recordset.Fields("phone")

txt_name.Text = Adodc1.Recordset.Fields("c_name")

txt_add.Text = Adodc1.Recordset.Fields("addr")

txt_c1.Text = Adodc1.Recordset.Fields("c1")

txt_c2.Text = Adodc1.Recordset.Fields("c2")

txt_c3.Text = Adodc1.Recordset.Fields("c3")

133
ELECTRICITY BILLING SYSTEM

lbl_d1.Caption = Adodc1.Recordset.Fields("d1")

lbl_d2.Caption = Adodc1.Recordset.Fields("d2")

lbl_d3.Caption = "AFTER" & " " & Adodc1.Recordset.Fields("d2")

txt_mno.Text = Adodc1.Recordset.Fields("m_no")

txt_tarrif.Text = Adodc1.Recordset.Fields("tariff")

txt_phase.Text = Adodc1.Recordset.Fields("phase")

txt_cload.Text = Adodc1.Recordset.Fields("c_load")

txt_pdate.Text = Adodc1.Recordset.Fields("pread_date")

txt_pread.Text = Adodc1.Recordset.Fields("pread")

txt_punit.Text = Adodc1.Recordset.Fields("punit")

txt_cdate.Text = Adodc1.Recordset.Fields("cread_date")

txt_cread.Text = Adodc1.Recordset.Fields("cread")

txt_cunit.Text = Adodc1.Recordset.Fields("cunit")

txt_ech.Text = Adodc1.Recordset.Fields("e_ch")

txt_dpscurr.Text = Adodc1.Recordset.Fields("dps")

txt_fxdch.Text = Adodc1.Recordset.Fields("fxd_ch")

txt_ed.Text = Adodc1.Recordset.Fields("ed")

txt_mrent.Text = Adodc1.Recordset.Fields("mrent")

txt_tass.Text = Adodc1.Recordset.Fields("tot")

txt_dues.Text = Adodc1.Recordset.Fields("dues")

txt_gtot.Text = Adodc1.Recordset.Fields("gtot")

txt_rebate.Text = Adodc1.Recordset.Fields("rebate")

txt_rno.Text = Adodc1.Recordset.Fields("r_no")

txt_date.Text = Adodc1.Recordset.Fields("r_date")

txt_amt.Text = Adodc1.Recordset.Fields("at")

134
ELECTRICITY BILLING SYSTEM

cmd_print.Enabled = True

cmd_first.Enabled = True

cmd_last.Enabled = True

cmd_previous.Enabled = True

cmd_next.Enabled = True

End Sub

Private Sub Form_Load()

Adodc1.Refresh

conn

cmd_print.Enabled = False

cmd_first.Enabled = False

cmd_last.Enabled = False

cmd_previous.Enabled = False

cmd_next.Enabled = False

cmd_reset.Enabled = True

cmd_save.Enabled = True

On Error GoTo X

Adodc2.RecordSource = "select
c.*,m.m_no,phase,conn_date,supp_section,tarrif,c_load,ca.c_date,ca.c_reading,ca.c_unit,b_id,b
ill_month,b_date,energy_charge,dps_cmonth,fixed_charge,electricity_duty,meter_rent,total_
assesment,rebait,ca.gross_total,dues,date1,charge1,date2,charge2,charge3,status from
customer c,meter m,measure re,calculate ca,bill b where c.cust_id=m.cust_id and
re.cust_id=c.cust_id and re.c_reading in (select c_reading from measure where
to_char(c_date,'MON YYYY')='" & UCase(Format(Now, "MMM YYYY")) & "') And c.cust_id
in (select cust_id from measure where to_char(c_date,'MON YYYY')='" &
UCase(Format(Now, "MMM YYYY")) & "') and re.c_reading=ca.c_reading and
ca.month=b.bill_month and c.cust_id=ca.cust_id and c.cust_id=b.cust_id"

135
ELECTRICITY BILLING SYSTEM

Adodc2.Refresh

Set DataGrid1.DataSource = Adodc2

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

DataGrid1.Columns(15).Caption = "READING DATE"

DataGrid1.Columns(16).Caption = "READING"

DataGrid1.Columns(17).Caption = "UNIT"

DataGrid1.Columns(18).Caption = "BILL NO."

DataGrid1.Columns(19).Caption = "BILL MONTH"

DataGrid1.Columns(20).Caption = "BILL DATE"

DataGrid1.Columns(21).Caption = "ENERGY CHARGE"

DataGrid1.Columns(22).Caption = "DPS"

DataGrid1.Columns(23).Caption = "FIXED CHARGE"

DataGrid1.Columns(24).Caption = "ELECTRICITY DUTY"

136
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(25).Caption = "METER RENT"

DataGrid1.Columns(26).Caption = "TOTAL"

DataGrid1.Columns(27).Caption = "REBAIT"

DataGrid1.Columns(28).Caption = "GROSS TOTAL"

DataGrid1.Columns(29).Caption = "DUES"

DataGrid1.Columns(30).Caption = "PAYBLE UPTO"

DataGrid1.Columns(31).Caption = "CHARGE"

DataGrid1.Columns(32).Caption = "PAYBLE UPTO"

DataGrid1.Columns(33).Caption = "CHARGE"

DataGrid1.Columns(34).Caption = "CHARGE"

DataGrid1.Columns(35).Caption = "STATUS"

Exit Sub

X:

Exit Sub

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Energy Bill") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

137
ELECTRICITY BILLING SYSTEM

RECEIPT

Dim id As Integer

Dim date1 As Date

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_pay_Click()

conn

If txt_cid.Text = "" And txt_amt.Text = "" Then

X = MsgBox("PLEASE ENTER CONSUMER ID", vbCritical, "Error")

txt_cid.SetFocus

ElseIf txt_amt.Text = "" Then

X = MsgBox("PLEASE ENTER AMOUNT", vbCritical, "Error")

txt_amt.SetFocus

Else

X = MsgBox("ARE YOU SURE TO PAY", vbInformation + vbYesNo, "Receipt") = vbYes

If X = True Then

sql = "insert into payment values('" + txt_eid.Text + "','" + txt_cid.Text + "'," +


txt_mno.Text + "," + txt_bid.Text + "," + txt_rno.Text + ",'" + txt_date.Text + "'," +
txt_amt.Text + ",'" + txt_bmonth.Text + "','" + txt_tot.Text + "'," + txt_dues.Text + ")"

Set r = c.Execute(sql)

sql = "update bill set status='PAID' where b_id=" + txt_bid.Text + ""

138
ELECTRICITY BILLING SYSTEM

c.Execute (sql)

X = MsgBox("PAYMENT SUCCESS", vbInformation + vbOKOnly, "Receipt") = vbOK

cmd_pay.Enabled = False

cmd_print.Enabled = True

cmd_reset.Enabled = False

cmd_exit.Enabled = False

cmd_print.SetFocus

Else

txt_amt.Text = ""

txt_dues.Text = ""

txt_amt.SetFocus

End If

End If

End Sub

Private Sub cmd_print_Click()

If DataEnvironment1.rsCommand1.State = 1 Then DataEnvironment1.rsCommand1.Close

Set r = New ADODB.Recordset

sql = "select max(b_id) from payment where cust_id='" & txt_cid.Text & "'"

Set r = c.Execute(sql)

DataEnvironment1.Command1 txt_cid, txt_cid, r.Fields(0)

DataReport1.Sections("section1").Controls("label18").Caption =
NoToWord(Val(txt_amt.Text))

DataReport1.Show

Call cmd_reset_Click

139
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub cmd_reset_Click()

txt_cname.Text = ""

txt_bid.Text = ""

txt_bmonth.Text = ""

txt_mno.Text = ""

txt_sdiv.Text = ""

txt_tot.Text = ""

txt_amt.Text = ""

txt_dues.Text = ""

txt_cid.Text = ""

txt_cid.SetFocus

Call Form_Load

End Sub

Private Sub Form_Load()

conn

sql = "select max(r_no) from payment"

Set r = c.Execute(sql)

If IsNull(r.Fields(0)) Then

txt_rno = 1

Else

id = r.Fields(0) + 1

txt_rno.Text = id

140
ELECTRICITY BILLING SYSTEM

End If

txt_div.Text = "DARBHANGA"

txt_date = Format(Now, "dd MMM yyyy")

txt_eid.Text = emp_id

sql = "select user_name from login where user_id='" + txt_eid.Text + "'"

Set r = c.Execute(sql)

txt_ename = r.Fields(0)

cmd_print.Enabled = False

cmd_pay.Enabled = True

cmd_exit.Enabled = True

cmd_reset.Enabled = True

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Payment") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_amt_Change()

If txt_amt.Text = "" Then

txt_dues.Text = ""

141
ELECTRICITY BILLING SYSTEM

Exit Sub

End If

txt_dues.Text = txt_tot.Text - txt_amt.Text

End Sub

Private Sub txt_amt_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If txt_amt.Text = "" Then Exit Sub

cmd_pay.Enabled = True

cmd_pay.SetFocus

End If

End Sub

Private Sub txt_amt_LostFocus()

Call txt_amt_KeyPress(13)

End Sub

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If txt_cid.Text = "" Then Exit Sub

Call txt_cid_LostFocus

conn

sql = "select distinct cust_id from bill where cust_id='" + txt_cid.Text + "'"

On Error GoTo X

Set r = c.Execute(sql)

142
ELECTRICITY BILLING SYSTEM

sql = "select count(b_id) from customer,bill where customer.cust_id='" + r.Fields(0) + "'


and bill.cust_id='" + r.Fields(0) + "'"

Set r = c.Execute(sql)

If r.Fields(0) = 0 Then

X = MsgBox("NEW CONSUMER", vbInformation + vbOKOnly, "Receipt") = vbOK

txt_cid.Text = ""

txt_cid.SetFocus

Exit Sub

End If

sql = "SELECT MAX(B_ID) FROM BILL WHERE CUST_ID= '" + txt_cid.Text + "'"

sql1 = "select max(b_id) from payment where cust_id='" + txt_cid.Text + "'"

Set r = c.Execute(sql)

Set r1 = c.Execute(sql1)

If r.Fields(0) = r1.Fields(0) Then

X = MsgBox("PAYMENT IS CLEAR", vbInformation + vbOKOnly, "Receipt") = vbOK

Exit Sub

X:

X = MsgBox("CONSUMER ID NOT MATCHED", vbInformation + vbOKOnly, "Receipt") =


vbOK

txt_cid.Text = ""

txt_cid.SetFocus

Exit Sub

End If

143
ELECTRICITY BILLING SYSTEM

sql = "select * from customer,bill where customer.cust_id='" + txt_cid + "' and


bill.cust_id='" + txt_cid.Text + "' and bill.b_id=(select max(b_id) from bill where
bill.cust_id='" + txt_cid.Text + "')"

Set r = c.Execute(sql)

txt_cname.Text = r.Fields("cust_name")

txt_bid.Text = r.Fields("b_id")

txt_bmonth.Text = r.Fields("bill_month")

txt_mno.Text = r.Fields("m_no")

txt_sdiv.Text = r.Fields("sub_division")

sql1 = "select * from bill where b_id=(select max(b_id)from bill where cust_id='" + txt_cid
+ "')"

Set r1 = c.Execute(sql1)

date1 = txt_date.Text

If date1 <= r1.Fields("date1") Then

txt_tot.Text = r.Fields("charge1")

ElseIf date1 <= r1.Fields("date2") Then

txt_tot.Text = r.Fields("charge2")

Else

txt_tot.Text = r.Fields("charge3")

End If

txt_amt.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

144
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_cid_LostFocus()

txt_cid.Text = UCase(Trim(txt_cid.Text))

End Sub

145
ELECTRICITY BILLING SYSTEM

CREATE USER

Dim str As String

Dim d As Date

Dim id As Integer

Private Sub cmd_cancel_Click()

Unload Me

End Sub

Private Sub cmd_reset_Click()

txt_eid.Text = ""

txt_name.Text = ""

txt_phno.Text = ""

txt_email.Text = ""

txt_add.Text = ""

txt_dis.Text = ""

txt_pin.Text = ""

dtp_doj = Now

txt_eid.Text = ""

txt_uname.Text = ""

txt_pass.Text = ""

txt_cpass.Text = ""

txt_ltype.Text = ""

146
ELECTRICITY BILLING SYSTEM

Call Form_Load

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Employee Record") =


vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_add_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_dis.SetFocus

End If

End Sub

Private Sub txt_add_LostFocus()

txt_add = UCase(Trim(txt_add))

End Sub

Private Sub txt_cpass_LostFocus()

If txt_pass <> txt_cpass Then

147
ELECTRICITY BILLING SYSTEM

X = MsgBox("PLEASE RE-ENTER THE PASSWORD", vbCritical, "Error")

txt_pass.Text = ""

txt_cpass.Text = ""

txt_pass.SetFocus

End If

End Sub

Private Sub txt_dis_LostFocus()

txt_dis = UCase(Trim(txt_dis))

End Sub

Private Sub txt_email_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_phno.SetFocus

End If

End Sub

Private Sub txt_dis_KeyPress(KeyAscii As Integer)

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii <>
8 And KeyAscii <> 32 And KeyAscii <> 13 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_dis.SetFocus

End If

If KeyAscii = 13 Then

148
ELECTRICITY BILLING SYSTEM

txt_pin.SetFocus

End If

End Sub

Private Sub txt_email_LostFocus()

txt_email.Text = Trim(txt_email.Text)

conn

sql = "select e_email from employee"

Set r = c.Execute(sql)

Do While Not r.EOF

If r.Fields(0) = txt_email.Text Then

X = MsgBox("EMAIL ALREADY EXIST", vbInformation + vbOKOnly, "Employee") = vbOK

txt_email.Text = ""

txt_email.SetFocus

Exit Sub

Else

r.MoveNext

End If

Loop

End Sub

Private Sub txt_name_Change()

If Len(txt_name) >= 30 Then

X = MsgBox("LENGTH SHOULD NOT EXCED THAN 30", vbCritical, "Error")

End If

149
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_name_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_name = UCase(Trim(txt_name.Text))

txt_add.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii
<> 8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_name.SetFocus

End If

End Sub

Private Sub txt_name_LostFocus()

txt_name.Text = Trim(txt_name.Text)

End Sub

Private Sub txt_phno_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_phno.SetFocus

End If

If KeyAscii = 13 Then

150
ELECTRICITY BILLING SYSTEM

'Call txt_phno_LostFocus

If txt_name.Text = "" And txt_phno.Text = "" And txt_email.Text = "" And txt_add.Text = ""
And txt_dis.Text = "" And txt_pin.Text = "" Then

X = MsgBox("PLEASE ENTER RECORD", vbCritical, "Error")

txt_name.SetFocus

Exit Sub

ElseIf txt_name = "" Then

X = MsgBox("PLEASE ENTER NAME", vbCritical, "Error")

txt_name.SetFocus

Exit Sub

ElseIf txt_add = "" Then

X = MsgBox("PLEASE ENTER ADDRESS", vbCritical, "Error")

txt_add.SetFocus

Exit Sub

ElseIf txt_dis = "" Then

X = MsgBox("PLEASE ENTER DISTRICT", vbCritical, "Error")

txt_dis.SetFocus

Exit Sub

ElseIf txt_pin = "" Then

X = MsgBox("PLEASE ENTER PIN CODE", vbCritical, "Error")

txt_pin.SetFocus

Exit Sub

Else

Frame1.Enabled = True

If txt_name.Text <> "" Then

151
ELECTRICITY BILLING SYSTEM

str = Mid(txt_name, 1, 3)

conn

sql = "select max(to_number(substr(e_id,4,length(e_id)))) from employee"

Set r = c.Execute(sql)

If IsNull(r.Fields(0)) Then

txt_eid.Text = str & 2

Else

id = r.Fields(0) + 1

txt_eid.Text = str & id

End If

End If

txt_uname.Text = txt_name.Text

txt_pass.SetFocus

txt_ltype.Text = "EMPLOYEE"

End If

End If

End Sub

Private Sub txt_phno_LostFocus()

If Len(txt_phno) <> 10 And Len(txt_phno) <> 0 Then

X = MsgBox("PLEASE ENTER A VALID PHONE NUMBER", vbCritical, "Error")

txt_phno.Text = ""

txt_phno.SetFocus

Exit Sub

End If

152
ELECTRICITY BILLING SYSTEM

conn

Set r = New ADODB.Recordset

sql = "select e_phno from employee"

Set r = c.Execute(sql)

Do While Not r.EOF

If r.Fields(0) = txt_phno.Text Then

X = MsgBox("PHONE NUMBER ALREADY EXIST", vbInformation + vbOKOnly, "Employee")


= vbOK

txt_phno.Text = ""

txt_phno.SetFocus

Exit Sub

Else

r.MoveNext

End If

Loop

Call txt_phno_KeyPress(13)

End Sub

Private Sub txt_pin_KeyPress(KeyAscii As Integer)

If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_pin.SetFocus

End If

If KeyAscii = 13 Then

153
ELECTRICITY BILLING SYSTEM

dtp_doj.SetFocus

End If

End Sub

Private Sub cmd_add_click()

If txt_name.Text = "" And txt_phno.Text = "" And txt_email.Text = "" And txt_add.Text = ""
And txt_dis.Text = "" And txt_pin.Text = "" Then

X = MsgBox("PLEASE ENTER RECORD", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_name = "" Then

X = MsgBox("PLEASE ENTER NAME", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_add = "" Then

X = MsgBox("PLEASE ENTER ADDRESS", vbCritical, "Error")

txt_add.SetFocus

ElseIf txt_dis = "" Then

X = MsgBox("PLEAE ENTER DISTRICT", vbCritical, "Error")

txt_dis.SetFocus

ElseIf txt_pin = "" Then

X = MsgBox("PLEASE ENTER PIN CODE", vbCritical, "Error")

txt_pin.SetFocus

ElseIf txt_phno.Text = "" Then

X = MsgBox("PLEASE ENTER PHONE NUMBER", vbCritical, "Error")

txt_phno.SetFocus

ElseIf txt_uname.Text = "" And txt_eid.Text = "" And txt_pass.Text = "" Then

154
ELECTRICITY BILLING SYSTEM

X = MsgBox("PLEASE ENTER LOGIN RECORD", vbCritical, "Error")

txt_uname.SetFocus

Exit Sub

ElseIf txt_uname.Text = "" Then

X = MsgBox("PLASE ENTER USER NAME", vbCritical, "Error")

txt_uname.SetFocus

Exit Sub

ElseIf txt_pass.Text = "" Then

X = MsgBox("PLEASE RE-ENTER THE PASSWORD", vbCritical, "Error")

txt_cpass.Text = ""

txt_pass.SetFocus

Exit Sub

ElseIf txt_cpass.Text = "" Then

X = MsgBox("PLEASE RE-ENTER THE PASSWORD", vbCritical, "Error")

txt_pass.Text = ""

txt_cpass.Text = ""

txt_pass.SetFocus

Exit Sub

Else

conn

sql = "insert into employee values('" + txt_eid.Text + "','" + txt_name.Text + "'," +


txt_phno.Text + ",'" + txt_email.Text + "','" + txt_add.Text + "','" + txt_dis.Text + "'," +
txt_pin.Text + ",'" + Format(dtp_doj.value, "DD MMM YY") + "')"

sql1 = "insert into login values('" + txt_uname.Text + "','" + txt_eid.Text + "','" +


txt_pass.Text + "','" + txt_ltype + "')"

Set r = c.Execute(sql)

155
ELECTRICITY BILLING SYSTEM

Set r1 = c.Execute(sql1)

Adodc1.Refresh

X = MsgBox("RECORD SAVED,DO YOU WANT TO CREATE NEW USER", vbInformation +


vbYesNo, "Employee Record") = vbYes

If X = True Then

Call cmd_reset_Click

Else

Unload Me

End If

End If

End Sub

Private Sub Form_Load()

Frame1.Enabled = False

End Sub

Private Sub txt_pass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cpass.SetFocus

End If

End Sub

Private Sub txt_cpass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If txt_pass.Text <> txt_cpass Then

156
ELECTRICITY BILLING SYSTEM

Call txt_cpass_LostFocus

End If

Call cmd_add_click

End If

End Sub

157
ELECTRICITY BILLING SYSTEM

UPDATE USER

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_reset_Click()

txt_eid.Text = ""

txt_name.Text = ""

txt_phno.Text = ""

txt_email.Text = ""

txt_add.Text = ""

txt_dis.Text = ""

txt_pin.Text = ""

dtp_doj.value = Now

Adodc1.Refresh

Call Form_Load

txt_eid.SetFocus

End Sub

Private Sub cmd_update_Click()

If txt_name.Text = "" And txt_add.Text = "" And txt_dis.Text = "" And txt_pin.Text = "" And
txt_phno.Text = "" And txt_email.Text = "" Then

X = MsgBox("PLEASE ENTER RECORD", vbCritical, "Error")

txt_name.SetFocus

158
ELECTRICITY BILLING SYSTEM

ElseIf txt_name.Text = "" Then

X = MsgBox("PLEASE ENTER NAME", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_add.Text = "" Then

X = MsgBox("PLEASE ENTER ADDRESS", vbCritical, "Error")

txt_add.SetFocus

ElseIf txt_dis.Text = "" Then

X = MsgBox("PLEASE ENTER DISTRICT", vbCritical, "Error")

txt_dis.SetFocus

ElseIf txt_pin.Text = "" Then

X = MsgBox("PLEASE ENTER PIN CODE", vbCritical, "Error")

txt_pin.SetFocus

ElseIf txt_phno.Text = "" Then

X = MsgBox("PLEASE ENTER PHONE NUMBER", vbCritical)

txt_phno.SetFocus

ElseIf txt_email.Text = "" Then

X = MsgBox("PLEASE ENTER EMAIL ID", vbCritical, "Error")

txt_email.SetFocus

Else

conn

sql = "update employee set e_nm='" + txt_name.Text + "',e_phno=" + txt_phno.Text +


",e_email='" + txt_email.Text + "',e_add='" + txt_add.Text + "',e_dist='" + txt_dis.Text +
"',e_pin=" + txt_pin + " where e_id='" + txt_eid.Text + "'"

Set r = c.Execute(sql)

X = MsgBox("RECORD UPDATED SUCCESSFULLY", vbInformation + vbOKOnly, "Employee


Updated Record") = vbOK

159
ELECTRICITY BILLING SYSTEM

Call cmd_reset_Click

End If

End Sub

Private Sub cmd_update_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

End If

End Sub

Private Sub Form_Load()

Frame3.Enabled = False

cmd_update.Enabled = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Update Emoloyee") =


vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

160
ELECTRICITY BILLING SYSTEM

Private Sub txt_add_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_dis.SetFocus

End If

End Sub

Private Sub txt_add_LostFocus()

txt_add.Text = UCase(Trim(txt_add.Text))

End Sub

Private Sub txt_dis_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_pin.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii
<> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

Private Sub txt_dis_LostFocus()

txt_dis.Text = UCase(Trim(txt_dis.Text))

End Sub

Private Sub txt_eid_KeyPress(KeyAscii As Integer)

161
ELECTRICITY BILLING SYSTEM

If KeyAscii = 13 Then

txt_eid.Text = UCase(Trim(txt_eid.Text))

conn

sql = "select * from employee where e_id='" + txt_eid.Text + "'"

On Error GoTo X

Frame3.Enabled = True

Set r = c.Execute(sql)

txt_name.Text = r.Fields("e_nm")

txt_phno.Text = r.Fields("e_phno")

txt_email.Text = r.Fields("e_email")

txt_add.Text = r.Fields("e_add")

txt_dis.Text = r.Fields("e_dist")

txt_pin.Text = r.Fields("e_pin")

dtp_doj = r.Fields("e_doj")

cmd_update.Enabled = True

txt_name.SetFocus

Exit Sub

X:

X = MsgBox("ID NOT FOUND", vbInformation + vbOKOnly, "Employee Updated Record") =


vbOK

txt_eid.Text = ""

txt_eid.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

162
ELECTRICITY BILLING SYSTEM

KeyAscii = 0

End If

End Sub

Private Sub txt_email_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

cmd_update.SetFocus

ElseIf KeyAscii = 32 Then

KeyAscii = 0

End If

End Sub

Private Sub txt_name_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_add.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii
<> 8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

Private Sub txt_name_LostFocus()

txt_name.Text = UCase(Trim(txt_name.Text))

End Sub

163
ELECTRICITY BILLING SYSTEM

Private Sub txt_phno_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_email.SetFocus

ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

Private Sub txt_pin_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

dtp_doj.SetFocus

ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

164
ELECTRICITY BILLING SYSTEM

CHANGE PASSWORD

Private Sub cmd_reset_Click()

txt_id.Text = ""

txt_name = ""

txt_ltype = ""

txt_pass = ""

txt_cpass = ""

Call Form_Load

txt_id.SetFocus

End Sub

Private Sub cmd_save_click()

If txt_pass <> txt_cpass Then

X = MsgBox("PASSWORD NOT MATCHED", vbCritical, , "Error")

txt_pass = ""

txt_cpass = ""

txt_pass.SetFocus

Else

conn

sql = "update login set password='" + txt_pass.Text + "' where user_id='" + txt_id + "'"

Set r = c.Execute(sql)

X = MsgBox("PASSWORD CHANGED SUCCESSFULLY", vbInformation + vbOKOnly, "Change


Pssword") = vbOK

165
ELECTRICITY BILLING SYSTEM

Adodc1.Refresh

Call cmd_reset_Click

End If

End Sub

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub Form_Load()

Frame1.Enabled = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Change Password") =


vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_cpass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

166
ELECTRICITY BILLING SYSTEM

cmd_save.SetFocus

End If

End Sub

Private Sub txt_id_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Frame1.Enabled = True

txt_id = UCase(Trim(txt_id))

conn

sql = "select * from login where user_id='" + txt_id + "'"

Set r = c.Execute(sql)

On Error GoTo X:

txt_name = r.Fields(0)

txt_ltype = r.Fields(3)

txt_pass.SetFocus

Else

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And (KeyAscii <
48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End If

Exit Sub

X:

167
ELECTRICITY BILLING SYSTEM

X = MsgBox("DATA NOT FOUND", vbInformation + vbOKOnly, "Change Password") =


vbOK

End Sub

Private Sub txt_pass_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cpass.SetFocus

End If

End Sub

168
ELECTRICITY BILLING SYSTEM

UPDATE DOMESTIC CHARGES

Dim c As ADODB.Connection

Dim r As ADODB.Recordset

Dim sql As String

Private Sub cmd_cancel_Click()

Unload Me

End Sub

Private Sub cmd_refresh_Click()

Call Form_Load

End Sub

Private Sub cmd_reset_Click()

txt_upto100 = ""

txt_upto200 = ""

txt_upto300 = ""

txt_above300 = ""

txt_dps = ""

txt_ed = ""

txt_fixed1 = ""

txt_akw1 = ""

txt_mrent1 = ""

169
ELECTRICITY BILLING SYSTEM

txt_fixed3 = ""

txt_akw3 = ""

txt_mrent3 = ""

txt_rebate = ""

End Sub

Private Sub cmd_update_Click()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select * from domestic"

Set r = c.Execute(sql)

sql = "update domestic set d_upto100=" + txt_upto100.Text + ",d_upto200=" +


txt_upto200.Text + ",d_upto300=" + txt_upto300.Text + ",d_above300=" +
txt_above300.Text + ",d_dps=" + txt_dps.Text + ",d_ed=" + txt_ed.Text + ",d_fc=" +
txt_fixed1.Text + ",d_akw=" + txt_akw1.Text + ",d_mrent=" + txt_mrent1.Text + ",d_fc3="
+ txt_fixed3.Text + ",d_akw3=" + txt_akw3.Text + ",d_mrent3=" + txt_mrent3.Text +
",d_rebate=" + txt_rebate.Text + ""

Set r = c.Execute(sql)

X = MsgBox("RECORD UPDATED", vbInformation + vbOKOnly, "Domestic Charge") =


vbOK

End Sub

Private Sub Form_Load()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

170
ELECTRICITY BILLING SYSTEM

sql = "select * from domestic"

Set r = c.Execute(sql)

txt_upto100.Text = r.Fields("D_UPTO100")

txt_upto200.Text = r.Fields("d_upto200")

txt_upto300.Text = r.Fields("d_upto300")

txt_above300.Text = r.Fields("d_above300")

txt_dps.Text = r.Fields("d_dps")

txt_ed.Text = r.Fields("d_ed")

txt_fixed1.Text = r.Fields("d_fc")

txt_akw1.Text = r.Fields("d_akw")

txt_mrent1.Text = r.Fields("d_mrent")

txt_fixed3.Text = r.Fields("d_fc3")

txt_akw3.Text = r.Fields("d_akw3")

txt_mrent3.Text = r.Fields("d_mrent3")

txt_rebate.Text = r.Fields("d_rebate")

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Domestic Charges") =


vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

171
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_above300_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_above300.SetFocus

End If

If KeyAscii = 13 Then

txt_dps.SetFocus

End If

End Sub

Private Sub txt_akw1_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_akw1.SetFocus

End If

If KeyAscii = 13 Then

172
ELECTRICITY BILLING SYSTEM

txt_mrent1.SetFocus

End If

End Sub

Private Sub txt_akw3_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_akw3.SetFocus

End If

If KeyAscii = 13 Then

txt_mrent3.SetFocus

End If

End Sub

Private Sub txt_dps_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

173
ELECTRICITY BILLING SYSTEM

txt_dps.SetFocus

End If

If KeyAscii = 13 Then

txt_ed.SetFocus

End If

End Sub

Private Sub txt_ed_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_ed.SetFocus

End If

If KeyAscii = 13 Then

txt_rebate.SetFocus

End If

End Sub

Private Sub txt_fixed1_KeyPress(KeyAscii As Integer)

174
ELECTRICITY BILLING SYSTEM

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_fixed1.SetFocus

End If

If KeyAscii = 13 Then

txt_akw1.SetFocus

End If

End Sub

Private Sub txt_fixed3_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_fixed3.SetFocus

End If

If KeyAscii = 13 Then

txt_akw3.SetFocus

End If

End Sub

175
ELECTRICITY BILLING SYSTEM

Private Sub txt_mrent1_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_mrent1.SetFocus

End If

If KeyAscii = 13 Then

txt_fixed3.SetFocus

End If

End Sub

Private Sub txt_mrent3_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_upto100.SetFocus

End If

If KeyAscii = 13 Then

cmd_update.SetFocus

176
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub txt_rebate_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_rebate.SetFocus

End If

If KeyAscii = 13 Then

txt_fixed1.SetFocus

End If

End Sub

Private Sub txt_upto100_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_upto100.SetFocus

End If

177
ELECTRICITY BILLING SYSTEM

If KeyAscii = 13 Then

txt_upto200.SetFocus

End If

End Sub

Private Sub txt_upto200_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_upto200.SetFocus

End If

If KeyAscii = 13 Then

txt_upto300.SetFocus

End If

End Sub

Private Sub txt_upto300_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_upto300.SetFocus

178
ELECTRICITY BILLING SYSTEM

End If

If KeyAscii = 13 Then

txt_above300.SetFocus

End If

End Sub

179
ELECTRICITY BILLING SYSTEM

UPDATE NON-DOMESTIC CHARGES

Dim c As ADODB.Connection

Dim r As ADODB.Recordset

Dim sql As String

Private Sub cmd_cancel_Click()

Unload Me

End Sub

Private Sub cmd_refresh_Click()

Call Form_Load

End Sub

Private Sub cmd_reset_Click()

txt_upto100 = ""

txt_upto200 = ""

txt_above200 = ""

txt_dps = ""

txt_ed = ""

txt_fixed1 = ""

txt_akw1 = ""

txt_mrent1 = ""

txt_fixed3 = ""

180
ELECTRICITY BILLING SYSTEM

txt_akw3 = ""

txt_mrent3 = ""

txt_rebate = ""

End Sub

Private Sub cmd_update_Click()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "update non_domestic set n_upto100=" + txt_upto100.Text + ",n_upto200=" +


txt_upto200.Text + ",n_above200=" + txt_above200.Text + ",n_dps=" + txt_dps.Text +
",n_ed=" + txt_ed.Text + ",n_fc=" + txt_fixed1.Text + ",n_akw=" + txt_akw1.Text +
",n_mrent=" + txt_mrent1.Text + ",n_fc3=" + txt_fixed3.Text + ",n_akw3=" +
txt_akw3.Text + ",n_mrent3=" + txt_mrent3.Text + ",n_rebate=" + txt_rebate + ""

Set r = c.Execute(sql)

X = MsgBox("RECORD UPDATED SUCCESSFULLY", vbInformation + vbOKOnly, "Non


Domestic Charge") = vbOK

End Sub

Private Sub Form_Load()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select * from non_domestic"

Set r = c.Execute(sql)

txt_upto100.Text = r.Fields("n_UPTO100")

txt_upto200.Text = r.Fields("n_upto200")

181
ELECTRICITY BILLING SYSTEM

txt_above200.Text = r.Fields("n_above200")

txt_dps.Text = r.Fields("n_dps")

txt_ed.Text = r.Fields("n_ed")

txt_fixed1.Text = r.Fields("n_fc")

txt_akw1.Text = r.Fields("n_akw")

txt_mrent1.Text = r.Fields("n_mrent")

txt_fixed3.Text = r.Fields("n_fc3")

txt_akw3.Text = r.Fields("n_akw3")

txt_mrent3.Text = r.Fields("n_mrent3")

txt_rebate.Text = r.Fields("n_rebate")

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Non-Domestic Charges")


= vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_above200_KeyPress(KeyAscii As Integer)

182
ELECTRICITY BILLING SYSTEM

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_above200.SetFocus

End If

If KeyAscii = 13 Then

txt_dps.SetFocus

End If

End Sub

Private Sub txt_akw1_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_akw1.SetFocus

End If

If KeyAscii = 13 Then

txt_mrent1.SetFocus

End If

End Sub

183
ELECTRICITY BILLING SYSTEM

Private Sub txt_akw3_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_akw3.SetFocus

End If

If KeyAscii = 13 Then

txt_mrent3.SetFocus

End If

End Sub

Private Sub txt_dps_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_dps.SetFocus

End If

If KeyAscii = 13 Then

txt_ed.SetFocus

184
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub txt_ed_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_ed.SetFocus

End If

If KeyAscii = 13 Then

txt_rebate.SetFocus

End If

End Sub

Private Sub txt_fixed1_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_fixed1.SetFocus

185
ELECTRICITY BILLING SYSTEM

End If

If KeyAscii = 13 Then

txt_akw1.SetFocus

End If

End Sub

Private Sub txt_fixed3_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_fixed3.SetFocus

End If

If KeyAscii = 13 Then

txt_akw3.SetFocus

End If

End Sub

Private Sub txt_mrent1_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

186
ELECTRICITY BILLING SYSTEM

KeyAscii = 0

txt_mrent1.SetFocus

End If

If KeyAscii = 13 Then

txt_fixed3.SetFocus

End If

End Sub

Private Sub txt_mrent3_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_upto100.SetFocus

End If

If KeyAscii = 13 Then

cmd_update.SetFocus

End If

End Sub

Private Sub txt_rebate_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

187
ELECTRICITY BILLING SYSTEM

KeyAscii = 0

txt_rebate.SetFocus

End If

If KeyAscii = 13 Then

txt_fixed1.SetFocus

End If

End Sub

Private Sub txt_upto200_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_upto200.SetFocus

End If

If KeyAscii = 13 Then

txt_above200.SetFocus

End If

End Sub

Private Sub txt_upto100_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii
<> 46) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_upto100.SetFocus

188
ELECTRICITY BILLING SYSTEM

End If

If KeyAscii = 13 Then

txt_upto200.SetFocus

End If

End Sub

189
ELECTRICITY BILLING SYSTEM

UPDATE CONSUMER RECORD

Dim c As ADODB.Connection

Dim r As ADODB.Recordset

Dim sql As String

Dim sql1 As String

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_reset_Click()

txt_cid = ""

txt_name = ""

txt_phno = ""

txt_eid = ""

txt_add = ""

txt_dist = ""

txt_pin = ""

txt_sdiv.Text = ""

txt_mno = ""

Combo_phase.ListIndex = -1

dtp_cdate.value = Now

190
ELECTRICITY BILLING SYSTEM

Combo_ssec.ListIndex = -1

Combo_tarrif.ListIndex = -1

txt_volt = ""

Adodc1.Refresh

End Sub

Private Sub cmd_update_Click()

If txt_name = "" And txt_phno = "" And txt_add = "" And txt_dist = "" And txt_pin = "" Then

X = MsgBox("PLEASE ENTER CONSUMER RECORD", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_name = "" Then

X = MsgBox("PLASE ENTER NAME", vbCritical, "Error")

txt_name.SetFocus

ElseIf txt_phno = "" Then

X = MsgBox("PLEASE ENTER PHONE NUMBER", vbCritical, "Error")

txt_phno.SetFocus

ElseIf txt_add = "" Then

X = MsgBox("PLEASE ENTER ADDRESS", vbCritical, "Error")

txt_add.SetFocus

ElseIf txt_dist = "" Then

X = MsgBox("PLEASE ENTER DISTRICT", vbCritical, "Error")

txt_dist.SetFocus

ElseIf txt_pin = "" Then

X = MsgBox("PLEASE ENTER PIN CODE", vbCritical, "Error")

txt_pin.SetFocus

191
ELECTRICITY BILLING SYSTEM

ElseIf txt_mno = "" And txt_cdate = "" And Combo_ssec = "" And Combo_phase = "" And
Combo_cload = "" Then

X = MsgBox("PLEASE ENTER METER DETAIL", vbCritical, "Error")

txt_mno.SetFocus

ElseIf txt_mno = "" Then

X = MsgBox("PLEASE ENTER METER NUMBER", vbCritical, "Error")

txt_mno.SetFocus

ElseIf Combo_phase = "" Then

X = MsgBox("PLEASE ENTER PHASE", vbCritical, "Error")

Combo_phase.SetFocus

ElseIf Combo_ssec = "" Then

X = MsgBox("PLEASE ENTER SUPPLY SECTION", vbCritical, "Error")

Combo_ssec.SetFocus

ElseIf Combo_tarrif = "" Then

X = MsgBox("PLASE ENTER TARRIF", vbCritical, "Error")

Combo_tarrif.SetFocus

ElseIf Combo_cload.Text = "" Then

X = MsgBox("PLEASE ENTER CONNECTION LOAD", vbCritical, "Error")

Combo_cload.SetFocus

Else

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = " update customer set cust_name='" + txt_name.Text + "',phone_no=" +


txt_phno.Text + ",email_id='" + txt_eid.Text + "',cust_add='" + txt_add.Text + "',district='"

192
ELECTRICITY BILLING SYSTEM

+ txt_dist.Text + "',p_code=" + txt_pin.Text + ",sub_division='" + txt_sdiv.Text + "' where


cust_id='" + txt_cid.Text + "'"

sql1 = "update meter set m_no=" + txt_mno.Text + ",phase=" + Combo_phase.Text +


",conn_date='" + Format(dtp_cdate.value, "dd mmm yy") + "',supp_section='" +
Combo_ssec.Text + "',tarrif='" + Combo_tarrif.Text + "',c_load = '" + Combo_cload.Text +
"' where cust_id='" + txt_cid.Text + "'"

c.Execute (sql)

c.Execute (sql1)

X = MsgBox("RECORD UPDATED SUCCESSFULLY", vbInformation + vbOKOnly, "Consumer


Record") = vbOK

Call cmd_reset_Click

cmd_update.Enabled = False

txt_cid.SetFocus

End If

End Sub

Private Sub Combo_phase_Click()

Combo_cload.Clear

If Combo_phase = "" Then Exit Sub

If Combo_phase = 1 Then

For i = 1 To 7

Combo_cload.AddItem i

Next

ElseIf Combo_phase = 3 Then

For i = 5 To 10

Combo_cload.AddItem i

Next

193
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Consumer Record") =


vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cid = UCase(Trim(txt_cid))

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select * from customer,meter where customer.cust_id='" + txt_cid.Text + "' and


meter.cust_id='" + txt_cid.Text + "'"

On Error GoTo X

Set r = c.Execute(sql)

Frame1.Enabled = True

Frame2.Enabled = True

194
ELECTRICITY BILLING SYSTEM

cmd_update.Enabled = True

txt_div.Text = r.Fields("DIVISION")

txt_name.Text = r.Fields("CUST_NAME")

If IsNull(r.Fields("phone_no")) Then

txt_phno.Text = ""

Else

txt_phno.Text = r.Fields("PHONE_NO")

End If

If IsNull(r.Fields("EMAIL_ID")) Then

txt_eid.Text = ""

Else

txt_eid.Text = r.Fields("EMAIL_ID")

End If

txt_add.Text = r.Fields("CUST_ADD")

txt_dist.Text = r.Fields("DISTRICT")

txt_pin.Text = r.Fields("P_CODE")

txt_mno.Text = r.Fields("M_NO")

dtp_cdate.value = r.Fields("conn_date")

If r.Fields("phase") = 1 Then

Combo_phase.ListIndex = 0

Else

Combo_phase.ListIndex = 1

End If

195
ELECTRICITY BILLING SYSTEM

txt_sdiv.Text = r.Fields("sub_division")

Combo_ssec.Clear

If txt_sdiv.Text = "DARBHANGA" Then

Combo_ssec.AddItem "DONAR"

Combo_ssec.AddItem "BELA"

ElseIf txt_sdiv.Text = "LAHERIASARAI" Then

Combo_ssec.AddItem "LAXMINAGAR"

Combo_ssec.AddItem "BENTA"

Combo_ssec.AddItem "PANDASARAI"

End If

If (r.Fields("supp_section") = "DONAR") Or (r.Fields("supp_section") = "LAXMINAGAR")


Then

Combo_ssec.ListIndex = 0

ElseIf (r.Fields("supp_section") = "BELA") Or (r.Fields("supp_section") = "BENTA") Then

Combo_ssec.ListIndex = 1

ElseIf r.Fields("supp_section") = "PANDASARAI" Then

Combo_ssec.ListIndex = 2

End If

If r.Fields("tarrif") = "DOMESTIC" Then

Combo_tarrif.ListIndex = 0

Else

Combo_tarrif.ListIndex = 1

End If

Call Combo_phase_Click

For i = 0 To Combo_cload.ListCount

196
ELECTRICITY BILLING SYSTEM

If r.Fields("c_load") = Combo_cload.List(i) Then

Combo_cload.ListIndex = i

txt_name.SetFocus

Exit Sub

End If

Next

Exit Sub

X:

X = MsgBox("CONSUMER DOES NOT EXIST", vbInformation + vbOKOnly, "Consumer


Record") = vbOK

txt_cid.Text = ""

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

Private Sub txt_eid_LostFocus()

txt_eid.Text = Trim(txt_eid.Text)

conn

sql = "select email_id from customer"

Set r = c.Execute(sql)

197
ELECTRICITY BILLING SYSTEM

Do While Not r.EOF

If r.Fields(0) = txt_eid.Text Then

X = MsgBox("EMAIL ALREADY EXIST", vbInformation + vbOKOnly, "Consumer") = vbOK

txt_eid.Text = ""

txt_eid.SetFocus

Exit Sub

Else

r.MoveNext

End If

Loop

End Sub

Private Sub txt_name_Change()

If Len(txt_name) >= 30 Then

X = MsgBox("LENGTH SHOULD NOT EXCEED THAN 30", vbCritical, "Error")

End If

End Sub

Private Sub txt_name_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_phno.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii
<> 8 And KeyAscii <> 32 Then

198
ELECTRICITY BILLING SYSTEM

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_name.SetFocus

End If

End Sub

Private Sub txt_phno_Change()

If Len(txt_phno) > 10 Then

X = MsgBox("LENGTH SHOULD NOT EXCEED THAN 10", vbCritical, "Error")

End If

End Sub

Private Sub txt_name_LostFocus()

txt_name.Text = UCase(Trim(txt_name.Text))

End Sub

Private Sub txt_phno_KeyPress(KeyAscii As Integer)

If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 13) Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_phno.SetFocus

End If

If KeyAscii = 13 Then

txt_eid.SetFocus

199
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub txt_phno_LostFocus()

If Len(txt_phno) <> 10 And Len(txt_phno) <> 0 Then

X = MsgBox("PLEASE ENTER A VALID PHONE NUMBER", vbCritical, "Error")

txt_phno.Text = ""

txt_phno.SetFocus

Exit Sub

End If

conn

Set r = New ADODB.Recordset

sql = "select phone_no from customer"

Set r = c.Execute(sql)

Do While Not r.EOF

If r.Fields(0) = txt_phno.Text Then

X = MsgBox("PHONE NUMBER ALREADY EXIST", vbInformation + vbOKOnly,


"Consumer") = vbOK

txt_phno.Text = ""

txt_phno.SetFocus

Exit Sub

Else

r.MoveNext

End If

Loop

200
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_pin_KeyPress(KeyAscii As Integer)

If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii
<> 13 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_pin.SetFocus

End If

If KeyAscii = 13 Then

txt_sdiv.SetFocus

End If

End Sub

Private Sub txt_pin_LostFocus()

If Len(txt_pin) <> 6 And Len(txt_pin) <> 0 Then

X = MsgBox("PLEASE ENTER A VALID PIN CODE", vbCritical, "Error")

txt_pin.Text = ""

txt_pin.SetFocus

End If

End Sub

Private Sub Combo_ssec_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Combo_tarrif.SetFocus

201
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub Combo_cload_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

cmd_update.SetFocus

End If

End Sub

Private Sub combo_tarrif_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Combo_cload.SetFocus

End If

End Sub

Private Sub dtp_cdate_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Combo_ssec.SetFocus

End If

End Sub

Private Sub txt_add_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_dist.SetFocus

End If

202
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_add_LostFocus()

txt_add = Trim(UCase(txt_add))

End Sub

Private Sub txt_dist_KeyPress(KeyAscii As Integer)

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii <>
8 And KeyAscii <> 32 And KeyAscii <> 13 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_dist.SetFocus

End If

If KeyAscii = 13 Then

txt_pin.SetFocus

End If

End Sub

Private Sub txt_dist_LostFocus()

txt_dist = Trim(UCase(txt_dist))

End Sub

Private Sub txt_eid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_add.SetFocus

203
ELECTRICITY BILLING SYSTEM

End If

End Sub

Private Sub combo_phase_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

dtp_cdate.SetFocus

End If

End Sub

Private Sub Txt_sdiv_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_mno.SetFocus

End If

End Sub

204
ELECTRICITY BILLING SYSTEM

UPDATE METER READING

Private Sub cmd_bill_Click()

frm_bill.txt_cid.Text = txt_cid.Text

frm_bill.Show

Call cmd_reset_Click

Unload frm_updmeter

End Sub

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_reset_Click()

txt_cid = ""

txt_name = ""

txt_mno = ""

txt_phase = ""

txt_condate = ""

txt_div = ""

txt_sdiv = ""

txt_ssec = ""

txt_tarrif = ""

205
ELECTRICITY BILLING SYSTEM

txt_eid.Text = ""

txt_pdate = ""

txt_pread = ""

txt_punit = ""

dtp_cdate.value = Now

txt_cread = ""

txt_cunit = ""

txt_cid.SetFocus

Call Form_Load

End Sub

Private Sub cmd_update_Click()

If txt_cread.Text = "" Then

X = MsgBox("PLEASE ENTER CURRENT READING", vbCritical)

txt_cread.SetFocus

Else

conn

sql = "select max(b_id) from payment where cust_id='" + txt_cid.Text + "' "

Set r = c.Execute(sql)

sql = "select b_id from bill where cust_id='" + txt_cid.Text + "' and bill_month=(select
to_char(p_date,'MON YYYY') from measure where cust_id='" + txt_cid.Text + "' and
to_char(c_date,'MON YYYY')=to_char((select sysdate from dual),'MON YYYY'))"

On Error GoTo X

Set r1 = c.Execute(sql)

If IsNull(r1.Fields(0)) Then

206
ELECTRICITY BILLING SYSTEM

GoTo X

End If

If r.Fields(0) = r1.Fields(0) Then

X = MsgBox("CANNOT UPDATED", vbCritical, "Error")

txt_cid.Text = ""

txt_cid.SetFocus

Call cmd_reset_Click

Exit Sub

End If

X:

sql = "delete from bill where cust_id='" + txt_cid.Text + "' and bill_month=(select
to_char(p_date,'MON YYYY') from measure where cust_id='" + txt_cid.Text + "' and
to_char(c_date,'MON YYYY')=to_char((select sysdate from dual),'MON YYYY'))"

c.Execute (sql)

sql = "delete from calculate where cust_id='" + txt_cid.Text + "' and month=(select
to_char(p_date,'MON YYYY') from measure where cust_id='" + txt_cid.Text + "' and
to_char(c_date,'MON YYYY')=to_char((select sysdate from dual),'MON YYYY'))"

c.Execute (sql)

X = MsgBox("ARE YOU SURE TO UPDATE?", vbYesNo + vbQuestion) = vbYes

If X = True Then

sql = "update measure set c_date='" + Format(dtp_cdate, "dd MMM yy") + "',c_reading="
+ txt_cread + ",c_unit=" + txt_cunit + " where cust_id='" + txt_cid.Text + "' and p_date='"
+ Format(txt_pdate.Text, "dd MMM yy") + "'"

Set r = c.Execute(sql)

X = MsgBox("RECORD UPDATED", vbInformation + vbOKOnly, "Meter Record Update") =


vbOK

207
ELECTRICITY BILLING SYSTEM

cmd_update.Enabled = False

cmd_bill.Enabled = True

cmd_exit.Enabled = False

cmd_reset.Enabled = False

cmd_bill.SetFocus

Adodc1.RecordSource = "select * from measure where cust_id='" + txt_cid.Text + "' and


to_char(c_date,'MON YYYY')=to_char((select sysdate from dual),'MON YYYY')"

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "EMPLOYEE ID"

DataGrid1.Columns(1).Caption = "CONSUMER ID"

DataGrid1.Columns(2).Caption = "METER NO."

DataGrid1.Columns(3).Caption = "PREV. DATE"

DataGrid1.Columns(4).Caption = "PREV. READING"

DataGrid1.Columns(5).Caption = "PREV. UNIT"

DataGrid1.Columns(6).Caption = "CURR. DATE"

DataGrid1.Columns(7).Caption = "CURR. READING"

DataGrid1.Columns(8).Caption = "CURR. UNIT"

Else

Exit Sub

End If

End If

End Sub

208
ELECTRICITY BILLING SYSTEM

Private Sub dtp_cdate_LostFocus()

If dtp_cdate.value > Now Then

X = MsgBox("INVALID DATE", vbCritical)

dtp_cdate.SetFocus

End If

End Sub

Private Sub Form_Load()

cmd_update.Enabled = False

cmd_bill.Enabled = False

cmd_reset.Enabled = True

cmd_exit.Enabled = True

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Update Meter Reading") =


vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

209
ELECTRICITY BILLING SYSTEM

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cid = UCase(Trim(txt_cid.Text))

conn

sql = "select distinct cust_id from measure where cust_id='" + txt_cid.Text + "'"

On Error GoTo y

Set r = c.Execute(sql)

sql = "select max(c_date) from measure where cust_id='" + r.Fields(0) + "' and
to_char(c_date,'MON YYYY')=to_char((select sysdate from dual),'MON YYYY')"

Set r1 = c.Execute(sql)

sql = "select * from measure where cust_id='" + txt_cid.Text + "' and (select sysdate from
dual) between '" & Format(r1.Fields(0), "dd MMM yy") & "' and '" & Format(r1.Fields(0) +
15, "dd MMM yy") & "'"

On Error GoTo xx

Set r = c.Execute(sql)

txt_eid.Text = emp_id

txt_cid.Text = r.Fields("cust_id")

txt_mno.Text = r.Fields("m_no")

txt_pdate.Text = r.Fields("p_date")

txt_pread.Text = r.Fields("p_reading")

txt_punit.Text = r.Fields("p_unit")

dtp_cdate.value = r.Fields("c_date")

txt_cread.Text = r.Fields("c_reading")

txt_cunit.Text = r.Fields("c_unit")

210
ELECTRICITY BILLING SYSTEM

sql = "select * from customer,meter where customer.cust_id='" + r.Fields("cust_id") + "'


And customer.cust_id = meter.cust_id"

Set r = c.Execute(sql)

txt_name.Text = r.Fields("cust_name")

txt_mno.Text = r.Fields("m_no")

txt_phase.Text = r.Fields("phase")

txt_condate.Text = r.Fields("conn_date")

txt_div.Text = r.Fields("division")

txt_sdiv.Text = r.Fields("sub_division")

txt_ssec.Text = r.Fields("supp_section")

txt_tarrif.Text = r.Fields("tarrif")

dtp_cdate.SetFocus

cmd_update.Enabled = True

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARCTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

Exit Sub

xx:

X = MsgBox("CANNOT BE UPDATED", vbCritical, "Error")

txt_cid.Text = ""

txt_cid.SetFocus

211
ELECTRICITY BILLING SYSTEM

Exit Sub

y:

y = MsgBox("CONSUMER DOES NOT EXIST", vbInformation + vbOKOnly, "Meter Update")


= vbOK

txt_cid.Text = ""

txt_cid.SetFocus

End Sub

Private Sub txt_cread_Change()

If txt_cread.Text = "" Then

txt_cunit.Text = ""

Exit Sub

End If

txt_cunit = Val(txt_cread) - Val(txt_pread)

End Sub

Private Sub txt_cread_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If txt_cread.Text = "" Then Exit Sub

cmd_update.SetFocus

End If

End Sub

Private Sub txt_cread_LostFocus()

Call txt_cread_KeyPress(13)

End Sub

212
ELECTRICITY BILLING SYSTEM

UPDATED BILL GENERATION

Dim r3 As ADODB.Recordset

Dim sql3 As String

Dim d As Date

Dim p As Double

Dim bid As Integer

Dim date1 As Date

Dim du As Double

Dim m1 As String

Dim d1 As Date

Dim d2 As Date

Private Sub cmd_print_Click()

conn

sql = "delete from temp"

Set r = c.Execute(sql)

sql = "insert into temp values(" + txt_bid + ",'" + Format(txt_bdate, "dd MMM yyyy") + "','"
+ txt_bmonth + "','" + Format(txt_ddate, "dd MMM yyyy") + "', '" + txt_cid + "','" +
txt_name + "','" + txt_add + "','" + txt_div + "','" + txt_sdiv + "'," + txt_mno + ",'" +
txt_tarrif + "'," + txt_phase + "," + txt_cload + ",'" + txt_eid.Text + "','" + txt_ename + "','"
+ txt_eadd + "'," + txt_ephone + ",'" + Format(txt_pdate, "dd MMM yyyy") + "'," +
txt_pread + "," + txt_punit + ",'" + Format(txt_cdate, "dd MMM yyyy") + "'," + txt_cread +
"," + txt_cunit + "," + txt_dues + "," + txt_ech + "," + txt_dpscurr + "," + txt_fxdch + "," +
txt_ed + "," + txt_mrent + "," + txt_tass + "," + txt_rebate + "," + txt_gtot + ",'" +
Format(lbl_d1.Caption, "dd MMM yyyy") + "','" + Format(lbl_d2.Caption, "dd MMM yyyy")
+ "'," + txt_c1 + "," + txt_c2 + "," + txt_c3 + ",'" + txt_rno + "','" + txt_date + "','" + txt_amt
+ "')"

213
ELECTRICITY BILLING SYSTEM

Set r = c.Execute(sql)

If DataEnvironment1.rsCommand2.State = 1 Then DataEnvironment1.rsCommand2.Close

Unload Me

DataReport2.Show

End Sub

Private Sub Form_Activate()

txt_cid.SetFocus

End Sub

Private Sub Form_Load()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select max(b_id) from bill"

Set r = c.Execute(sql)

If IsNull(r.Fields(0)) Then

txt_bid = 1

Else

id = r.Fields(0) + 1

txt_bid.Text = id

End If

txt_bdate = Format(Now, "dd MMM yyyy")

214
ELECTRICITY BILLING SYSTEM

txt_eid.Text = emp_id

d = txt_bdate.Text

lbl_d1.Caption = Format(d + 14, "dd MMM yyyy")

d = lbl_d1.Caption

lbl_d2.Caption = Format(d + 7, "dd MMM yyyy")

lbl_d3.Caption = "After" + " " + Format(d + 7, "dd MMM yyyy")

txt_ddate.Text = Format(lbl_d1.Caption, "dd MMM yyyy")

cmd_print.Enabled = False

End Sub

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cid = UCase(Trim(txt_cid))

conn

'============================ CHECK BILL GENERATION


================================

sql = "select max(c_reading) from calculate where cust_id='" + txt_cid.Text + "'"

Set r = c.Execute(sql)

sql1 = "select max(c_reading) from measure where cust_id='" + txt_cid.Text + "'"

Set r1 = c.Execute(sql1)

If IsNull(r.Fields(0)) Then GoTo next1 '-------------- if bill is not generted

If IsNull(r1.Fields(0)) Then GoTo next1 '-------------- when no unit is consumed (1st time)

If r.Fields(0) = r1.Fields(0) Then

215
ELECTRICITY BILLING SYSTEM

X = MsgBox("BILL ALRADY GENERATED", vbInformation + vbOKOnly, "Energy Bill") =


vbOK

Exit Sub

End If

'================= CHECK NEW CUSTOMER


=====================

next1:

sql = "select count(c_unit) from customer,meter,measure where customer.cust_id='" +


txt_cid.Text + "' and meter.cust_id='" + txt_cid.Text + "' and measure.cust_id='" +
txt_cid.Text + "'"

Set r = c.Execute(sql)

If (r.Fields(0) = 0) Then

X = MsgBox("NEW CONSUMER", vbInformation + vbOKOnly, "Energy Bill") = vbOK

Exit Sub

Else

'===================================================
=== DUES/RECEIPT DETAIL ENTRY ==============================

sql = "select * FROM bill where B_ID=(SELECT MAX(B_ID) FROM BILL WHERE CUST_ID=
'" + txt_cid.Text + "')"

sql1 = "select * from payment where b_id=(select max(b_id) from payment where
cust_id='" + txt_cid.Text + "')"

Set r = c.Execute(sql)

Set r1 = c.Execute(sql1)

'============================== FIRST TIME RECEIPT DETAIL


====================

If r.BOF Or r.EOF Then

216
ELECTRICITY BILLING SYSTEM

txt_rno.Text = "XXXXX"

txt_date.Text = "XXXXX"

txt_amt.Text = "XXXXX"

txt_dues.Text = 0

GoTo n1

End If

'===================================================
============================

'========================= IF NO ANY PREVIOUS RECEIPT DETAIL(2ND


TIME BILL AND NO PAYMENT) ======================

If r1.BOF Or r1.EOF Then

txt_rno.Text = "XXXXX"

txt_date.Text = "XXXXX"

txt_amt.Text = "XXXXX"

GoTo n2

End If

'===================================================
====================================================
=====

'====================================== PREVIOUS RECEIPT


DETAIL ===================

txt_rno.Text = r1.Fields("r_no")

txt_date.Text = r1.Fields("r_date")

txt_amt.Text = r1.Fields("amount")

'===================================================
===============================

217
ELECTRICITY BILLING SYSTEM

If IsNull(r1.Fields("b_id")) Then

bid = 0

Else

bid = r1.Fields("b_id")

End If

n2:

date1 = txt_bdate.Text

If r.Fields("b_id") <> bid Then

sql3 = New ADODB.Connection

Set r3 = New ADODB.Recordset

sql3 = "select count(dues) from payment where b_id=(select max(b_id) from payment
where cust_id='" + txt_cid.Text + "')"

Set r3 = c.Execute(sql3)

If (r3.Fields(0) = 0) Then

du = 0

Else

du = r1.Fields("dues")

End If

txt_dues.Text = r.Fields("gross_total") + du

Else

txt_dues.Text = r1.Fields("dues")

End If

'============================= DUES/RECEIPT DETAIL END


==================================

218
ELECTRICITY BILLING SYSTEM

'============================ INFORMATION ENTRY


====================================

n1:

Set r = New ADODB.Recordset

sql = "select * from customer,meter,measure where customer.cust_id='" + txt_cid.Text + "'


and meter.cust_id='" + txt_cid.Text + "' and measure.cust_id='" + txt_cid.Text + "' and
measure.c_reading=(select max(c_reading) from measure where measure.cust_id='" +
txt_cid.Text + "' )"

Set r = c.Execute(sql)

'======================== CUSTOMER INFORMATION


===============================

txt_div.Text = r.Fields("DIVISION")

txt_sdiv.Text = r.Fields("sub_division")

txt_name.Text = r.Fields("CUST_NAME")

txt_add.Text = r.Fields("CUST_ADD")

txt_mno.Text = r.Fields("M_NO")

txt_tarrif.Text = r.Fields("tarrif")

txt_phase.Text = r.Fields("phase")

txt_cload.Text = r.Fields("c_load")

'===================================================
==========================

'============================ PREVIOUS READING DETAIL


==================================

txt_pdate.Text = r.Fields("p_date")

txt_pread.Text = r.Fields("p_reading")

219
ELECTRICITY BILLING SYSTEM

txt_punit.Text = r.Fields("p_unit")

txt_cdate.Text = r.Fields("c_date")

txt_cread.Text = r.Fields("c_reading")

txt_cunit.Text = r.Fields("c_unit")

txt_bmonth = UCase(Format(txt_pdate.Text, "MMM yyyy"))

sql = "select * from employee where e_id='" + txt_eid.Text + "'"

Set r = c.Execute(sql)

txt_ename.Text = r.Fields("e_nm")

txt_eadd.Text = r.Fields("e_add")

txt_ephone.Text = r.Fields("e_phno")

'================================== INFORMATION END


=======================================

'=================================== CALCULATION
====================================================

'===================================================
=== DOMESTIC CALCULATION
=====================================

If txt_tarrif.Text = "DOMESTIC" Then

sql = "select * from domestic"

Set r = c.Execute(sql)

If (txt_cunit < 101) Then

220
ELECTRICITY BILLING SYSTEM

txt_ech.Text = (r.Fields("d_upto100") * txt_cunit.Text)

ElseIf (txt_cunit < 201) Then

txt_ech.Text = (r.Fields("d_upto200") * txt_cunit.Text)

ElseIf (txt_cunit < 301) Then

txt_ech.Text = (r.Fields("d_upto300") * txt_cunit.Text)

Else

txt_ech.Text = (r.Fields("d_above300") * txt_cunit.Text)

End If

txt_ed.Text = (txt_ech.Text * r.Fields("d_ed") / 100)

txt_rebate.Text = (txt_cunit.Text * r.Fields("d_rebate") / 100)

txt_dpscurr.Text = (txt_dues.Text * r.Fields("d_dps") / 100)

p = r.Fields("d_dps")

For i = 1 To 10

'========================== IF PHASE=1 AND CONNECTION LOAD


CALCULATION =============================

If txt_phase = 1 And txt_cload.Text = i Then

txt_fxdch.Text = (r.Fields("d_fc") + (r.Fields("d_akw") * (i - 1)))

txt_mrent.Text = r.Fields("d_mrent")

ElseIf txt_phase.Text = 3 And txt_cload.Text = i Then

'===================================================
================================================

'========================== IF PHASE=3 AND CONNECTION LOAD


CALCULATION =============================

txt_fxdch.Text = (r.Fields("d_fc3") + (r.Fields("d_akw3") * (i - 1)))

221
ELECTRICITY BILLING SYSTEM

txt_mrent.Text = r.Fields("d_mrent3")

End If

'===================================================
==================================================

Next

'================================= DOMESTIC CALCULATION END


===================================================

'=================================================
NON-DOMESTIC CALCULATION
====================================

ElseIf txt_tarrif.Text = "NON-DOMESTIC" Then

sql = "select * from non_domestic"

Set r = c.Execute(sql)

If (txt_cunit < 101) Then

txt_ech.Text = (r.Fields("n_upto100") * txt_cunit.Text)

ElseIf (txt_cunit < 201) Then

txt_ech.Text = (r.Fields("n_upto200") * txt_cunit.Text)

Else

txt_ech.Text = (r.Fields("d_above200") * txt_cunit.Text)

End If

txt_ed.Text = (txt_ech.Text * r.Fields("n_ed") / 100)

txt_rebate.Text = (txt_cunit.Text * r.Fields("n_rebate") / 100)

txt_dpscurr.Text = (txt_dues.Text * r.Fields("n_dps") / 100)

p = r.Fields("n_dps")

For i = 1 To 10

222
ELECTRICITY BILLING SYSTEM

'=========================== IF PHASE=1 AND CONNECTION LOAD


CALCULATION ==============================

If txt_phase = 1 And txt_cload.Text = i Then

txt_fxdch.Text = (r.Fields("n_fc") + (r.Fields("n_akw") * (i - 1)))

txt_mrent.Text = r.Fields("n_mrent")

'===================================================
====================================================
===========

'======================================== IF PHASE =3 AND


CONNECTION LOAD CALCULATION
=================================

ElseIf txt_phase.Text = 3 And txt_cload.Text = i Then

txt_fxdch.Text = (r.Fields("n_fc3") + (r.Fields("n_akw3") * (i - 1)))

txt_mrent.Text = r.Fields("n_mrent3")

End If

'===================================================
====================================================
================

Next

End If

'===================================== NON-DOMESTIC
CALCULATION END ======================================

'===================================== TOTAL AND GROSS


TOTAL CALCULATE ==================================

223
ELECTRICITY BILLING SYSTEM

txt_tass.Text = Val(txt_ech.Text) + Val(txt_dpscurr) + Val(txt_fxdch) + Val(txt_ed) +


Val(txt_mrent)

txt_gtot = Val(txt_tass.Text) + Val(txt_dues.Text)

txt_c1.Text = txt_gtot.Text - txt_rebate.Text

txt_c2.Text = txt_gtot.Text

txt_c3.Text = txt_gtot.Text + (txt_gtot.Text * p / 100)

sql = "insert into calculate values('" + txt_eid.Text + "','" + txt_cid.Text + "'," +


txt_mno.Text + "," + txt_ech.Text + "," + txt_dpscurr.Text + "," + txt_fxdch.Text + "," +
txt_ed.Text + "," + txt_mrent.Text + "," + txt_tass.Text + "," + txt_rebate.Text + "," +
txt_gtot.Text + "," + txt_dues.Text + ",'" + txt_bmonth.Text + "','" + Format(txt_cdate.Text,
"dd MMM yyyy") + "'," + txt_cread.Text + "," + txt_cunit + ")"

sql1 = "insert into bill values('" + txt_eid.Text + "','" + txt_cid.Text + "'," + txt_mno.Text +
"," + txt_bid.Text + ",'" + txt_bdate.Text + "','" + txt_bmonth.Text + "'," + txt_gtot.Text +
",'" + lbl_d1.Caption + "','" + lbl_d2.Caption + "'," + txt_c1.Text + "," + txt_c2.Text + "," +
txt_c3.Text + ",'UN PAID')"

Set r = c.Execute(sql)

Set r = c.Execute(sql1)

X = MsgBox("RECORD SAVED SUCCESSFULLY", vbInformation + vbOKOnly, "Energy Bill")


= vbOK

cmd_print.Enabled = True

cmd_print.SetFocus

Exit Sub

'===================================================
====================================================
=

X:

X = MsgBox("USER NAME DOES NOT EXIST", vbInformation + vbOKOnly, "Energy Bill") =


vbOK

txt_cid.Text = ""

224
ELECTRICITY BILLING SYSTEM

Exit Sub

End If

Else

KeyAscii = 0

End If

End Sub

Private Sub txt_cid_LostFocus()

Call txt_cid_KeyPress(13)

End Sub

225
ELECTRICITY BILLING SYSTEM

SEARCHING CONSUMER RECORD

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_first_Click()

Adodc1.Recordset.MoveFirst

Call value

End Sub

Private Sub cmd_last_Click()

Adodc1.Recordset.MoveLast

Call value

End Sub

Private Sub cmd_next_Click()

On Error GoTo X

Adodc1.Recordset.MoveNext

Call value

Exit Sub

X:

X = MsgBox("LAST RECORD", vbInformation + vbOKOnly, "View Record") = vbOK

End Sub

226
ELECTRICITY BILLING SYSTEM

Private Sub cmd_previous_Click()

On Error GoTo X

Adodc1.Recordset.MovePrevious

Call value

Exit Sub

X:

X = MsgBox(" FIRST RECORD", vbInformation + vbOKOnly, "View Record") = vbOK

End Sub

Private Sub cmd_print_Click()

If DataEnvironment1.rsCommand6.State = 1 Then DataEnvironment1.rsCommand6.Close

DataEnvironment1.rsCommand6.Open Adodc1.RecordSource

DataReport4.Show

End Sub

Private Sub cmd_reset_Click()

Combo_search.ListIndex = -1

txt_search.Text = ""

txt_search.Visible = False

txt_cid.Text = ""

txt_name.Text = ""

txt_phno.Text = ""

txt_eid.Text = ""

txt_add.Text = ""

227
ELECTRICITY BILLING SYSTEM

txt_dist.Text = ""

txt_pin.Text = ""

txt_sdiv.Text = ""

txt_mno.Text = ""

txt_phase.Text = ""

txt_cdate.Text = ""

txt_ssec.Text = ""

txt_tarrif.Text = ""

txt_div.Text = ""

txt_cload.Text = ""

MonthView1.Visible = False

Call Form_Load

Combo_search.SetFocus

End Sub

Private Sub Combo_search_Click()

txt_search.Text = ""

txt_search.Visible = False

txt_cid.Text = ""

txt_name.Text = ""

txt_phno.Text = ""

txt_eid.Text = ""

txt_add.Text = ""

228
ELECTRICITY BILLING SYSTEM

txt_dist.Text = ""

txt_pin.Text = ""

txt_sdiv.Text = ""

txt_mno.Text = ""

txt_phase.Text = ""

txt_cdate.Text = ""

txt_ssec.Text = ""

txt_tarrif.Text = ""

txt_div.Text = ""

txt_cload.Text = ""

If Combo_search.Text = "CONSUMER ID" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

ElseIf Combo_search.Text = "METER NO." Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

229
ELECTRICITY BILLING SYSTEM

ElseIf Combo_search.Text = "CONSUMER NAME" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

ElseIf Combo_search.Text = "SUB DIVISION" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

ElseIf Combo_search.Text = "TARRIF" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

ElseIf Combo_search.Text = "CONNECTION DATE" Then

txt_search.Visible = True

MonthView1.Visible = False

230
ELECTRICITY BILLING SYSTEM

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = True

ElseIf Combo_search.Text = "CONNECTION MONTH" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

ElseIf Combo_search.Text = "CONNECTION YEAR" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

ElseIf Combo_search.Text = "SUPPLY SECTION" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

231
ELECTRICITY BILLING SYSTEM

ElseIf Combo_search.Text = "PHASE" Then

MonthView1.Visible = False

txt_search.Visible = True

txt_search.Text = ""

txt_search.SetFocus

txt_search.Locked = False

ElseIf Combo_search.Text = "ALL" Then

cmd_print.Enabled = True

cmd_print.SetFocus

Call rs

On Error GoTo X

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

232
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(14).Caption = "LOAD"

Call value

Exit Sub

X:

X = MsgBox("NO RECORD FOUND", vbInformation + vbOKOnly, "View Record") = vbOK

Call cmd_reset_Click

End If

End Sub

Private Sub Combo_search_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_search.SetFocus

End If

End Sub

Private Sub Form_Load()

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.phone_no,customer.email_id,customer.cust
_add,customer.district,customer.p_code,customer.division,customer.sub_division,meter.m_
no,meter.phase,meter.conn_date,meter.supp_section,meter.tarrif,meter.c_load from
customer,meter where customer.cust_id='0'"

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

233
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

cmd_print.Enabled = False

cmd_first.Enabled = False

cmd_last.Enabled = False

cmd_previous.Enabled = False

cmd_next.Enabled = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "View Consumer Record")


= vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

234
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)

txt_search.Text = MonthView1.value

MonthView1.Visible = False

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.phone_no,customer.email_id,customer.cust
_add,customer.district,customer.p_code,customer.division,customer.sub_division,meter.m_
no,meter.phase,meter.conn_date,meter.supp_section,meter.tarrif,meter.c_load from
customer,meter where customer.cust_id=meter.cust_id and customer.cust_id in (select
cust_id from customer where conn_date='" + Format(txt_search.Text, "dd MMM yy") + "')"

On Error GoTo xx

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

Call value

235
ELECTRICITY BILLING SYSTEM

Exit Sub

xx:

X = MsgBox("RECORD NOT AVAILABLE", vbInformation + vbOKOnly, "View Reord") =


vbOK

txt_cid.Text = ""

txt_name.Text = ""

txt_phno.Text = ""

txt_eid.Text = ""

txt_add.Text = ""

txt_dist.Text = ""

txt_pin.Text = ""

txt_sdiv.Text = ""

txt_mno.Text = ""

txt_phase.Text = ""

txt_cdate.Text = ""

txt_ssec.Text = ""

txt_tarrif.Text = ""

txt_div.Text = ""

txt_cload.Text = ""

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.phone_no,customer.email_id,customer.cust
_add,customer.district,customer.p_code,customer.division,customer.sub_division,meter.m_
no,meter.phase,meter.conn_date,meter.supp_section,meter.tarrif,meter.c_load from
customer,meter where customer.cust_id='0'"

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

236
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

cmd_print.Enabled = False

cmd_first.Enabled = False

cmd_last.Enabled = False

cmd_previous.Enabled = False

cmd_next.Enabled = False

txt_search.Text = ""

txt_search.SetFocus

End Sub

Private Sub txt_search_Change()

If Combo_search.Text = "CONNECTION DATE" Then

txt_search.Text = Format(txt_search.Text, "dd MMM yyyy")

End If

237
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_search_GotFocus()

Call rs

If Combo_search.Text = "CONNECTION DATE" Then

MonthView1.Visible = True

End If

End Sub

Private Sub txt_search_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

MonthView1.Visible = False

If txt_search.Text = "" Then

X = MsgBox("PLEASE ENTER THE DATA", vbCritical, "Error")

Exit Sub

End If

txt_search.Text = UCase(Trim(txt_search.Text))

Call rs

On Error GoTo X

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

238
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

Call value

Else

Call valid(KeyAscii)

End If

Exit Sub

X:

X = MsgBox("NO RECORD FOUND", vbInformation + vbOKOnly, "View Record") = vbOK

txt_cid.Text = ""

txt_name.Text = ""

txt_phno.Text = ""

txt_eid.Text = ""

txt_add.Text = ""

txt_dist.Text = ""

txt_pin.Text = ""

txt_sdiv.Text = ""

txt_mno.Text = ""

txt_phase.Text = ""

txt_cdate.Text = ""

239
ELECTRICITY BILLING SYSTEM

txt_ssec.Text = ""

txt_tarrif.Text = ""

txt_div.Text = ""

txt_cload.Text = ""

MonthView1.Visible = False

cmd_print.Enabled = False

cmd_first.Enabled = False

cmd_last.Enabled = False

cmd_previous.Enabled = False

cmd_next.Enabled = False

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.phone_no,customer.email_id,customer.cust
_add,customer.district,customer.p_code,customer.division,customer.sub_division,meter.m_
no,meter.phase,meter.conn_date,meter.supp_section,meter.tarrif,meter.c_load from
customer,meter where customer.cust_id='0'"

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

240
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

txt_search.Text = ""

txt_search.SetFocus

End Sub

Public Sub value()

txt_cid.Text = Adodc1.Recordset.Fields("cust_ID")

txt_div.Text = Adodc1.Recordset.Fields("DIVISION")

txt_name.Text = Adodc1.Recordset.Fields("cust_name")

If Not IsNull(Adodc1.Recordset.Fields("phone_no")) Then

txt_phno.Text = Adodc1.Recordset.Fields("PHONE_NO")

End If

If Not IsNull(Adodc1.Recordset.Fields("email_id")) Then

txt_eid.Text = Adodc1.Recordset.Fields("EMAIL_ID")

End If

txt_add.Text = Adodc1.Recordset.Fields("cust_add")

txt_dist.Text = Adodc1.Recordset.Fields("DISTRICT")

txt_pin.Text = Adodc1.Recordset.Fields("P_CODE")

txt_mno.Text = Adodc1.Recordset.Fields("M_NO")

txt_cdate.Text = Adodc1.Recordset.Fields("CONN_DATE")

'txt_volt.Text = Adodc1.Recordset.Fields("SUPPLY_VOLTAGE")

txt_sdiv.Text = Adodc1.Recordset.Fields("SUB_DIVISION")

txt_phase.Text = Adodc1.Recordset.Fields("PHASE")

241
ELECTRICITY BILLING SYSTEM

txt_tarrif.Text = Adodc1.Recordset.Fields("TARRIF")

txt_cload.Text = Adodc1.Recordset.Fields("C_LOAD")

txt_ssec.Text = Adodc1.Recordset.Fields("SUPP_SECTION")

cmd_print.Enabled = True

cmd_first.Enabled = True

cmd_last.Enabled = True

cmd_previous.Enabled = True

cmd_next.Enabled = True

End Sub

Public Sub rs()

conn

If Combo_search.Text = "CONSUMER ID" Then

txt_search.MaxLength = 0

'txt_search.Locked = False

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.phone_no,customer.email_id,customer.cust
_add ,customer.district,customer.p_code,customer.division,customer.sub_division
,meter.m_no,meter.phase,meter.conn_date,meter.supp_section,meter.tarrif,meter.c_load
from customer,meter where customer.cust_id='" + txt_search.Text + "' and
customer.cust_id=meter.cust_id"

txt_search.MaxLength = 10

ElseIf Combo_search.Text = "METER NO." Then

txt_search.MaxLength = 0

Adodc1.RecordSource = "select customer.cust_id,customer.cust_name,customer.phone_no


,customer.email_id,customer.cust_add ,customer.district
,customer.p_code,customer.division,customer.sub_division,meter.m_no ,meter.phase
,meter.conn_date,meter.supp_section ,meter.tarrif ,meter.c_load from customer,meter

242
ELECTRICITY BILLING SYSTEM

where meter.cust_id=(select cust_id from meter where m_no=" + txt_search.Text + ") and
customer.cust_id=meter.cust_id"

txt_search.MaxLength = 8

ElseIf Combo_search.Text = "CONSUMER NAME" Then

txt_search.MaxLength = 0

Adodc1.RecordSource = "select customer.cust_id,customer.cust_name ,customer.phone_no


,customer.email_id ,customer.cust_add ,customer.district ,customer.p_code
,customer.division ,customer.sub_division ,meter.m_no ,meter.phase ,meter.conn_date
,meter.supp_section ,meter.tarrif ,meter.c_load from customer,meter where
customer.cust_id=meter.cust_id and customer.cust_id in (select cust_id from customer
where cust_name='" + txt_search.Text + "')"

txt_search.MaxLength = 30

ElseIf Combo_search.Text = "SUB DIVISION" Then

txt_search.MaxLength = 0

Adodc1.RecordSource = "select customer.cust_id,customer.cust_name


,customer.phone_no,customer.email_id ,customer.cust_add ,customer.district
,customer.p_code ,customer.division ,customer.sub_division
,meter.m_no,meter.phase,meter.conn_date,meter.supp_section ,meter.tarrif,meter.c_load
from customer,meter where customer.cust_id=meter.cust_id and customer.cust_id in
(select cust_id from customer where sub_division='" + txt_search.Text + "')"

txt_search.MaxLength = 25

ElseIf Combo_search.Text = "TARRIF" Then

txt_search.MaxLength = 0

Adodc1.RecordSource = "select customer.cust_id,customer.cust_name ,customer.phone_no


,customer.email_id ,customer.cust_add,customer.district,customer.p_code
,customer.division ,customer.sub_division ,meter.m_no
,meter.phase,meter.conn_date,meter.supp_section ,meter.tarrif,meter.c_load from
customer,meter where customer.cust_id=meter.cust_id and customer.cust_id in (select
cust_id from customer where tarrif='" + txt_search.Text + "')"

txt_search.MaxLength = 15

ElseIf Combo_search.Text = "CONNECTION DATE" Then

243
ELECTRICITY BILLING SYSTEM

txt_search.MaxLength = 0

Adodc1.RecordSource = "select customer.cust_id ,customer.cust_name ,customer.phone_no


,customer.email_id,customer.cust_add ,customer.district,customer.p_code
,customer.division ,customer.sub_division ,meter.m_no ,meter.phase ,meter.conn_date
,meter.supp_section,meter.tarrif,meter.c_load from customer,meter where
customer.cust_id=meter.cust_id and customer.cust_id in (select cust_id from customer
where conn_date='" + Format(txt_search.Text, "dd MMM yy") + "')"

ElseIf Combo_search.Text = "CONNECTION MONTH" Then

txt_search.MaxLength = 0

Adodc1.RecordSource = "select customer.cust_id,customer.cust_name


,customer.phone_no,customer.email_id ,customer.cust_add ,customer.district
,customer.p_code ,customer.division ,customer.sub_division,meter.m_no
,meter.phase,meter.conn_date,meter.supp_section ,meter.tarrif ,meter.c_load from
customer,meter where customer.cust_id=meter.cust_id and customer.cust_id in (select
cust_id from customer where to_char(conn_date,'MON YY')='" + txt_search.Text + "')"

txt_search.MaxLength = 6

ElseIf Combo_search.Text = "CONNECTION YEAR" Then

txt_search.MaxLength = 0

Adodc1.RecordSource = "select customer.cust_id ,customer.cust_name ,customer.phone_no


,customer.email_id,customer.cust_add ,customer.district
,customer.p_code,customer.division ,customer.sub_division ,meter.m_no ,meter.phase
,meter.conn_date ,meter.supp_section ,meter.tarrif,meter.c_load from customer,meter
where customer.cust_id=meter.cust_id and customer.cust_id in (select cust_id from
customer where to_char(conn_date,'YYYY')='" + txt_search.Text + "')"

txt_search.MaxLength = 4

ElseIf Combo_search.Text = "PHASE" Then

txt_search.MaxLength = 0

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.phone_no,customer.email_id,customer.cust

244
ELECTRICITY BILLING SYSTEM

_add,customer.district,customer.p_code,customer.division,customer.sub_division,meter.m_
no,meter.phase,meter.conn_date,meter.supp_section,meter.tarrif,meter.c_load from
customer,meter where customer.cust_id=meter.cust_id and customer.cust_id in (select
cust_id from customer where phase=" + txt_search.Text + ")"

txt_search.MaxLength = 1

ElseIf Combo_search.Text = "ALL" Then

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.phone_no,customer.email_id,customer.cust
_add,customer.district,customer.p_code,customer.division,customer.sub_division,meter.m_
no,meter.phase,meter.conn_date,meter.supp_section,meter.tarrif,meter.c_load from
customer,meter where customer.cust_id=meter.cust_id"

End If

End Sub

Public Function valid(KeyAscii)

If Combo_search.Text = "SUB DIVISION" Or Combo_search.Text = "TARRIF" Then

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii <>
8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_search.SetFocus

End If

ElseIf Combo_search.Text = "METER NO." Or Combo_search.Text = "PHASE" Or


Combo_search.Text = "CONNECTION YEAR" Then

If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_search.SetFocus

245
ELECTRICITY BILLING SYSTEM

End If

ElseIf Combo_search.Text = "CONSUMER NAME" Then

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And KeyAscii <>
8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_search.SetFocus

End If

ElseIf Combo_search.Text = "CONNECTION MONTH" Then

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And (KeyAscii <
48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

txt_search.SetFocus

End If

ElseIf Combo_search.Text = "CONSUMER ID" Then

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And (KeyAscii <
48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

txt_search.SetFocus

End If

End If

End Function

246
ELECTRICITY BILLING SYSTEM

CONSUMED UNIT SEARCHING

Private Sub cmd_clear_Click()

Call Form_Load

txt_cid.Text = ""

txt_cid.SetFocus

End Sub

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_print_Click()

If DataEnvironment1.rsCommand5.State = 1 Then

DataEnvironment1.rsCommand5.Close

End If

DataEnvironment1.Command5 txt_cid.Text

DataReport7.Show

End Sub

Private Sub Form_Load()

Adodc1.RecordSource = "select
customer.*,meter.m_no,phase,conn_date,supp_section,tarrif,c_load,c_date,c_reading,c_unit,b
_id,bill_month,b_date,gross_total,date1,charge1,date2,charge2,charge3,status from

247
ELECTRICITY BILLING SYSTEM

customer,meter,bill,measure where customer.cust_id=meter.cust_id and


customer.cust_id='0'and bill.cust_id=measure.cust_id and bill.cust_id=customer.cust_id"

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

DataGrid1.Columns(15).Caption = "READING DATE"

DataGrid1.Columns(16).Caption = "READING"

DataGrid1.Columns(17).Caption = "UNIT"

DataGrid1.Columns(18).Caption = "BILL NO."

DataGrid1.Columns(19).Caption = "BILL MONTH"

DataGrid1.Columns(20).Caption = "BILL DATE"

DataGrid1.Columns(21).Caption = "GROSS TOTAL"

DataGrid1.Columns(22).Caption = "PAYBLE UPTO"

DataGrid1.Columns(23).Caption = "CHARGE"

DataGrid1.Columns(24).Caption = "PAYBLE UPTO"

248
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(25).Caption = "CHARGE"

DataGrid1.Columns(26).Caption = "CHARGE"

DataGrid1.Columns(27).Caption = "STATUS"

cmd_print.Enabled = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Consume Unit") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If txt_cid.Text = "" Then Exit Sub

txt_cid.Text = UCase(txt_cid.Text)

conn

sql = "select cust_id from customer"

Set r = c.Execute(sql)

Do While Not r.EOF

If r.Fields(0) = txt_cid.Text Then

249
ELECTRICITY BILLING SYSTEM

a=1

Adodc1.RecordSource = "select
customer.*,meter.m_no,phase,conn_date,supp_section,tarrif,c_load,c_date,c_reading,c_unit,b
_id,bill_month,b_date,gross_total,date1,charge1,date2,charge2,charge3,status from
measure,customer,meter,bill where customer.cust_id=meter.cust_id and
customer.cust_id=measure.cust_id and customer.cust_id=bill.cust_id and
customer.cust_id='" + txt_cid.Text + "' and to_char(measure.p_date,'MON
YYYY')=bill.bill_month"

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "PHONE"

DataGrid1.Columns(3).Caption = "EMAIL ID"

DataGrid1.Columns(4).Caption = "ADDRESS"

DataGrid1.Columns(6).Caption = "PIN"

DataGrid1.Columns(8).Caption = "SUB DIVISION"

DataGrid1.Columns(9).Caption = "METER NO."

DataGrid1.Columns(11).Caption = "CONNECTION DATE"

DataGrid1.Columns(12).Caption = "SUPPLY SECTION"

DataGrid1.Columns(14).Caption = "LOAD"

DataGrid1.Columns(15).Caption = "READING DATE"

DataGrid1.Columns(16).Caption = "READING"

DataGrid1.Columns(17).Caption = "UNIT"

DataGrid1.Columns(18).Caption = "BILL NO."

DataGrid1.Columns(19).Caption = "BILL MONTH"

DataGrid1.Columns(20).Caption = "BILL DATE"

250
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(21).Caption = "GROSS TOTAL"

DataGrid1.Columns(22).Caption = "PAYBLE UPTO"

DataGrid1.Columns(23).Caption = "CHARGE"

DataGrid1.Columns(24).Caption = "PAYBLE UPTO"

DataGrid1.Columns(25).Caption = "CHARGE"

DataGrid1.Columns(26).Caption = "CHARGE"

DataGrid1.Columns(27).Caption = "STATUS"

cmd_print.Enabled = True

cmd_print.SetFocus

Exit Sub

End If

r.MoveNext

Loop

If a <> 1 Then

X = MsgBox("DATA NOT FOUND", vbInformation + vbOKOnly, "Unit Record") = vbOK

Call cmd_clear_Click

End If

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

251
ELECTRICITY BILLING SYSTEM

Private Sub txt_cid_LostFocus()

Call txt_cid_KeyPress(13)

End Sub

252
ELECTRICITY BILLING SYSTEM

SEARCHING GENERATED BILL

Dim r2 As New ADODB.Recordset

Dim r3 As New ADODB.Recordset

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_print_Click()

If DataEnvironment1.rsCommand3.State = 1 Then DataEnvironment1.rsCommand3.Close

DataEnvironment1.Command3 txt_cid.Text, Combo_bmonth.Text

DataReport3.Sections("section1").Controls("lbl_div").Caption = txt_div.Text

DataReport3.Sections("section1").Controls("lbl_sdiv").Caption = txt_sdiv.Text

DataReport3.Sections("section1").Controls("lbl_tarrif").Caption = txt_tarrif.Text

DataReport3.Sections("section1").Controls("lbl_phase").Caption = txt_phase.Text

DataReport3.Sections("section1").Controls("lbl_cload").Caption = txt_cload.Text

DataReport3.Sections("section1").Controls("lbl_cnm").Caption = txt_name.Text

DataReport3.Sections("section1").Controls("lbl_cadd").Caption = txt_add.Text

DataReport3.Sections("section1").Controls("lbl_rno").Caption = txt_rno.Text

DataReport3.Sections("section1").Controls("lbl_rdate").Caption = txt_date.Text

DataReport3.Sections("section1").Controls("lbl_ramt").Caption = txt_amt.Text

DataReport3.Sections("section1").Controls("lbl_enm").Caption = txt_ename.Text

DataReport3.Sections("section1").Controls("lbl_eadd").Caption = txt_eadd.Text

253
ELECTRICITY BILLING SYSTEM

DataReport3.Sections("section1").Controls("lbl_ephno").Caption = txt_ephone.Text

DataReport3.Sections("section1").Controls("lbl_pdate").Caption = txt_pdate.Text

DataReport3.Sections("section1").Controls("lbl_pread").Caption = txt_pread.Text

DataReport3.Sections("section1").Controls("lbl_punit").Caption = txt_punit.Text

DataReport3.Show

End Sub

Private Sub cmd_reset_Click()

txt_cid.Text = ""

txt_sdiv.Text = ""

txt_name.Text = ""

txt_add.Text = ""

txt_mno.Text = ""

txt_tarrif.Text = ""

txt_cload.Text = ""

txt_phase.Text = ""

txt_c1.Text = ""

txt_c2.Text = ""

txt_c3.Text = ""

txt_ename.Text = ""

txt_eadd.Text = ""

txt_ephone.Text = ""

txt_pdate.Text = ""

txt_pread.Text = ""

txt_punit.Text = ""

254
ELECTRICITY BILLING SYSTEM

txt_cdate.Text = ""

txt_cread.Text = ""

txt_cunit.Text = ""

txt_rno.Text = ""

txt_amt.Text = ""

txt_date.Text = ""

txt_ech.Text = ""

txt_dpscurr.Text = ""

txt_fxdch.Text = ""

txt_ed.Text = ""

txt_mrent.Text = ""

txt_tass.Text = ""

txt_rebate.Text = ""

txt_dues.Text = ""

txt_gtot.Text = ""

txt_bid.Text = ""

txt_bdate.Text = ""

txt_div.Text = ""

txt_eid.Text = ""

txt_sdiv.Text = ""

txt_ddate.Text = ""

Combo_bmonth.Clear

Call Form_Load

End Sub

255
ELECTRICITY BILLING SYSTEM

Private Sub Combo_bmonth_Click()

conn

sql = "select * from customer,meter where customer.cust_id='" + txt_cid.Text + "' and


meter.cust_id='" + txt_cid.Text + "'"

Set r = c.Execute(sql)

'======================== CONSUMER INFORMATION


===============================

txt_div.Text = r.Fields("DIVISION")

txt_sdiv.Text = r.Fields("sub_division")

txt_name.Text = r.Fields("CUST_NAME")

txt_add.Text = r.Fields("CUST_ADD")

txt_mno.Text = r.Fields("M_NO")

txt_tarrif.Text = r.Fields("tarrif")

txt_phase.Text = r.Fields("phase")

txt_cload.Text = r.Fields("c_load")

'===================================================
==========================

sql = "select * from measure,calculate where calculate.cust_id='" + txt_cid.Text + "' and


measure.cust_id='" + txt_cid.Text + "' and calculate.month='" + Combo_bmonth.Text + "'
and calculate.c_reading=measure.c_reading"

Set r = c.Execute(sql)

'============================ PREVIOUS READING DETAIL


==================================

txt_pdate.Text = r.Fields("p_date")

256
ELECTRICITY BILLING SYSTEM

txt_pread.Text = r.Fields("p_reading")

txt_punit.Text = r.Fields("p_unit")

txt_cdate.Text = r.Fields("c_date")

txt_cread.Text = r.Fields("c_reading")

txt_cunit.Text = r.Fields("c_unit")

txt_bmonth = Format(txt_cdate.Text, "MMM yy")

sql = "select * from employee where e_id='" & r.Fields("e_id") & "'"

Set r = c.Execute(sql)

txt_eid.Text = r.Fields("e_id")

txt_ename.Text = r.Fields("e_nm")

txt_eadd.Text = r.Fields("e_add")

txt_ephone.Text = r.Fields("e_phno")

Set r = New ADODB.Recordset

index1 = Combo_bmonth.ListIndex - 1

sql = "select r_no,r_date,amount from payment where cust_id='" & txt_cid.Text & "' and
b_month='" & Combo_bmonth.List(index1) & "'"

On Error GoTo X

Set r = c.Execute(sql)

txt_rno.Text = r.Fields(0)

txt_date.Text = r.Fields(1)

txt_amt.Text = r.Fields(2)

GoTo next1

257
ELECTRICITY BILLING SYSTEM

X:

txt_rno.Text = "XXXXX"

txt_date.Text = "XXXXX"

txt_amt.Text = "XXXXX"

next1:

sql = "select * from calculate,bill where calculate.cust_id='" & txt_cid.Text & "' and
bill.cust_id='" & txt_cid.Text & "' and calculate.month='" & Combo_bmonth.Text & "' and
calculate.month=bill.bill_month and bill.bill_month='" & Combo_bmonth.Text & "'"

Set r = c.Execute(sql)

txt_dues.Text = r.Fields("dues")

txt_ech.Text = r.Fields("energy_charge")

txt_dpscurr.Text = r.Fields("dps_cmonth")

txt_fxdch.Text = r.Fields("fixed_charge")

txt_ed.Text = r.Fields("electricity_duty")

txt_mrent.Text = r.Fields("meter_rent")

txt_tass.Text = r.Fields("total_assesment")

txt_rebate.Text = r.Fields("rebait")

txt_gtot.Text = r.Fields("gross_total")

txt_bid.Text = r.Fields("b_id")

txt_bdate.Text = r.Fields("b_date")

txt_ddate.Text = r.Fields("date1")

lbl_d1.Caption = r.Fields("date1")

lbl_d2.Caption = r.Fields("date2")

258
ELECTRICITY BILLING SYSTEM

lbl_d3.Caption = "After" & r.Fields("date2")

txt_c1.Text = r.Fields("charge1")

txt_c2.Text = r.Fields("charge2")

txt_c3.Text = r.Fields("charge3")

cmd_print.Enabled = True

End Sub

Private Sub Combo_bmonth_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

cmd_print.SetFocus

End If

End Sub

Private Sub Form_Load()

cmd_print.Enabled = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Energy Bill") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

259
ELECTRICITY BILLING SYSTEM

End Sub

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cid.Text = UCase(Trim(txt_cid.Text))

conn

sql = "select distinct cust_id from bill where cust_id='" + txt_cid.Text + "'"

On Error GoTo X

Set r = c.Execute(sql)

sql = "select bill_month from bill where cust_id='" + r.Fields(0) + "'"

Set r = c.Execute(sql)

Combo_bmonth.Clear

Do While Not r.EOF

Combo_bmonth.AddItem r.Fields(0)

r.MoveNext

Loop

Combo_bmonth.SetFocus

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER", vbCritical, "Error")

KeyAscii = 0

260
ELECTRICITY BILLING SYSTEM

End If

Exit Sub

X:

X = MsgBox("CONSUMER ID NOT MATCHED", vbInformation + vbOKOnly, "Energy Bill") =


vbOK

Call cmd_reset_Click

txt_cid.SetFocus

End Sub

261
ELECTRICITY BILLING SYSTEM

SEARCHING GENERATED RECEIPT

Private Sub cmbo_rmonth_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

conn

sql = "select * from payment where cust_id='" + txt_cid.Text + "' and b_month='" +
cmbo_rmonth.Text + "'"

Set r = c.Execute(sql)

txt_bid.Text = r.Fields("b_id")

txt_bmonth.Text = r.Fields("b_month")

txt_mno.Text = r.Fields("m_no")

txt_tot.Text = r.Fields("tot_bill")

txt_amt.Text = r.Fields("amount")

txt_rno.Text = r.Fields("r_no")

txt_date.Text = r.Fields("r_date")

txt_dues.Text = r.Fields("dues")

txt_eid.Text = r.Fields("e_id")

sql = "select e_nm from employee where e_id='" + r.Fields("e_id") + "'"

Set r = c.Execute(sql)

txt_ename.Text = r.Fields("e_nm")

sql = "select * from customer where cust_id='" + txt_cid.Text + "'"

Set r = c.Execute(sql)

txt_cname.Text = r.Fields("cust_name")

txt_sdiv.Text = r.Fields("sub_division")

262
ELECTRICITY BILLING SYSTEM

txt_div.Text = r.Fields("division")

End If

End Sub

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_print_Click()

If DataEnvironment1.rsCommand10.State = 1 Then
DataEnvironment1.rsCommand10.Close

Set r = New ADODB.Recordset

DataEnvironment1.Command10 txt_cid, txt_date

DataReport8.Sections("section1").Controls("label18").Caption =
NoToWord(Val(txt_amt.Text))

DataReport8.Show

Call cmd_reset_Click

End Sub

Private Sub cmd_reset_Click()

cmbo_rmonth.Clear

txt_cname.Text = ""

txt_bid.Text = ""

txt_bmonth.Text = ""

txt_mno.Text = ""

263
ELECTRICITY BILLING SYSTEM

txt_sdiv.Text = ""

txt_tot.Text = ""

txt_rno.Text = ""

txt_date.Text = ""

txt_eid.Text = ""

txt_ename.Text = ""

txt_amt.Text = ""

txt_dues.Text = ""

txt_cid.Text = ""

txt_cid.SetFocus

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Payment") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_cid_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txt_cid.Text = UCase(Trim(txt_cid.Text))

conn

264
ELECTRICITY BILLING SYSTEM

sql = "select b_month from payment where cust_id='" + txt_cid.Text + "' "

Set r = c.Execute(sql)

If r.EOF Or r.BOF = True Then

X = MsgBox("NEW CONSUMER", vbInformation + vbOKOnly, "Receipt") = vbOK

txt_cid.Text = ""

Else

Do While Not r.EOF

cmbo_rmonth.AddItem r.Fields(0)

r.MoveNext

Loop

cmbo_rmonth.SetFocus

End If

ElseIf (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And
(KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then

X = MsgBox("PLEASE ENTER ONLY CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End Sub

265
ELECTRICITY BILLING SYSTEM

PAID/UNPAID CONSUMER SEARCH

Private Sub cmd_exit_Click()

Unload Me

End Sub

Private Sub cmd_print_Click()

If Combo_status.Text = "PAID" Then

If DataEnvironment1.rsCommand7.State = 1 Then DataEnvironment1.rsCommand7.Close

DataEnvironment1.rsCommand7.Open Adodc1.RecordSource

DataReport5.Show

ElseIf Combo_status.Text = "UN PAID" Then

If DataEnvironment1.rsCommand8.State = 1 Then DataEnvironment1.rsCommand8.Close

DataEnvironment1.rsCommand8.Open Adodc1.RecordSource

DataReport6.Show

End If

End Sub

Private Sub Combo_status_Click()

If Combo_status.Text = "" Then Exit Sub

If Combo_status.Text = "PAID" Then

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.cust_add,customer.division,customer.sub_
division,meter.m_no,meter.conn_date,meter.tarrif,meter.phase,meter.c_load,bill.b_id,bill.b_
date,bill.bill_month,bill.gross_total,payment.r_no,payment.r_date,payment.amount,payment
.dues from customer,meter,bill,payment where customer.cust_id=meter.cust_id and

266
ELECTRICITY BILLING SYSTEM

customer.cust_id in (select distinct bill.cust_id from bill,calculate where


bill.bill_month=calculate.month and bill.status='PAID' and bill.bill_month='" +
txt_month.Text + "') and bill.cust_id=customer.cust_id and bill.bill_month='" +
txt_month.Text + "' and payment.cust_id=customer.cust_id and payment.b_month='" +
txt_month.Text + "' "

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "ADDRESS"

DataGrid1.Columns(4).Caption = "SUB DIVISION"

DataGrid1.Columns(5).Caption = "METER NO."

DataGrid1.Columns(6).Caption = "CONNECTION DATE"

DataGrid1.Columns(9).Caption = "LOAD"

DataGrid1.Columns(10).Caption = "BILL NO."

DataGrid1.Columns(11).Caption = "BILL MONTH"

DataGrid1.Columns(12).Caption = "BILL DATE"

DataGrid1.Columns(13).Caption = "GROSS TOTAL"

DataGrid1.Columns(14).Caption = " RECEIPT NO"

DataGrid1.Columns(15).Caption = " RECEIPT DATE"

DataGrid1.Columns(16).Caption = "AMOUNT"

DataGrid1.Columns(17).Caption = "DUES"

ElseIf Combo_status.Text = "UN PAID" Then

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.cust_add,customer.division,customer.sub_
division,meter.m_no,meter.conn_date,meter.tarrif,meter.phase,meter.c_load,bill.b_id,bill.b_
date,bill.bill_month,bill.gross_total from customer,meter,bill where
customer.cust_id=meter.cust_id and customer.cust_id in (select distinct bill.cust_id from

267
ELECTRICITY BILLING SYSTEM

bill,calculate where bill.bill_month=calculate.month and bill.status='UN PAID' and


bill.bill_month='" + txt_month.Text + "') and bill.cust_id=customer.cust_id and
bill.bill_month='" + txt_month.Text + "' "

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "ADDRESS"

DataGrid1.Columns(4).Caption = "SUB DIVISION"

DataGrid1.Columns(5).Caption = "METER NO."

DataGrid1.Columns(6).Caption = "CONNECTION DATE"

DataGrid1.Columns(9).Caption = "LOAD"

DataGrid1.Columns(10).Caption = "BILL NO."

DataGrid1.Columns(11).Caption = "BILL MONTH"

DataGrid1.Columns(12).Caption = "BILL DATE"

DataGrid1.Columns(13).Caption = "GROSS TOTAL"

End If

cmd_print.Enabled = True

Exit Sub

End Sub

Private Sub cmd_clear_Click()

Call Form_Load

txt_month.Text = ""

txt_month.SetFocus

268
ELECTRICITY BILLING SYSTEM

cmd_print.Enabled = False

End Sub

Private Sub Combo_status_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

cmd_print.SetFocus

End If

End Sub

Private Sub Form_Load()

Adodc1.RecordSource = "select
customer.cust_id,customer.cust_name,customer.cust_add,customer.division,customer.sub_
division,meter.m_no,meter.conn_date,meter.tarrif,meter.phase,meter.c_load,bill.b_id,bill.b_
date,bill.bill_month,bill.gross_total from customer,meter,bill where
customer.cust_id=meter.cust_id and customer.cust_id='0'"

Adodc1.Refresh

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns(0).Caption = "CONSUMER ID"

DataGrid1.Columns(1).Caption = "NAME"

DataGrid1.Columns(2).Caption = "ADDRESS"

DataGrid1.Columns(4).Caption = "SUB DIVISION"

DataGrid1.Columns(5).Caption = "METER NO."

DataGrid1.Columns(6).Caption = "CONNECTION DATE"

DataGrid1.Columns(9).Caption = "LOAD"

DataGrid1.Columns(10).Caption = "BILL NO."

DataGrid1.Columns(11).Caption = "BILL MONTH"

269
ELECTRICITY BILLING SYSTEM

DataGrid1.Columns(12).Caption = "BILL DATE"

DataGrid1.Columns(13).Caption = "GROSS TOTAL"

Combo_status.Visible = False

cmd_print.Enabled = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

X = MsgBox("ARE YOU SURE TO EXIT", vbQuestion + vbYesNo, "Status") = vbYes

If X = True Then

Unload Me

Else

Cancel = 1

End If

End Sub

Private Sub txt_month_GotFocus()

Combo_status.Visible = False

End Sub

Private Sub txt_month_KeyPress(KeyAscii As Integer)

If txt_month.Text = "" Then Exit Sub

If KeyAscii = 13 Then

txt_month.Text = UCase(Trim(txt_month.Text))

conn

sql = "select bill_month from bill"

270
ELECTRICITY BILLING SYSTEM

Set r = c.Execute(sql)

Do While r.EOF = False

If r.Fields(0) = txt_month.Text Then

Combo_status.Visible = True

Combo_status.ListIndex = -1

Combo_status.SetFocus

a=1

Exit Sub

End If

r.MoveNext

Loop

If a <> 1 Then

X = MsgBox("DATA NOT FOUND", vbInformation + vbOKOnly, "View Consumer Record")


= vbOK

Call cmd_clear_Click

End If

Else

If (KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122) And (KeyAscii <
48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 32 Then

X = MsgBox("PLEASE ENTER ONL CHARACTER AND NUMBER", vbCritical, "Error")

KeyAscii = 0

End If

End If

End Sub

271
ELECTRICITY BILLING SYSTEM

Private Sub txt_month_LostFocus()

Call txt_month_KeyPress(13)

End Sub

272
ELECTRICITY BILLING SYSTEM

VIEW DOMESTIC CHARGES

Private Sub Form_Load()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select * from domestic"

Set r = c.Execute(sql)

txt_upto100.Text = r.Fields("D_UPTO100")

txt_upto200.Text = r.Fields("d_upto200")

txt_upto300.Text = r.Fields("d_upto300")

txt_above300.Text = r.Fields("d_above300")

txt_dps.Text = r.Fields("d_dps")

txt_ed.Text = r.Fields("d_ed")

txt_fixed1.Text = r.Fields("d_fc")

txt_akw1.Text = r.Fields("d_akw")

txt_mrent1.Text = r.Fields("d_mrent")

txt_fixed3.Text = r.Fields("d_fc3")

txt_akw3.Text = r.Fields("d_akw3")

txt_mrent3.Text = r.Fields("d_mrent3")

txt_rebate.Text = r.Fields("d_rebate")

End Sub

273
ELECTRICITY BILLING SYSTEM

VIEW NON-DOMESTIC CHARGES

Private Sub Form_Load()

Set c = New ADODB.Connection

c.Open "provider=msdaora.1;user id=project/prakash;persist security info=true"

Set r = New ADODB.Recordset

sql = "select * from non_domestic"

Set r = c.Execute(sql)

txt_upto100.Text = r.Fields("n_UPTO100")

txt_upto200.Text = r.Fields("n_upto200")

txt_above200.Text = r.Fields("n_above200")

txt_dps.Text = r.Fields("n_dps")

txt_ed.Text = r.Fields("n_ed")

txt_fixed1.Text = r.Fields("n_fc")

txt_akw1.Text = r.Fields("n_akw")

txt_mrent1.Text = r.Fields("n_mrent")

txt_fixed3.Text = r.Fields("n_fc3")

txt_akw3.Text = r.Fields("n_akw3")

txt_mrent3.Text = r.Fields("n_mrent3")

txt_rebate.Text = r.Fields("n_rebate")

End Sub

274
ELECTRICITY BILLING SYSTEM

OUTPUT
SCREEN

275
ELECTRICITY BILLING SYSTEM

ENERGY BILL

276
ELECTRICITY BILLING SYSTEM

PAYMENT RECEIPT

277
ELECTRICITY BILLING SYSTEM

CONSUMER RECORD SEARCHING

278
ELECTRICITY BILLING SYSTEM

CONSUMED UNIT SEARCHING

279
ELECTRICITY BILLING SYSTEM

PREVIOUS BILL SEARCHING

280
ELECTRICITY BILLING SYSTEM

PREVIOUS RECEIPT SEARCHING

281
ELECTRICITY BILLING SYSTEM

PAID COSUMER RECORD SEARCHING

282
ELECTRICITY BILLING SYSTEM

UNPAID CONSUMER RECORD SEARCH

283
ELECTRICITY BILLING SYSTEM

TEST PROCEDURES
AND
IMPLEMENTATION

284
ELECTRICITY BILLING SYSTEM

INTRODUCTION

Testing presents an interesting anomaly for the software


engineer. During earlier software engineering activities, the engineer
attempts to build software from an abstract concept to a tangible
product. Now comes testing. The engineer creates a series of test cases
that are intended to “demolish” the software that has been built. In
fact, testing is the one step in the software process that could be
viewed (psychologically, at least) as destructive rather than
constructive.

Software engineers are by their nature constructive people.


Testing requires that the developer discard preconceived notions of the
“correctness” of software just developed and overcome a conflict of
interest that occurs when errors are uncovered.

If testing is conducted successfully (according to the objectives


stated previously), it will uncover errors in the software. As a secondary
benefit, testing demonstrates that software functions appear to be
working according to specification, that behavioral and performance

285
ELECTRICITY BILLING SYSTEM

requirements appear to have been met. In addition, data collected as


testing is conducted provide a good indication of software reliability
and some indication of software quality as a whole. But testing cannot
show the absence of errors and defects, it can show

Only that software errors and defects are present. It is important


to keep this (rather gloomy) statement in mind as testing is being
conducted.

286
ELECTRICITY BILLING SYSTEM

Testing principles

Before applying methods to design effective test cases, a software


engineer must understand the basic principle that guide software
testing:

All tests should be traceable to customer requirements

Tests should be planned long before testing begins

80 percent of all errors uncovered during testing will likely be


traceable to 20 percent of all program components. The problem, of
course, is to isolate these suspect components and to thoroughly test
them.

Testing should being “in the small” and progress toward testing
“in the large”.

Exhaustive testing is not possible

To be most effective an independent third party should conduct


testing

A rich variety of test case design methods have evolved for


software. These methods provide the developer with a systematic
approach to testing. More important, methods provide a mechanism

287
ELECTRICITY BILLING SYSTEM

that can help to ensure the completeness of tests and provide the
highest likelihood for uncovering errors in software.

Any engineered product (and most other things) can be tested in one of
two ways:

Knowing the specified function that a product has been designed


to perform, tests can be conducted that demonstrate each function is
fully operational

While at the same time searching for errors in each function; (2)
knowing the internal

Working of a product, tests can be conducted to ensure that “all


gears mesh,” that is, internal operations are performed according to
specifications and all internal components have been adequately
exercised. The first test approach is called black box testing and the
second, white-box testing.

 Testing performed were:

 UNIT TESTING
 INTEGRATION TESTING

288
ELECTRICITY BILLING SYSTEM

 DATABASE TESTING
 RECOVERY TESTING
 FUNCTIONALITY TESTING
 COMPATIBILITY TESTING
 LOAD TESTING
 SYSTEM TESTING
 PERFORMANCE TESTING
 USER ACCEPTANCE TESTING

289
ELECTRICITY BILLING SYSTEM

White box testing

Sometimes called glass-box testing is a test case design method


that uses the control structure of the procedural design to derive test
cases. Using white-box testing methods, the software engineer can
derive test cases that (1) guarantee that all independent paths within a
module have been exercised at least once, (2) exercise all logical
decisions on their true and false sides, (3) execute all loops at their
boundaries and within their operational bounds, and (4) exercise
internal data structures to ensure their validity.
White-box testing of software is predicated on close examination of
procedural detail. Providing test cases that exercise specific sets of
conditions and/or loops tests logical paths through the software. The
“status of the program” may be examined at various points to
determine if the expected or asserted status corresponds to the actual
status. Basis path testing is a white-box testing technique first proposed
by Tom McCabe. The basis path method enables the test case designer
to derive a logical complexity measure of a procedural design and use
this measure as a guide for defining a basis set of execution paths. Test
cases derived to exercise the basis set are guaranteed to execute every
statement in the program at least one time during testing.

290
ELECTRICITY BILLING SYSTEM

In this system, the system was tested for the calculation matters
were the data provided for giving the right output or not. If wrong data
was provided then what it is throwing error or accepting.

291
ELECTRICITY BILLING SYSTEM

Black box testing

Also called behavioral testing, focuses on the functional


requirements of the software. That is, black box testing enables the
software engineer to derive sets of input conditions that will fully
exercise all functional requirements for a program. Black box testing is
not an alternative to white-box techniques. Rather, it is a
complementary approach that is likely to uncover a different class of
error than white-box methods. When computer software is considered,
black box testing alludes to tests that are conducted at the software
interface. Although they are designed to uncover errors, black-box tests
are used to demonstrate that software functions are operational, that
input is

Properly accepted and output is correctly produced and that the


integrity of external information is maintained. A black-box test
examines some fundamental aspect of a system with a little regard for
the internal logical structure of the software. Black-box testing
attempts to find errors in the following categories:

1. Incorrect or missing functions,

292
ELECTRICITY BILLING SYSTEM

2. Interface errors,
3. Errors in data structures or external database access,
4. Behavior or performance errors, and
5. Initialization and termination errors. By applying back-box
techniques, we derive a set of test cases that satisfy the following
criteria:
a. Test cases that reduce, by a count that is greater than
one, the number of additional test cases that must be designed to
achieve reasonable testing and
b. Test cases that tell us something about the presence or
absence of classes of errors, rather than an error associated only with
the specific test at hand.

White-box testing should not, however, be dismissed as


impractical. A limited number of important logical paths can be
selected and exercised. Important data structures can be probed for
validity. The attributes of both black and white box testing can be
combined to provide an approach that validates the software interface
and selectively ensures that the internal workings of the software are
correct.

293
ELECTRICITY BILLING SYSTEM

Black box testing for this system was done to check the internal
testing i.e, the system is working properly in each case or no. What kind
of errors are there in database design.

294
ELECTRICITY BILLING SYSTEM

Testing Process
The testing process can be shown as:

Levels of testing
Test Plan Test Procedures

Yes
Test Case
Specification

Test Case Execution

Is Error
Test Case Analysis
Uncovered?

No

Test Report

295
ELECTRICITY BILLING SYSTEM

MENU TREE

296
ELECTRICITY BILLING SYSTEM

Main Page

Entry Edit Bill Payment View Admin Logout Exit


Exit Exit Exit Exit Exit Exit
Exit

Change Fixed
Consumer Energy
Charge
Bill
Record
Consumer Receipt Create user

Meter Record

Meter Modify user


Reading
datails and
Reading password

Consumer Fixed Unit Detail Bill Receipt Status


Charge Detail Detail
Record

297
ELECTRICITY BILLING SYSTEM

USER MANUAL

298
ELECTRICITY BILLING SYSTEM

MENU DESCRIPTION

Entry Menu:
In this menu consumer record, meter record and
consumed unit is processed.

New Consumer Entry:


The first sub-menu item of this screen is new consumer
entry. In this form we take the entry of consumer record such as his
name, address, subdivision and meter details such as tariff, phase,
connection load etc. This whole record is saved into a database through
the add command which is given on the respected form. There is one
reset button which clear all the records and one exit button which exit
through the form.

Meter Entry:
This is the second sub-module of this process. At this form
the consumed unit details used by the consumer in a single month is
entered. The previous reading date, unit consumed and reading like this
also current reading date, current unit consumed and reading. All this
information is saved into the respected database through the add
command. There is also one reset command which clear all the record
after processing of records and there is one exit button which executed
exit process to back from that form and comes to the main form.

299
ELECTRICITY BILLING SYSTEM

Edit Menu:
In this menu editing of consumer and meter entry
record is processed if any wrong information is entered.

Consumer Entry:
In this sub-menu there is a form on which consumer record
is updated. If any record is inputted wrong then we have the
facility to update the whole record. This process is completed by
an update button. This is the update command which update the
whole record and saved into the respected database. In this there
is reset button which clear all the record after the updating of
right record and there is exit button which performs the exit from
the form.

Meter Entry:
In tis sub-menu there is form on which the consumer
consumed unit is updated through the update command. There is
an update button which modifies the consumed unit if entry is
wrong. There is a reset button which clears all the record after
updating. There is an exit button which performs exit process the
form.

300
ELECTRICITY BILLING SYSTEM

Bill Menu:
In this menu there is a form which is known as bill form. In
this billing process is performed.

Energy Bill:
In this sub-menu all consumer billing is performed
month by month .In this there is a generate bill command is
mentioned through which the bill of all consumer is generated.
There is a save command through which all the bill is saved into
their respected database. There is a print command button which
prints the entire consumer bill at a time. At this form there is a
first command button which shows the whole record of all
consumers, there is a last and previous button which skip the
record next and back, there is a last command button which
shows the last consumer record. In this there is a reset button
which clears all the data from the form and there is an exit button
which performs the exit process from the form.

Payment Menu:
In this menu the payment of consumer is processed.

Receipt:
In tis sub-menu the receipt of consumer who
pays the bill is generated. At this form the payment process
is performed and saved in the respected database through

301
ELECTRICITY BILLING SYSTEM

the save command button. In this pay command button is


available through which the payment of consumer is finally
processed and report is generated. There is reset command
button which clear all the data after processing and there is
an exit button which holds the performance of go back from
the form.

View Menu:
In this menu we can search and view all consumer records,
meter details, bill details, receipt details and consumer status.

Consumer Record:
In this sub-menu we can view consumer records on
different fields such as consumer id, name, sub-division, tariff,
phase, connection date, month, and year. At this form we enter
required data and all the data is showed on the form. The whole
record is printed through the print command button. There is first
command button which shows the first record. There is next and
previous button command which forward and backward the
record. There is last command button which shows the last
consumer record.There is reset command button which clear all
the data after processing and there is an exit button which holds
the performance of go back from the form.

302
ELECTRICITY BILLING SYSTEM

Bill Detail:
In this sub-menu the bill details of consumer is showed on
the form. The bill of all previous month shows at the form. There
is print command button which print the entire previous bill in a
well-knit format.There is reset command button which clear all
the data after processing and there is an exit button by which user
comes out from that form.

Receipt Detail:
In this sub-menu the previous receipt which is generated at
previous and if consumer wants the previous receipt of his
payment then the through the print command button the receipt
is printed. In this there is a reset command button which performs
the clear all record from the form and there is an exit button
which take out the consumer from the form.

Status:
In this sub-menu the current status of consumer is
shown in the data grid. The entire consumer record that paid the
bill and the consumer who has not paid the bill is showed. The
print command button prints all the consumer record. The clear
command button clears all the data grid record.

303
ELECTRICITY BILLING SYSTEM

Meter Detail:
In this sub-menu the previous consumed unit of
consumer is shown in the data grid.In it at a time a particular
consumer entire consumed unit will be shown with all its
records.The print command button prints the record.The clear
command button clears all the data grid record.

Administrator:
Handling databases is in the power of the admin person
only. It performs general and special purpose both type of work.

Update Fixed Charge:

In this sub module the administrator can change the


fixed charge if there is any change is going to be happened.

Create user:
In this sub module the new user account is created by
the administrator and the user id and password is given to the
user to use it. The add command button is used to save all the
data record in the database. The reset command button is used to
clear all the data after processing and exit command button is
used to come back from that form

304
ELECTRICITY BILLING SYSTEM

Modify User Details:


In this sub menu the user details is modified by the
administrator. User user id and password is updated and again
save to the respected database. The update command button is
used to modify the user record. The reset command button is
used to clear all the data after processing and exit command
button is used to come back from that form.

305
ELECTRICITY BILLING SYSTEM

GANNT CHART(TIME FRAME)

Analysis

Design

Coding

Testing

Implement

25 SEP’1520 NOV’15 10 DEC’15 20DEC’15 05 JAN’16 15 JAN’16

306
ELECTRICITY BILLING SYSTEM

JOB DISTRIBUTION AMONG TEAM MEMBER

Member Name Job Description

Chandra Prakash Analysis, Design,Coding,


Testing

Prince Analysis, Coding,Testing,


Documentation

Jitendra Kumar Verma Analysis,Database and


Interface Design

307
ELECTRICITY BILLING SYSTEM

PROPOSED
ENHANCEMENTS

308
ELECTRICITY BILLING SYSTEM

FUTURE SCOPE
The scope of the project includes that what all future enhancements
can be done in this system to make it more feasible to use

 Databases for different products range and storage can be


provided.

 Multilingual support can be provided so that it can be


understandable by the person of any language.

 More graphics can be added to make it more user-friendly and


understandable.

 Manage & backup versions of documents online.

309
ELECTRICITY BILLING SYSTEM

DRAWBACKS AND LIMITATIONS

1. The system is not capable of handling more than 6 users at a time.

2. Some keywords in system are difficult to understand so the admin


n operator person should understand them thoroughly to use the
system accurately.

3. Graphs could have been added in order to get the records more
clearly.

310
ELECTRICITY BILLING SYSTEM

CONCLUSION

While developing the system a conscious effort has been made to


create and develop a software package, making use of available tools,
techniques and resources – that would generate a proper System

While making the system, an eye has been kept on making it as


user-friendly, as cost-effective and as flexible as possible. As such one
may hope that the system will be acceptable to any user and will
adequately meet his/her needs.

As in case of any system development processes where there are


a number of shortcomings, there have been some shortcomings in the
development of this system also. The project is still under modification.

311
ELECTRICITY BILLING SYSTEM

BIBLIOGRAPHY

BOOKS REFERRED

 Introduction To Programming with Visual Basic .NET


By Gary J. Bronson
 SQL/PLSQL ORACLE 9i
By P.S.Deshpande
 Introduction To Database Management System
The Tata Macraw Hill

WEB LINK

 http://www.nbpdcl.com

312

You might also like