-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbegin.py
More file actions
132 lines (114 loc) · 4.83 KB
/
begin.py
File metadata and controls
132 lines (114 loc) · 4.83 KB
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
import tkinter as tk
import check
from Object import ConntectDB
import tkinter.messagebox as msg
def frame(): # 主界面
global root
root = tk.Tk()
root.geometry('900x700')
root.title('图书管理系统')
label0 = tk.Label(root, text='欢迎来到JXNU图书馆', bg='pink', font=('微软雅黑', 50)).pack()
canvas = tk.Canvas(root, height=500, width=500)
image_file = tk.PhotoImage(file='1.gif')
image = canvas.create_image(250, 150, image=image_file)
canvas.place(x=170, y=170)
tk.Button(root, text='登 录', font=('微软雅黑', 15), width=10, height=2, command=login).place(x=225, y=550)
tk.Button(root, text='注 册', font=('微软雅黑', 15), width=10, height=2, command=register).place(x=475, y=550)
root.mainloop()
def opt(name, key):
a = name.get()
b = key.get()
root1.destroy()
check.skip(a, b)
def login(): # 登录
global root1
root1 = tk.Tk()
root1.wm_attributes('-topmost', 1)
root1.title('登录')
root1.geometry('500x300')
label1 = tk.Label(root1, text='账号:', font=25).place(x=100, y=50)
label2 = tk.Label(root1, text='密码:', font=25).place(x=100, y=100)
global entry_name, entry_key
name = tk.StringVar()
key = tk.StringVar()
entry_name = tk.Entry(root1, textvariable=name, font=25) # 账号
entry_name.place(x=180, y=50)
entry_key = tk.Entry(root1, show='*', textvariable=key, font=25) # 密码(密文)
entry_key.place(x=180, y=100)
button1 = tk.Button(root1, text='确定', height=2, width=10, command=lambda: opt(entry_name, entry_key)).place(x=210,
y=200)
def register(): # 注册
global root2
root2 = tk.Tk()
root2.wm_attributes('-topmost', 1) # 将注册窗口置顶
root2.title('注册')
root2.geometry('500x300')
label1 = tk.Label(root2, text='账号:', font=25).place(x=100, y=50)
label2 = tk.Label(root2, text='密码:', font=25).place(x=100, y=100)
label3 = tk.Label(root2, text='确认密码:', font=25).place(x=80, y=150)
global entry_id, entry_key, entry_kkey
id = tk.StringVar()
key = tk.StringVar()
kkey = tk.StringVar()
entry_id = tk.Entry(root2, textvariable=id, font=25)
entry_id.place(x=180, y=50)
entry_key = tk.Entry(root2, textvariable=key, font=25, show='*')
entry_key.place(x=180, y=100)
entry_kkey = tk.Entry(root2, textvariable=kkey, font=25, show='*')
entry_kkey.place(x=180, y=150)
button1 = tk.Button(root2, text='确定', height=2, width=10,
command=lambda: add_check(entry_id, entry_key, entry_kkey)).place(x=210, y=200)
def add_infrom(ID): # (新账号)填写信息
root2.destroy()
global root3
root3 = tk.Tk()
root3.wm_attributes('-topmost', 1)
root3.title('填写信息')
root3.geometry('500x300')
label1 = tk.Label(root3, text='姓名:', font=25).place(x=100, y=50)
label2 = tk.Label(root3, text='性别:', font=25).place(x=100, y=100)
label3 = tk.Label(root3, text='学号:', font=25).place(x=100, y=150)
global entry_name, entry_sex, entry_stuID
name = tk.StringVar()
sex = tk.StringVar()
stuID = tk.StringVar()
entry_name = tk.Entry(root3, textvariable=name, font=25)
entry_name.place(x=180, y=50)
entry_sex = tk.Entry(root3, textvariable=sex, font=25)
entry_sex.place(x=180, y=100)
entry_stuID = tk.Entry(root3, textvariable=stuID, font=25)
entry_stuID.place(x=180, y=150)
button = tk.Button(root3, text='确定', height=2, width=10,
command=lambda: UP(ID, entry_name, entry_sex, entry_stuID)).place(x=210, y=200)
def UP(ID, A, B, C): # 提交信息
conn = ConntectDB()
cur = conn.cursor()
cur.execute(
"insert into student (id, name ,sex, stuID) values ('%s', '%s', '%s', '%s')" % (ID, A.get(), B.get(), C.get()))
conn.commit()
msg._show(title='成功!', message='注册成功!')
come_begin()
def add_check(A, K, KK): # 检查账号是否存在,不存在则填写信息
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select accountID from account")
Account = cur.fetchall()
List = []
for i in Account:
for j in i:
List.append(j)
if A.get() in List: # 账号存在
msg._show(title='错误!', message='账号已存在!')
elif K.get() != KK.get():
msg._show(title='错误!', message='两次密码不同!')
else:
cur.execute(
"insert into account (accountID,password) values ('%s', '%s')" % (A.get(), K.get()))
conn.commit()
cur.execute("select id from account where accountID = %s", A.get())
ID = cur.fetchone()
add_infrom(ID[0])
def come_begin(): # 将填写信息的窗口关闭
root3.destroy()
if __name__ == '__main__':
frame()