Professional Documents
Culture Documents
Cbse Telephone Biiling System Using Python
Cbse Telephone Biiling System Using Python
#=======================================================
# FUNCTION TO CALCULATE THE BILL
#=======================================================
def dispbill(self):
import os
os.system('cls')
print("\n"*4)
if self.found:
print("\n")
print("="*31,"Telephone Bill","="*32)
print("Name:",self.c.name)
print("-"*79)
print("Address:",self.c.addr)
print("="*79)
print("Telephone Number",end=' '*3)
print("Consumer Number",end=' '*3)
print("Previous reading",end=' '*3)
print("Current reading:")
print("="*79)
print(self.c.ph,end=' '*11)
print(self.c.cno,end=' '*12)
print(self.oprd,end=' '*18)
print(self.clrd)
print("-"*79)
print("Metered Calls"," "*30,":"," "*9,self.mcalls)
print("Free Calls"," "*33,":"," "*9,self.fcalls)
print("Chargable calls"," "*28,":"," "*9,self.chargec)
print("Debits"," "*37,":"," "*9,self.debits)
print("Taxes"," "*38,":"," "*9,self.tax)
print("Gross Amount"," "*31,":"," "*9,int(self.grossamt))
print("Credits"," "*36,":"," "*9,self.credit)
print("-"*79)
print("Amount payable before"," "*22,":"," "*9,int(self.netamtbef))
print("-"*79)
print("Surcharge"," "*34,":"," "*9,self.surcharge)
print("-"*79)
print("Amount payable after"," "*23,":"," "*9,int(self.netamtaft))
print("="*79)
input("\n\t\t\tPress any key to continue")
#=======================================================
# FUNCTION TO ADD A NEW CUSTOMER
#=======================================================
def addrec():
import pickle
file=open("bill.dat",'ab')
c=customer()
import os
while True:
os.system('cls')
print("\n"*4)
c.getdata()
pickle.dump(c,file)
ch=input("\n\t\t\tDo You Want To Enter More Records:")
if ch.upper()=='N':
break
file.close()
#=======================================================
# FUNCTION TO SHOW ALL THE CUSTOMERS FROM THE FILE
#=======================================================
def showrec():
import pickle
file=open('bill.dat','rb')
c=customer()
import os
os.system('cls')
print("\n"*4)
print("\t\tPhone No.\t Consumer No.\t Type\t Name")
try:
while True:
c=pickle.load(file)
print('\n')
c.showcust()
except EOFError:
pass
file.close()
input("\n\t\t\tPress Any Key To Continue")
def searchrec():
import pickle
file=open("bill.dat","rb")
c=customer()
import os
os.system('cls')
print("\n"*4)
phn=int(input("\n\t\t\tEnter The Telephone No. :"))
found=False
try:
while True:
c=pickle.load(file)
if phn==c.ph:
found=True
break
except EOFError:
pass
if found:
c.showdata()
input("\n\t\t\tPress Enter To Continue")
else:
print("\n\t\t\tRecord not found:")
input("\n\t\t\tPress Enter To Continue")
file.close()
#=======================================================
# FUNCTION TO DELETE RECORD OF A CUSTOMER FROM THE FILE
#=======================================================
def delrec():
import pickle
import os
file=open("bill.dat","rb")
temp=open('temp.dat','ab')
import os
os.system('cls')
print("\n"*4)
phone=int(input("\n\t\t\tEnter The Phone Number:"))
c=customer()
try:
while True:
c=pickle.load(file)
if c.ph==phone:
print("\n\t\t\tRecord Successfully Deleted")
c.showdata()
input("\n\t\t\tPress any key to continue")
pass
elif c.ph!=phone:
pickle.dump(c,temp)
except EOFError:
pass
file.close()
temp.close()
os.remove('bill.dat')
os.rename('temp.dat','bill.dat')
#=======================================================
# FUNCTION TO MODIFY DETAILS OF A CUSTOMER
#=======================================================
def modrec():
import pickle
file = open("bill.dat", 'rb')
clist = list()
i = 0
c = customer()
import os
os.system('cls')
print("\n"*4)
phn = int(input("\n\t\t\tEnter The Telephone Number : "))
try:
while True :
c = pickle.load(file)
clist.append(c)
except EOFError :
pass
file.close()
found = False
i = 0
for c in clist :
if ( c.ph==phn ) :
found = True
break
else :
i = i+1
if ( not found ) :
print("\n\t\t\tInvalid Phone Number ")
return
import os
os.system('cls')
print("\n"*4)
print("\n\t\t\tEnter The New Details About The Customer:")
clist[i].getdata()
file = open("bill.dat", 'wb')
for c in clist :
pickle.dump(c,file)
file.close()
#=======================================================
# MAIN MENU
#=======================================================
def menu():
import os
os.system('cls')
print("\n"*4)
print("\n\t\t\t\tMAIN MENU")
print("\n\t\t\tPress 1 : To Generate a Bill")
print("\n\t\t\tPress 2 : To List all Customers")
print("\n\t\t\tPress 3 : To Manage Customers")
print("\n\t\t\tPress 4 : To Exit")
#=======================================================
# CUSTOMER MENU
#=======================================================
def menurec():
import os
os.system('cls')
print("\n"*4)
print("\n\t\t\t\tCUSTOMER MENU")
print("\n\t\t\tPress 1 : To List All Customer")
print("\n\t\t\tPress 2 : To Add a Customer")
print("\n\t\t\tPress 3 : To Show Details About A Customer")
print("\n\t\t\tpress 4 : To Delete a Customer")
print("\n\t\t\tPress 5 : To Modify a Existing Customer")
print("\n\t\t\tPress 6 : To Go Back To Previous Menu")
#=======================================================
# MAIN
#=======================================================
opt=0
while opt!=4:
menu()
opt=int(input("\n\t\t\tEnter Your Choice:"))
if opt==1:
b=bill()
b.calbill()
b.dispbill()
elif opt==2:
showrec()
elif opt==3:
ropt=0
while ropt!=4:
menurec()
ropt=int(input("\n\t\t\tEnter Your Choice:"))
if ropt==1:
showrec()
elif ropt==2:
addrec()
elif ropt==3:
searchrec()
elif ropt==4:
delrec()
elif ropt==5:
modrec()
elif ropt==6:
break
else:
print("\n\t\t\tInvalid Choice")
input("\n\t\t\tPress Any Key To Continue")
elif opt==4:
print("\n\t\t\tGood Bye")
input("\n\t\t\tPress Any Key To Continue")
break
else:
print("\n\t\t\tInvalid Choice")
input("\n\t\t\tPress Any Key To Continue")