-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser_ID.py
299 lines (218 loc) · 8.65 KB
/
User_ID.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
from tkinter import *
import tkinter as tk
from tkinter.messagebox import showerror, showwarning, showinfo, askyesno
import Controller.DAO as Conn
import Main
# def center_window_on_screen(root):
# window_width = 500
# window_height = 450
# screen_width = root.winfo_screenwidth()
# screen_height = root.winfo_screenheight()
# center_x = int(screen_width/2 - window_width / 2)
# center_y = int(screen_height/2 - window_height / 2)
# screen = (f'{window_width}x{window_height}+{center_x}+{center_y}')
# return screen
class Register(tk.Tk):
def __init__(self):
super().__init__()
self.title("Sign Up")
self.iconbitmap('assets/img/logo/logo.ico')
window_width = 450
window_height = 500
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
center_x = int(screen_width/2 - window_width / 2)
center_y = int(screen_height/2 - window_height / 2)
self.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')
self.iconbitmap('assets/img/logo/logo.ico')
# screen = center_window_on_screen(self)
# data = "{}".format(screen)
# self.geometry(data)
self.configure(bg = "#ffffff")
canvas = Canvas(
self,
bg = "#ffffff",
height = 500,
width = 450,
bd = 0,
highlightthickness = 0,
relief = "ridge")
canvas.place(x = 0, y = 0)
background_img = PhotoImage(file = f"assets/img/Register/background.png")
background = canvas.create_image(
225, 230,
image=background_img)
TB_YourID_img = PhotoImage(file = f"assets/img/Register/TextBox_YourID.png")
TB_YourID_bg = canvas.create_image(
212, 265,
image = TB_YourID_img)
TB_YourID = Entry(
self,
bd = 0,
bg = "#ffffff",
highlightthickness = 0)
TB_YourID.place(
x = 60, y = 218,
width = 332,
height = 23)
TB_Phone_img = PhotoImage(file = f"assets/img/Register/TextBox_Phone.png")
TB_Phone_bg = canvas.create_image(
59, 318,
image = TB_Phone_img)
TB_Phone = Entry(
self,
bd = 0,
bg = "#ffffff",
highlightthickness = 0)
TB_Phone.place(
x = 59, y = 318,
width = 332,
height = 23)
def Signup_clicked():
if TB_YourID.get() == ("") or TB_Phone.get() == (""):
showwarning(title='Error', message='Vui lòng nhập ID và số điện thoại !')
else:
click = askyesno(title='Success', message='Tiếp tục ?')
if click == 1:
# try:
Id = TB_YourID.get()
Phone = TB_Phone.get()
conn = Conn.connectDatabase()
cursor = conn.cursor()
# sql = "select * from user_ID"
# for row in cursor.execute(sql):
# print(row)
# sql_ID = """select * from user_ID where ID ='{}' and SDT = '{});'""".format(Id,Phone)
sql_ID = "select * from user_ID"
#loop 1 phat ra dinh 1 trong 3 truong hop
flag = True
for row in cursor.execute(sql_ID):
if Id == row.ID:
showwarning(title='Error', message='ID đã tồn tại !')
# khong break no se tiep tuc vong lap
flag = False
break
elif Phone == row.SDT:
showwarning(title='Error', message='Số điện thoại đã tồn tại!')
flag = False
break
if flag == True:
sql = "insert into user_ID (ID,SDT) values ('{}','{}');".format(Id, Phone)
cursor.execute(sql)
showinfo(title='success', message='Tạo ID thành công')
conn.commit()
TB_YourID.delete(0,'end')
TB_Phone.delete(0,'end')
conn.close()
# except:
# print("Connect error !!!")
img_sigup = PhotoImage(file = f"assets/img/Register/Button_Signup.png")
button_sigup = Button(
image = img_sigup,
borderwidth = 0,
highlightthickness = 0,
command = Signup_clicked,
relief = "flat")
button_sigup.place(
x = 100, y = 400,
width = 244,
height = 58)
def back_clicked():
self.destroy()
move = Main.main()
img_back = PhotoImage(file = f"assets/img/Register/back.png")
button_back = Button(
image = img_back,
borderwidth = 0,
highlightthickness = 0,
command = back_clicked,
relief = "flat")
button_back.place(
x = 10, y = 460,
width = 29,
height = 29)
self.resizable(False,False)
self.mainloop()
class Fogot(tk.Tk):
def __init__(self):
super().__init__()
self.title("Fogot ID")
self.iconbitmap('assets/img/logo/logo.ico')
window_width = 450
window_height = 500
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
center_x = int(screen_width/2 - window_width / 2)
center_y = int(screen_height/2 - window_height / 2)
self.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')
self.configure(bg = "#ffffff")
canvas = Canvas(
self,
bg = "#ffffff",
height = 500,
width = 450,
bd = 0,
highlightthickness = 0,
relief = "ridge")
canvas.place(x = 0, y = 0)
background_img = PhotoImage(file = f"assets/img/Fogot/background.png")
background = canvas.create_image(
225, 227,
image=background_img)
TextBox_Phone_img = PhotoImage(file = f"assets/img/Fogot/TextBox_Phone.png")
TextBox_Phone_bg = canvas.create_image(
220, 262,
image = TextBox_Phone_img)
TextBox_Phone = Entry(
bd = 0,
bg = "#ffffff",
highlightthickness = 0)
TextBox_Phone.place(
x = 60, y = 250,
width = 332,
height = 23)
def next_clicked():
Phone = TextBox_Phone.get()
if Phone == (""):
showerror(title='Error',message='Số điện thoại không được để trống !')
else:
conn = Conn.connectDatabase()
cursor = conn.cursor()
sql = "select ID from user_ID where SDT = {};".format(Phone)
flag = True
for row in cursor.execute(sql):
if row.ID != (""):
flag = False
data = row.ID
if flag == False:
showinfo(title='Your ID',message='ID của bạn là: {}'.format(data))
else:
showerror(title='error',message='ID hoặc số điện thoại không tồn tại!')
img_next = PhotoImage(file = f"assets/img/Fogot/next.png")
button_next = Button(
image = img_next,
borderwidth = 0,
highlightthickness = 0,
command = next_clicked,
relief = "flat")
button_next.place(
x = 130, y = 400,
width = 188,
height = 58)
def back_clicked():
self.destroy()
move = Main.main()
img_back = PhotoImage(file = f"assets/img/Fogot/back.png")
button_back = Button(
image = img_back,
borderwidth = 0,
highlightthickness = 0,
command = back_clicked,
relief = "flat")
button_back.place(
x = 10, y = 460,
width = 29,
height = 29)
self.resizable(False, False)
self.mainloop()
# thanh = Fogot()