-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_centres.py
142 lines (133 loc) · 5.49 KB
/
admin_centres.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#Admin Module (Centres Table)
import mysql.connector
def DisplayRec_Centres():
conn=mysql.connector.connect(host="localhost",user="root",
password="tiger",database="project")
cur=conn.cursor()
print("*"*121)
cur.execute("Select * From centres")
records=cur.fetchall()
for i in records:
print(i[0],i[1],i[2],i[3],i[4],i[5],i[6],sep=" | ")
print("*"*121)
#DisplayRec_Centres()
def GetAdmno_Centres():
conn=mysql.connector.connect(host="localhost",user="root",
password="tiger",database="project")
cur=conn.cursor()
query="SELECT SNO FROM centres order by SNO desc limit 1"
cur.execute(query)
a=cur.fetchone()
return a[0]
def Insertion_Centres():
conn=mysql.connector.connect(host="localhost",user="root",
password="tiger",database="project")
cur=conn.cursor()
print("*"*80)
SNo=GetAdmno_Centres()+1
Cname=input("ENTER THE CENTRE NAME \t\t:\t")
addres=input("ENTER THE ADDRESS \t\t:\t")
cont=input("ENTER THE CONTACT NUMBER \t:\t")
Email=input("ENTER THE EMAIL ID\t\t:\t")
Tim=input("ENTER THE TIMINGS\t\t:\t")
Fees=input("ENTER THE MEMBERSHIP FEES\t:\t")
print("*"*80)
query="INSERT INTO Centres VALUES({},'{}','{}','{}','{}','{}','{}')".format(SNo,Cname,addres,cont,Email,Tim,Fees)
cur.execute(query)
cur.execute("commit")
print("\t\t\t RECORD INSERTED SUCCESSFULLY")
print("*"*80)
#Insertion_Centres()
def Updation_Centres():
conn=mysql.connector.connect(host="localhost",user="root",
password="tiger",database="project")
cur=conn.cursor()
print("*"*80)
Cnt=input("ENTER THE CENTRE NAME\t:\t")
print("*"*80)
m1="SELECT * from Centres where centre_name='{}'".format(Cnt)
cur.execute(m1)
cur.fetchall()
if cur.rowcount==0:
print("*"*80)
print("\t\t NO RECORD FOUND OF SUCH CENTRE NAME")
print("*"*80)
else:
print("*"*80)
while True:
print("\t\t\t 1. UPDATE ADDRESS ")
print("\t\t\t 2. UPDATE TIMINGS")
print("\t\t\t 3. UPDATE MEMBERSHIP FEES")
print("\t\t\t 4. UPDATE CONTACT NUMBER")
print("\t\t\t 5. UPDATE EMAIL ADDRESS")
print("\t\t\t 6. EXIT")
print("*"*80)
choice =int(input("ENTER THE CHOICE\t\t:\t"))
print("*"*80)
if choice == 1:
new_adr= input("ENTER THE ADDRESS \t\t:\t")
print("*"*80)
query= "UPDATE Centres SET address ='{}' WHERE centre_name='{}'".format(new_adr,Cnt)
cur.execute(query)
cur.execute("commit")
print(" \t\t\t RECORD UPDATED SUCCESSFULLY")
print("*"*80)
if choice == 2:
new_tim= input("ENTER THE TIMINGS \t\t:\t")
print("*"*80)
query= "UPDATE Centres SET Timings ='{}' WHERE centre_name='{}'".format(new_tim,Cnt)
cur.execute(query)
cur.execute("commit")
print(" \t\t\t RECORD UPDATED SUCCESSFULLY")
print("*"*80)
if choice == 3:
new_fee= input("ENTER THE MEMBERSHIP FEES \t:\t")
print("*"*80)
query= "UPDATE Centres SET Membership_fees ='{}' WHERE centre_name='{}'".format(new_fee,Cnt)
cur.execute(query)
cur.execute("commit")
print(" \t\t\t RECORD UPDATED SUCCESSFULLY")
print("*"*80)
if choice == 4:
new_cont= input("ENTER THE CONTACT NUMBER \t:\t")
print("*"*80)
query= "UPDATE Centres SET contact ='{}' WHERE centre_name='{}'".format(new_cont,Cnt)
cur.execute(query)
cur.execute("commit")
print(" \t\t\t RECORD UPDATED SUCCESSFULLY")
print("*"*80)
if choice == 5:
new_mail= input("ENTER THE EMAIL ADDRESS \t:\t")
print("*"*80)
query= "UPDATE Centres SET email_id ='{}' WHERE centre_name='{}'".format(new_mail,Cnt)
cur.execute(query)
cur.execute("commit")
print(" \t\t\t RECORD UPDATED SUCCESSFULLY")
print("*"*80)
if choice==6:
break
print("*"*80)
#Updation_Centres()
def Deletionmain_Centres():
def Deletion(x):
query="SELECT * FROM Centres WHERE Contact = '{}'".format(x)
cur.execute(query)
cur.fetchall()
return cur.rowcount
conn=mysql.connector.connect(host="localhost",user="root",
password="tiger",database="project")
cur=conn.cursor()
print("*"*80)
x =input("ENTER THE CONTACT NUMBER\t:\t")
print("*"*80)
count= Deletion(x)
if count!= 0:
query= "DELETE FROM Centres WHERE Contact='{}'".format(x)
cur.execute(query)
print("\t\t\tRECORD DELETED SUCCESSFULLY")
print("*"*80)
cur.execute("commit")
else:
print(" \t\t NO RECORD FOUND OF SUCH CONTACT NUMBER")
print("*"*80)
#Deletionmain_Centres()