@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1 @@
|
||||
python课程设计
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.11" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/python课程设计.iml" filepath="$PROJECT_DIR$/.idea/python课程设计.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,125 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
from tkinter import messagebox
|
||||
from PIL import Image, ImageTk
|
||||
from main_pack.Save_excel import save_execel
|
||||
from image import try_dun as bt
|
||||
|
||||
def check(a):
|
||||
if type(a)==type(None):
|
||||
return 'Null'
|
||||
else:
|
||||
return a
|
||||
|
||||
def fan_check(a):
|
||||
if a=='Null' or a=='':
|
||||
return None
|
||||
else:
|
||||
return int(a)
|
||||
|
||||
def change(cur,num,name,money,password,fix_num):
|
||||
print([name,fan_check(money),password,fan_check(fix_num),int(num)])
|
||||
sql='UPDATE administration SET Administration_name=%s ,Administration_money=%s,Administration_password=%s,Administration_fix_num=%s where Administration_num=%s'
|
||||
cur.execute(sql,[name,fan_check(money),password,fan_check(fix_num),int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息更新成功!')
|
||||
|
||||
def input_name(name,cur,treeview):
|
||||
if name=="":
|
||||
messagebox.showwarning(title="错误", message='请输入信息!')
|
||||
else:
|
||||
sql="select * from administration where Administration_name like '%"+name+"%'"
|
||||
cur.execute(sql)
|
||||
n = cur.fetchall()
|
||||
print(n)
|
||||
messagebox.showwarning(title="正确", message='信息查询成功!')
|
||||
for i in range(len(n)):
|
||||
treeview.insert("",i,values=(n[i][0],n[i][1],n[i][2],n[i][3],n[i][4]))
|
||||
|
||||
def treeview_sort_column(tv, col, reverse):
|
||||
l = [(tv.set(k, col), k) for k in tv.get_children('')]
|
||||
print(tv.get_children(''))
|
||||
l.sort(reverse=reverse)
|
||||
for index, (val, k) in enumerate(l):
|
||||
tv.move(k, '', index)
|
||||
print(k)
|
||||
tv.heading(col, command=lambda: treeview_sort_column(tv, col, not reverse))
|
||||
|
||||
def administration(Main,cur):
|
||||
root, ft, ft1, ft2 = Main.yemian(None)
|
||||
frame_new, label_tk = Main.getframe(None, root)
|
||||
global photo
|
||||
img = Image.open('D:\carrepairsystem\image\左贴图.jpg')
|
||||
photo = ImageTk.PhotoImage(img)
|
||||
Label(frame_new, image=photo).place(x=0, y=0)
|
||||
bt.button_fun(root, frame_new,cur,Main)
|
||||
def delete(cur, num, frame):
|
||||
print(num)
|
||||
sql = "delete from administration where Administration_num=%s"
|
||||
cur.execute(sql, [int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息删除成功!')
|
||||
frame.destroy()
|
||||
win()
|
||||
def win():
|
||||
frame=Main.Frame_fun(None,root)
|
||||
root.title('汽车修理系统——人员信息')
|
||||
n=cur.execute("select * from Administration")
|
||||
n=cur.fetchall()
|
||||
print(n)
|
||||
num=len(n)
|
||||
LabelList=[]
|
||||
ButtonList=[[i for j in range(2)] for i in range(num)]
|
||||
EntryList=[[i for j in range(4)] for i in range(num)]
|
||||
for i in range(num):
|
||||
LabelList.append(i)
|
||||
Label(frame, text="用户编号 ",font=ft1,bg='#d3d7d4').grid(row=0,column=1)
|
||||
Label(frame, text="用户名称 ",font=ft1,bg='#d3d7d4').grid(row=0,column=2)
|
||||
Label(frame, text="用户工资 ",font=ft1,bg='#d3d7d4').grid(row=0,column=3)
|
||||
Label(frame, text="用户密码 ",font=ft1,bg='#d3d7d4').grid(row=0,column=4)
|
||||
Label(frame, text="修理数量 ",font=ft1,bg='#d3d7d4').grid(row=0,column=5)
|
||||
Label(frame, text="具体",font=ft1,bg='#d3d7d4').grid(row=0,column=6)
|
||||
Label(frame, text="操作 ", font=ft1, bg='#d3d7d4').grid(row=0, column=7)
|
||||
for i in range(num):
|
||||
LabelList[i]=Label(frame,text=n[i][0],font=ft1,anchor="nw")
|
||||
LabelList[i].grid(row=i+1, column=1)
|
||||
for j in range(4):
|
||||
EntryList[i][j]=Entry(frame, font=ft1, width=11)
|
||||
EntryList[i][j].grid(row=1 + i, column=2+j)
|
||||
EntryList[i][j].delete(0, "end")
|
||||
EntryList[i][j].insert(0,check(n[i][j+1]))
|
||||
if j==3:
|
||||
ButtonList[i][0]=Button(frame, text="删除",font=ft2,background="#90d7ec",relief=FLAT,command=lambda f=LabelList[i].cget("text"):delete(cur,f,frame))#删除按钮
|
||||
ButtonList[i][1]=Button(frame, text="修改", font=ft2,background="#90d7ec",relief=FLAT,\
|
||||
command=lambda f=LabelList[i].cget("text"),fname=EntryList[i][0].get(),fmoney=EntryList[i][1].get(),fpasword=EntryList[i][2].get(),fnum=EntryList[i][3].get()\
|
||||
:change(cur,f,fname,fmoney,fpasword,fnum)) # 修改按钮
|
||||
ButtonList[i][0].grid(row=1 + i, column=6)
|
||||
ButtonList[i][1].grid(row=1 + i, column=7)
|
||||
win()
|
||||
frame1 = Main.Frame_fun2(None, root)
|
||||
colums = ("用户编号", "用户名称", "用户工资", "用户密码", "修理数量")
|
||||
treeview = ttk.Treeview(frame1, height=190, show="headings", columns=colums)
|
||||
treeview.column("用户编号", width=100, anchor='center')
|
||||
treeview.column("用户名称", width=100, anchor='center')
|
||||
treeview.column("用户工资", width=100, anchor='center')
|
||||
treeview.column("用户密码", width=100, anchor='center')
|
||||
treeview.column("修理数量", width=100, anchor='center')
|
||||
treeview.heading('用户编号', text='用户编号')
|
||||
treeview.heading('用户名称', text='用户名称')
|
||||
treeview.heading('用户工资', text='用户工资')
|
||||
treeview.heading('用户密码', text='用户密码')
|
||||
treeview.heading('修理数量', text='修理数量')
|
||||
treeview.place(x=0, y=0)
|
||||
labe1=Label(frame1,text="用户姓名:",font=ft1)
|
||||
labe1.place(x=525,y=50)
|
||||
entry_next=Entry(frame1,font=ft1)
|
||||
entry_next.place(x=640,y=50,width=130)
|
||||
button_next=Button(frame1,text="查 询",font=ft2,command=lambda :input_name(entry_next.get(),cur,treeview))
|
||||
button_next.place(x=535,y=90,width=230)
|
||||
button_next_1=Button(frame1,text="导出数据",font=ft2,command=lambda :save_execel(cur,"administration"))
|
||||
button_next_1.place(x=535,y=130,width=230)
|
||||
button_next_2=Button(frame1,text="回到主页",font=ft2)
|
||||
#button_next_2.place(x=535,y=170,width=230)
|
||||
for col in colums:
|
||||
if col!="用户名称" and col!="用户密码":
|
||||
treeview.heading(col, text=col, command=lambda _col=col: treeview_sort_column(treeview, _col, False))
|
||||
|
||||
root.mainloop()
|
@ -0,0 +1,165 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
from tkinter import messagebox
|
||||
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
from main_pack.Save_excel import save_execel
|
||||
from image import try_dun as bt
|
||||
|
||||
|
||||
def check(a):
|
||||
if type(a)==type(None):
|
||||
return 'Null'
|
||||
else:
|
||||
return a
|
||||
|
||||
def fan_check(a):
|
||||
if a=='Null' or a=='':
|
||||
return None
|
||||
else:
|
||||
return int(a)
|
||||
|
||||
def change(cur,num,name,money,password,fix_num):
|
||||
sql='UPDATE car_master SET car_master_name=%s ,car_master_phnum=%s,car_master_cartype=%s,car_master_user=%s where car_master_num=%s'
|
||||
cur.execute(sql,[name,money,password,fix_num,int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息更新成功!')
|
||||
|
||||
def input_name(name,cur,treeview):
|
||||
if name=="":
|
||||
messagebox.showwarning(title="错误", message='请输入信息!')
|
||||
else:
|
||||
sql="select * from car_master where car_master_user like '%"+name+"%'"
|
||||
cur.execute(sql)
|
||||
n = cur.fetchall()
|
||||
print(n)
|
||||
messagebox.showwarning(title="正确", message='信息查询成功!')
|
||||
for i in range(len(n)):
|
||||
treeview.insert("",i,values=(n[i][0],n[i][1],n[i][2],n[i][3],n[i][4]))
|
||||
|
||||
|
||||
def car_master(Main,cur):
|
||||
root, ft, ft1, ft2 = Main.yemian(None)
|
||||
frame_new, label_tk = Main.getframe(None, root)
|
||||
global photo
|
||||
img = Image.open('D:\carrepairsystem\image\左贴图.jpg') # 打开图片
|
||||
photo = ImageTk.PhotoImage(img)
|
||||
Label(frame_new, image=photo).place(x=0, y=0)
|
||||
bt.button_fun(root, frame_new,cur,Main)#按钮
|
||||
# 弹窗插入数据页面——新建一个页面
|
||||
def win_new():
|
||||
root_new = Tk()
|
||||
root_new.title("车主信息表——插入数据")
|
||||
width = 400
|
||||
height = 300
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
x = int(screen_width / 2 - width / 2)
|
||||
y = int(screen_height / 2 - height / 2)
|
||||
size = '{}x{}+{}+{}'.format(width, height, x, y)
|
||||
#输入框
|
||||
labe1_new=Label(root_new,text="车主名称:",font=ft1)
|
||||
labe2_new=Label(root_new,text='手机号码:',font=ft1)
|
||||
labe3_new=Label(root_new,text="车主车型:",font=ft1)
|
||||
labe1_new.place(x=30,y=40)
|
||||
labe2_new.place(x=30,y=80)
|
||||
labe3_new.place(x=30,y=120)
|
||||
entry1_new=Entry(root_new,width=30)
|
||||
entry2_new=Entry(root_new,width=30)
|
||||
entry3_new=Entry(root_new,width=30)
|
||||
entry1_new.place(x=120,y=40)
|
||||
entry2_new.place(x=120,y=80)
|
||||
entry3_new.place(x=120,y=120)
|
||||
button1_new=Button(root_new,text="确定",font=ft2,width=15,command=lambda :insert_fun(cur,entry1_new.get(),entry2_new.get(),entry3_new.get(),root_new))
|
||||
button2_new=Button(root_new,text="取消",font=ft2,width=15,command=root_new.destroy)
|
||||
button1_new.place(x=40,y=160)
|
||||
button2_new.place(x=180,y=160)
|
||||
root_new.geometry(size)
|
||||
# 输入框设置
|
||||
|
||||
root_new.mainloop()
|
||||
def delete(cur, num, frame): # 删除函数
|
||||
print(num)
|
||||
sql = "delete from car_master where car_master_num=%s"
|
||||
cur.execute(sql, [int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息删除成功!')
|
||||
frame.destroy()
|
||||
win()
|
||||
|
||||
def insert_fun(cur, name, phnum, cartype, root):
|
||||
|
||||
if name == "" or phnum == "" or cartype == "":
|
||||
messagebox.showwarning(title="失败", message='请输入完整信息')
|
||||
else:
|
||||
|
||||
sql = "insert into car_master(car_master_name,car_master_phnum,car_master_cartype,car_master_user)values(%s,%s,%s,%s)"
|
||||
cur.execute(sql, [name, phnum, cartype, "SONG"])
|
||||
messagebox.showwarning(title="成功", message='信息插入成功!')
|
||||
root.destroy()
|
||||
win()
|
||||
|
||||
|
||||
def win():
|
||||
frame=Main.Frame_fun(None,root)
|
||||
root.title('汽车修理系统——车主信息')
|
||||
cur.execute("select * from car_master")
|
||||
n=cur.fetchall()
|
||||
print(n)
|
||||
num=len(n)
|
||||
LabelList=[]
|
||||
ButtonList=[[i for j in range(2)] for i in range(num)]
|
||||
EntryList=[[i for j in range(4)] for i in range(num)]
|
||||
for i in range(num):
|
||||
LabelList.append(i)
|
||||
Label(frame, text="车主编号 ",font=ft1,bg='#d3d7d4').grid(row=0,column=1)
|
||||
Label(frame, text="车主名称 ",font=ft1,bg='#d3d7d4').grid(row=0,column=2)
|
||||
Label(frame, text="手机号码 ",font=ft1,bg='#d3d7d4').grid(row=0,column=3)
|
||||
Label(frame, text="车主车型 ",font=ft1,bg='#d3d7d4').grid(row=0,column=4)
|
||||
Label(frame, text="负责人员 ",font=ft1,bg='#d3d7d4').grid(row=0,column=5)
|
||||
Label(frame, text="具体",font=ft1,bg='#d3d7d4').grid(row=0,column=6)
|
||||
Label(frame, text="操作 ", font=ft1, bg='#d3d7d4').grid(row=0, column=7)
|
||||
for i in range(num):
|
||||
|
||||
LabelList[i]=Label(frame,text=n[i][0],font=ft1,anchor="nw")
|
||||
LabelList[i].grid(row=i+1, column=1)
|
||||
for j in range(4):
|
||||
EntryList[i][j]=Entry(frame, font=ft1, width=11)
|
||||
EntryList[i][j].grid(row=1 + i, column=2+j)
|
||||
EntryList[i][j].delete(0, "end")
|
||||
EntryList[i][j].insert(0,check(n[i][j+1]))
|
||||
if j==3:
|
||||
ButtonList[i][0]=Button(frame, text="删除",font=ft2,background="#90d7ec",relief=FLAT,command=lambda f=LabelList[i].cget("text"):delete(cur,f,frame))#删除按钮
|
||||
ButtonList[i][1]=Button(frame, text="修改", font=ft2,background="#90d7ec",relief=FLAT,\
|
||||
command=lambda f=LabelList[i].cget("text"),fname=EntryList[i][0].get(),
|
||||
fmoney=EntryList[i][1].get(),fpasword=EntryList[i][2].get(),fnum=EntryList[i][3].get()\
|
||||
:change(cur,f,fname,fmoney,fpasword,fnum)) # 修改按钮
|
||||
ButtonList[i][0].grid(row=1 + i, column=6)
|
||||
ButtonList[i][1].grid(row=1 + i, column=7)
|
||||
win()
|
||||
frame1 = Main.Frame_fun2(None, root)
|
||||
colums = ("车主编号", "车主名称", "手机号码", "车主车型", "负责人员")
|
||||
treeview = ttk.Treeview(frame1, height=190, show="headings", columns=colums)
|
||||
treeview.column("车主编号", width=100, anchor='center')
|
||||
treeview.column("车主名称", width=100, anchor='center')
|
||||
treeview.column("手机号码", width=100, anchor='center')
|
||||
treeview.column("车主车型", width=100, anchor='center')
|
||||
treeview.column("负责人员", width=100, anchor='center')
|
||||
treeview.heading('车主编号', text='车主编号')
|
||||
treeview.heading('车主名称', text='车主名称')
|
||||
treeview.heading('手机号码', text='手机号码')
|
||||
treeview.heading('车主车型', text='车主车型')
|
||||
treeview.heading('负责人员', text='负责人员')
|
||||
treeview.place(x=0, y=0)
|
||||
labe1=Label(frame1,text="用户姓名:",font=ft1)
|
||||
labe1.place(x=525,y=50)
|
||||
entry_next=Entry(frame1,font=ft1)
|
||||
entry_next.place(x=640,y=50,width=130)
|
||||
button_next=Button(frame1,text="查 询",font=ft2,command=lambda :input_name(entry_next.get(),cur,treeview))
|
||||
button_next.place(x=535,y=90,width=230)
|
||||
button_next_1=Button(frame1,text="导出数据",font=ft2,command=lambda :save_execel(cur,"car_master"))
|
||||
button_next_1.place(x=535,y=130,width=230)
|
||||
button_next_2=Button(frame1,text="插入数据",font=ft2,command=win_new)
|
||||
button_next_2.place(x=535,y=170,width=230)
|
||||
|
||||
|
||||
root.mainloop()
|
@ -0,0 +1,191 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
from tkinter import messagebox
|
||||
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
from main_pack.Save_excel import save_execel
|
||||
from image import try_dun as bt
|
||||
|
||||
|
||||
def treeview_sort_column(tv, col, reverse):#Treeview、列名、排列方式
|
||||
l = [(tv.set(k, col), k) for k in tv.get_children('')]
|
||||
print(tv.get_children(''))
|
||||
l.sort(reverse=reverse)#排序方式
|
||||
for index, (val, k) in enumerate(l):#根据排序后索引移动
|
||||
tv.move(k, '', index)
|
||||
print(k)
|
||||
tv.heading(col, command=lambda: treeview_sort_column(tv, col, not reverse))#重写标题,使之成为再点倒序的标题
|
||||
|
||||
def delButton(tree):#删除条目
|
||||
x=tree.get_children()
|
||||
for item in x:
|
||||
tree.delete(item)
|
||||
|
||||
def check(a):
|
||||
if type(a)==type(None):
|
||||
return 'Null'
|
||||
else:
|
||||
return a
|
||||
|
||||
def fan_check(a):
|
||||
if a=='Null' or a=='':
|
||||
return None
|
||||
else:
|
||||
return int(a)
|
||||
|
||||
def change(cur,num,name,money,password,fix_num):
|
||||
sql='UPDATE fix SET car_master_name=%s ,fix_money=%s,fix_user=%s,fix_part=%s where fix_num=%s'
|
||||
cur.execute(sql,[name,int(money),password,fix_num,int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息更新成功!')
|
||||
|
||||
def input_name(name,cur,treeview):
|
||||
if name=="":
|
||||
messagebox.showwarning(title="错误", message='请输入信息!')
|
||||
else:
|
||||
sql="select * from fix where fix_user like '%"+name+"%'"
|
||||
cur.execute(sql)
|
||||
n = cur.fetchall()
|
||||
print(n)
|
||||
messagebox.showwarning(title="正确", message='信息查询成功!')
|
||||
for i in range(len(n)):
|
||||
treeview.insert("",i,values=(n[i][0],n[i][1],n[i][2],n[i][3],n[i][4]))
|
||||
|
||||
|
||||
def Fix_fun(Main,cur):
|
||||
root, ft, ft1, ft2 = Main.yemian(None)
|
||||
frame_new, label_tk = Main.getframe(None, root)
|
||||
global photo
|
||||
img = Image.open('D:\carrepairsystem\image\左贴图.jpg') # 打开图片
|
||||
photo = ImageTk.PhotoImage(img)
|
||||
Label(frame_new, image=photo).place(x=0, y=0)
|
||||
bt.button_fun(root, frame_new,cur,Main)#按钮
|
||||
# 弹窗插入数据页面——新建一个页面
|
||||
def win_new():
|
||||
root_new = Tk()
|
||||
root_new.title("零件信息表——插入数据")
|
||||
# frame_new=Frame(root_new,width=300,height=250,bg='#BEE7E9')
|
||||
# frame_new.place(x=20)
|
||||
# 屏幕参数设置
|
||||
width = 400
|
||||
height = 300
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
x = int(screen_width / 2 - width / 2)
|
||||
y = int(screen_height / 2 - height / 2)
|
||||
size = '{}x{}+{}+{}'.format(width, height, x, y)
|
||||
#输入框
|
||||
labe1_new=Label(root_new,text="车主名字:",font=ft1)
|
||||
labe2_new=Label(root_new,text='修理费用:',font=ft1)
|
||||
labe3_new=Label(root_new,text="所用零件:",font=ft1)
|
||||
#labe4_new = Label(root_new, text="生产地区:", font=ft1)
|
||||
labe1_new.place(x=30,y=40)
|
||||
labe2_new.place(x=30,y=80)
|
||||
labe3_new.place(x=30,y=120)
|
||||
#labe4_new.place(x=30,y=160)
|
||||
entry1_new=Entry(root_new,width=30)
|
||||
entry2_new=Entry(root_new,width=30)
|
||||
entry3_new=Entry(root_new,width=30)
|
||||
#entry4_new=Entry(root_new,width=30)
|
||||
entry1_new.place(x=120,y=40)
|
||||
entry2_new.place(x=120,y=80)
|
||||
entry3_new.place(x=120,y=120)
|
||||
# entry4_new.place(x=120,y=160)
|
||||
button1_new=Button(root_new,text="确定",font=ft2,width=15,command=lambda :insert_fun(cur,entry1_new.get(),entry2_new.get(),entry3_new.get(),root_new))
|
||||
button2_new=Button(root_new,text="取消",font=ft2,width=15,command=root_new.destroy)
|
||||
button1_new.place(x=40,y=160)
|
||||
button2_new.place(x=180,y=160)
|
||||
root_new.geometry(size)
|
||||
# 输入框设置
|
||||
|
||||
root_new.mainloop()
|
||||
def delete(cur, num, frame): # 删除函数
|
||||
print(num)
|
||||
sql = "delete from part where part_num=%s"
|
||||
cur.execute(sql, [int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息删除成功!')
|
||||
frame.destroy()
|
||||
win()
|
||||
|
||||
def insert_fun(cur, name, phnum, cartype,root):
|
||||
|
||||
if name == "" or phnum == "" or cartype == "":
|
||||
messagebox.showwarning(title="失败", message='请输入完整信息')
|
||||
else:
|
||||
|
||||
sql = "insert into fix(car_master_name,fix_money,fix_user,fix_part)values(%s,%s,%s,%s)"
|
||||
cur.execute(sql, [name, phnum, "SONG",cartype])
|
||||
messagebox.showwarning(title="成功", message='信息插入成功!')
|
||||
root.destroy()
|
||||
win()
|
||||
|
||||
|
||||
def win():
|
||||
frame=Main.Frame_fun(None,root)
|
||||
root.title('汽车修理系统——修理信息')
|
||||
cur.execute("select * from fix")
|
||||
n=cur.fetchall()
|
||||
num=len(n)#数据量
|
||||
LabelList=[]#用户编号列表
|
||||
ButtonList=[[i for j in range(2)] for i in range(num)]#按钮列表——二维
|
||||
EntryList=[[i for j in range(4)] for i in range(num)]#输入框列表——num行4列
|
||||
for i in range(num):
|
||||
LabelList.append(i)
|
||||
#ButtonList.append(i)
|
||||
#创建标题行
|
||||
Label(frame, text="事件编号 ",font=ft1,bg='#d3d7d4').grid(row=0,column=1)
|
||||
Label(frame, text="车主姓名 ",font=ft1,bg='#d3d7d4').grid(row=0,column=2)
|
||||
Label(frame, text="修理价格 ",font=ft1,bg='#d3d7d4').grid(row=0,column=3)
|
||||
Label(frame, text="经手员工 ",font=ft1,bg='#d3d7d4').grid(row=0,column=4)
|
||||
Label(frame, text="所用零件 ",font=ft1,bg='#d3d7d4').grid(row=0,column=5)
|
||||
Label(frame, text="具体",font=ft1,bg='#d3d7d4').grid(row=0,column=6)
|
||||
Label(frame, text="操作 ", font=ft1, bg='#d3d7d4').grid(row=0, column=7)
|
||||
for i in range(num):
|
||||
#编号
|
||||
LabelList[i]=Label(frame,text=n[i][0],font=ft1,anchor="nw")
|
||||
LabelList[i].grid(row=i+1, column=1)
|
||||
#输入框
|
||||
for j in range(4):
|
||||
EntryList[i][j]=Entry(frame, font=ft1, width=11)
|
||||
EntryList[i][j].grid(row=1 + i, column=2+j)
|
||||
EntryList[i][j].delete(0, "end")
|
||||
EntryList[i][j].insert(0,check(n[i][j+1]))
|
||||
if j==3:
|
||||
ButtonList[i][0]=Button(frame, text="删除",font=ft2,background="#90d7ec",relief=FLAT,command=lambda f=LabelList[i].cget("text"):delete(cur,f,frame))#删除按钮
|
||||
ButtonList[i][1]=Button(frame, text="修改", font=ft2,background="#90d7ec",relief=FLAT,\
|
||||
command=lambda f=LabelList[i].cget("text"),fname=EntryList[i][0].get(),
|
||||
fmoney=EntryList[i][1].get(),fpasword=EntryList[i][2].get(),fnum=EntryList[i][3].get()\
|
||||
:change(cur,f,fname,fmoney,fpasword,fnum)) # 修改按钮
|
||||
ButtonList[i][0].grid(row=1 + i, column=6)
|
||||
ButtonList[i][1].grid(row=1 + i, column=7)
|
||||
win()
|
||||
frame1 = Main.Frame_fun2(None, root)
|
||||
colums = ("事件编号", "车主姓名", "修理价格", "经手员工", "所用零件")
|
||||
treeview = ttk.Treeview(frame1, height=190, show="headings", columns=colums)
|
||||
treeview.column("事件编号", width=100, anchor='center')
|
||||
treeview.column("车主姓名", width=100, anchor='center')
|
||||
treeview.column("修理价格", width=100, anchor='center')
|
||||
treeview.column("经手员工", width=100, anchor='center')
|
||||
treeview.column("所用零件", width=100, anchor='center')
|
||||
treeview.heading('事件编号', text='事件编号')
|
||||
treeview.heading('车主姓名', text='车主姓名')
|
||||
treeview.heading('修理价格', text='修理价格')
|
||||
treeview.heading('经手员工', text='经手员工')
|
||||
treeview.heading('所用零件', text='所用零件')
|
||||
treeview.place(x=0, y=0)
|
||||
labe1=Label(frame1,text="经手员工:",font=ft1)
|
||||
labe1.place(x=525,y=50)
|
||||
entry_next=Entry(frame1,font=ft1)
|
||||
entry_next.place(x=640,y=50,width=130)
|
||||
button_next=Button(frame1,text="查 询",font=ft2,command=lambda :[delButton(treeview),input_name(entry_next.get(),cur,treeview)])
|
||||
button_next.place(x=535,y=90,width=230)
|
||||
button_next_1=Button(frame1,text="导出数据",font=ft2,command=lambda :save_execel(cur,"fix"))
|
||||
button_next_1.place(x=535,y=130,width=230)
|
||||
button_next_2=Button(frame1,text="插入数据",font=ft2,command=win_new)
|
||||
button_next_2.place(x=535,y=170,width=230)
|
||||
for col in colums: # 给所有标题加(循环上边的“手工”)
|
||||
if col!="车主姓名" and col!="经手员工" and col!="所用零件":
|
||||
treeview.heading(col, text=col, command=lambda _col=col: treeview_sort_column(treeview, _col, False))
|
||||
|
||||
|
||||
root.mainloop()
|
@ -0,0 +1,186 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
from tkinter import messagebox
|
||||
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
from main_pack.Save_excel import save_execel
|
||||
from image import try_dun as bt
|
||||
|
||||
|
||||
def treeview_sort_column(tv, col, reverse):#Treeview、列名、排列方式
|
||||
l = [(tv.set(k, col), k) for k in tv.get_children('')]
|
||||
print(tv.get_children(''))
|
||||
l.sort(reverse=reverse)#排序方式
|
||||
for index, (val, k) in enumerate(l):#根据排序后索引移动
|
||||
tv.move(k, '', index)
|
||||
print(k)
|
||||
tv.heading(col, command=lambda: treeview_sort_column(tv, col, not reverse))#重写标题,使之成为再点倒序的标题
|
||||
|
||||
def check(a):
|
||||
if type(a)==type(None):
|
||||
return 'Null'
|
||||
else:
|
||||
return a
|
||||
|
||||
def fan_check(a):
|
||||
if a=='Null' or a=='':
|
||||
return None
|
||||
else:
|
||||
return int(a)
|
||||
|
||||
def change(cur,num,name,money,password,fix_num):
|
||||
sql='UPDATE part SET part_name=%s ,part_money=%s,part_left_num=%s,part_start=%s where part_num=%s'
|
||||
cur.execute(sql,[name,int(money),int(password),fix_num,int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息更新成功!')
|
||||
|
||||
def input_name(name,cur,treeview):
|
||||
if name=="":
|
||||
messagebox.showwarning(title="错误", message='请输入信息!')
|
||||
else:
|
||||
sql="select * from part where part_name like '%"+name+"%'"
|
||||
cur.execute(sql)
|
||||
n = cur.fetchall()
|
||||
print(n)
|
||||
messagebox.showwarning(title="正确", message='信息查询成功!')
|
||||
for i in range(len(n)):
|
||||
treeview.insert("",i,values=(n[i][0],n[i][1],n[i][2],n[i][3],n[i][4]))
|
||||
|
||||
|
||||
def Staff(Main,cur):
|
||||
root, ft, ft1, ft2 = Main.yemian(None)
|
||||
frame_new, label_tk = Main.getframe(None, root)
|
||||
global photo
|
||||
img = Image.open('D:\carrepairsystem\image\左贴图.jpg') # 打开图片
|
||||
photo = ImageTk.PhotoImage(img)
|
||||
Label(frame_new, image=photo).place(x=0, y=0)
|
||||
bt.button_fun(root, frame_new,cur,Main)#按钮
|
||||
# 弹窗插入数据页面——新建一个页面
|
||||
def win_new():
|
||||
root_new = Tk()
|
||||
root_new.title("零件信息表——插入数据")
|
||||
# frame_new=Frame(root_new,width=300,height=250,bg='#BEE7E9')
|
||||
# frame_new.place(x=20)
|
||||
# 屏幕参数设置
|
||||
width = 400
|
||||
height = 300
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
x = int(screen_width / 2 - width / 2)
|
||||
y = int(screen_height / 2 - height / 2)
|
||||
size = '{}x{}+{}+{}'.format(width, height, x, y)
|
||||
#输入框
|
||||
labe1_new=Label(root_new,text="零件名称:",font=ft1)
|
||||
labe2_new=Label(root_new,text='零件价格:',font=ft1)
|
||||
labe3_new=Label(root_new,text="零件数量:",font=ft1)
|
||||
labe4_new = Label(root_new, text="生产地区:", font=ft1)
|
||||
labe1_new.place(x=30,y=40)
|
||||
labe2_new.place(x=30,y=80)
|
||||
labe3_new.place(x=30,y=120)
|
||||
labe4_new.place(x=30,y=160)
|
||||
entry1_new=Entry(root_new,width=30)
|
||||
entry2_new=Entry(root_new,width=30)
|
||||
entry3_new=Entry(root_new,width=30)
|
||||
entry4_new=Entry(root_new,width=30)
|
||||
entry1_new.place(x=120,y=40)
|
||||
entry2_new.place(x=120,y=80)
|
||||
entry3_new.place(x=120,y=120)
|
||||
entry4_new.place(x=120,y=160)
|
||||
button1_new=Button(root_new,text="确定",font=ft2,width=15,command=lambda :insert_fun(cur,entry1_new.get(),entry2_new.get(),entry3_new.get(),entry4_new.get(),root_new))
|
||||
button2_new=Button(root_new,text="取消",font=ft2,width=15,command=root_new.destroy)
|
||||
button1_new.place(x=40,y=200)
|
||||
button2_new.place(x=180,y=200)
|
||||
root_new.geometry(size)
|
||||
# 输入框设置
|
||||
|
||||
root_new.mainloop()
|
||||
def delete(cur, num, frame): # 删除函数
|
||||
print(num)
|
||||
sql = "delete from part where part_num=%s"
|
||||
cur.execute(sql, [int(num)])
|
||||
messagebox.showwarning(title="成功", message='信息删除成功!')
|
||||
frame.destroy()
|
||||
win()
|
||||
|
||||
def insert_fun(cur, name, phnum, cartype, satrt,root):
|
||||
|
||||
if name == "" or phnum == "" or cartype == "":
|
||||
messagebox.showwarning(title="失败", message='请输入完整信息')
|
||||
else:
|
||||
|
||||
sql = "insert into part(part_name,part_money,part_left_num,part_start)values(%s,%s,%s,%s)"
|
||||
cur.execute(sql, [name, phnum, cartype,satrt])
|
||||
messagebox.showwarning(title="成功", message='信息插入成功!')
|
||||
root.destroy()
|
||||
win()
|
||||
|
||||
|
||||
def win():
|
||||
frame=Main.Frame_fun(None,root)
|
||||
root.title('汽车修理系统——零件信息')
|
||||
cur.execute("select * from part")
|
||||
n=cur.fetchall()
|
||||
num=len(n)#数据量
|
||||
LabelList=[]#用户编号列表
|
||||
ButtonList=[[i for j in range(2)] for i in range(num)]#按钮列表——二维
|
||||
EntryList=[[i for j in range(4)] for i in range(num)]#输入框列表——num行4列
|
||||
for i in range(num):
|
||||
LabelList.append(i)
|
||||
#ButtonList.append(i)
|
||||
#创建标题行
|
||||
Label(frame, text="零件编号 ",font=ft1,bg='#d3d7d4').grid(row=0,column=1)
|
||||
Label(frame, text="零件名称 ",font=ft1,bg='#d3d7d4').grid(row=0,column=2)
|
||||
Label(frame, text="零件价格 ",font=ft1,bg='#d3d7d4').grid(row=0,column=3)
|
||||
Label(frame, text="剩余数量 ",font=ft1,bg='#d3d7d4').grid(row=0,column=4)
|
||||
Label(frame, text="生产地区 ",font=ft1,bg='#d3d7d4').grid(row=0,column=5)
|
||||
Label(frame, text="具体",font=ft1,bg='#d3d7d4').grid(row=0,column=6)
|
||||
Label(frame, text="操作 ", font=ft1, bg='#d3d7d4').grid(row=0, column=7)
|
||||
for i in range(num):
|
||||
#编号
|
||||
LabelList[i]=Label(frame,text=n[i][0],font=ft1,anchor="nw")
|
||||
LabelList[i].grid(row=i+1, column=1)
|
||||
#输入框
|
||||
for j in range(4):
|
||||
EntryList[i][j]=Entry(frame, font=ft1, width=11)
|
||||
EntryList[i][j].grid(row=1 + i, column=2+j)
|
||||
EntryList[i][j].delete(0, "end")
|
||||
EntryList[i][j].insert(0,check(n[i][j+1]))
|
||||
if j==3:
|
||||
ButtonList[i][0]=Button(frame, text="删除",font=ft2,background="#90d7ec",relief=FLAT,command=lambda f=LabelList[i].cget("text"):delete(cur,f,frame))#删除按钮
|
||||
ButtonList[i][1]=Button(frame, text="修改", font=ft2,background="#90d7ec",relief=FLAT,\
|
||||
command=lambda f=LabelList[i].cget("text"),fname=EntryList[i][0].get(),
|
||||
fmoney=EntryList[i][1].get(),fpasword=EntryList[i][2].get(),fnum=EntryList[i][3].get()\
|
||||
:change(cur,f,fname,fmoney,fpasword,fnum)) # 修改按钮
|
||||
ButtonList[i][0].grid(row=1 + i, column=6)
|
||||
ButtonList[i][1].grid(row=1 + i, column=7)
|
||||
win()
|
||||
frame1 = Main.Frame_fun2(None, root)
|
||||
colums = ("零件编号", "零件名称", "零件价格", "剩余数量", "生产地区")
|
||||
treeview = ttk.Treeview(frame1, height=190, show="headings", columns=colums)
|
||||
treeview.column("零件编号", width=100, anchor='center')
|
||||
treeview.column("零件名称", width=100, anchor='center')
|
||||
treeview.column("零件价格", width=100, anchor='center')
|
||||
treeview.column("剩余数量", width=100, anchor='center')
|
||||
treeview.column("生产地区", width=100, anchor='center')
|
||||
treeview.heading('零件编号', text='零件编号')
|
||||
treeview.heading('零件名称', text='零件名称')
|
||||
treeview.heading('零件价格', text='零件价格')
|
||||
treeview.heading('剩余数量', text='剩余数量')
|
||||
treeview.heading('生产地区', text='生产地区')
|
||||
treeview.place(x=0, y=0)
|
||||
labe1=Label(frame1,text="零件名称:",font=ft1)
|
||||
labe1.place(x=525,y=50)
|
||||
entry_next=Entry(frame1,font=ft1)
|
||||
entry_next.place(x=640,y=50,width=130)
|
||||
button_next=Button(frame1,text="查 询",font=ft2,command=lambda :input_name(entry_next.get(),cur,treeview))
|
||||
button_next.place(x=535,y=90,width=230)
|
||||
button_next_1=Button(frame1,text="导出数据",font=ft2,command=lambda :save_execel(cur,"part"))
|
||||
button_next_1.place(x=535,y=130,width=230)
|
||||
button_next_2=Button(frame1,text="插入数据",font=ft2,command=win_new)
|
||||
button_next_2.place(x=535,y=170,width=230)
|
||||
for col in colums: # 给所有标题加(循环上边的“手工”)
|
||||
if col!="零件名称" and col!="生产地区":
|
||||
treeview.heading(col, text=col, command=lambda _col=col: treeview_sort_column(treeview, _col, False))
|
||||
|
||||
|
||||
root.mainloop()
|
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,63 @@
|
||||
import Car_pack.Car_fun as cf
|
||||
import Staff_pack.staff_fun as stf
|
||||
import Staff_pack.fix_fun as fi
|
||||
import Administration_pack.Administration_information as ad
|
||||
import main_pack.main_python as ma
|
||||
from tkinter import *
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
from main_pack.main_python import main2
|
||||
|
||||
|
||||
def button_fun(root,frame,cur,Main):
|
||||
# 按钮重绘过程----------------------------------------------------------------------------------
|
||||
# ----------------------------------------------------------
|
||||
img_log = Image.open("D:\carrepairsystem\image\log.png")
|
||||
global img_log_tk
|
||||
img_log_tk = ImageTk.PhotoImage(img_log)
|
||||
Button_log = Button(frame, image=img_log_tk, compound=TOP, width=78,
|
||||
height=80, text="系统主页", bd=1, bg="#3fcefe", relief=GROOVE,
|
||||
command=lambda: [root.destroy(), main2(cur)])
|
||||
Button_log.place(x=0, y=80)
|
||||
img_staff_information = Image.open("D:\carrepairsystem\image\imformation.png")
|
||||
global img_staff_information_tk
|
||||
img_staff_information_tk = ImageTk.PhotoImage(img_staff_information)
|
||||
|
||||
img_carmain_information = Image.open("D:\carrepairsystem\image\Boss.png")
|
||||
global img_carmain_information_tk
|
||||
img_carmain_information_tk = ImageTk.PhotoImage(img_carmain_information)
|
||||
|
||||
img_carlinjian_information = Image.open("D:\carrepairsystem\image\零件.png")
|
||||
global img_carlinjian_information_tk
|
||||
img_carlinjian_information_tk = ImageTk.PhotoImage(img_carlinjian_information)
|
||||
|
||||
img_fix_information = Image.open("D:\carrepairsystem\image\修理信息.png")
|
||||
global img_fix_information_tk
|
||||
img_fix_information_tk = ImageTk.PhotoImage(img_fix_information)
|
||||
|
||||
img_tui = Image.open("D:\carrepairsystem\image\退出.png")
|
||||
global img_tui_tk
|
||||
img_tui_tk = ImageTk.PhotoImage(img_tui)
|
||||
|
||||
Button_staff_information = Button(frame, image=img_staff_information_tk, compound=TOP, width=78,
|
||||
height=80, text="人员信息", bd=1, bg="#3fcefe", relief=GROOVE,
|
||||
command=lambda: [root.destroy(), ad.administration(Main, cur)])
|
||||
Button_carmain_information = Button(frame, image=img_carmain_information_tk, compound=TOP, width=78,
|
||||
height=80, text="车主信息", bd=1, bg="#3fcefe", relief=GROOVE,
|
||||
command=lambda: [root.destroy(), cf.car_master(Main, cur)])
|
||||
Button_carlinjian_information = Button(frame, image=img_carlinjian_information_tk, compound=TOP, width=78,
|
||||
height=80, text="零件信息", bd=1, bg="#3fcefe", relief=GROOVE
|
||||
, command=lambda: [root.destroy(), stf.Staff(Main, cur)])
|
||||
Button_fix_information = Button(frame, image=img_fix_information_tk, compound=TOP, width=78,
|
||||
height=80, text="修理信息", bd=1, bg="#3fcefe", relief=GROOVE,
|
||||
command=lambda: [root.destroy(), fi.Fix_fun(Main, cur)])
|
||||
Button_tui = Button(frame, image=img_tui_tk, compound=TOP, width=78,
|
||||
height=80, text="退出登录", bd=1, bg="#3fcefe", relief=GROOVE,
|
||||
command=lambda: [root.destroy(), ma.main_pace(cur)])
|
||||
Button_staff_information.place(x=0, y=170)
|
||||
Button_carmain_information.place(x=0, y=260)
|
||||
Button_carlinjian_information.place(x=0, y=350)
|
||||
Button_fix_information.place(x=0, y=440)
|
||||
Button_tui.place(x=0, y=530)
|
||||
# ----------------------------------------------------------
|
||||
# 按钮重绘过程----------------------------------------------------------------------------------
|
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 672 B |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 5.7 KiB |
@ -0,0 +1,40 @@
|
||||
import xlwt
|
||||
from tkinter import messagebox
|
||||
def save_execel(curs,tablename):
|
||||
sql='select * from '+tablename
|
||||
curs.execute(sql)
|
||||
rows = curs.fetchall() # 获取所有数据
|
||||
#二、初始化excel文件
|
||||
w=xlwt.Workbook(encoding='utf-8')
|
||||
style=xlwt.XFStyle()
|
||||
font=xlwt.Font()
|
||||
font.name="微软雅黑"
|
||||
style.font=font
|
||||
if tablename=="administration":
|
||||
ws = w.add_sheet("用户信息", cell_overwrite_ok=True)
|
||||
title = "用户ID,用户名,用户工资,密码,修理数量"
|
||||
title = title.split(",")
|
||||
elif tablename=="car_master":
|
||||
ws = w.add_sheet("车主信息", cell_overwrite_ok=True)
|
||||
title = "车主ID,车主名,手机号码,车辆类型,负责人员"
|
||||
title = title.split(",")
|
||||
elif tablename=="part":
|
||||
ws = w.add_sheet("零件信息", cell_overwrite_ok=True)
|
||||
title = "零件编号,零件名称,零件价格,剩余数量,生产地区"
|
||||
title = title.split(",")
|
||||
else:
|
||||
ws = w.add_sheet("修理信息", cell_overwrite_ok=True)
|
||||
title = "事件编号,车主姓名,修理价格,经手员工,所用零件"
|
||||
title = title.split(",")
|
||||
|
||||
for i in range(len(title)):
|
||||
ws.write(0, i, title[i], style)
|
||||
for i in range(len(rows)):
|
||||
row = rows[i]
|
||||
for j in range(len(row)):
|
||||
if row[j]:
|
||||
item = row[j]
|
||||
ws.write(i + 1, j, item, style)
|
||||
path='./'+tablename+".xls"
|
||||
w.save(path)
|
||||
messagebox.showwarning(title="成功", message='信息保存成功,请到本地目录查看!')
|
@ -0,0 +1,25 @@
|
||||
from tkinter import *
|
||||
def clear_fun(frame):
|
||||
for widget in frame.winfo_children():
|
||||
print(widget)
|
||||
def say_hi():
|
||||
print("hello ~ !")
|
||||
|
||||
|
||||
root = Tk()
|
||||
|
||||
frame1 = Frame(root)
|
||||
frame2 = Frame(root)
|
||||
root.title("tkinter frame")
|
||||
|
||||
label = Label(frame1, text="Label", justify=LEFT)
|
||||
label.pack(side=LEFT)
|
||||
|
||||
hi_there = Button(frame2, text="say hi~", command=say_hi)
|
||||
hi_there.pack()
|
||||
|
||||
frame1.pack(padx=1, pady=1)
|
||||
frame2.pack(padx=10, pady=10)
|
||||
clear_fun(frame1)
|
||||
clear_fun(frame2)
|
||||
root.mainloop()
|