import tkinter as tk from tkinter import ttk import pymysql,datetime window=tk.Tk() window.title('盘点单') window.geometry('1200x600-100-100') window['bg'] = 'Beige' window.resizable(False, False)#不允许改变窗口大小 class pandian: def __init__(self,window): nowTime = datetime.datetime.now().strftime('%Y-%m-%d ') pandian_id_Entry=tk.Entry(window,width=15) pandian_id_Entry.place(x=175,y=83) pandian_date_Entry=tk.Entry(window,width=15) pandian_date_Entry.place(x=375,y=83) pandian_date_Entry.insert('end',nowTime) pandian_WareHouse_Entry=tk.Entry(window,width=15) pandian_WareHouse_Entry.place(x=575,y=83) pandian_Department_Entry=tk.Entry(window,width=15) pandian_Department_Entry.place(x=175,y=123) pandian_Department_Entry.insert('end', '仓储部') pandian_OutBoundCatagory_Entry=tk.Entry(window,width=15) pandian_OutBoundCatagory_Entry.place(x=375,y=123) pandian_InBoundCatagory_Entry=tk.Entry(window,width=15) pandian_InBoundCatagory_Entry.place(x=575,y=123) pandian_JingShouRen_Entry=tk.Entry(window,width=15) pandian_JingShouRen_Entry.place(x=175,y=163) pandian_reference_Entry=tk.Entry(window,width=15) pandian_reference_Entry.place(x=375,y=163,width=310) pandian_ZhiDanRen_Entry = tk.Entry(window, width=15) pandian_ZhiDanRen_Entry.place(x=170, y=450) pandian_JiZhangRen_Entry = tk.Entry(window,width=15) pandian_JiZhangRen_Entry.place(x=380, y=450) var_pandian_id_Text = pandian_id_Entry.get()#盘点单变量 var_date_Text = pandian_date_Entry.get() var_WareHouse_Text = pandian_WareHouse_Entry.get() var_Department_Text = pandian_Department_Entry.get() var_OutBoundCatagory_Text = pandian_OutBoundCatagory_Entry.get() var_InBoundCatagory_Text = pandian_InBoundCatagory_Entry.get() var_JingShouRen_IDText = pandian_JingShouRen_Entry.get() var_ZhiDanRen_IDText=pandian_ZhiDanRen_Entry.get() #var_JiZhangRen_IDText=pandian_JiZhangRen_Entry var_reference_Text = pandian_reference_Entry.get() def submit(): self.conn=pymysql.Connect( host='localhost', port=3306, user='root', password='12345', db='库存与存货系统', charset="utf8" ) cursor=self.conn.cursor() cursor.execute("insert into inventory(InventoryID,InventoryDate,WarehouseID,DepartID,OutCategory,InCategory,HandleIID,Notes)values('%s','%s','%s','%s','%s','%s','%s','%s')" %(var_pandian_id_Text,var_date_Text,var_WareHouse_Text,var_Department_Text,var_OutBoundCatagory_Text,var_InBoundCatagory_Text, var_JingShouRen_IDText,var_reference_Text)) self.conn.commit() tk.Button(window, text='提交', width=10, height=1, command=submit,bg= 'LemonChiffon').place(x=600, y=440) #Label pandian_name_Label=tk.Label(window,text='盘点单',font=('Arial',25),bg= 'Beige') pandian_name_Label.place(x=350,y=15) pandian_id_Label=tk.Label(window,text='盘点单号:',font=('Arial',12),bg= 'Beige') pandian_id_Label.place(x=100,y=80) pandian_date_Label=tk.Label(window,text='盘点日期:',font=('Arial',12),bg= 'Beige') pandian_date_Label.place(x=300,y=80) pandian_WareHouse_Label=tk.Label(window,text='盘点仓库:',font=('Arial',12),bg= 'Beige') pandian_WareHouse_Label.place(x=500,y=80) pandian_Department_Label=tk.Label(window,text='部门:',font=('Arial',12),bg= 'Beige') pandian_Department_Label.place(x=132,y=120) pandian_OutBoundCatagory_Label=tk.Label(window,text='出库类别:',font=('Arial',12),bg= 'Beige') pandian_OutBoundCatagory_Label.place(x=300,y=120) pandian_InBoundCatagory_Label=tk.Label(window,text='入库类别:',font=('Arial',12),bg= 'Beige') pandian_InBoundCatagory_Label.place(x=500,y=120) pandian_JingShouRen_Label=tk.Label(window,text='经手人:',font=('Arial',12),bg= 'Beige') pandian_JingShouRen_Label.place(x=117,y=160) pandian_reference_Label=tk.Label(window,text='备注:',font=('Arial',12),bg= 'Beige') pandian_reference_Label.place(x=332,y=160) pandian_ZhiDanRen_Label = tk.Label(window, text='制单人:', font=('Arial', 12),bg= 'Beige') pandian_ZhiDanRen_Label.place(x=100, y=450) pandian_JiZhangRen_Label = tk.Label(window, text='记账人:', font=('Arial', 12),bg= 'Beige') pandian_JiZhangRen_Label.place(x=310, y=450) #详细 frame = tk.Frame(window) # 锁定框架 frame.place(x=85, y=200, width=620, height=230) scrollBarx = tk.Scrollbar(frame, orient='horizontal') # 定义滑动条 scrollBarx.pack(side=tk.BOTTOM, fill=tk.X) scrollBary = tk.Scrollbar(frame) scrollBary.pack(side=tk.RIGHT, fill=tk.Y) global tree tree = ttk.Treeview(frame, show="headings", xscrollcommand=scrollBarx.set, yscrollcommand=scrollBary.set) scrollBarx['command'] = tree.xview # 根据视图x移动 scrollBary['command'] = tree.yview # 根据视图y移动 tree['columns'] = ('存货编码', '颜色', '硬度', '批号', '账面数量', '盘点数量', '盈亏数量', '原因') tree.column('存货编码', width=80, anchor='center') tree.column('颜色', width=80, anchor='center') tree.column('硬度', width=80, anchor='center') tree.column('批号', width=80, anchor='center') tree.column('账面数量', width=80, anchor='center') tree.column('盘点数量', width=80, anchor='center') tree.column('盈亏数量', width=80, anchor='center') tree.column('原因', width=120, anchor='center') tree.heading('存货编码', text='存货编码') tree.heading('颜色', text='颜色') tree.heading('硬度', text='硬度') tree.heading('批号', text='批号') tree.heading('账面数量', text='账面数量') tree.heading('盘点数量', text='盘点数量') tree.heading('盈亏数量', text='盈亏数量') tree.heading('原因', text='原因') tree.insert('', 'end', values=('', '', '', '', '', '', '', '')) def insert_product(): tree.insert('', 'end', values=('', '', '', '', '', '', '', '')) tk.Button(window, text='插入一行数据', width=10, height=1, command=insert_product,bg= 'LemonChiffon').place(x=500, y=440) tree.pack() def treeviewClick(event): s = tree.selection() print(s)#元祖(x,y) if s: var_id_Text = tk.StringVar()# var 变量 var_color_Text = tk.StringVar() var_hard_Text = tk.DoubleVar var_pihao_Text = tk.StringVar() var_zhangmianSL_Text = tk.IntVar() var_pandianSL_Text = tk.IntVar() var_yingkuiSL_Text = tk.IntVar() var_reason_Text = tk.StringVar() product = tk.Tk() product.title('详细货物') product.geometry('500x400') product['bg']='Beige' id_Label=tk.Label(product,text='存货编码:',font=('Arial',12),bg= 'Beige') id_Label.place(x=100,y=20) color_Label=tk.Label(product,text='存货颜色:',font=('Arial',12),bg= 'Beige') color_Label.place(x=100, y=50) hard_Label=tk.Label(product, text='存货硬度:', font=('Arial', 12),bg= 'Beige') hard_Label.place(x=100, y=80) pihao_Label = tk.Label(product, text='存货批号:', font=('Arial', 12),bg= 'Beige') pihao_Label.place(x=100, y=110) zhangmianSL_Label = tk.Label(product, text='账面数量:', font=('Arial', 12),bg= 'Beige') zhangmianSL_Label.place(x=100, y=140) pandianSL_Label = tk.Label(product, text='盘点数量:', font=('Arial', 12),bg= 'Beige') pandianSL_Label.place(x=100, y=170) yingkuiSL_Label = tk.Label(product, text='盈亏数量:', font=('Arial', 12),bg= 'Beige') yingkuiSL_Label.place(x=100, y=200) reason_Label = tk.Label(product, text='备注原因:', font=('Arial', 12),bg= 'Beige') reason_Label.place(x=100, y=230) #Entry id_Entry =tk.Entry(product, width=15) id_Entry.place(x=175, y=20) color_Entry = tk.Entry(product, width=15) color_Entry.place(x=175, y=50) hard_Entry = tk.Entry(product, width=15) hard_Entry.place(x=175, y=80) pihao_Entry = tk.Entry(product, width=15) pihao_Entry.place(x=175, y=110) zhangmianSL_Entry = tk.Entry(product, width=15) zhangmianSL_Entry.place(x=175, y=140) pandianSL_Entry = tk.Entry(product, width=15) pandianSL_Entry.place(x=175, y=170) yingkuiSL_Entry = tk.Entry(product, width=15) yingkuiSL_Entry.place(x=175, y=200) reason_Entry = tk.Entry(product, width=15) reason_Entry.place(x=175, y=230, width=310) #变量赋值 def insert_point(): var_id_Text = id_Entry.get() var_color_Text = color_Entry.get() var_hard_Text = hard_Entry.get() var_pihao_Text = pihao_Entry.get() var_zhangmianSL_Text = zhangmianSL_Entry.get() var_pandianSL_Text = pandianSL_Entry.get() var_yingkuiSL_Text = yingkuiSL_Entry.get() var_reason_Text = reason_Entry.get() tree.delete(s) tree.insert('','end',values=(var_id_Text, var_color_Text, var_hard_Text,var_pihao_Text,var_zhangmianSL_Text,var_pandianSL_Text,var_yingkuiSL_Text, var_reason_Text)) self.conn = pymysql.Connect( host='localhost', port=3306, user='root', password='12345', db='库存与存货系统', charset="utf8" ) cursor = self.conn.cursor() cursor.execute( "insert into inventorydetails(inventoryid,color,hard,G_M_ID,batchnumber,listnum,inventorynum,profitnum,reason)values ('%s','%s','%s','%s','%s','%s','%s','%s','%s');" % (var_pandian_id_Text,var_id_Text, var_color_Text, var_hard_Text,var_pihao_Text,var_zhangmianSL_Text,var_pandianSL_Text,var_yingkuiSL_Text, var_reason_Text)) self.conn.commit() cursor.close() tk.Button(product, text='插入', width=15, height=2, command=insert_point).place(x=180,y=260) product.mainloop() tree.bind('<Double-Button-1>',treeviewClick) def show(self,window): window.mainloop() pandiandan=pandian(window) pandiandan.show(window) window.mainloop()
盘点单
最新推荐文章于 2020-03-28 10:01:17 发布