-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.py
554 lines (375 loc) · 17.8 KB
/
App.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.uic import loadUiType
import sys
import MySQLdb
import webbrowser
import pyqrcode
from pyqrcode import QRCode
from xlsxwriter.workbook import Workbook
from datetime import datetime
ui,_ = loadUiType('Payment Gateway.ui')
LoginUi,_ = loadUiType('Login_PG.ui')
class LoginApp(QMainWindow, LoginUi):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
self.handleButton()
self.setTheme()
def handleButton(self):
self.pushButton_22.clicked.connect(sys.exit)
self.pushButton_21.clicked.connect(self.LoginUser)
self.pushButton_5.clicked.connect(self.dev_Vishwa_Linkedin)
self.pushButton_6.clicked.connect(self.dev_Vishwa_Insta)
self.pushButton_7.clicked.connect(self.dev_raghav_Linkedin)
self.pushButton_8.clicked.connect(self.dev_raghav_Insta)
def setTheme(self):
file = open('Themes/ThemeConfig.txt', 'r')
x = file.read()
x = x.split(' ')
ThemeVariable = ('Themes/' + x[-1])
style = open(ThemeVariable)
style = style.read()
self.setStyleSheet(style)
def LoginUser(self):
uName = self.lineEdit_10.text()
uPass = self.lineEdit_7.text()
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
try:
self.cur.execute('''select uName, uPass from users''')
uData = self.cur.fetchall()
print(uData)
for i in uData:
if uName == i[0] and uPass == i[1]:
self.MainObj = MainApp()
self.MainObj.show()
self.hide()
break
else:
self.label_18.setText('Incorrect credentials !')
except:
self.statusBar().showMessage('Unable to login !')
def dev_Vishwa_Linkedin(self):
webbrowser.open('https://www.linkedin.com/in/vishwa-h-a47b6852/')
def dev_Vishwa_Insta(self):
webbrowser.open('https://www.instagram.com/vishwa_karthik_/?hl=en')
def dev_raghav_Linkedin(self):
webbrowser.open('https://www.linkedin.com/in/raghavendra-vasista-l-a6384b27/')
def dev_raghav_Insta(self):
webbrowser.open('https://www.instagram.com/raghav_vasishta/?hl=en')
class MainApp(QMainWindow, ui):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
self.setTheme()
self.Handle_Buttons()
self.Handle_UI_Changes()
self.Show_Participant()
self.Show_Events_ComboBox()
self.Show_Event()
def Handle_UI_Changes(self):
self.tabWidget.tabBar().setVisible(False)
def Handle_Buttons(self):
self.pushButton_3.clicked.connect(self.Open_Day_Transactions) # Side buttons#
self.pushButton_5.clicked.connect(self.Events)
self.pushButton_4.clicked.connect(self.Users)
self.pushButton_6.clicked.connect(self.View_Participants)
self.pushButton_7.clicked.connect(self.Themes)
self.pushButton_2.clicked.connect(self.Add_New_Event)
self.pushButton.clicked.connect(self.Add_Participant)
self.pushButton_17.clicked.connect(self.setDarkBlue) # Theme Buttons#
self.pushButton_8.clicked.connect(self.setDarkOrange)
self.pushButton_9.clicked.connect(self.setDarkGray)
self.pushButton_18.clicked.connect(self.Combinear)
self.pushButton_12.clicked.connect(self.Search_Event)
self.pushButton_16.clicked.connect(self.Search_Participant)
self.pushButton_11.clicked.connect(self.Edit_Event)
self.pushButton_10.clicked.connect(self.Delete_Event)
self.pushButton_13.clicked.connect(self.Add_New_User)
self.pushButton_14.clicked.connect(self.Login)
self.pushButton_15.clicked.connect(self.Edit_User)
self.pushButton_19.clicked.connect(self.Logout)
self.pushButton_20.clicked.connect(self.Excel_Export)
self.pushButton_21.clicked.connect(self.Display_Qr)
############################ Trigger #######
def showTrigger(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
try :
self.cur.execute('''select uTotal from users''')
data = self.cur.fetchone()
print(data)
self.label_39.setText(str(data[0]))
self.lineEdit_34.setText(str(data[0]))
except:
pass
############################## download excel ########
def Excel_Export(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
try:
self.cur.execute('''select name, event, phone,amount from participants''')
bill = self.cur.fetchall()
x = datetime.now()
xlName = 'Details-' + str(x.day) + '-' + str(x.month) + '-' + str(x.year) + '-' + str(x.hour) + '-' + str(
x.minute) + '-' + str(x.second)
xlDate = str(x.day) + '-' + str(x.month) + '-' + str(x.year)
XL = Workbook(xlName + '.xlsx')
S1 = XL.add_worksheet()
S1.write(1, 0, 'Details' + xlDate)
S1.write(3, 0, 'Participant Name')
S1.write(3, 1, 'Event Name')
S1.write(3, 2, 'Participant Phone No')
S1.write(3, 3, 'Paid')
rowPos = 5
for row in bill:
colPos = 0
for i in row:
S1.write(rowPos, colPos, str(i))
colPos += 1
rowPos += 1
self.statusBar().showMessage('Participant exported')
XL.close()
except:
self.statusBar().showMessage('Unable to export to excel')
############################### QR Code ##############
def Display_Qr(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
try:
Participant_Name = self.lineEdit_31.text()
Participant_Phone = self.lineEdit_33.text()
self.cur.execute('''select name,event,phone from participants where name=%s and phone=%s''',(Participant_Name,Participant_Phone))
s = self.cur.fetchone()
print(s)
text = ('Scan QR code To view info')
qrr = pyqrcode.create(text)
qrr.png('QRCode/qrcode1.png', scale=5.5)
self.label_18.setStyleSheet("background-image: url(QRCode/qrcode1.png);")
#Execute m
except:
print('din happen !')
################################## OPENING BUTTONS #########
def Open_Day_Transactions(self):
self.tabWidget.setCurrentIndex(0)
def Add_Participant(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
Participant_Name = self.lineEdit.text()
Participant_Event = self.comboBox.currentText()
Participant_Amount = self.lineEdit_2.text()
Participant_PhoneNo = self.lineEdit_9.text()
phn = Participant_PhoneNo
lenp = len(phn)
if lenp == 10:
if phn.isdigit():
self.cur.execute('''INSERT INTO participants (name,event,phone,amount) VALUES (%s,%s,%s,%s)''',(Participant_Name, Participant_Event, Participant_PhoneNo, Participant_Amount))
self.db.commit()
self.statusBar().showMessage(" PARTICIPANT ADDED !")
else:
self.statusBar().showMessage('Enter valid phone number')
self.Show_Participant()
self.showTrigger()
def Show_Participant(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
self.cur.execute('''SELECT name, event ,phone ,amount FROM participants''')
data_1 = self.cur.fetchall()
if data_1:
self.tableWidget.setRowCount(0)
self.tableWidget.insertRow(0)
for row, form in enumerate(data_1):
for column, item in enumerate(form):
self.tableWidget.setItem(row, column, QTableWidgetItem(str(item)))
column += 1
row_position = self.tableWidget.rowCount()
self.tableWidget.insertRow(row_position)
def Events(self):
self.tabWidget.setCurrentIndex(1)
def Users(self):
self.tabWidget.setCurrentIndex(2)
def View_Participants(self):
self.tabWidget.setCurrentIndex(3)
def Themes(self):
self.tabWidget.setCurrentIndex(4)
########################################## EVENTS ##############
def Add_New_Event(self):
self.db = MySQLdb.connect(host='127.0.0.1',user='root',password='YOUR_PASSWORD',db='payment')
self.cur = self.db.cursor()
Event_Name = self.lineEdit_3.text()
Event_Price = self.lineEdit_5.text()
Event_Venue = self.lineEdit_6.text()
Event_Time = self.lineEdit_11.text()
try:
self.cur.execute('''INSERT INTO event (eName,eTime,ePrice,eVenue) VALUES (%s,%s,%s,%s)''',(Event_Name,Event_Time,Event_Price,Event_Venue))
self.db.commit()
self.statusBar().showMessage(" EVENT ADDED !")
self.lineEdit_3.setText('') # clear record after 1st Iteration
self.lineEdit_5.setText('')
self.lineEdit_6.setText('')
self.lineEdit_11.setText('')
self.Show_Event()
self.Show_Events_ComboBox()
except :
warning = QMessageBox.warning(self, 'Event Clashed ', "Your New Event gets Clashed ! ",QMessageBox.Yes)
if warning == QMessageBox.Yes:
pass
def Show_Event(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
self.cur.execute('''SELECT eName, ePrice FROM Event''')
data = self.cur.fetchall()
if data:
self.tableWidget_2.setRowCount(0)
self.tableWidget_2.insertRow(0)
for row, form in enumerate(data):
for column , item in enumerate(form):
self.tableWidget_2.setItem(row , column, QTableWidgetItem(str(item)))
column+=1
row_position = self.tableWidget_2.rowCount()
self.tableWidget_2.insertRow(row_position)
def Search_Event(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
Event_Name = self.lineEdit_20.text()
self.cur.execute('''SELECT eName ,eTime,ePrice,eVenue FROM event WHERE eName = %s''' , [(Event_Name)] )
data1 = self.cur.fetchone()
self.lineEdit_4.setText(data1[0])
self.lineEdit_32.setText(str(data1[1]))
self.lineEdit_8.setText(str(data1[2]))
self.lineEdit_12.setText(data1[3])
def Edit_Event(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
Event_Name = self.lineEdit_4.text()
Event_Time = self.lineEdit_32.text()
Event_Price = self.lineEdit_8.text()
Event_Venue = self.lineEdit_12.text()
Search_Event_Title = self.lineEdit_20.text()
self.cur.execute('''UPDATE event SET eName=%s ,eTime=%s, eVenue=%s, ePrice=%s WHERE eName=%s ''',(Event_Name,Event_Time,Event_Venue,Event_Price,Search_Event_Title))
self.db.commit()
self.statusBar().showMessage("EVENT MODIFIED !")
def Delete_Event(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
Search_Event_Title = self.lineEdit_20.text()
warning = QMessageBox.warning(self , 'Delete Event ? ' , "Are you Sure of Deleting this ? ", QMessageBox.Yes | QMessageBox.No)
if warning == QMessageBox.Yes :
self.cur.execute('''DELETE FROM event WHERE eName=%s''',[(Search_Event_Title)])
self.db.commit()
self.statusBar().showMessage("EVENT DELETED !")
self.Show_Event()
########################################## USERS #################
def Add_New_User(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
UserName = self.lineEdit_22.text()
password = self.lineEdit_23.text()
Email = self.lineEdit_21.text()
ConPassword = self.lineEdit_24.text()
try:
if password == ConPassword :
self.cur.execute('''INSERT INTO users(uName,uPass,uMail) VALUES (%s ,%s,%s) ''',(UserName,password,Email))
self.db.commit()
self.statusBar().showMessage("NEW USER ADDED !")
else:
self.label_9.setText("PASSWORD DONT MATCH ! RECHECK .")
except:
self.statusBar().showMessage('User Name Exists !')
def Login(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
Username = self.lineEdit_26.text()
Password = self.lineEdit_25.text()
sql = '''SELECT * FROM users'''
self.cur.execute(sql)
data = self.cur.fetchall()
for row in data:
if Username == row[1] and Password == row[2]:
self.statusBar().showMessage("Valid Client !")
self.groupBox_4.setEnabled(True)
self.label_3.setText(Username)
self.lineEdit_30.setText(row[1])
self.lineEdit_29.setText(row[3])
def Edit_User(self):
Email = self.lineEdit_29.text()
Username = self.lineEdit_30.text()
tempUsername = self.lineEdit_26.text()
Password = self.lineEdit_28.text()
ConPassword = self.lineEdit_27.text()
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
if Password == ConPassword :
self.cur.execute('''UPDATE users SET uName=%s,uPass=%s,uMail=%s WHERE uName=%s ''',(Username,Password,Email,tempUsername))
self.db.commit()
self.statusBar().showMessage("Credentials Modified !")
else:
self.statusBar().showMessage("Password Dont Match !")
########################################## VIEW PARTICIPANT #######################
def View_Participant(self):
pass
def Search_Participant(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
Participant_Name = self.lineEdit_31.text()
Participant_Phone = self.lineEdit_33.text()
self.cur.execute('''call fetchParticipant(%s,%s)''',(Participant_Name,Participant_Phone))
data2 = self.cur.fetchone()
print(data2)
self.label_35.setText(data2[0])
self.label_37.setText(data2[1])
self.label_42.setText(str(data2[2]))
############################################## THEMES TAB ##########
def setTheme(self):
file = open('Themes/ThemeConfig.txt', 'r')
x = file.read()
x = x.split(' ')
ThemeVariable = ('Themes/' + x[-1])
style = open(ThemeVariable)
style = style.read()
self.setStyleSheet(style)
def setDarkBlue(self):
file = open('Themes/ThemeConfig.txt', 'w')
file.write('Default theme: darkstyle.css')
file.close()
self.setTheme()
def setDarkOrange(self):
file = open('Themes/ThemeConfig.txt', 'w')
file.write('Default theme: darkorange.css')
file.close()
self.setTheme()
def setDarkGray(self):
file = open('Themes/ThemeConfig.txt', 'w')
file.write('Default theme: darkgray.css')
file.close()
self.setTheme()
def Combinear(self):
file = open('Themes/ThemeConfig.txt', 'w')
file.write('Default theme: Combinear.css')
file.close()
self.setTheme()
################# combo box ######
def Show_Events_ComboBox(self):
self.db = MySQLdb.connect(host='127.0.0.1', user='root', password='YOUR_PASSWORD', db='payment')
self.cur = self.db.cursor()
self.cur.execute(''' SELECT eName from event''')
data_2 = self.cur.fetchall()
self.comboBox.clear()
for eName in data_2:
self.comboBox.addItem(eName[0])
def Logout(self):
warning = QMessageBox.warning(self, 'Sure to sign out ?', "Are you Sure you wanna logout !",
QMessageBox.Yes | QMessageBox.No)
if warning == QMessageBox.Yes:
self.LoopObj = LoginApp()
self.LoopObj.show()
self.hide()
def main():
Final = QApplication(sys.argv)
Windows = LoginApp()
Windows.show()
Final.exec_()
if __name__ == '__main__':
main()