ERP-库存与存货-原材料


#显示在当前时间下的仓库中库存的原材料情况

import tkinter as tk
from  tkinter import ttk
from tkinter import *                                                               #导入tkinter
from  tkinter import ttk
from tkinter import *                                                               #导入tkinter
from tkinter import messagebox                                                      #引入弹出框
#from typing import Any, Union
import pymysql                                                                       #导入pymysql
from pymysql.cursors import Cursor                                                  #导入游标
from hashlib import sha1                                                            #导入hashlib,引用函数
from PIL import Image                                                                #图像缩放
from tkinter import Scrollbar
from tkinter.ttk import Treeview
import datetime


window=tk.Tk()
window.title('库存与存货管理-成品')
window.geometry('1200x600-100-100')
window['bg'] = 'Beige'
window.resizable(False, False)#不允许改变窗口大小
class yuanliao:
    def __init__(self,window):
        self.conn = pymysql.Connect(
            host='localhost',
            port=3306,
            user='root',
            passwd='12345',
            db='库存与存货系统',
            charset="utf8"
        )

    #Label
        yuanliao_name_Label=tk.Label(window,text='原材料清单',font=('Arial',25),bg= 'Beige')
        yuanliao_name_Label.place(x=350,y=15)

        yuanliao_date_Label=tk.Label(window,text='日期:',font=('Arial',12),bg= 'Beige')
        yuanliao_date_Label.place(x=100,y=80)
        yuanliao_warehouse_Label=tk.Label(window,text='仓库:',font=('Arial',12),bg= 'Beige')
        yuanliao_warehouse_Label.place(x=350,y=80)
        yuanliao_depart_Label=tk.Label(window,text='部门:',font=('Arial',12),bg= 'Beige')
        yuanliao_depart_Label.place(x=550,y=80)

        yuanliao_notes_Label=tk.Label(window,text='备注:',font=('Arial',12),bg= 'Beige')
        yuanliao_notes_Label.place(x=100,y=120)


        #详细
        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)
        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=160, anchor='center')
        tree.column('原材料名称', width=160, anchor='center')
        tree.column('原材料类别', width=120, anchor='center')
        tree.column('计量单位', width=100, anchor='center')
        tree.column('数量', width=120, anchor='center')
        tree.column('单价', width=120, anchor='center')
        tree.column('金额', width=160, anchor='center')
        tree.column('生产批号', width=160, anchor='center')
        tree.column('生产日期', width=160, anchor='center')
        tree.column('备注', width=160, 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.heading('生产日期', text='生产日期')
        tree.heading('备注', text='备注')
        cursor = self.conn.cursor()
        cursor.execute("select * from material ")
        self.conn.commit()
        data = cursor.fetchall()
        print(data[1][1])
        cursor = self.conn.cursor()
        cursor.execute("select count(*) from material ")
        row1=cursor.fetchall()
        self.conn.commit()
        row=row1[0][0]
        int(row)
        print(row)                     #qud
        for i in range (row):
            print(data[1][1])                                       #测试
            print(data[i][1] )
            tree.insert('', 'end', values=(data[i][0], data[i][1], data[i][2], data[i][5], data[i][3], data[i][4],data[i][3]*data[i][4], data[i][7], data[i][6], data[i][8]))
            #tree.insert('', 'end', values=('%s', '%s', '%s', '%s', '%d', '%d', '%d', '%s', '%Y-%m-%d %H:%M:%S', '%s'),(data[0][1]))




        tree.insert('', 'end', values=('', '', '', '', '', '', '', '', '', ''))
        #def insert_product():
            #tree.insert('', 'end', values=('', '', '', '', '', '', '', ''))
        tree.pack()




    def __Entry(self,window):
        yuancailiao_date_Entry=tk.Entry(window,width=20)
        yuancailiao_date_Entry.place(x=175,y=83)

        #window.yuancailiao_date_Entry.insert('end', nowTime)
        yuancailiao_warehouse_Entry=tk.Entry(window,width=15)
        yuancailiao_warehouse_Entry.place(x=400,y=83)
        yuancailiao_depart_Entry=tk.Entry(window,width=15)
        yuancailiao_depart_Entry.place(x=600,y=83)
        yuancailiao_notes_Entry=tk.Entry(window,width=75)
        yuancailiao_notes_Entry.place(x=175,y=123)


        def out():
            window.quit()

        def okk():
            cursor = self.conn.cursor()
            cursor.execute("select * from material " )

            self.conn.commit()
            data = cursor.fetchall()
            print(data[1][1])                                    # 测试获取到数据

            nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')  # 现在时间

            yuancailiao_date_Entry.insert('end', nowTime)
            yuancailiao_warehouse_Entry.insert('end', '原材料仓库')
            yuancailiao_depart_Entry.insert('end', '仓储部门')
            yuancailiao_notes_Entry.insert('end', '该清单显示在当前时间情况下原材料的相关库存信息!')





        tk.Button(window, text='确定', width=10, height=1, command=okk).place(x=200, y=440)
        tk.Button(window, text='退出', width=10, height=1, command=out).place(x=400, y=440)

    def show(self,window):
        self.__Entry(window)
        window.mainloop()

yuanliao=yuanliao(window)
yuanliao.show(window)

window.mainloop()

猜你喜欢

转载自blog.csdn.net/weixin_40838568/article/details/81043319