-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank.py
350 lines (303 loc) · 14.9 KB
/
bank.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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'bank.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from register import Ui_MainWindow2
import mysql.connector as sql
from main import mainwin
from withdraw import withdraw
mycon= sql.connect(host="localhost",user="root",password="jehan26122003",database="bank")
mycur= mycon.cursor()
class Ui_MainWindow(object):
def openWindow(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_MainWindow2()
self.ui.setupUi(self.window)
self.window.show()
def opene(self):
self.window3 = QtWidgets.QMainWindow()
self.ui3 = mainwin()
self.ui3.setupUi(self.window3)
self.window3.show()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(621, 452)
MainWindow.setStyleSheet("background-color: rgb(18, 18, 18);")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(300, 50, 281, 41))
self.label.setStyleSheet("color: rgb(255, 255, 255);\n"
"font: 18pt \"Fredoka One\";")
self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(294, 102, 291, 41))
self.lineEdit.setStyleSheet("QLineEdit {\n"
" border-radius: 20px;\n"
" font: 14pt \"Fredoka One Light\";\n"
" color: rgb(255, 255, 255);\n"
" border: 2px solid rgb(160,160,160);\n"
" padding: 5px;\n"
" selection-color: rgb(0, 0, 255);\n"
"}\n"
"\n"
"QLineEdit:focus {\n"
" border: 2px solid rgb(0, 153, 188);\n"
"}\n"
"")
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(294, 220, 291, 41))
self.lineEdit_2.setStyleSheet("QLineEdit {\n"
" border-radius: 20px;\n"
" font: 14pt \"Fredoka One Light\";\n"
" color: rgb(255, 255, 255);\n"
" border: 2px solid rgb(160,160,160);\n"
" padding: 5px;\n"
" selection-color: rgb(0, 0, 255);\n"
"}\n"
"\n"
"QLineEdit:focus {\n"
" border: 2px solid rgb(0, 153, 188);\n"
"}\n"
"")
self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password)
self.lineEdit_2.setObjectName("lineEdit_2")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(300, 174, 281, 41))
self.label_2.setStyleSheet("color: rgb(255, 255, 255);\n"
"font: 18pt \"Fredoka One\";")
self.label_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.label_2.setObjectName("label_2")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(294, 314, 121, 51))
self.pushButton.setStyleSheet("QPushButton{\n"
"color: rgb(255, 255, 255);\n"
"font: 18pt \"Fredoka One \";\n"
"border: 2px solid rgb(160,160,160);\n"
"padding: 5px;\n"
"border-radius: 6px;\n"
"}\n"
"QPushButton:pressed {\n"
" \n"
" background-color: rgb(0, 85, 255);\n"
"}\n"
"")
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(457, 314, 121, 51))
self.pushButton_2.setStyleSheet("QPushButton{\n"
"color: rgb(255, 255, 255);\n"
"font: 18pt \"Fredoka One \";\n"
"border: 2px solid rgb(160,160,160);\n"
"padding: 5px;\n"
"border-radius: 6px;\n"
"}\n"
"QPushButton:pressed {\n"
" \n"
" background-color: rgb(0, 85, 255);\n"
"}\n"
"")
self.pushButton_2.setObjectName("pushButton_2")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(40, 50, 221, 301))
self.label_3.setText("")
self.label_3.setPixmap(QtGui.QPixmap("bankimg.png"))
self.label_3.setObjectName("label_3")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 621, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "Username :"))
self.label_2.setText(_translate("MainWindow", "Password :"))
self.pushButton.setText(_translate("MainWindow", "Login"))
self.pushButton_2.setText(_translate("MainWindow", "Register"))
self.pushButton_2.clicked.connect(self.openWindow)
self.pushButton.clicked.connect(self.login)
def login(self):
import datetime as date
from deposit import deposit
from last5 import last
from profile import Profile
from update import update
dates1=date.datetime.now()
self.window2 = QtWidgets.QMainWindow()
self.ui2 = withdraw()
self.ui2.setupUi(self.window2)
self.window4 = QtWidgets.QMainWindow()
self.ui4 = deposit()
self.ui4.setupUi(self.window4)
self.window5 = QtWidgets.QMainWindow()
self.ui5 = last()
self.ui5.setupUi(self.window5)
self.window6 = QtWidgets.QMainWindow()
self.ui6 = Profile()
self.ui6.setupUi(self.window6)
self.window7 = QtWidgets.QMainWindow()
self.ui7 = update()
self.ui7.setupUi(self.window7)
usere= self.lineEdit.text()
pase = self.lineEdit_2.text()
a="select * from bank where UserName='{}' and Password='{}'".format(self.lineEdit.text(),self.lineEdit_2.text())
mycur.execute(a)
data=mycur.fetchall()
if data:
def delt():
print('hi')
ns="SET FOREIGN_KEY_CHECKS=0"
mycur.execute(ns)
mycon.commit()
ps="delete from bank where password='{}'".format(pase)
mycur.execute(ps)
mycon.commit()
gs="delete from transaction where UserName1='{}'".format(usere)
mycur.execute(gs)
mycon.commit()
ns1="SET FOREIGN_KEY_CHECKS=1"
mycur.execute(ns1)
mycon.commit()
self.window3.close()
def updatee():
nmm="Select Name,UserName,Password, Address, Mobile_Number, Aadhar_no, Balance from bank where UserName='{}'".format(usere)
mycur.execute(nmm)
for i in mycur:
self.ui7.lineEdit_5.setText(i[0])
self.ui7.lineEdit_6.setText(i[1])
self.ui7.lineEdit_7.setText(i[2])
self.ui7.lineEdit_9.setText(i[3])
self.ui7.lineEdit_8.setText(i[4])
def upd():
if ((self.ui7.lineEdit_5.text() == '') or (self.ui7.lineEdit_6.text() == '') or (self.ui7.lineEdit_7.text() == '') or (self.ui7.lineEdit_8.text() == '') or (self.ui7.lineEdit_9.text() == '')):
print('uh')
elif len(self.ui7.lineEdit_8.text())!=10 or self.ui7.lineEdit_8.text().isalpha():
print('uh')
else:
ns="update bank set name='{}' where UserName='{}'".format(self.ui7.lineEdit_5.text(),usere)
mycur.execute(ns)
mycon.commit()
gf="SET FOREIGN_KEY_CHECKS=0"
mycur.execute(gf)
mycon.commit()
nm="update bank set UserName='{}' where password='{}'".format(self.ui7.lineEdit_6.text(),pase)
mycur.execute(nm)
mycon.commit()
gf1="SET FOREIGN_KEY_CHECKS=1"
mycur.execute(gf1)
mycon.commit()
us="update bank set Password='{}' where UserName='{}'".format(self.ui7.lineEdit_7.text(),usere)
mycur.execute(us)
mycon.commit()
us="update bank set Mobile_Number='{}' where UserName='{}'".format(self.ui7.lineEdit_8.text(),usere)
mycur.execute(us)
mycon.commit()
ns1="update bank set address='{}' where UserName='{}'".format(self.ui7.lineEdit_9.text(),usere)
mycur.execute(ns1)
mycon.commit()
msg2 = QtWidgets.QMessageBox()
msg2.setText('Account detalis updated successfuly')
msg2.exec_()
self.window7.close()
self.ui7.pushButton.clicked.connect(upd)
self.window7.show()
def viewe():
nmm="Select Name,UserName,Password, Address, Mobile_Number, Aadhar_no, Balance from bank where UserName='{}'".format(usere)
mycur.execute(nmm)
for i in mycur:
self.ui6.label_2.setText('Name :{}'.format(i[0]))
self.ui6.label_3.setText('User Name :{}'.format(i[1]))
self.ui6.label_4.setText('Password :{}'.format(i[2]))
self.ui6.label_5.setText('Address :{}'.format(i[3]))
self.ui6.label_6.setText('Mobile No. {}'.format(i[4]))
self.ui6.label_7.setText('Aadhar No. {}'.format(i[5]))
self.ui6.label_8.setText('Balance: {}'.format(i[6]))
self.window6.show()
def laste():
prt="Select Credited,Debited,Date from Transaction where UserName1='{}'".format(usere)
mycur.execute(prt)
ie=0
for i in mycur:
self.ui5.plainTextEdit.insertPlainText("Credited , Debited , Date : '{}','{}','{}'" .format(i[0],i[1],i[2]))
self.ui5.plainTextEdit.insertPlainText('\n \n \n')
ie+=1
if ie==5:
break
self.window5.show()
def deposite():
def confde():
Debited=0
t6= "update bank set Balance=Balance +'{}' where UserName='{}'".format(self.ui4.lineEdit_5.text(),usere)
mycur.execute(t6)
mycon.commit()
mn="insert into transaction values('{}','{}','{}','{}')".format(self.ui4.lineEdit_5.text(),Debited,usere,dates1)
mycur.execute(mn)
mycon.commit()
np9="select Balance from bank where UserName='{}'".format(usere)
mycur.execute(np9)
bal2=mycur.fetchone()[0]
msg1 = QtWidgets.QMessageBox()
msg1.setText('Credited with {}'.format(int(self.ui4.lineEdit_5.text())))
msg1.exec_()
self.window4.close()
self.window4.show()
self.ui4.pushButton_7.clicked.connect(confde)
def withdrew():
def confirm():
if int(self.ui2.lineEdit_5.text())<=bal:
credited=0
t6= "update bank set Balance=GREATEST(0,Balance - '{}') where UserName='{}'".format(int(self.ui2.lineEdit_5.text()),usere)
mycur.execute(t6)
mycon.commit()
gfn="SET FOREIGN_KEY_CHECKS=0"
mycur.execute(gfn)
mycon.commit()
bp="insert into transaction values('{}','{}','{}','{}')".format(credited,int(self.ui2.lineEdit_5.text()),usere,dates1)
mycur.execute(bp)
mycon.commit()
gf="SET FOREIGN_KEY_CHECKS=1"
mycur.execute(gf)
mycon.commit()
np9="select Balance from bank where UserName='{}'".format(usere)
mycur.execute(np9)
bal1=mycur.fetchone()[0]
msg = QtWidgets.QMessageBox()
msg.setText('Debited with {}'.format(int(self.ui2.lineEdit_5.text())))
msg.exec_()
self.window2.close()
self.window2.show()
np="select Balance from bank where UserName='{}'".format(usere)
mycur.execute(np)
bal=mycur.fetchone()[0]
self.ui2.label.setText('Current Balance is {}:'.format(str(bal)))
self.ui2.pushButton_7.clicked.connect(confirm)
self.opene()
self.ui3.pushButton.clicked.connect(withdrew)
self.ui3.pushButton_2.clicked.connect(deposite)
self.ui3.pushButton_3.clicked.connect(laste)
self.ui3.pushButton_4.clicked.connect(viewe)
self.ui3.pushButton_5.clicked.connect(updatee)
self.ui3.pushButton_7.clicked.connect(lambda : self.window3.close())
self.ui3.pushButton_6.clicked.connect(delt)
else:
print('hehhehehehe')
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())