-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperation.py
More file actions
189 lines (159 loc) · 7.73 KB
/
operation.py
File metadata and controls
189 lines (159 loc) · 7.73 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
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
import tkinter as tk
import tkinter.messagebox as msg
from tkinter import ttk
import begin
import search
from Admin import AddBook, RemoveBook, AdminExamine, GetAllExamine
from Object import ConntectDB
conn = ConntectDB()
DIR = {'人文': 0, '艺术': 1, '计算机': 2, '科技': 3, '杂志': 4, '其他': 5}
def frame(): # 管理员界面
global window
window = tk.Tk()
window.title('管理员')
window.geometry('900x600')
label0 = tk.Label(window, text='欢迎来到JXNU图书馆', bg='pink', font=('微软雅黑', 50)).pack()
label1 = tk.Label(window, text='请选择操作:', font=('微软雅黑', 20)).place(x=80, y=400)
tk.Button(window, text='图书入库', font=('微软雅黑', 15), width=10, height=2, command=purchase).place(x=350, y=200)
tk.Button(window, text='图书出库', font=('微软雅黑', 15), width=10, height=2, command=cancel).place(x=350, y=300)
tk.Button(window, text='信息查询', font=('微软雅黑', 15), width=10, height=2, command=search_frame).place(x=350, y=400)
tk.Button(window, text='审 核', font=('微软雅黑', 15), width=10, height=2, command=audit).place(x=350, y=500)
tk.Button(window, text='注销', font=('微软雅黑', 12), bg='red', width=8, height=2, command=exit).place(x=760, y=535)
window.mainloop()
def purchase(): # 图书入库信息填写
window.destroy()
global win1
win1 = tk.Tk()
win1.title('管理员')
win1.geometry('900x300')
win1.wm_attributes('-topmost', 1)
lable1 = tk.Label(win1, text='请填写进购图书的信息:', font=('微软雅黑', 20)).place(x=30, y=100)
tk.Label(win1, text='图书类目:', font=('宋体', 12)).place(x=25, y=200)
global list # 这个是一个下拉页表项,只能从下面的list['values']里边选
comvalue = tk.StringVar()
list = ttk.Combobox(win1, textvariable=comvalue, height=10, width=10)
list.place(x=100, y=200)
list['values'] = ('人文', '艺术', '计算机', '科技', '杂志', '其他')
list.current(0) # 默认显示'人文'
N = tk.StringVar()
A = tk.StringVar()
C = tk.StringVar()
P = tk.StringVar()
global bookname
tk.Label(win1, text='书名', font=('宋体', 12)).place(x=200, y=200)
bookname = tk.Entry(win1, textvariable=N, font=('宋体', 12), width=10)
bookname.place(x=250, y=200)
global author
tk.Label(win1, text='作者', textvariable=A, font=('宋体', 12)).place(x=350, y=200)
author = tk.Entry(win1, font=('宋体', 12), width=10)
author.place(x=400, y=200)
global count
tk.Label(win1, text='数量', font=('宋体', 12)).place(x=580, y=200)
count = tk.Entry(win1, textvariable=C, font=('宋体', 12), width=5)
count.place(x=630, y=200)
global price
tk.Label(win1, text='价格', font=('宋体', 12)).place(x=460, y=200)
price = tk.Entry(win1, textvariable=P, font=('宋体', 12), width=8)
price.place(x=510, y=200)
button1 = tk.Button(win1, text='确认入库', font=('宋体', 12), width=10,
command=lambda: add(list, bookname, author, price, count)).place(x=700, y=195)
tk.Button(win1, text='返回', font=('宋体', 12), width=10, command=exit1).place(x=700, y=250)
def add(Type, Bookname, Author, Price, count): # 图书入库的数据库操作
# print(Bookname.get(), Author.get(), Price.get(), DIR[Type.get()])
AddBook(Bookname.get(), Author.get(), Price.get(), DIR[Type.get()], count.get())
win1.destroy()
frame()
# print(Type, Bookname, Author, Price, Count)
def exit1(): # 回到用户界面
win1.destroy()
frame()
def cancel(): # 图书出库填写
window.destroy()
global win2
win2 = tk.Tk()
win2.title('管理员')
win2.geometry('900x300')
win2.wm_attributes('-topmost', 1)
label1 = tk.Label(win2, text='请填写出库图书信息', font=('微软雅黑', 20)).place(x=30, y=100)
# tk.Label(win2, text='图书类目:', font=('宋体', 12)).place(x=25, y=200)
# global list # 这个是一个下拉页表项,只能从下面的list['values']里边选
# comvalue = tk.StringVar()
# list = ttk.Combobox(win2, textvariable=comvalue, height=10, width=10)
# list.place(x=100, y=200)
# list['values'] = ('人文', '艺术', '计算机', '科技', '杂志')
# list.current(0) # 默认显示'人文'
global bookname
bookname_str = tk.StringVar()
tk.Label(win2, text='书名', font=('宋体', 12)).place(x=200, y=200)
bookname = tk.Entry(win2, font=('宋体', 12), textvariable=bookname_str, width=10)
bookname.place(x=250, y=200)
global author
author_str = tk.StringVar()
tk.Label(win2, text='作者', font=('宋体', 12)).place(x=350, y=200)
author = tk.Entry(win2, font=('宋体', 12), textvariable=author_str, width=10)
author.place(x=400, y=200)
button1 = tk.Button(win2, text='确认出库', font=('宋体', 12), width=10,
command=lambda: delete(list, bookname, author)).place(x=600,
y=195)
tk.Button(win2, text='返回', font=('宋体', 12), width=10, command=exit2).place(x=700, y=250)
def delete(Type, Bookname, Author): # 图书出库的数据库操作
RemoveBook(Bookname.get(), Author.get())
win2.destroy()
frame()
def exit2(): # 回到用户界面
win2.destroy()
frame()
def audit(): # 审核
window.destroy()
global win3
win3 = tk.Tk()
win3.title('审核')
win3.geometry('700x600')
label1 = tk.Label(win3, text='需审核信息:', bg='pink', font=('微软雅黑', 20)).place(x=40, y=20)
tree = ttk.Treeview(win3, columns=('1', '2', '3', '4', '5'), show='headings')
tree.column('1', width=100, anchor='center')
tree.column('2', width=100, anchor='center')
tree.column('3', width=100, anchor='center')
tree.column('4', width=100, anchor='center')
tree.column('5', width=100, anchor='center')
tree.heading('1', text='姓名')
tree.heading('2', text='学号')
tree.heading('3', text='书名')
tree.heading('4', text='作者')
tree.heading('5', text='价格')
tree.place(x=40, y=100)
# 测试数据
# sales_data = [('电子产品', '27812', '21223', '2112', '12312'),
# ('化妆品', '28329', '92732', '2723', '23232'),
# ('快消品', '12821', '29761', '127271', '29092'),
# ('日杂', '2939', '23932', '23993', '6892')
# ]
# cur = conn.cursor()
# cur.execute("select id, accountID, password, judge from examine")
sales_data = GetAllExamine()
# 此处使用函数读取数据 并insert到表格
# 将测试数据添加到表格中
data = []
for i in sales_data:
t = (i[2], i[1], i[4], i[5], i[6])
data.append(t)
for i in range(len(data)):
tree.insert('', 'end', values=data[i])
def cleck(Type): # focus就是点击选中
sales_data = GetAllExamine()
print(tree.index(tree.selection())) # 获取当前focus的item的索引值
print(sales_data)
AdminExamine(sales_data, tree.index(tree.selection()), Type)
tree.delete(tree.selection()) # 删除当前focus的item
tk.Button(win3, text='同 意', font=('宋体', 20), width=10, bg='red', command=lambda: cleck(1)).place(x=550, y=20)
tk.Button(win3, text='拒 绝', font=('宋体', 20), width=10, bg='red', command=lambda: cleck(0)).place(x=550, y=80)
tk.Button(win3, text='返 回', font=('宋体', 15), width=10, command=fanhui).place(x=550, y=550)
win3.mainloop()
def search_frame(): # 跳转至查询界面
window.destroy()
search.operation_search()
def fanhui(): # 退出审核界面,回到管理员界面
win3.destroy()
frame()
def exit(): # 退出管理员界面,回到主界面
window.destroy()