Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 36

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

VIDYAVARDHINI’S BHAUSAHEB VARTAK

POLYTECHNIC, VASAI ROAD WEST

MICRO PROJECT

Academic year: 2023-2024

TITLE OF PROJECT: Different type of Operating System

Program: Computer Engineering (CO) Semester: Fifth

Course: Operating System Code: 22516

Name:

Roll No:

Enrolment No:

Name of faculty: Ms.Amrita Rathod


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

Certificate

This is to certify that Mr. /Ms.


of FIFTH Semester of Diploma in Computer Engineering.
Institute, B. V. POLYTECHNIC (Code: 0093) has completed the Micro
Project satisfactorily in Subject –Operating System (22516) for the
academic year 2022- 2023 as prescribed in the curriculum.

Place: Vasai Enrolment No: …………………….

Date: …………… Exam Seat No: ……………………..

Subject Teacher Head of the Department Principal

SEAL OF
INSTITUTE
Part A: Micro Project Proposal

1.0 Aim/Benefits of the Micro-Project:


Electricity Billing System Project in Java is a software-based application
developed in Java programming language. The project aims at serving the
department of electricity by computerizing the billing system. It mainly
focuses on the calculation of Units consumed during the specified time and
the money to be paid to electricity offices. This computerized system will
make the overall billing system easy, accessible, comfortable and effective for
consumers.
2.0 Course Outcomes integrated:
• This project system excludes the need of maintaining paper electricity
bill as all the electricity bill records are managed electronically.
• Administrator doesn’t have to keep a manual track of the users. The
system automatically calculates fine.
• Users don’t have to visit to the office for bill payment.
• There is no need of delivery boy for delivery bills to user’s place. o Thus,
it saves human efforts and resources.

3.0 Proposed Methodology:


1. Define Objectives and Scope
2. Literature Review
3. Data Collection
4. Case Studies
5. Comparative Analysis
6. Operating System Evolution
7. Future Generations
4.0 Action Plan

Sr. Details of the activity Planned Planned Name of


Start date Members
No. Finish
1 Formation of Group & Topic Selection All members

2 Submission of Proposed Plan All members

3 Preparation of Report All members

4 Final valuation of a working Report All members

5 Presentation of Report All members

6 Submission of Final Report All members

5.0 Resource Required:

Name of Specifications Qty


Sr.
Remarks resources/Material
No.
1. Computer System I5 processor ,2GBRAM 1
2. Microsoft Word NetBeans IDE
3. Operating System Windows7(For practical Study)

4. Printer Hp Laser Jet 1

5. Browser Support Support Google Chrome (for data


analysis)
6.0 Name of Team Members with Roll No:

Sr Roll Name of Students Process and Individual


Total No. No. Product
Assessment Presentation (10)

(06) (04)

01

02

03

Name & Signature of Faculty:Ms.Amrita Rathod


Title: ELECTRICITY BILLING SYSTEM
Rationale: Electricity Billing System Project in Java is a software-based
application developed in Java programming language. The project aims at
serving the department of electricity by computerizing the billing system. It
mainly focuses on the calculation of Units consumed during the specified time
and the money to be paid to electricity offices. This computerized system will
make the overall billing system easy, accessible, comfortable and effective for
consumers.
Course Outcomes Integrated:
• This project system excludes the need of maintaining paper electricity
bill as all the electricity bill records are managed electronically.
• Administrator doesn’t have to keep a manual track of the users. The
system automatically calculates fine.
Actual Procedure Followed:
1. Introduction and Permission
2. Observation
3. Equipment Inspection
4. Technician Interaction
5. Regulatory Compliance
6. Data Collection
7. Questioning and Discussion
8. Thanking and Departure
4.0: Actual Resources
Required:
Sr. Name of resources/Material Specifications Qty
Remarks No.
1. Computer System I5 processor ,2GBRAM 1

2. Microsoft Word Netbeans IDE


3. Operating System Windows7(For practical
Study)
4. Printer Hp Laser Jet 1

5. Browser Support Support Google Chrome (for


data analysis)
Rubrics for Assessment of Micro-Project
Title: Different type of Operating System
Institute Code: 0093 Academic year:2023
Program: Computer Engineering Course & Code: OS (22516)
Name of Candidate: Roll No:
Semester: Fifth Name of Faculty: Ms.Amrita Rathod

Sr. Characteristic to be Assessed Poor Average Good Excellent


No. (Marks 1-3) (Marks 4-5) (Marks 6-8) (Marks 9-10)

1. Relevance to the Course

2. Literature Survey/Information
Collection
3. Project Proposal

4. Completion of the Target as per


Project Proposal
5. Analysis of Data and
Representation
6. Quality of Prototype/Model

7. Report Preparation

8. Presentation

9. Viva

7
Micro-Project Evaluation Sheet
Title: Different type of Operating System

Institute Code: 0093 Academic year:2023


Program: Computer Engineering Course & Code: OS (22516)
Name of Candidate: Roll No:
Semester: Fifth Name of Faculty: Ms.Amrita Rathod
Course Outcomes Achieved:

• This project system excludes the need of maintaining paper


electricity bill as all the electricity bill records are managed
electronically.
• Administrator doesn’t have to keep a manual track of the
users. The system automatically calculates fine.
Evaluation as per Suggested Rubric for Assessment of Micro Project
Sr. Characteristic to be assessed Poor Average Good Excellent
Sub No. Marks Marks Marks Marks
Total
1-3 4-5 6-8 9-10
(A) Process and product assessment Out Of 6

1 Relevance to the course

2 Literature Survey Information Collection .

3 Completion of the Target as per project


proposal
4 Analysis of Data and representation

5 Quality of Prototype/Model/Content

6 Report Preparation

(B) Individual Presentation/Viva Out of 4

7 Presentation .

8 Viva

Name and designation of the Faculty Member:


8
WEEKLY ACTIVITY SHEET

Title: Different type of Operating System


Institute Code: 0093 Academic year: 2022
Program: Computer Course & Code: OS(22516)
Engineering
Roll No:
Name of Candidate:
Name of Faculty: Ms.Amrita Rathod

SR. WEEK ACTIVITY PERFORMED


NO
1. 1st Week Discussion and Finalization
of Topic

2. 2nd Week Literature Review

3. 3rd Week Submission of Proposed Plan

4 4th Week Information Collection

5. 5th Week Analysis of Data

6. 6th Week Compilation of content

7. 7th Week Editing and Revising the Content

8. 8th Week Report Preparation

9. 9th Week Report Preparation

10. 10th - 12th Week Submission

9
Index
Sr. Page
Content
No. No.

1. Introduction 11

Features of the Electricity Billing System:


2. 12

Advantages and disadvantages of electricity billing


3. system: 12

Complete Code for Electricity Bill Management System


4. Project in Java 13- 31

5. Conclusion 32

6. Reference 32

10
Introduction

Electricity Billing System Project in Java is a software-based application


developed in Java programming language. The project aims at serving the
department of electricity by computerizing the billing system. It mainly focuses
on the calculation of Units consumed during the specified time and the money
to be paid to electricity offices. This computerized system will make the overall
billing system easy, accessible, comfortable and effective for consumers.

To design the billing system more service oriented and simple, the following
features have been implemented in the project. The application has high speed
of performance with accuracy and efficiency.

The software provides facility of data sharing, it does not require any staff as in
the conventional system. Once it is installed on the system only the meter
readings are to be given by the admin where customer can view all details, it
has the provision of security
restriction.

The electricity billing software calculates the units consumed by the customer
and makes bills, it requires small storage for installation and functioning. There
is provision for debugging if any problem is encountered in the system.

The system excludes the need of maintaining paper electricity bill,


administrator does not have to keep a manual track of the users, users can
pay the amount without visiting the office. Thus, it saves human efforts and
resources.

for the provi


hasinstallationprovidsecurityy
thencounteredandgiven
is
Theu
readings
convention
softwareto
itsare beof thofTheresharing,customer
consumedfunctioning.it
ion
insystssystemrestrictiTheprovision
l thebym.
facilicustom
the
byOnc adminstallmakestheesystem
isa aandelectritcityfornot
n whereon
is d dbills, requires
onlyall
if details,as
billingrequiresmallstaff
itcan view any problem
it
11
Features of the Electricity Billing System:
There are two aspects of this application – Admin and Customer
• The admin can create a new customer with new meter information
assigned to the customer, view all customer details, and calculate the
bills of all the customers.
• The user can create his own account after the admin has created his
meter information and once the account is created user can view his
account information.
• Manage all the information about Customer, Reading, Units.
• Admin can track all the information of units, Bills, Customer, etc.
• Admin can edit, add, delete, and update, the records of connection,
Reading consumption.

Advantages and disadvantages of electricity billing


system:

Advantages
• The system excludes the need of maintaining paper electricity bill as all
the electricity bill records are managed electronically.
• Administrator doesn’t have to keep a manual track of the users. The
system automatically calculates fine
• The system excludes manual bill calculation.
• Users don’t have visit the office for bill payment.
• There is no need of delivery boy for delivering bills to users place.
• Thus, it saves human efforts and resources.
Disadvantages
• Users must have a reliable internet connection.
• There is no human interaction if users have some enquiry.

12
Complete Code for Electricity Bill Management
System Project in Java

MySQL setup for Electricity Bill Management System in Java


Open the MySQL workbench and run the following command. These
commands will create a new database and two tables with the name login and
customer.
CREATE DATABASE ebs;
USE ebs;
create table login (
meter_no varchar(20),
username varchar(30),
name varchar(30),
password varchar(20),
user varchar(200)
);
create table customer (
name varchar(20),
meter_no varchar(20),
address varchar(50),
city varchar(30),
state varchar(30),
email varchar(40),
phone varchar(20)
);

1. Database Connection module


In this module, we create the conn.java class which is used to connect to
MySQL Database and in all other java classes, we use the object of this class to
perform all the operations on the database. In this file, you have to keep the
credentials of your MySQL server account.

1. import java.sql.*;
2. public class Conn {
3. Connection c;
4. Statement s;
5. Conn() {
6. try {
7. c = DriverManager.getConnection("jdbc:mysql:///ebs", "root", "root"); // replace the
password according to your account
8. s = c.createStatement();
9. } catch (Exception e) {
10. }
11. }
13
12. }

2. Main Screen Module


The Electricity Bill Management System starts from here. There is a progress
bar on this screen and when the time is over the login module is called from
here. Name it MainScreen.java.

import javax.swing.*;
import java.awt.*;
public class MainScreen {

JFrame frame;

ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icon/electricity.png"));


Image i2 = i1.getImage();
ImageIcon i3 = new ImageIcon(i2);
JLabel image=new JLabel(i3);
JLabel text=new JLabel("Electricity Management System");
JProgressBar progressBar=new JProgressBar();
JLabel message=new JLabel();
MainScreen() {
createGUI();
addImage();
addText();
addProgressBar();
runningPBar();
}

public void createGUI(){


frame=new JFrame();
frame.getContentPane().setLayout(null);
frame.setUndecorated(true);
frame.setSize(600,600);
frame.setLocationRelativeTo(null);
frame.getContentPane().setBackground(new Color(0X78DEC7));
frame.setVisible(true);
}
public void addImage(){
image.setBounds(90, 70, 400, 200);
frame.add(image);
}

public void addText()


{
text.setFont(new Font("MV Boli",Font.BOLD,22));
text.setBounds(120,300,400,50);
text.setForeground(Color.black);
frame.add(text);
}

public void addProgressBar(){


progressBar.setBounds(100,380,400,30);
progressBar.setBorderPainted(true);

14
progressBar.setStringPainted(true);
progressBar.setBackground(Color.black);
progressBar.setForeground(new Color(0XFF6464));
progressBar.setValue(0);
frame.add(progressBar);
}
public void runningPBar(){
int i=0;
while( i<=100)
{
try{
Thread.sleep(40);
progressBar.setValue(i);
i++;
if(i==100)
frame.dispose();
}catch(Exception e){
e.printStackTrace();
}
}
}

public static void main(String[] args) {


new MainScreen();
new Login();
}
}

15
3. Login Module
This class of Electricity Bill Management System will help to create a
login/register page so the user can enter the details and log in or go to the
signup page to register. Name it Login.java.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Login extends JFrame implements ActionListener{
JButton login, cancel, signup;
JTextField username, password;
Choice logginin;
Login() {
super("Login Page");
getContentPane().setBackground(new Color(0X78DEC7));
setLayout(null);

JLabel lblusername = new JLabel("Username");


lblusername.setBounds(350, 120, 100, 20);
lblusername.setFont(new Font("MV BOli", Font.BOLD, 14));
add(lblusername);

username = new JTextField();


username.setBounds(450, 120, 150, 20);
add(username);

JLabel lblpassword = new JLabel("Password");


lblpassword.setFont(new Font("MV BOli", Font.BOLD, 14));
lblpassword.setBounds(350, 160, 100, 20);
add(lblpassword);

password = new JTextField();


password.setBounds(450, 160, 150, 20);
add(password);

JLabel loggininas = new JLabel("Loggin in as");


loggininas.setFont(new Font("MV BOli", Font.BOLD, 14));
loggininas.setBounds(350, 200, 100, 20);
add(loggininas);

logginin = new Choice();


logginin.add("Admin");
logginin.add("Customer");
logginin.setBounds(450, 200, 150, 20);
add(logginin);

login = new JButton("Login");


login.setBounds(350, 260, 100, 40);
login.setBackground(Color.orange);
login.addActionListener(this);
add(login);

cancel = new JButton("Cancel");


cancel.setBounds(450, 350, 100, 40);

16
cancel.setBackground(Color.orange);
cancel.addActionListener(this);
add(cancel);

signup = new JButton("Signup");


signup.setBackground(Color.orange);
signup.setBounds(550, 260, 100, 40);
signup.addActionListener(this);
add(signup);

ImageIcon i7 = new ImageIcon(ClassLoader.getSystemResource("icon/secondd.png"));


Image i8 = i7.getImage().getScaledInstance(150, 150, Image.SCALE_DEFAULT);
ImageIcon i9 = new ImageIcon(i8);
JLabel image = new JLabel(i9);
image.setBounds(40, 70, 250, 250);
add(image);

setSize(840, 500);
setLocation(200, 100);
setVisible(true);
}

@Override
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == login) {
String susername = username.getText();
String spassword = password.getText();
String user = logginin.getSelectedItem();

try {
Conn c = new Conn();
String query = "select * from login where username = '"+susername+"' and password =
'"+spassword+"' and user = '"+user+"'";

ResultSet rs = c.s.executeQuery(query);

if (rs.next()) {
String meter = rs.getString("meter_no");
setVisible(false);
new Home(user, meter);
} else {
JOptionPane.showMessageDialog(null, "Invalid Login");
username.setText("");
password.setText("");
}

} catch (Exception e) {
}
} else if (ae.getSource() == cancel) {
setVisible(false);
} else if (ae.getSource() == signup) {
setVisible(false);

new Signup();
}
}

17
public static void main(String[] args) {
new Login();
}
}

4. Signup Module
On this page of Electricity Bill Management System, the user can enter the
details and create an account as a customer or an admin. Name it Signup.java.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Signup extends JFrame implements ActionListener{
JButton create;
Choice accountType;
JTextField meter, username, name, password;
Signup(){

setBounds(450, 150, 700, 400);


getContentPane().setBackground(new Color(0X78DEC7));
setLayout(null);

JPanel panel = new JPanel();


panel.setBounds(30, 30, 650, 300);
panel.setBackground(new Color(0X78DEC7));
panel.setLayout(null);
add(panel);

JLabel heading = new JLabel("Create Account As");


heading.setBounds(100, 50, 140, 20);
heading.setForeground(Color.black);
heading.setFont(new Font("MV Boli", Font.BOLD, 14));
panel.add(heading);

18
accountType = new Choice();
accountType.add("Admin");
accountType.add("Customer");
accountType.setBounds(260, 50, 150, 20);
panel.add(accountType);

JLabel lblmeter = new JLabel("Meter Number");


lblmeter.setBounds(100, 90, 140, 20);
lblmeter.setForeground(Color.black);
lblmeter.setFont(new Font("MV BOli", Font.BOLD, 14));
lblmeter.setVisible(false);
panel.add(lblmeter);

meter = new JTextField();


meter.setBounds(260, 90, 150, 20);
meter.setVisible(false);
panel.add(meter);

JLabel lblusername = new JLabel("Username");


lblusername.setBounds(100, 130, 140, 20);
lblusername.setForeground(Color.black);
lblusername.setFont(new Font("MV Boli", Font.BOLD, 14));
panel.add(lblusername);

username = new JTextField();


username.setBounds(260, 130, 150, 20);
panel.add(username);

JLabel lblname = new JLabel("Name");


lblname.setBounds(100, 170, 140, 20);
lblname.setForeground(Color.black);
lblname.setFont(new Font("MV Boli", Font.BOLD, 14));
panel.add(lblname);

name = new JTextField();


name.setBounds(260, 170, 150, 20);
panel.add(name);

meter.addFocusListener(new FocusListener() {

public void focusGained(FocusEvent fe) {}

public void focusLost(FocusEvent fe) {


try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from login where meter_no =
'"+meter.getText()+"'");
while(rs.next()) {
name.setText(rs.getString("name"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
});

19
JLabel lblpassword = new JLabel("Password");
lblpassword.setBounds(100, 210, 140, 20);
lblpassword.setForeground(Color.black);
lblpassword.setFont(new Font("MV Boli", Font.BOLD, 14));
panel.add(lblpassword);

password = new JTextField();


password.setBounds(260, 210, 150, 20);
panel.add(password);

accountType.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ae) {
String user = accountType.getSelectedItem();
if (user.equals("Customer")) {
lblmeter.setVisible(true);
meter.setVisible(true);
name.setEditable(false);
} else {
lblmeter.setVisible(false);
meter.setVisible(false);
name.setEditable(true);
}
}
});

create = new JButton("Create");


create.setBackground(Color.black);
create.setForeground(Color.white);
create.setBounds(260, 260, 120, 25);
create.addActionListener(this);
panel.add(create);

setVisible(true);
}

public void actionPerformed(ActionEvent ae) {


if (ae.getSource() == create) {
String atype = accountType.getSelectedItem();
String susername = username.getText();
String sname = name.getText();
String spassword = password.getText();
String smeter = meter.getText();

try {
Conn c = new Conn();

String query = null;


if (atype.equals("Admin")) {
query = "insert into login values('"+smeter+"', '"+susername+"', '"+sname+"',
'"+spassword+"', '"+atype+"')";
} else {
query = "update login set username = '"+susername+"', password = '"+spassword+"', user
= '"+atype+"' where meter_no = '"+smeter+"'";
}
c.s.executeUpdate(query);

20
JOptionPane.showMessageDialog(null, "Successfull");
setVisible(false);
new Login();
} catch (Exception e) {
}
}
}
public static void main(String[] args) {
new Signup();
}
}

5. Home Module
After the user is logged in, he will be redirected to this screen where a bunch of
options is available according to the user type i.e admin or customer. Name
it Home.java.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Home extends JFrame implements ActionListener{
String atype, meter;
Home(String atype, String meter) {
this.atype = atype;
this.meter = meter;
setLayout(null);
setBounds(300, 100, 700, 600);
setResizable(false);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icon/elec1.png"));
Image i2 = i1.getImage().getScaledInstance(700, 600, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel image = new JLabel(i3);
add(image);

JMenuBar mb = new JMenuBar();

21
mb.setBackground(new Color(0XFF5757));
setJMenuBar(mb);

JMenu master = new JMenu("Administrator");


master.setFont(new Font("MV Boli", Font.BOLD, 25));
master.setForeground(Color.black);

JMenuItem newcustomer = new JMenuItem("New Customer");


newcustomer.setFont(new Font("MV Boli", Font.BOLD, 15));
newcustomer.setBackground(Color.WHITE);
newcustomer.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
newcustomer.setPreferredSize(new Dimension(170, 50));
newcustomer.addActionListener(this);
master.add(newcustomer);

JMenuItem customerdetails = new JMenuItem("Customer Details");


customerdetails.setFont(new Font("MV Boli", Font.BOLD, 15));
customerdetails.setBackground(Color.WHITE);
customerdetails.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
customerdetails.setPreferredSize(new Dimension(170, 50));
customerdetails.addActionListener(this);
master.add(customerdetails);

JMenuItem calculatebill = new JMenuItem("Calculate Bill");


calculatebill.setFont(new Font("MV Boli", Font.BOLD, 15));
calculatebill.setBackground(Color.WHITE);
calculatebill.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
calculatebill.setPreferredSize(new Dimension(170, 50));
calculatebill.addActionListener(this);
master.add(calculatebill);

JMenu info = new JMenu("Information");


info.setFont(new Font("MV Boli", Font.BOLD, 25));
info.setForeground(Color.black);

JMenuItem viewinformation = new JMenuItem("View Information");


viewinformation.setFont(new Font("MV Boli", Font.BOLD, 15));
viewinformation.setBackground(Color.WHITE);
viewinformation.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
viewinformation.setPreferredSize(new Dimension(170, 50));
viewinformation.addActionListener(this);
info.add(viewinformation);

if (atype.equals("Admin")) {
mb.add(master);
} else {
mb.add(info);
}
setLayout(new FlowLayout());

setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
String msg = ae.getActionCommand();

22
if (msg.equals("New Customer")) {
new NewCustomer();
} else if (msg.equals("Customer Details")) {
new CustomerDetails();
} else if (msg.equals("Calculate Bill")) {
new CalculateBill();
} else if (msg.equals("View Information")) {
new ViewInformation(meter);
}
}
public static void main(String[] args) {
new Home("", "");
}
}

6. New Customer Module


This java class of Electricity Bill Management System Project in Java will be
responsible for creating a new customer in the database from the admin
account. Name it NewCustomer.java.
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class NewCustomer extends JFrame implements ActionListener{
JTextField tfname, tfaddress, tfstate, tfcity, tfemail, tfphone;
JButton next;
JLabel lblmeter;
NewCustomer() {
setSize(700, 500);
setLocation(400, 100);

JPanel p = new JPanel();


p.setLayout(null);

23
p.setBackground(new Color(0X78DEC7));
add(p);

JLabel heading = new JLabel("New Customer");


heading.setBounds(180, 10, 200, 25);
heading.setFont(new Font("Tahoma", Font.PLAIN, 24));
p.add(heading);

JLabel lblname = new JLabel("Customer Name");


lblname.setBounds(100, 80, 100, 20);
p.add(lblname);

tfname = new JTextField();


tfname.setBounds(240, 80, 200, 20);
p.add(tfname);

JLabel lblmeterno = new JLabel("Meter Number");


lblmeterno.setBounds(100, 120, 100, 20);
p.add(lblmeterno);

lblmeter = new JLabel("");


lblmeter.setBounds(240, 120, 100, 20);
p.add(lblmeter);

Random ran = new Random();


long number = ran.nextLong() % 1000000;
lblmeter.setText("" + Math.abs(number));

JLabel lbladdress = new JLabel("Address");


lbladdress.setBounds(100, 160, 100, 20);
p.add(lbladdress);

tfaddress = new JTextField();


tfaddress.setBounds(240, 160, 200, 20);
p.add(tfaddress);

JLabel lblcity = new JLabel("City");


lblcity.setBounds(100, 200, 100, 20);
p.add(lblcity);

tfcity = new JTextField();


tfcity.setBounds(240, 200, 200, 20);
p.add(tfcity);

JLabel lblstate = new JLabel("State");


lblstate.setBounds(100, 240, 100, 20);
p.add(lblstate);

tfstate = new JTextField();


tfstate.setBounds(240, 240, 200, 20);
p.add(tfstate);

JLabel lblemail = new JLabel("Email");


lblemail.setBounds(100, 280, 100, 20);
p.add(lblemail);

24
tfemail = new JTextField();
tfemail.setBounds(240, 280, 200, 20);
p.add(tfemail);

JLabel lblphone = new JLabel("Phone Number");


lblphone.setBounds(100, 320, 100, 20);
p.add(lblphone);

tfphone = new JTextField();


tfphone.setBounds(240, 320, 200, 20);
p.add(tfphone);

next = new JButton("Submit");


next.setBounds(250, 390, 100,25);
next.setBackground(Color.BLACK);
next.setForeground(Color.WHITE);
next.addActionListener(this);
p.add(next);

setLayout(new BorderLayout());

add(p, "Center");

ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icon/new-cust.png"));


Image i2 = i1.getImage().getScaledInstance(150, 150, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel image = new JLabel(i3);
add(image, "East");

getContentPane().setBackground(new Color(0X78DEC7));

setVisible(true);
}

public void actionPerformed(ActionEvent ae) {


if (ae.getSource() == next) {
String name = tfname.getText();
String meter = lblmeter.getText();
String address = tfaddress.getText();
String city = tfcity.getText();
String state = tfstate.getText();
String email = tfemail.getText();
String phone = tfphone.getText();

String query1 = "insert into customer values('"+name+"', '"+meter+"', '"+address+"', '"+city+"',


'"+state+"', '"+email+"', '"+phone+"')";
String query2 = "insert into login values('"+meter+"', '', '"+name+"', '', '')";

try {
Conn c = new Conn();
c.s.executeUpdate(query1);
c.s.executeUpdate(query2);

JOptionPane.showMessageDialog(null, "Successful");
setVisible(false);
} catch (Exception e) {

25
}
}
}

public static void main(String[] args) {


new NewCustomer();
}
}

7. Customer Details Module


This class is responsible for showing the details of all the customers in the
admin account. Name it CustomerDetails.java.
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import net.proteanit.sql.DbUtils;
import java.awt.event.*;
import java.awt.print.PrinterException;
public class CustomerDetails extends JFrame implements ActionListener{
JTable table;
JButton print;

CustomerDetails(){
super("Customer Details");

setSize(700, 500);
setLocation(200, 150);

table = new JTable();


table.setBackground(new Color(0X78DEC7));
try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from customer");

26
table.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
}

JScrollPane sp = new JScrollPane(table);


add(sp);

print = new JButton("Print");


print.addActionListener(this);
print.setBackground(new Color(0X78DEC7));
add(print, "South");

setVisible(true);
}

public void actionPerformed(ActionEvent ae) {


try {
table.print();
} catch (PrinterException e) {
}
}
public static void main(String[] args) {
new CustomerDetails();
}
}

8. Calculate Bill Module


This java class of Electricity Bill Management System Project in Java will be
responsible for showing the calculate bill option to the admin. The admin can
update the bill of all the users from this page. Name it CalculateBill.java.
import javax.swing.*;

27
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class CalculateBill extends JFrame implements ActionListener{
JTextField tfunits;
JButton next;
JLabel lblname, labeladdress;
Choice meternumber, cmonth;
CalculateBill() {
setSize(600, 500);
setLocation(400, 150);

JPanel p = new JPanel();


p.setLayout(null);
p.setBackground(new Color(0X78DEC7));
add(p);

JLabel heading = new JLabel("Calculate Electricity Bill");


heading.setBounds(150, 10, 400, 25);
heading.setFont(new Font("MV Boli", Font.BOLD, 25));
p.add(heading);

JLabel lblmeternumber = new JLabel("Meter Number");


lblmeternumber.setBounds(100, 80, 100, 20);
p.add(lblmeternumber);

meternumber = new Choice();

try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from customer");
while(rs.next()) {
meternumber.add(rs.getString("meter_no"));
}
} catch (Exception e)
{}

meternumber.setBounds(240, 80, 200, 20);


p.add(meternumber);

JLabel lblmeterno = new JLabel("Name");


lblmeterno.setBounds(100, 120, 100, 20);
p.add(lblmeterno);

lblname = new JLabel("");


lblname.setBounds(240, 120, 100, 20);
p.add(lblname);

JLabel lbladdress = new JLabel("Address");


lbladdress.setBounds(100, 160, 100, 20);
p.add(lbladdress);

labeladdress = new JLabel();


labeladdress.setBounds(240, 160, 200, 20);
p.add(labeladdress);

28
try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from customer where meter_no =
'"+meternumber.getSelectedItem()+"'");
while(rs.next()) {
lblname.setText(rs.getString("name"));
labeladdress.setText(rs.getString("address"));
}
} catch (Exception e) {
}

meternumber.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ie) {
try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from customer where meter_no =
'"+meternumber.getSelectedItem()+"'");
while(rs.next()) {
lblname.setText(rs.getString("name"));
labeladdress.setText(rs.getString("address"));
}
} catch (Exception e) {
}
}
});

JLabel lblcity = new JLabel("Units Consumed");


lblcity.setBounds(100, 200, 100, 20);
p.add(lblcity);

tfunits = new JTextField();


tfunits.setBounds(240, 200, 200, 20);
p.add(tfunits);

JLabel lblstate = new JLabel("Month");


lblstate.setBounds(100, 240, 100, 20);
p.add(lblstate);

cmonth = new Choice();


cmonth.setBounds(240, 240, 200, 20);
cmonth.add("January");
cmonth.add("February");
cmonth.add("March");
p.add(cmonth);

next = new JButton("Submit");


next.setBounds(250, 350, 100,25);
next.setBackground(Color.BLACK);
next.setForeground(Color.WHITE);
next.addActionListener(this);
p.add(next);

setLayout(new BorderLayout());

add(p, "Center");

29
getContentPane().setBackground(new Color(0X78DEC7));

setVisible(true);
}

public void actionPerformed(ActionEvent ae) {


JOptionPane.showMessageDialog(null, "Customer Bill Updated Successfully");
}

public static void main(String[] args) {


new CalculateBill();
}
}

9. View Information Module


import javax.swing.*;
import java.awt.*;
import java.sql.*;
public class ViewInformation extends JFrame{
ViewInformation(String meter) {
setBounds(350, 150, 500, 300);
getContentPane().setBackground(new Color(0X78DEC7));
setLayout(null);

JLabel heading = new JLabel("CUSTOMER INFORMATION");


heading.setBounds(150, 20, 500, 40);
heading.setFont(new Font("MV Boli", Font.BOLD, 15));
add(heading);

JLabel lblname = new JLabel("Name:");

30
lblname.setFont(new Font("MV Boli", Font.BOLD, 15));
lblname.setBounds(100, 60, 100, 40);
add(lblname);

JLabel name = new JLabel("");


name.setFont(new Font("MV Boli", Font.BOLD, 15));
name.setBounds(250, 60, 100, 40);
add(name);

JLabel lblmeternumber = new JLabel("Meter No:");


lblmeternumber.setFont(new Font("MV Boli", Font.BOLD, 15));
lblmeternumber.setBounds(70, 130, 100, 40);
add(lblmeternumber);

JLabel meternumber = new JLabel("");


meternumber.setFont(new Font("MV Boli", Font.BOLD, 20));
meternumber.setBounds(250, 130, 100, 40);
add(meternumber);

try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from customer where meter_no = '"+meter+"'");
while(rs.next()) {
name.setText(rs.getString("name"));
meternumber.setText(rs.getString("meter_no"));
}
} catch (Exception e) {
}
setVisible(true);
}
public static void main(String[] args) {
new ViewInformation("");
}
}

31
Conclusion:
Electricity Billing System project reports Before suggesting this solution they
were using a manual process on meter reading, amount calculation, and billing
customer and so on. The interaction between customer and Electricity Board
was very poor and it took much longer to respond to customer queries.

References:
https://chat.openai.com/
https://itsourcecode.com/
https://www.youtube.com/

32

You might also like