Skip to content

Commit 25ad7ab

Browse files
Merge pull request prathimacode-hub#695 from Knighthawk-Leo/Knighthawk-Leo-patch-1
Added Code For KhataBook Script
2 parents 09fc7ae + 26a61f0 commit 25ad7ab

File tree

7 files changed

+239
-0
lines changed

7 files changed

+239
-0
lines changed
57.5 KB
Loading
61.7 KB
Loading
54.5 KB
Loading
67.4 KB
Loading
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# KhataBook
2+
3+
## Aim
4+
* To help the local shopkeeprs to manage the credits of customers.
5+
6+
## Purpose
7+
* Is to serve a fully automated software to handle the credits.
8+
9+
10+
## Short Discription
11+
This is an UI based Credit Management System App . This Will Manage credits of customers for local shops . As we know in India the credit system is very useful and this will help the shopkeepers to manage their shops. They can manage the customer profiles by just their Id they can perform Multiple Operations Such As
12+
13+
* Add Customer Data
14+
* update The Data
15+
* Delete The Data
16+
* To show All remaining credits.
17+
18+
## Setup Discription
19+
### you need to install following libraries to run this python program in cmd
20+
```
21+
pip install mysql.connector
22+
pip install tkinter
23+
pip install speech_recognitio
24+
pip install pyttsx3
25+
26+
```
27+
## Compilation Steps
28+
You Need to install the Mysql server and create a database named kbbokand
29+
Or Just copy the following command
30+
```
31+
create database kbook;
32+
33+
```
34+
change the paasword in khata_book.py at line 19
35+
36+
### Now you are good to go just Run khata_book.py
37+
38+
## The UI Looks Like This
39+
<img src="https://github.com/Knighthawk-Leo/Awesome_Python_Scripts/blob/Knighthawk-Leo-patch-1/GUIScripts/Khata%20Book%20Management%20System/Images/khata.jpg">
40+
41+
## To Insert The Record Use This
42+
<img src="https://github.com/Knighthawk-Leo/Awesome_Python_Scripts/blob/Knighthawk-Leo-patch-1/GUIScripts/Khata%20Book%20Management%20System/Images/KhataAdding.jpg">
43+
44+
## To Acces Particular Customer Data
45+
<img src="https://github.com/Knighthawk-Leo/Awesome_Python_Scripts/blob/Knighthawk-Leo-patch-1/GUIScripts/Khata%20Book%20Management%20System/Images/Showcust.jpg">
46+
47+
## To Show All remaining Money
48+
<img src="https://github.com/Knighthawk-Leo/Awesome_Python_Scripts/blob/Knighthawk-Leo-patch-1/GUIScripts/Khata%20Book%20Management%20System/Images/showall.jpg">
49+
50+
51+
52+
# Author
53+
## <a href="https://github.com/Knighthawk-Leo">Sanskar Dwivedi ❤️ </a>
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Including required modules
2+
3+
import mysql.connector
4+
from tkinter import *
5+
import speech_recognition as sr
6+
import pyttsx3
7+
8+
# assigining the voice commands
9+
engine = pyttsx3.init('sapi5')
10+
voices = engine.getProperty('voices')
11+
# print(voices[1].id)
12+
engine.setProperty('voice', voices[0].id)
13+
14+
# function to speak
15+
def speak(audio):
16+
engine.say(audio)
17+
engine.runAndWait()
18+
# making the connections towards the mysql
19+
def connection():
20+
try:
21+
con=mysql.connector.connect(user='root',password='4844',host='127.0.0.1',database='kbook')
22+
mycursor=con.cursor()
23+
#creating the servers
24+
mycursor.execute("CREATE TABLE IF NOT EXIST ITEMS (CID INT PRIMARY KEY,COUSTOMER_NAME VARCHAR(25),ITEM1 VARCHAR(20),WORTH1 INT,ITEM2 VARCHAR(20),WORTH2 INT,TOTAL_AMOUNT INT)")
25+
except:
26+
print("cannot Connect to database")
27+
return con
28+
29+
30+
# function to search records in mysql tables
31+
def Search_Records():
32+
con=connection()
33+
cursor=con.cursor()
34+
CID=e1.get()
35+
query=("select * from items where CID=%s") #executive the querry
36+
data=(CID,)
37+
cursor.execute(query,data)
38+
dasd = cursor.fetchall()
39+
for x in dasd:
40+
t1.insert(END,str(x)+"\n")
41+
speak("Record Found")
42+
43+
44+
45+
# function to Insert records in mysql tables
46+
def Insert_Records():
47+
con=connection()
48+
cursor=con.cursor()
49+
CID=e1.get()
50+
Coustomer_Name=e2.get()
51+
Item1=e3.get()
52+
worth1=int(e4.get())
53+
Item2=e5.get()
54+
worth2=int(e6.get())
55+
total_amount=worth1+worth2
56+
query=("insert into items values(%s,%s,%s,%s,%s,%s,%s)")
57+
data=(CID,Coustomer_Name,Item1,worth1,Item2,worth2,total_amount)
58+
cursor.execute(query,data)
59+
cursor.close()
60+
t1.insert(END,"ADDED SUCCESSFULLY\n")
61+
speak("Record Inserted")
62+
con.commit()
63+
con.close()
64+
65+
# function to show all records in mysql tables
66+
def show_money():
67+
con=connection()
68+
cur=con.cursor()
69+
query=("select Coustomer_Name,total_amount from items ")
70+
cur.execute(query,)
71+
y=cur.fetchall()
72+
for x in y:
73+
t1.insert(END,str(x)+"\n")
74+
75+
speak(query)
76+
cur.close()
77+
con.commit()
78+
con.close()
79+
80+
#Function To delete the records
81+
def delete():
82+
con=connection()
83+
cur=con.cursor()
84+
CID=e1.get()
85+
query=("delete from items where CID=%s")
86+
data=(CID,)
87+
cur.execute(query,data)
88+
speak("Record Deleted")
89+
con.commit()
90+
cur.close()
91+
con.close()
92+
t1.insert(END,"Record Deleted \n")
93+
94+
95+
96+
97+
98+
def close():
99+
sys.exit()
100+
101+
#Starting the UI Work........
102+
103+
104+
root=Tk()
105+
root.title("KHATA BOOK SOFT")
106+
#decalring the variables...
107+
CID=StringVar()
108+
Customer_Name=StringVar()
109+
Item1=StringVar()
110+
worth1=StringVar()
111+
Item2=StringVar()
112+
worth2=StringVar()
113+
114+
#making the labels for fields in UI...........
115+
116+
label1=Label(root,text="Customer ID",font="arial 10 bold")
117+
label1.place(x=0,y=0)
118+
119+
label12=Label(root,text="Customer_Name",font="arial 10 bold")
120+
label12.place(x=0,y=30)
121+
122+
label13=Label(root,text="ITEM1",font="arial 10 bold")
123+
label13.place(x=0,y=60)
124+
125+
label14=Label(root,text="worth1",font="arial 10 bold")
126+
label14.place(x=0,y=90)
127+
128+
label15=Label(root,text="ITEM2",font="arial 10 bold ")
129+
label15.place(x=0,y=120)
130+
131+
label16=Label(root,text="worth2",font="arial 10 bold")
132+
label16.place(x=0,y=150)
133+
134+
# MAking th entry field .........
135+
e1=Entry(root,textvariable=CID,bg="lightblue")
136+
e1.place(x=120,y=0)
137+
138+
e2=Entry(root,textvariable=Customer_Name,bg="lightblue")
139+
e2.place(x=120,y=30)
140+
141+
e3=Entry(root,textvariable=Item1,bg="lightblue")
142+
e3.place(x=120,y=60)
143+
144+
e4=Entry(root,textvariable=worth1,bg="lightblue")
145+
e4.place(x=120,y=90)
146+
147+
e5=Entry(root,textvariable=Item2,bg="lightblue")
148+
e5.place(x=120,y=120)
149+
150+
e6=Entry(root,textvariable=worth2,bg="lightblue")
151+
e6.place(x=120,y=150)
152+
153+
154+
# OUTPUT AREA....................
155+
t1=Text(root,width=80,height=20,bg="green",font="arial 10 bold")
156+
t1.grid(row=9,column=1)
157+
158+
#Buttons That Triggers the Functions............
159+
160+
b1=Button(root,text="Seacrch CUSTOMER",command=Search_Records,width=40,bg="orange",font="arial 10 bold")
161+
b1.grid(row=11,column=0)
162+
163+
b2=Button(root,text="INSERT_RECORDS",command=Insert_Records,width=40,bg="pink",font="arial 10 bold")
164+
b2.grid(row=12,column=0)
165+
166+
b3=Button(root,text="CLOSE",command=close,width=40,bg="Yellow",font="arial 10 bold")
167+
b3.grid(row=14,column=0)
168+
169+
b4=Button(root,text="SHOW ALL REAMAING MONEY",command=show_money,width=40,bg="pink",font="arial 10 bold")
170+
b4.grid(row=10,column=0)
171+
172+
b5=Button(root,text="DELETE RECORDS",command=delete,width=40,bg="orange",font="arial 10 bold")
173+
b5.grid(row=13,column=0)
174+
175+
176+
177+
178+
root.mainloop()
179+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mysql.connector
2+
tkinter
3+
speech_recognition
4+
pyttsx3
5+
6+
and mysql server. and create a database named kbook.
7+

0 commit comments

Comments
 (0)