ERP-库存与存货-仓储部原材料入库


import tkinter as tk
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 YLCG:                                                             #原料采购
    def __init__(self,window):
        self.conn = pymysql.Connect(
            host='localhost',
            port=3306,
            user='root',
            passwd='12345',
            db='库存与存货系统',
            charset="utf8"
        )

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

        YLCG_id_Label=tk.Label(window,text='入库单号:',font=('Arial',12),bg= 'Beige')
        YLCG_id_Label.place(x=100,y=80)

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

        YLCG_WareHouse_Label=tk.Label(window,text='入库仓库:',font=('Arial',12),bg= 'Beige')
        YLCG_WareHouse_Label.place(x=500,y=80)

        YLCG_Department_Label=tk.Label(window,text='部门:',font=('Arial',12),bg= 'Beige')
        YLCG_Department_Label.place(x=132,y=120)

        YLCG_reference_Label=tk.Label(window,text='入库日期:',font=('Arial',12),bg= 'Beige')
        YLCG_reference_Label.place(x=300,y=83)

        YLCG_ZhiDanRen_Label = tk.Label(window, text='制单人:', font=('Arial', 12),bg= 'Beige')
        YLCG_ZhiDanRen_Label.place(x=100, 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)
        tree = ttk.Treeview(frame, show="headings", xscrollcommand=scrollBarx.set, yscrollcommand=scrollBary.set)
        scrollBarx['command'] = tree.xview  # 根据视图x移动
        scrollBary['command'] = tree.yview  # 根据视图y移动
        tree['columns'] = ('原料编码', '原料名字', '原料类别', '采购数目', '价格', '主计量', '采购时间', '生产批号', '描述', '颜色', '硬度', '供应商ID')
        tree.column('原料编码', width=120, anchor='center')
        tree.column('原料名字', width=120, anchor='center')
        tree.column('原料类别', width=120, anchor='center')
        tree.column('采购数目', width=120, anchor='center')
        tree.column('价格', width=120, anchor='center')
        tree.column('主计量', width=120, anchor='center')
        tree.column('采购时间', width=120, anchor='center')
        tree.column('生产批号', width=120, anchor='center')
        tree.column('描述', width=120, anchor='center')
        tree.column('颜色', width=120, anchor='center')
        tree.column('硬度', width=120, anchor='center')
        tree.column('供应商ID', 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.heading('描述', text='描述')
        tree.heading('颜色', text='颜色')
        tree.heading('硬度', text='硬度')
        tree.heading('供应商ID', text='供应商ID')
        tree.insert('', 'end', values=('', '', '', '', '', '', '', '', '', '', '', ''))

        def view_material():
            cursor = self.conn.cursor()                                 #从数据库选数据
            cursor.execute("select * from material_linshi ")
            self.conn.commit()
            data = cursor.fetchall()
            print(data[0][0])

            cursor = self.conn.cursor()                                 #取行数
            cursor.execute("select count(*) from material_linshi ")
            row1 = cursor.fetchall()
            self.conn.commit()
            row = row1[0][0]
            int(row)
            print(row)
            for i in range(row):
                print(data[0][1])  # 测试
                print(data[i][1])
                tree.insert('', 'end', values=(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], data[i][5], data[i][6],data[i][7], data[i][8], data[i][9], data[i][10], data[i][11]))

        def add_material():
            cursor = self.conn.cursor()
            cursor.execute("select count(*) from material_linshi ")
            row1 = cursor.fetchall()
            self.conn.commit()
            row = row1[0][0]
            int(row)
            print(row)  # 取行数

            cursor = self.conn.cursor()  # 变动数据
            cursor.execute("select * from material_linshi ")
            data = cursor.fetchall()
            self.conn.commit()

            for i in range(row):
                cursor = self.conn.cursor()  # 原本数据
                print(data[i][0])
                cursor.execute("select * from material where `MaterialID`='%s' " % data[i][0])
                print(2)  # 测试
                datayep = cursor.fetchone()
                print(datayep)
                self.conn.commit()
                ok = datayep[3] + data[i][3]
                cursor.execute("update material set `MaterialNum`='%s' where `MaterialID`= '%s'" % (ok, data[i][0]))

                #清空临时表
                cursor.execute("DELETE FROM material_linshi")
            self.conn.commit()

            print(1)  # 此时产品数据库表数据变动

        tk.Button(window, text='确定入库', width=10, height=1, command=add_material,bg= 'LemonChiffon').place(x=500, y=440)
        tk.Button(window, text='查看', width=10, height=1, command=view_material, bg='LemonChiffon').place(x=350, y=440)
        tree.pack()


    def __Entry(self,window):
        YLCG_MaterialID_Entry=tk.Entry(window,width=15)              #入库单号
        YLCG_MaterialID_Entry.place(x=175,y=83)
        YLCG_MaterialID_Entry.insert('end', 124)

        YLCG_MaterialName_Entry=tk.Entry(window,width=18)            #日期
        YLCG_MaterialName_Entry.place(x=375,y=83)
        nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')  # 现在时间
        YLCG_MaterialName_Entry.insert('end', nowTime)

        YLCG_M_Category_Entry=tk.Entry(window,width=15)              #入库仓库
        YLCG_M_Category_Entry.place(x=575,y=83)
        YLCG_M_Category_Entry.insert('end', '原材料库')

        YLCG_MateriralNum_Entry=tk.Entry(window,width=15)            #部门
        YLCG_MateriralNum_Entry.place(x=175,y=123)
        YLCG_MateriralNum_Entry.insert('end', '仓储部')

        YLCG_date_Entry = tk.Entry(window, width=47)
        YLCG_date_Entry.place(x=350, y=120)                           #备注
        YLCG_date_Entry.insert('end', '该表显示当前时间下的准入库情况!')


        YLCG_SupplierID_Entry = tk.Entry(window, width=15)           #制单人
        YLCG_SupplierID_Entry.place(x=170, y=450)
        YLCG_SupplierID_Entry.insert('end', '0002')



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

YLCG=YLCG(window)
YLCG.show(window)

window.mainloop()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值