0% found this document useful (0 votes)
9 views

Cs Project

TELEPHONE BILLING SYSTEM

Uploaded by

grohithmv009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Cs Project

TELEPHONE BILLING SYSTEM

Uploaded by

grohithmv009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Introduction

Overview of the System:


This system manages customer records
for a telephone service provider.
Key functionalities include user
registration, billing generation, payment
management, and customer record
updates.
Objective:
To streamline the billing process for a
telephone service provider and ensure
efficient tracking of customer data and
payments.
Features of the System
Register New Users:
Add new customers with details like phone
number, name, address, and more.
View Customer Details:
Retrieve and display customer information
based on phone number.
Generate Bill:
Generate a bill based on call count, with
different charges for different usage tiers.
Make Payment:
Track payments and update payment status for
each customer.
Update Customer Records:
Update fields such as name, address, call
count, and more.
Delete Customer:
Remove customers from the database.
Database Structure
Customer Table:
Phno (Phone Number): Primary key.
Name: Customer’s full name.
Address: Customer's address.
Aadhar_no: Unique Aadhar number
(Indian identity number).
Email: Customer's email address.
Call_count: Number of calls made.
Ftp (Bill Amount): Current bill amount.
Payment_status: Whether the bill is paid or
pending.
Functionality Walkthrough
User Registration Process:
User inputs customer data (phone number,
name, etc.).
The system validates and inserts the data
into the database.
Generating a Bill:
Based on the call count, the bill is
computed by applying different rates for
usage tiers.
The bill is updated in the database.
Making a Payment:
The customer can confirm payment, which
updates the bill to "Paid" and sets the FTP
to 0.
PYTHON CODE
import mysql.connector as mq

class Database:
def __init__(self, host, user, password,
database):
self.host = host
self.user = user
self.password = password
self.database = database
self.connection = None

def connect(self):
try:
self.connection = mq.connect(
host=self.host,
user=self.user,
password=self.password,
database=self.database
)
except mq.Error as e:
print(f"Database Connection Error:
{e}")

def execute_query(self, query, values=()):


try:
if not self.connection:
self.connect()
cursor = self.connection.cursor()
cursor.execute(query, values)
self.connection.commit()
except mq.Error as e:
print(f"Query Execution Error: {e}")

def fetch_all(self, query, values=()):


try:
if not self.connection:
self.connect()
cursor = self.connection.cursor()
cursor.execute(query, values)
return cursor.fetchall()
except mq.Error as e:
print(f"Query Fetch Error: {e}")
return []

def close(self):
if self.connection:
self.connection.close()

def register_user(db):
print("\n--- Registering New User ---")
ph = input("Enter Phone Number: ")
name = input("Enter Name: ")
address = input("Enter Address: ")
aadhar = input("Enter Aadhar Number: ")
email = input("Enter Email: ")

try:
initial_calls = int(input("Enter Initial Call
Count: "))
initial_ftp = float(input("Enter Initial FTP
(Bill Amount): "))
except ValueError:
print("Invalid input for call count or FTP.
Please enter numerical values.")
return

db.execute_query(
"INSERT INTO customer (Phno, name,
address, aadhar_no, email, call_count, ftp,
payment_status) VALUES (%s, %s, %s, %s,
%s, %s, %s, %s)",
(ph, name, address, aadhar, email,
initial_calls, initial_ftp, "Paid")
)
print("User registered successfully!")

def view_customer_details(db):
print("\n--- Viewing Customer Details ---")
ph = input("Enter Phone Number: ")

customer = db.fetch_all("SELECT * FROM


customer WHERE Phno = %s", (ph,))
if not customer:
print("Customer not found!")
return

customer = customer[0]
print("\n--- Customer Details ---")
print(f"Phone Number: {customer[0]}")
print(f"Name: {customer[1]}")
print(f"Address: {customer[2]}")
print(f"Aadhar Number: {customer[3]}")
print(f"Email: {customer[4]}")
print(f"Call Count: {customer[5]}")
print(f"FTP (Bill Amount):
₹{customer[6]}")
print(f"Payment Status: {customer[7]}")

def show_all_records(db):
print("\n--- All Customer Records ---")
customers = db.fetch_all("SELECT *
FROM customer")

if not customers:
print("No customer records found!")
return
print(f"\n{'Phone':<15}{'Name':<20}{'Addres
s':<30}{'Aadhar':<15}{'Email':<25}{'Calls':<1
0}{'FTP':<10}{'Payment Status':<15}")
print("=" * 140)
for customer in customers:

print(f"{customer[0]:<15}{customer[1]:<20}{
customer[2]:<30}{customer[3]:<15}{custome
r[4]:<25}{customer[5]:<10}{customer[6]:<10
}{customer[7]:<15}")
print("=" * 140)

def make_payment(db):
print("\n--- Making Payment ---")
ph = input("Enter Phone Number: ")

customer = db.fetch_all("SELECT * FROM


customer WHERE Phno = %s", (ph,))
if not customer:
print("Customer not found!")
return

customer = customer[0]
outstanding_bill = customer[6]
payment_status = customer[7]

if payment_status == "Paid":
print("No pending bills! All dues are
cleared.")
return

print(f"Outstanding Bill:
₹{outstanding_bill}")
confirm = input("Confirm payment?
(yes/no): ").strip().lower()

if confirm == "yes":
query = "UPDATE customer SET ftp =
%s, payment_status = %s WHERE Phno =
%s"
db.execute_query(query, (0, "Paid", ph))
print("Payment successful! All dues are
cleared.")
else:
print("Payment cancelled.")

def delete_customer(db):
print("\n--- Deleting Customer ---")
ph = input("Enter Phone Number: ")

customer = db.fetch_all("SELECT * FROM


customer WHERE Phno = %s", (ph,))
if not customer:
print("Customer not found!")
return
db.execute_query("DELETE FROM
customer WHERE Phno = %s", (ph,))
print(f"Customer with Phone Number {ph}
deleted successfully!")

def update_customer(db):
print("\n--- Updating Customer Details ---")
ph = input("Enter Phone Number: ")

customer = db.fetch_all("SELECT * FROM


customer WHERE Phno = %s", (ph,))
if not customer:
print("Customer not found!")
return

print("1. Update Name")


print("2. Update Address")
print("3. Update Aadhar Number")
print("4. Update Email")
print("5. Update Call Count")
choice = int(input("Enter choice: "))

if choice == 1:
new_name = input("Enter New Name: ")
db.execute_query("UPDATE customer
SET name = %s WHERE Phno = %s",
(new_name, ph))
elif choice == 2:
new_address = input("Enter New
Address: ")
db.execute_query("UPDATE customer
SET address = %s WHERE Phno = %s",
(new_address, ph))
elif choice == 3:
new_aadhar = input("Enter New Aadhar
Number: ")
db.execute_query("UPDATE customer
SET aadhar_no = %s WHERE Phno = %s",
(new_aadhar, ph))
elif choice == 4:
new_email = input("Enter New Email: ")
db.execute_query("UPDATE customer
SET email = %s WHERE Phno = %s",
(new_email, ph))
elif choice == 5:
try:
new_call_count = int(input("Enter
New Call Count: "))
db.execute_query("UPDATE customer
SET call_count = %s WHERE Phno = %s",
(new_call_count, ph))
except ValueError:
print("Invalid input! Please enter a
valid integer for the call count.")
return
else:
print("Invalid choice!")
return

print("Customer details updated


successfully!")

def generate_bill(db):
print("\n--- Generating Bill ---")
ph = input("Enter Phone Number: ")

customer = db.fetch_all("SELECT * FROM


customer WHERE Phno = %s", (ph,))
if not customer:
print("Customer not found!")
return

customer = customer[0]
call_count = customer[5]
ftp = customer[6]

print(f"Customer: {customer[1]}, Calls


Made: {call_count}, Current Bill: ₹{ftp}")
print("Generating bill based on new
calls...")

try:
new_calls = int(input("Enter new call
count: "))
except ValueError:
print("Invalid input! Please enter a valid
integer for call count.")
return

updated_call_count = call_count +
new_calls

if updated_call_count <= 50:


new_bill = 0
elif updated_call_count <= 100:
new_bill = (updated_call_count - 50) * 1
elif updated_call_count <= 150:
new_bill = 50 * 1 + (updated_call_count
- 100) * 2
else:
new_bill = 50 * 1 + 50 * 2 +
(updated_call_count - 150) * 3

total_bill = ftp + new_bill

db.execute_query(
"UPDATE customer SET call_count =
%s, ftp = %s, payment_status = %s WHERE
Phno = %s",
(updated_call_count, total_bill,
"Pending", ph)
)
print(f"Updated Bill: ₹{total_bill}")

def main_menu():
db = Database(host="localhost",
user="root", password="rithick123",
database="telephone2")

while True:
print("\n--- ONLINE TELEPHONE
BILLING SYSTEM ---")
print("1. Register User")
print("2. View Customer Details")
print("3. Show All Records")
print("4. Generate Bill")
print("5. Make Payment")
print("6. Delete Customer")
print("7. Update Customer")
print("8. Exit")
try:
choice = int(input("Enter your choice:
"))
except ValueError:
print("Invalid input! Please enter a
number between 1 and 8.")
continue

if choice == 1:
register_user(db)
elif choice == 2:
view_customer_details(db)
elif choice == 3:
show_all_records(db)
elif choice == 4:
generate_bill(db)
elif choice == 5:
make_payment(db)
elif choice == 6:
delete_customer(db)
elif choice == 7:
update_customer(db)
elif choice == 8:
print("Exiting...")
db.close() # Close the database
connection when exiting
break # Exit the loop and terminate
the program
else:
print("Invalid choice! Please try
again.")
if __name__ == "__main__":
main_menu()
SQL CODE
CREATE DATABASE telephone;

USE telephone;

CREATE TABLE customer (


Phno VARCHAR(15) PRIMARY KEY,
name VARCHAR(100),
address VARCHAR(255),
aadhar_no VARCHAR(12),
email VARCHAR(100),
call_count INT DEFAULT 0,
ftp DECIMAL(10, 2) DEFAULT 0,
payment_status ENUM('Paid', 'Pending')
DEFAULT 'Pending'
);
Output
MAIN SCREEN

REGISTERING NEW USER


VIEW CUSTOMER DETAILS

0SHOWING ALL THE RECORDS IN THE DATABASE


GENERATE BILL

MAKE PAYMENT
DELETING THE CUSTOMER RECORD

UPDATING CUSTOMER DETAILS


EXIT TO THE PROGRAM
SQL CODE
TABULAR COLOUMN CREATED IN SQL
USING PYTHON
Conclusion
Summary
The Online Telephone Billing System
effectively manages customer data, billing,
and payments.
It provides a user-friendly interface for
customer management and helps automate
billing.
Next Steps
Further testing and deployment.
Expanding functionality as needed based
on user feedback.
CERTIFICATE
This is to certify that R.RITHICK BALAJI of
class 12 of MARG VIDHYALAYA SENIOR
SECONDARY SCHOOL, CHENNAI has
completed his project file under my guidance. He
has taken proper care and shown utmost sincerity
in completing this project.
I certify that this project is up to my expectation
and as per the guidelines issued by CBSE

_____________
ACKNOWLEDGEMENT
I would like to express my special thanks
of gratitude to my teacher Mrs. G. Sujeetha
as well as our principal Mrs. K. Geetha
who gave me the golden opportunity to do
this wonderful project on the topic
“Telephone Billing System", which also
helped me in doing a lot of research and I
came to know about so many new things. I
am really thankful to them.
Secondly, I would also like to thank my
parents and friends who helped me a lot in
finalizing this project within the limited
time frame.
R.RITHICK BALAJI
XII A
COMPUTER SCIENCE PROJECT

TELEPHONE BILLING SYSTEM


2024-2025

PREPARED BY: GUIDED BY:


_____________ _____________

PRINCIPAL SIGN: TEACHER SIGN:


_________________ ________________

You might also like