亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

python如何實現商品進銷存管理系統

發布時間:2022-05-30 16:35:57 來源:億速云 閱讀:527 作者:iii 欄目:開發技術

本文小編為大家詳細介紹“python如何實現商品進銷存管理系統”,內容詳細,步驟清晰,細節處理妥當,希望這篇“python如何實現商品進銷存管理系統”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。

基于python,MySQL,tkinter

import pymysql #導入數據庫模塊
import tkinter #導入相關的窗體模塊
import os #利用os模塊可以方便定義完整路徑
import  tkinter.messagebox#實現提示框的組件
import  tkinter.simpledialog#簡單對話框
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import threading
import pandas as pd  #對數據進行訪問
import  sys  #與操作系統交互
def get_resources_path(relative_path):#利用此函數實現資源路徑的定位
    if getattr(sys,"frozen",False):
        base_path=sys._MEIPASS #獲取臨時資源
    else:
        base_path=os.path.abspath(".") #獲取當前路徑
    return os.path.join(base_path,relative_path)  #獲得絕對路徑
LOGO_PATH=get_resources_path(os.path.join("resources",'shop_logo.ico'))  #'resources'+os.sep + 'shop_logo.ico'#logo文件路徑
IMAGES_PATH=get_resources_path(os.path.join("resources",'background.png'))#'resources' +os.sep+ 'background.png'#圖像文件路徑
Warehouse_PATH=get_resources_path(os.path.join("resources",'店鋪.png'))#'resources' +os.sep+ '店鋪.png'#圖像文件路徑
COMMODITY_DELETE_PATH=get_resources_path(os.path.join("resources",'店鋪修改背景圖.png'))#'resources' +os.sep+ '店鋪修改背景圖.png'#圖像文件路徑
WORDCLOUD_PATH='詞云圖.png'
EXCEL_COMMODITY=get_resources_path(os.path.join("resources",'商品數據.xlsx'))#'resources'+ os.sep + '商品數據.xlsx'#商品數據的路徑
EXCEL_STORE=get_resources_path(os.path.join("resources",'店鋪.xlsx'))#'resources'+ os.sep + '店鋪.xlsx'#店鋪數據的路徑
EXCEL_WAREHOUSE=get_resources_path(os.path.join("resources",'庫房.xlsx'))#'resources'+ os.sep + '庫房.xlsx'#庫房數據的路徑
EXCEL_CUSTOMER=get_resources_path(os.path.join("resources",'顧客數據.xlsx'))#'resources'+ os.sep + '顧客數據.xlsx'#顧客數據的路徑
class MainForm: #定義窗體類,父類
    def __init__(self):#構造窗體
        self.root=tkinter.Tk()#創建一個窗體
        self.root.title("露露小賣店")#設置標題
        self.root.iconbitmap(LOGO_PATH)#設置logo資源
        self.root.geometry('680x500+150+50')#初始化窗口大小
        self.root.resizable(False,False) #固定窗口大小
    def worcloud_s(self,text):    #生產詞云圖片
        wc= WordCloud(
            collocations=False,
            font_path=r"C:/Windows/Fonts/simfang.ttf",
            background_color="black",
            width=600,
            height=300,
            max_words=50).generate(text)
        wc.to_image()
        wc.to_file("詞云圖.png")
class The_login(MainForm):  #登錄窗口
    def __init__(self):
        super().__init__()
        photo = tkinter.PhotoImage(file=IMAGES_PATH)  # 設置圖像資源
        tkinter.Label(self.root, image=photo,width=680,height=500).place(x=0,y=0)
        tkinter.Label(self.root, text="用戶名", font=("黑體", 20)).place(x=150,y=200)
        self.entry1 = tkinter.Entry(self.root,font=("黑體", 20))
        self.entry1.place(x=300,y=200)
        tkinter.Label(self.root, text="密碼", font=("黑體", 20)).place(x=150,y=250)
        self.entry2 = tkinter.Entry(self.root,font=("黑體", 20),show="*")
        self.entry2.place(x=300,y=250)
        tkinter.Button(self.root, text="店鋪登錄",command=self.bidui, width=15, font=("微軟雅黑", 10)).place(x=150,y=300)
        tkinter.Button(self.root, text="退出", command=self.root.quit, width=15, font=("微軟雅黑", 10)).place(x=450, y=300)
        tkinter.Button(self.root, text="導入店鋪信息", command=self.store_in, width=10, font=("微軟雅黑", 10)).place(x=550, y=450)
        tkinter.Button(self.root, text="店鋪注冊", command=self.Registered, width=10, font=("微軟雅黑", 10)).place(x=0, y=450)
        self.root1=self.root.mainloop()
      #對用戶賬號,密碼進行查詢,比對
    def bidui(self):
        global global_id
        def find_store():#查找店鋪賬號和密碼數據
            cursor=conn.cursor()
            sql='select * from store where store_id="%s" and store_password="%s"'%(self.entry1.get(),self.entry2.get())
            cursor.execute(sql)
            conn.commit()
            cursor.close()
            return cursor.fetchone()
        try :
            if bool(find_store())==1:
                print("登錄成功")
                global_id=self.entry1.get()
                self.root.destroy()
                The_store()
            else:
                labell = tkinter.Label(self.root, text='登陸失敗!', font=("黑體", 10))  ##
                labell.place(x=300, y=0)
        except:
            pass
    def store_in(self):
        def remove_store_all():  # 清除店鋪中的數據表數據
            cursor = conn.cursor()  # 創建游標
            cursor.execute('delete from store')
            conn.commit()  # 提交
            cursor.close()  # 關閉游標
        def store_Add():  # 向店鋪的表中導入數據
            cursor = conn.cursor()  # 創建游標
            for co in range(len(df["店鋪賬號"])-1):
                print(co)
                try:
                    sql = 'insert into store values (%s,%s,%s,%s,%s,%s,%s);'  # 添加數據
                    cursor.execute(sql,(
                        df["店鋪賬號"][co],
                        df["店鋪密碼"][co],
                        df["店鋪名稱"][co],
                        df["店鋪地址"][co],
                        df["店鋪電話"][co],
                        df["店主"][co],
                        df["盈虧"][co]))  # 執行添加數據
                    conn.commit()  # 提交
                except:
                    print(df["店鋪名稱"][co])
            cursor.close()  # 關閉游
        df = pd.read_excel(EXCEL_STORE)
        remove_store_all()
        store_Add()
        #——————————————————————-——————————店鋪注冊------------------------------
    def Registered(self):  #店鋪注冊信息
        def remove_prompt():  # 清空提示信息
            Entry_prompt.delete(0.0, tkinter.END)
            Entry_prompt.update()
            Entry_prompt.insert(tkinter.INSERT,"———————————店鋪注冊——————————")
        def store_add():#添加店鋪信息
            if Entry_user.get()=='':  #用戶名不能為空
                remove_prompt()
                Entry_prompt.insert(tkinter.INSERT, "用戶名輸入為空\n")
            elif Entry_password.get()=='': #密碼不能為空
                remove_prompt()
                Entry_prompt.insert(tkinter.INSERT, "密碼輸入為空\n")
            elif Entry_name.get() == '':  # 名稱不能為空
                remove_prompt()
                Entry_prompt.insert(tkinter.INSERT, "店鋪名稱輸入為空\n")
            elif Entry_address.get() == '':  # 地址不能為空
                remove_prompt()
                Entry_prompt.insert(tkinter.INSERT, "店鋪地址輸入為空\n")
            elif Entry_phon.get() == '':  # 電話不能為空
                remove_prompt()
                Entry_prompt.insert(tkinter.INSERT, "店鋪電話輸入為空\n")
            elif Entry_master.get() == '':  # 店主不能為空
                remove_prompt()
                Entry_prompt.insert(tkinter.INSERT, "店主輸入為空\n")
            else:
                remove_prompt()
                cursor = conn.cursor()  # 創建游標
                try:
                    sql = 'insert into store values (%s,%s,%s,%s,%s,%s,%s);'  # 添加數據
                    cursor.execute(sql, (
                        Entry_user.get(),  #賬號
                        Entry_password.get(),#密碼
                        Entry_name.get(),#名稱
                        Entry_address.get(),#地址
                        Entry_phon.get(),#電話
                        Entry_master.get(),#店主
                        0       )#盈虧
                                   )  # 執行添加數據
                    conn.commit()  # 提交
                    cursor.execute('select * from store where store_id="%s";'%(Entry_user.get()))
                    conn.commit()
                    Entry_prompt.insert(tkinter.INSERT, "店鋪注冊成功\n")
                    Entry_prompt.insert(tkinter.INSERT, cursor.fetchall())
                except:
                    Entry_prompt.insert(tkinter.INSERT, "店鋪賬號已存在,請從新輸入:\n")
                cursor.close()  # 關閉游
        root=tkinter.Toplevel()   #創建一個附屬窗口
        root.title("露露小賣店")   #標題
        root.iconbitmap(LOGO_PATH)  # 設置logo資源
        root.geometry('380x400+150+50')  # 初始化窗口大小
        root.resizable(False, False)  # 固定窗口大小
        tkinter.Button(root,text="確認添加",command=store_add,font=("微軟雅黑", 10)).place(x=30,y=360)
        tkinter.Button(root, text="退出", command=root.destroy, font=("微軟雅黑", 10)).place(x=320, y=360)
       #店鋪賬號    店鋪密碼    店鋪名稱    店鋪地址    店鋪電話    店主
        tkinter.Label(root,text="店鋪賬號",font=("微軟雅黑", 10)).place(x=60,y=120)
        tkinter.Label(root, text="店鋪密碼", font=("微軟雅黑", 10)).place(x=60, y=160)
        tkinter.Label(root, text="店鋪名稱", font=("微軟雅黑", 10)).place(x=60, y=200)
        tkinter.Label(root, text="店鋪地址", font=("微軟雅黑", 10)).place(x=60, y=240)
        tkinter.Label(root, text="店鋪電話", font=("微軟雅黑", 10)).place(x=60, y=280)
        tkinter.Label(root, text="店    主", font=("微軟雅黑", 10)).place(x=60, y=320)
        Entry_prompt = tkinter.Text(root, width=44,height=5,font=("微軟雅黑", 10))
        Entry_prompt.place(x=12, y=10)
        Entry_user=tkinter.Entry(root,font=("微軟雅黑", 10))
        Entry_user.place(x=120,y=120)
        Entry_password = tkinter.Entry(root, font=("微軟雅黑", 10))
        Entry_password.place(x=120, y=160)
        Entry_name = tkinter.Entry(root, font=("微軟雅黑", 10))
        Entry_name.place(x=120, y=200)
        Entry_address = tkinter.Entry(root, font=("微軟雅黑", 10))
        Entry_address.place(x=120, y=240)
        Entry_phon = tkinter.Entry(root, font=("微軟雅黑", 10))
        Entry_phon.place(x=120, y=280)
        Entry_master = tkinter.Entry(root, font=("微軟雅黑", 10))
        Entry_master.place(x=120, y=320)
        remove_prompt()
class The_store(MainForm):#主頁面設置
    def __init__(self):
        super().__init__()
        self.Label=tkinter.Label(self.root,text="歡迎光臨露露小賣店",bg='#233233',width=32,height=10,
                                     fg='#ffffff',font=("黑體",30))
        self.Label.place(x=20,y=0)
        self.button1 = tkinter.Button(self.root, text="初始化", command=self.Ininia, height=3, width=10).place(x=0,y=430)
        self.button2 = tkinter.Button(self.root, text="商品", command=self.Commodity_switch, height=3, width=10).place(x=150,y=430)
        self.button3 = tkinter.Button(self.root, text="店鋪", command=self.Shop_switch, height=3, width=10).place(x=300,y=430)
        self.button4 = tkinter.Button(self.root, text="庫房", command=self.Warehouse_switch, height=3, width=10).place(x=450,y=430)
        self.button1 = tkinter.Button(self.root, text="退出", command=quit, height=3, width=10).place(x=600,y=430)
        self.root.mainloop()
    def  Commodity_switch(self):  #商品
        self.root.destroy()  #關閉主界面
        Commodity_From()   #進入商品界面
    def Shop_switch(self):   #店鋪
        self.root.destroy()  # 關閉主界面
        Shop_From()
    def Warehouse_switch(self):  #庫房
        self.root.destroy()  # 關閉主界面
        Warehouse()
    def Ininia(self):   #具體初始化
        self.Label.place_forget()
        text=tkinter.Text(self.root,width=80,height=20,font=('微軟雅黑', 10))
        scroll = tkinter.Scrollbar()
        scroll.pack(side=tkinter.RIGHT, fill=tkinter.Y)
        text.place(x=20, y=20)
        scroll.config(command=text.yview)
        text.config(yscrollcommand=scroll.set)
        text.insert(tkinter.INSERT,"----------數據加載開始---------\n")
        INn=Initialize()
        def After_xx():
            for i in INn.Accord():
               text.insert(tkinter.INSERT,i)
               text.insert(tkinter.INSERT, '\n')
            text.insert(tkinter.END,"數據加載完畢")
        self.root.after(100,After_xx())
class Initialize:  #對數據庫進行初始化
    def __init__(self):
        self.df_commodity=pd.read_excel(EXCEL_COMMODITY)
        self.df_warehouse = pd.read_excel(EXCEL_WAREHOUSE)
        self.df_customer = pd.read_excel(EXCEL_CUSTOMER)
        self.remove_all()
        self.all_refresh()
    def remove_all(self):  #清除數據表數據
        cursor = conn.cursor()   #創建游標
        cursor.execute('delete from commodity;')   #清除商品數據
        cursor.execute('delete from warehouse;')       #清除庫房信息
        cursor.execute('delete from customer') #清除顧客信息
        conn.commit()    #提交
        cursor.close()  #關閉游標
    def all_refresh(self):
        def commodity_Add():#向商品commodity的表中導入數據'DW-1201090311','其它蔬菜',4,2,20210101,'2年',1,8
            global global_id
            cursor = conn.cursor()   #創建游標
            for co in range(len(self.df_commodity["商品編碼"])):
                try:
                    sql = 'insert into commodity values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'#添加數據
                    cursor.execute(sql, (
                    self.df_commodity["商品編碼"][co],
                    self.df_commodity["商品名稱"][co],
                    self.df_commodity["商品售價"][co],
                    self.df_commodity["商品進價"][co],
                    self.df_commodity["生產日期"][co],
                    self.df_commodity["保質期"][co],
                    self.df_commodity["商品規格"][co],
                    self.df_commodity["銷售數量"][co],
                    global_id,
                    self.df_commodity["庫房編號"][co],
                    None)
                                   )  # 執行添加數據
                except:
                    print(self.df_commodity["商品編碼"][co])
            conn.commit()  # 提交
            cursor.close()  # 關閉游標
        def warehouse_Add():#向庫房的表中導入數據'DW-1201090311','其它蔬菜',4,2,20210101,'2年',1,8
            global global_id
            cursor = conn.cursor()   #創建游標
            for co in range(len(self.df_warehouse["庫房編號"])):
                try:
                    sql = 'insert into warehouse values (%s,%s,%s,%s,%s,%s,%s);'#添加數據
                    cursor.execute(sql, (
                    self.df_warehouse["庫房編號"][co],
                    self.df_warehouse["庫房密碼"][co],
                    self.df_warehouse["庫房名稱"][co],
                    self.df_warehouse["庫房地址"][co],
                    self.df_warehouse["庫房電話"][co],
                    self.df_warehouse["庫房管理人"][co],
                    global_id     )
                                   )  # 執行添加數據
                except:
                    print(self.df_warehouse["庫房編號"][co])
            conn.commit()  # 提交
            cursor.close()  # 關閉游標
        def customer_Add():#向顧客的表中導入數據
            global global_id
            def go_shopping():  #查看購物情況
                sql=' select sum(commodity_amount) from commodity GROUP BY customer_id;'
                cursor.execute(sql)
                conn.commit()
                return  cursor.fetchall()
            cursor = conn.cursor()  # 創建游標
            for co in range(len(self.df_customer["用戶賬號"])):
                try:
                    sql = 'insert into customer values (%s,%s,%s,%s,%s,%s);'#添加數據
                    cursor.execute(sql, (
                    self.df_customer["用戶賬號"][co],
                    self.df_customer["密碼"][co],
                    self.df_customer["用戶名"][co],
                    self.df_customer["電話"][co],
                    go_shopping(),
                    global_id  )
                                   )  # 執行添加數據
                except:
                    print(self.df_customer["用戶賬號"][co])
            conn.commit()  # 提交
            cursor.close()  # 關閉游標
        commodity_Add()
        warehouse_Add()
        customer_Add()
    def Accord(self):
        cursor = conn.cursor()  #創建游標
        a=[]
        for co1 in range(len(self.df_commodity["商品編碼"])):
            try:
                sql='select * from commodity where commodity_id="%s"'%(self.df_commodity["商品編碼"][co1])
                cursor.execute(sql)
                a.append(cursor.fetchall())   #結果導出
            except:
                continue
        for co2 in range(len(self.df_warehouse["庫房編號"])):
            try:
                sql='select * from warehouse where warehouse_id="%s"'%(self.df_warehouse["庫房編號"][co2])
                cursor.execute(sql)
                a.append(cursor.fetchall())   #結果導出
            except:
                continue
        for co in range(len(self.df_customer["用戶賬號"])):
            try:
                sql='select * from customer where customer_id="%s"'%(self.df_customer["用戶賬號"][co])
                cursor.execute(sql)
                a.append(cursor.fetchall())   #結果導出
            except:
                continue
        conn.commit()        #提交
        cursor.close()    #關閉游標
        return a
class Commodity_From(MainForm):  #商品界面設置
    def __init__(self):
        super().__init__()
        self.Commodity_select_photo()
        photo_word = tkinter.PhotoImage(file=WORDCLOUD_PATH)
        tkinter.Label(self.root, image=photo_word, width=600, height=400).place(x=30, y=0)
        tkinter.Label(self.root,text="------------你的年度銷量---------",font=("微軟雅黑", 20)).place(x=100,y=0)
        self.button1 = tkinter.Button(self.root, text="增加", command=self.Commodity_add_s, height=3, width=10).place(x=0, y=430)
        self.button2 = tkinter.Button(self.root, text="刪除", command=self.Commodity_drop_s, height=3, width=10).place(x=150, y=430)
        self.button3 = tkinter.Button(self.root, text="修改", command=self.Commodity_delente_s, height=3, width=10).place(x=300, y=430)
        self.button4 = tkinter.Button(self.root, text="查詢", command=self.Commodity_select_s, height=3, width=10).place(x=450, y=430)
        self.button1 = tkinter.Button(self.root, text="返回", command=self.The_store_power, height=3, width=10).place(x=600, y=430)
        self.root.mainloop()
    def Commodity_add_s(self):#  進入增加界面
        self.root.destroy()  # 關閉商品界面
        Commodity_add()    #進入增加界面
    def Commodity_drop_s(self):#進入刪除界面
        self.root.destroy()
        Commodity_drop()
    def Commodity_delente_s(self): #進去修改界面
        self.root.destroy()
        Commodity_delente()
    def Commodity_select_s(self): #進入查詢界面
        self.root.destroy()
        Commodity_select()
    def The_store_power(self): #進入主界面
        self.root.destroy()
        The_store()
    def Commodity_select_photo(self):#查詢所有的商品信息commodity_name
        global global_id
        a=[]
        cursor=conn.cursor()
        sql='select commodity_name from commodity where store_id="%s"'%(global_id)
        cursor.execute(sql)
        conn.commit()
        cursor.close()
        for i in cursor.fetchall():
            a.append(i[0])
        self.worcloud_s(str(a))   #生成圖片
class Commodity_add(MainForm):# 商品類,,增刪除,改,查
    def __init__(self):
        super().__init__()
        tkinter.Label(self.root,text="增加商品信息",font=("微軟雅黑", 20)).place(x=260,y=0)
        tkinter.Label(self.root, text="商品編碼", font=("微軟雅黑", 10)).place(x=0,y=200)
        self.entryss1 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss1.place(x=60,y=200)
        tkinter.Label(self.root, text="商品名稱", font=("微軟雅黑", 10)).place(x=200,y=200)
        self.entryss2 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss2.place(x=260,y=200)
        self.Text_1 = tkinter.Text(self.root, height=6, width=80,font=("微軟雅黑", 10))   #輸出標注框
        self.Text_1.place(x=20,y=50)
        tkinter.Label(self.root, text="商品售價", font=("微軟雅黑", 10)).place(x=0,y=270)
        self.entryss3 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss3.place(x=60,y=270)
        tkinter.Label(self.root, text="商品進價", font=("微軟雅黑", 10)).place(x=0,y=350)
        self.entryss4 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss4.place(x=60,y=350)
        tkinter.Label(self.root, text="生產日期", font=("微軟雅黑", 10)).place(x=200,y=270)
        self.entryss5 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss5.place(x=260,y=270)
        tkinter.Label(self.root, text="保質期", font=("微軟雅黑", 10)).place(x=200,y=350)
        self.entryss6 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss6.place(x=260,y=350)
        tkinter.Label(self.root, text="商品規格", font=("微軟雅黑", 10)).place(x=400,y=270)
        self.entryss7 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss7.place(x=460,y=270)
        tkinter.Label(self.root, text="銷售數量", font=("微軟雅黑", 10)).place(x=400,y=350)
        self.entryss8 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss8.place(x=460,y=350)
        tkinter.Label(self.root, text="倉庫編號", font=("微軟雅黑", 10)).place(x=400, y=200)
        self.entryss9 = tkinter.Entry(self.root, font=("微軟雅黑", 10))
        self.entryss9.place(x=460, y=200)
        tkinter.Button(self.root,text="確認添加",command=self.add_s,font=("微軟雅黑", 15)).place(x=200,y=420)
        tkinter.Button(self.root, text="取消   ", command=self.add_Cancel, font=("微軟雅黑",15)).place(x=400,y=420)
        tkinter.Button(self.root, text="返回主菜單", command=self.The_store_1, font=("微軟雅黑", 15)).place(x=0, y=450)
        tkinter.Button(self.root, text="返回     ", command=self.Commodity_From_1, font=("微軟雅黑", 15)).place(x=600, y=450)
        self.root.mainloop()
    def The_store_1(self):#返回主菜單
        self.root.destroy()
        The_store()
    def Commodity_From_1(self):    #返回商品菜單
        self.root.destroy()
        Commodity_From()
    def drop_Text_1(self):#清除顯示信息
        self.Text_1.delete(0.0, tkinter.END)
        self.Text_1.update()
    def add_s(self):  #處理增加
        global global_id
        cursor = conn.cursor()  # 創建sql游標
        if self.entryss1.get() =='':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT,"你的商品編碼輸入為空")
        elif self.entryss2.get() =='':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT,"你的商品名稱輸入為空")
        elif self.entryss3.get() == '':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT, "你的商品售價輸入為空")
        elif self.entryss4.get() == '':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT, "你的商品進價輸入為空")
        elif self.entryss5.get() == '':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT, "你的生產日期輸入為空")
        elif self.entryss6.get() == '':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT, "你的保質期輸入為空")
        elif self.entryss7.get() == '':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT, "你的商品規格輸入為空")
        elif self.entryss8.get() == '':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT, "你的銷售數量輸入為空")
        elif self.entryss9.get() == '':
            self.drop_Text_1()
            self.Text_1.insert(tkinter.INSERT, "你的倉庫編號輸入為空")
        else:
            try:
                sql = "insert into commodity values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"  # 添加數據
                cursor.execute(sql,(
                        self.entryss1.get(),  #商品編號
                        self.entryss2.get(),  #商品名稱
                        self.entryss3.get(),  #商品售價
                        self.entryss4.get(),  #商品進價
                        self.entryss5.get(), #生產日期
                        self.entryss6.get(),  #保質期
                        self.entryss7.get(),  #商品規格
                        self.entryss8.get(),  #銷售數量
                        global_id,           #店鋪編號
                        self.entryss9.get(),  #庫房編號
                        None                        #顧客編號為空
                                            ))
                conn.commit()   #提交
                cursor.execute('select * from commodity where commodity_id="%s"' % (self.entryss1.get()))
                conn.commit()
                cursor.close()  #關閉游標
                self.drop_Text_1()
                self.Text_1.insert(tkinter.INSERT, "數據添加成功")
                self.Text_1.insert(tkinter.INSERT,cursor.fetchall())
 
            except:
                try:
                    sql = 'select * from commodity where commodity_id="%s"' % (self.entryss1.get())
                    cursor.execute(sql)
                    conn.commit()
                    self.drop_Text_1()
                    self.Text_1.insert(tkinter.INSERT, "數據存在:")
                    self.Text_1.insert(tkinter.INSERT, cursor.fetchall())
                    cursor.close()
                except:
                    self.drop_Text_1()
                    self.Text_1.insert(tkinter.INSERT, "商品數據不符合類型,從新添加:")
    def add_Cancel(self):   #取消輸入的信息
        self.entryss1.delete(0, tkinter.END)
        self.entryss2.delete(0, tkinter.END)
        self.entryss3.delete(0, tkinter.END)
        self.entryss4.delete(0, tkinter.END)
        self.entryss5.delete(0, tkinter.END)
        self.entryss6.delete(0, tkinter.END)
        self.entryss7.delete(0, tkinter.END)
        self.entryss8.delete(0, tkinter.END)
        self.entryss9.delete(0, tkinter.END)
        self.Text_1.delete(0.0, tkinter.END)
        self.entryss1.update()
        self.entryss2.update()
        self.entryss3.update()
        self.entryss4.update()
        self.entryss5.update()
        self.entryss6.update()
        self.entryss7.update()
        self.entryss8.update()
        self.entryss9.update()
        self.Text_1.update()
        self.Text_1.insert(tkinter.INSERT,"請選擇其他")
        #————————————————————————————店鋪————————————————————————————————,
class Commodity_drop(MainForm):  #刪除界面
    def __init__(self):
        super().__init__()
        self.Textw = tkinter.Text(self.root, height=18, width=80, font=("微軟雅黑", 10))
        self.Textw.place(x=15, y=0)
        tkinter.Label(self.root,text="輸入需要刪除的商品編號或商品名稱",font=("微軟雅黑", 20)).place(x=100,y=350)
        self.Entry_1=tkinter.Entry(self.root,font=("微軟雅黑", 20))
        self.Entry_1.place(x=20,y=400)
        tkinter.Button(self.root,text="查詢",command=self.commodity_select_drop,font=("微軟雅黑", 10)).place(x=380,y=400)
        tkinter.Button(self.root, text="返回", command=self.commodity_return, font=("微軟雅黑", 10)).place(x=600, y=450)
        tkinter.Button(self.root, text="確定清除", command=self.commodity_confirm, font=("微軟雅黑", 10)).place(x=450, y=400)
        tkinter.Button(self.root, text="取消清除", command=self.commodity_confirm, font=("微軟雅黑", 10)).place(x=550, y=400)
        self.commodity_refersh()   #顯示提示頁面
        self.commodity_select()  #顯示所有的商品信息
        self.root.mainloop()
    def commodity_return(self): #返回商品菜單
        self.root.destroy()
        Commodity_From()
    def commodity_confirm(self):  #提示確認查詢
        self.commodity_refersh()
        self.Textw.insert(tkinter.INSERT,"請先查詢\n")
        self.commodity_select()
    def commodity_refersh(self):  #刷新界面
        self.Textw.delete(0.0,tkinter.END)
        self.Textw.update()
        self.Textw.insert(tkinter.INSERT,
                          "----------------------------------請輸入你要刪除的商品編號,或商品名稱----------------------------------\n")
    def commodity_select(self):  #查詢所有的商品
        cursor = conn.cursor()  # 創建sql游標
        sql = 'select * from commodity '   # 查詢所有商品的信息
        cursor.execute(sql)
        self.Textw.insert(tkinter.INSERT, "你的商品信息為:\n")
        for fetchone in cursor.fetchall():
            self.Textw.insert(tkinter.INSERT, fetchone)
            self.Textw.insert(tkinter.INSERT, '\n')
    #——————————————————————————————————————————————————————刪除頁面————————————————————————————————————————————————————
    def commodity_select_drop(self):  #查詢需要刪除的商品信息
        if self.Entry_1.get() == '':
            self.commodity_refersh()
            self.Textw.insert(tkinter.INSERT, "你的輸入為空:\n")
            self.commodity_select()
        else:
            try:
                def selecte_id_look():
                    cursor = conn.cursor()  # 創建sql游標
                    sql1 = 'select * from commodity where commodity_id="%s"' % (self.Entry_1.get())  # 查詢需要刪除的信息
                    cursor.execute(sql1)
                    conn.commit()  # 提交
                    cursor.close()  # 關閉游標
                    self.commodity_refersh()
                    self.Textw.insert(tkinter.INSERT, "你輸入的的商品編號查詢的信息為:\n")
                    return cursor.fetchall()
                def selecte_name_look():
                    cursor = conn.cursor()  # 創建sql游標
                    sql2 = 'select * from commodity where commodity_name="%s"' % (self.Entry_1.get())  # 查詢需要刪除的信息
                    cursor.execute(sql2)
                    conn.commit()  # 提交
                    cursor.close()  # 關閉游標
                    self.commodity_refersh()
                    self.Textw.insert(tkinter.INSERT, "你輸入的的商品名稱查詢的信息為:\n")
                    return cursor.fetchall()
                def button_id():
                    tkinter.Button(self.root, text="確定清除", command=delete_id,
                                   font=("微軟雅黑", 10)).place(x=450, y=400)
                    tkinter.Button(self.root, text="取消清除", command=self.commodity_select, font=("微軟雅黑", 10)).place(
                        x=550, y=400)
                def button_name():
                    tkinter.Button(self.root, text="確定清除", command=delete_name,
                                   font=("微軟雅黑", 10)).place(x=450, y=400)
                    tkinter.Button(self.root, text="取消清除", command=self.commodity_select, font=("微軟雅黑", 10)).place(
                        x=550, y=400)
                def delete_id():
                    cursor = conn.cursor()  # 創建sql游標
                    sql = 'delete from commodity where commodity_id="%s"' % (self.Entry_1.get())
                    cursor.execute(sql)
                    conn.commit()  # 提交
                    cursor.close()  # 關閉游標
                    self.Textw.insert(tkinter.INSERT, "數據刪除成功\n")
                def delete_name():
                    cursor = conn.cursor()  # 創建sql游標
                    sql = 'delete from commodity where commodity_name="%s"' % (self.Entry_1.get())
                    cursor.execute(sql)
                    conn.commit()  # 提交
                    cursor.close()  # 關閉游標
                    self.Textw.insert(tkinter.INSERT, "數據刪除成功\n")
                if bool(selecte_id_look())==True:
                    for fetchone in selecte_id_look():
                        self.Textw.insert(tkinter.INSERT, fetchone)
                        self.Textw.insert(tkinter.INSERT, '\n')
                    button_id()
                elif bool(selecte_name_look())==True:
                    for fetchone in selecte_name_look():
                        self.Textw.insert(tkinter.INSERT, fetchone)
                        self.Textw.insert(tkinter.INSERT, '\n')
                    button_name()
                else:
                    self.commodity_refersh()
                    self.Textw.insert(tkinter.INSERT, "你輸入的的商品信息錯誤或沒有此商品:\n")
            except:
                self.Textw.insert(tkinter.INSERT, "程序運行故障:\n")
        #_____________________________________修改頁面————————————————————————————————————————————————————————————
class Commodity_delente(MainForm): #修改
    def __init__(self):
        super().__init__()
        photo=tkinter.PhotoImage(file=COMMODITY_DELETE_PATH)
        tkinter.Label(self.root, image=photo, width=680, height=500).place(x=0, y=0)
        tkinter.Label(self.root,text="修改商品信息",font=("黑體",20)).place(x=250,y=0)
        tkinter.Label(self.root, text="所有商品信息", font=("微軟雅黑", 10)).place(x=110, y=30)
        self.Text_select=tkinter.Text(self.root,width=40,height=13,font=("微軟雅黑", 10))  #顯示所有商品信息
        self.Text_select.place(x=10,y=50)
        tkinter.Label(self.root, text="修改商品信息", font=("微軟雅黑", 10)).place(x=110, y=300)  #顯示查詢和修改的商品信息
        self.Text_delete = tkinter.Text(self.root, width=40, height=8,font=("微軟雅黑", 10))
        self.Text_delete.place(x=10, y=320)
        tkinter.Label(self.root, text="查詢商品信息", font=("微軟雅黑", 10)).place(x=500, y=30)
        tkinter.Label(self.root, text="輸入商品編號:", font=("微軟雅黑", 10)).place(x=350, y=50)
        self.Entry_id = tkinter.Entry(self.root,font=("微軟雅黑", 10))   #輸入商品編號
        self.Entry_id.place(x=450, y=50)
        tkinter.Button(self.root, text="查詢",command=self.select_id_commodity, font=("微軟雅黑", 7)).place(x=630, y=50)
        tkinter.Label(self.root, text="修改商品內容:", font=("微軟雅黑", 10)).place(x=350, y=100)
        self.Entry_update = tkinter.Entry(self.root, font=("微軟雅黑", 10))  #輸入修改的商品信息
        self.Entry_update.place(x=450, y=100)
        tkinter.Button(self.root,text="商品名稱",command=self.update_name,font=("微軟雅黑",10)).place(x=450,y=150)
        tkinter.Button(self.root, text="商品售價", command=self.update_price, font=("微軟雅黑", 10)).place(x=550, y=150)
        tkinter.Button(self.root, text="商品進價", command=self.update_pur_price, font=("微軟雅黑", 10)).place(x=450, y=200)
        tkinter.Button(self.root, text="生產日期", command=self.update_production, font=("微軟雅黑", 10)).place(x=550, y=200)
        tkinter.Button(self.root, text="保質期", command=self.update_life, font=("微軟雅黑", 10)).place(x=450, y=250)
        tkinter.Button(self.root, text="商品規格", command=self.update_speci, font=("微軟雅黑", 10)).place(x=550, y=250)
        tkinter.Button(self.root,text="庫房編號",command=self.warehouse_id,font=("微軟雅黑",10)).place(x=450,y=300)
        tkinter.Button(self.root, text="返回", command=self.commodity_return, font=("微軟雅黑", 10)).place(x=600, y=450)
        self.selecte_Text_query()   #跟新并查詢商品信息
        self.root.mainloop()
    def commodity_return(self):  #返回商品菜單
        self.root.destroy()
        Commodity_From()
    def selecte_Text_query(self):  # 更新并查詢商品信息
        self.Text_select.delete(0.0, tkinter.END)
        self.Text_select.update()
        try:
            cursor=conn.cursor()
            sql='select * from commodity '
            cursor.execute(sql)
            conn.commit()
            cursor.close()
            for i in cursor.fetchall():
                self.Text_select.insert(tkinter.INSERT,i)
                self.Text_select.insert(tkinter.INSERT,'\n')
        except:
            pass
    def delete_Text_query(self): #跟新輸出顯示框的信息
        self.Text_delete.delete(0.0,tkinter.END)
        self.Text_delete.update()
        self.Text_delete.insert(tkinter.INSERT,"你查詢到的商品為:\n")
    def select_id_commodity(self):   #根據id查詢信息
        def commodity_select_id():  #查詢商品信息
            def select_id():
                cursor = conn.cursor()  # 創建sql游標
                sql = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
                cursor.execute(sql)
                conn.commit()  # 提交
                cursor.close()  # 關閉游標
                return cursor.fetchall()
            if bool(select_id())==True:
                for i in select_id():
                    self.Text_delete.insert(tkinter.INSERT, i)
                    self.Text_delete.insert(tkinter.INSERT,'\n')
            else:
                self.Text_delete.insert(tkinter.INSERT,"沒有該商品信息:\n")
        if self.Entry_id.get()=='':
            self.delete_Text_query()
            self.Text_delete.insert(tkinter.INSERT,"你的輸入為空:\n請從新輸入;\n")
        else:
            commodity_select_id()
    def update_name(self):
        self.delete_Text_query()
        try:
            cursor=conn.cursor()
            sql='update commodity set commodity_name="%s" where commodity_id="%s"'%(self.Entry_update.get(),self.Entry_id.get())
            cursor.execute(sql)
            conn.commit()
            sql2 = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
            cursor.execute(sql2)
            conn.commit()
            self.Text_delete.insert(tkinter.INSERT,cursor.fetchall())
            cursor.close()
            self.Text_delete.insert(tkinter.INSERT, "\n你的商品名稱修改成功;\n")
        except:
            pass
    def update_price(self):
        self.delete_Text_query()
        try:
            cursor=conn.cursor()
            sql='update commodity set commodity_price="%s" where commodity_id="%s"'%(self.Entry_update.get(),self.Entry_id.get())
            cursor.execute(sql)
            conn.commit()
            sql2 = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
            cursor.execute(sql2)
            conn.commit()
            self.Text_delete.insert(tkinter.INSERT,cursor.fetchall())
            cursor.close()
            self.Text_delete.insert(tkinter.INSERT, "\n你的商品售價修改成功;\n")
        except:
            pass
    def update_pur_price(self):
        self.delete_Text_query()
        try:
            cursor=conn.cursor()
            sql='update commodity set commodity_pur_price="%s" where commodity_id="%s"'%(self.Entry_update.get(),self.Entry_id.get())
            cursor.execute(sql)
            conn.commit()
            sql2 = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
            cursor.execute(sql2)
            conn.commit()
            self.Text_delete.insert(tkinter.INSERT,cursor.fetchall())
            cursor.close()
            self.Text_delete.insert(tkinter.INSERT, "\n你的商品進價修改成功;\n")
        except:
            pass
    def update_production(self):
        self.delete_Text_query()
        try:
            cursor=conn.cursor()
            sql='update commodity set commodity_production="%s" where commodity_id="%s"'%(self.Entry_update.get(),self.Entry_id.get())
            cursor.execute(sql)
            conn.commit()
            sql2 = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
            cursor.execute(sql2)
            conn.commit()
            self.Text_delete.insert(tkinter.INSERT,cursor.fetchall())
            cursor.close()
            self.Text_delete.insert(tkinter.INSERT, "\n你的生產日期修改成功;\n")
        except:
            pass
    def update_life(self):
        self.delete_Text_query()
        try:
            cursor=conn.cursor()
            sql='update commodity set commodity_life="%s" where commodity_id="%s"'%(self.Entry_update.get(),self.Entry_id.get())
            cursor.execute(sql)
            conn.commit()
            sql2 = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
            cursor.execute(sql2)
            conn.commit()
            self.Text_delete.insert(tkinter.INSERT,cursor.fetchall())
            cursor.close()
            self.Text_delete.insert(tkinter.INSERT, "\n你的保質期修改成功;\n")
        except:
            pass
    def update_speci(self):
        self.delete_Text_query()
        try:
            cursor=conn.cursor()
            sql='update commodity set commodity_speci="%s" where commodity_id="%s"'%(self.Entry_update.get(),self.Entry_id.get())
            cursor.execute(sql)
            conn.commit()
            sql2 = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
            cursor.execute(sql2)
            conn.commit()
            self.Text_delete.insert(tkinter.INSERT,cursor.fetchall())
            cursor.close()
            self.Text_delete.insert(tkinter.INSERT, "\n你的商品規格修改成功;\n")
        except:
            pass
    def warehouse_id(self):
        self.delete_Text_query()
        try:
            cursor=conn.cursor()
            sql='update commodity set warehouse_id="%s" where commodity_id="%s"'%(self.Entry_update.get(),self.Entry_id.get())
            cursor.execute(sql)
            conn.commit()
            sql2 = 'select * from commodity where commodity_id="%s"' % (self.Entry_id.get())
            cursor.execute(sql2)
            conn.commit()
            self.Text_delete.insert(tkinter.INSERT,cursor.fetchall())
            cursor.close()
            self.Text_delete.insert(tkinter.INSERT, "\n你的庫房修改成功;\n")
        except:
            pass
class Commodity_select(MainForm) :  #查詢
    def __init__(self):
        super().__init__()
        tkinter.Label(self.root, text="查詢商品信息", font=("黑體", 20)).place(x=250, y=0)
        tkinter.Label(self.root, text="所有商品信息", font=("微軟雅黑", 10)).place(x=110, y=30)
        self.Text_select = tkinter.Text(self.root, width=40, height=13, font=("微軟雅黑", 10))  # 顯示所有商品信息
        self.Text_select.place(x=10, y=50)
        tkinter.Label(self.root, text="查詢商品信息", font=("微軟雅黑", 10)).place(x=500, y=30)
        #商品編號
        tkinter.Label(self.root, text="輸入商品編號查詢:", font=("微軟雅黑", 10)).place(x=350, y=50)
        self.Entry_id = tkinter.Entry(self.root, font=("微軟雅黑", 10))  # 輸入商品編號
        self.Entry_id.place(x=450, y=50)
        tkinter.Button(self.root, text="查詢",command=self.selecte_id_commodity ,font=("微軟雅黑", 7)).place(x=630, y=50)
        tkinter.Label(self.root, text="所有商品編號信息", font=("微軟雅黑", 10)).place(x=100, y=300)  # 顯示查詢和修改的商品信息
        self.Text_id = tkinter.Text(self.root, width=30, height=8, font=("微軟雅黑", 10))
        self.Text_id.place(x=10, y=320)
        # 商品名稱
        tkinter.Label(self.root, text="輸入商品名稱查詢:", font=("微軟雅黑", 10)).place(x=350, y=100)
        self.Entry_name = tkinter.Entry(self.root, font=("微軟雅黑", 10))  # 輸入修改的商品信息
        self.Entry_name.place(x=450, y=100)
        tkinter.Button(self.root, text="查詢",command=self.selecte_name_commodity, font=("微軟雅黑", 7)).place(x=630, y=100)
        tkinter.Label(self.root, text="所有商品名稱信息", font=("微軟雅黑", 10)).place(x=300, y=300)  # 顯示查詢和修改的商品信息
        self.Text_name = tkinter.Text(self.root, width=30, height=8, font=("微軟雅黑", 10))
        self.Text_name.place(x=210, y=320)
        #商品庫房名稱
        tkinter.Label(self.root, text="輸入庫房名稱查詢:", font=("微軟雅黑", 10)).place(x=350, y=150)
        self.Entry_warehouse = tkinter.Entry(self.root, font=("微軟雅黑", 10))  # 輸入修改的商品信息
        self.Entry_warehouse.place(x=450, y=150)
        tkinter.Button(self.root, text="查詢",command=self.selecte_warehouse_commodity, font=("微軟雅黑", 7)).place(x=630, y=150)
        tkinter.Label(self.root, text="庫房所有商品信息", font=("微軟雅黑", 10)).place(x=500, y=300)  # 顯示查詢和修改的商品信息
        self.Text_warehouse = tkinter.Text(self.root, width=30, height=8, font=("微軟雅黑", 10))
        self.Text_warehouse.place(x=410, y=320)
        tkinter.Button(self.root, text="返回", command=self.commodity_return, font=("微軟雅黑", 10)).place(x=600, y=450)
        self.selecte_Text_query()  # 跟新并查詢商品信息
        self.root.mainloop()
    def commodity_return(self): #返回商品界面
        self.root.destroy()
        Commodity_From()
    def selecte_Text_query(self):  # 更新并查詢商品信息
        self.Text_select.delete(0.0, tkinter.END)
        self.Text_select.update()
        try:
            cursor = conn.cursor()
            sql = 'select * from commodity '
            cursor.execute(sql)
            conn.commit()
            cursor.close()
            for i in cursor.fetchall():
                self.Text_select.insert(tkinter.INSERT, i)
                self.Text_select.insert(tkinter.INSERT, '\n')
        except:
            pass
    def selecte_id_commodity(self): #根據商品id查詢商品信息
        def text_id_query():  #清空text里面的信息
            self.Text_id.delete(0.0,tkinter.END)
            self.Text_id.update()
        if self.Entry_warehouse.get()=='':
            text_id_query()
            self.Text_id.insert(tkinter.INSERT,"你輸入的庫房賬號為空\n")
        else:
            text_id_query()
            def select_id():
                cursor=conn.cursor()
                sql='select * from commodity where warehouse_id="%s"'%(self.Entry_warehouse.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                return cursor.fetchall()
            if bool(select_id())==True:
                for i in select_id():
                    self.Text_id.insert(tkinter.INSERT,i)
                    self.Text_id.insert(tkinter.INSERT,'\n')
            else:
                self.Text_id.insert(tkinter.INSERT,"你輸入的商品不在店鋪\n")
    def selecte_name_commodity(self): #根據商品name查詢商品信息
        def text_name_query():  #清空text里面的信息
            self.Text_name.delete(0.0,tkinter.END)
            self.Text_name.update()
        if self.Entry_name.get()=='':
            text_name_query()
            self.Text_name.insert(tkinter.INSERT,"你輸入的商品名稱為空\n")
        else:
            text_name_query()
            def select_name():
                cursor=conn.cursor()
                sql='select * from commodity where commodity_name="%s"'%(self.Entry_name.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                return cursor.fetchall()
            if bool(select_name())==True:
                for i in select_name():
                    self.Text_name.insert(tkinter.INSERT,i)
                    self.Text_name.insert(tkinter.INSERT,'\n')
            else:
                self.Text_name.insert(tkinter.INSERT,"你輸入的商品名稱查詢不在店鋪\n")
    def selecte_warehouse_commodity(self): #根據商品id查詢商品信息
        def text_warehouse_query():  #清空text里面的信息
            self.Text_warehouse.delete(0.0,tkinter.END)
            self.Text_warehouse.update()
        if self.Entry_warehouse.get()=='':
            text_warehouse_query()
            self.Text_warehouse.insert(tkinter.INSERT,"你輸入的庫房為空\n")
        else:
            text_warehouse_query()
            def select_warehouse():
                cursor=conn.cursor()
                sql='select * from commodity where commodity_id="%s"'%(self.Entry_id.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                return cursor.fetchall()
            if bool(select_warehouse())==True:
                for i in select_warehouse():
                    self.Text_warehouse.insert(tkinter.INSERT,i)
                    self.Text_warehouse.insert(tkinter.INSERT,'\n')
            else:
                self.Text_warehouse.insert(tkinter.INSERT,"你輸入的庫房查詢不在店鋪\n")
class Shop_From(MainForm):  #店鋪界面設置,店鋪可以查詢,修改,導出倉庫信息全部商品
    def __init__(self):
        super().__init__()
        self.button1 = tkinter.Button(self.root, text="顧客", command=self.Customer, height=3, width=10).place(x=0, y=430)
        self.button2 = tkinter.Button(self.root, text="商品", command=self.Commodiyt_from_1, height=3, width=10).place(x=150, y=430)
        self.button3 = tkinter.Button(self.root, text="庫房", command=self.Warehouse_1, height=3, width=10).place(x=300, y=430)
        self.button4 = tkinter.Button(self.root, text="導入導出", command=self.export_1, height=3, width=10).place(x=450, y=430)
        self.button1 = tkinter.Button(self.root, text="返回", command=self.The_store_1, height=3, width=10).place(x=600, y=430)
        self.root.mainloop()
    def Commodiyt_from_1(self):#進入商品界面
        self.root.destroy()
        Commodity_From()
    def The_store_1(self):#進入主界面
        self.root.destroy()
        The_store()
    def Warehouse_1(self):  # 進入庫房界面
        self.root.destroy()
        Warehouse()
    def export_1(self):#進入導出界面
        self.root.destroy()
        Shop_export()
    def Customer(self):#  顧客管理
        def remove_Text_purint():  #清空Customer_Text_purint數據
            Customer_Text_purint.delete(0.0, tkinter.END)
            Customer_Text_purint.update()
        def import_user():  #導出所有用戶信息到Customer_Text中
            cursor = conn.cursor()
            sql = 'select * from customer'
            cursor.execute(sql)
            Customer_Text.delete(0.0, tkinter.END)
            Customer_Text.update()
            Customer_Text.insert(tkinter.INSERT, '你的所有商品信息\n')
            for x in cursor.fetchall():
                Customer_Text.insert(tkinter.INSERT,x)
                Customer_Text.insert(tkinter.INSERT, '\n')
            conn.commit()
            cursor.close()
        def query_user():# 查詢用戶信息
            cursor=conn.cursor()
            sql='select * from customer where customer_id="%s" and customer_password="%s"'%(Customer_Entry_user.get(),Customer_Entry_password.get())
            cursor.execute(sql)
            conn.commit()
            cursor.close()
            return cursor.fetchall()
        #....................修改用戶名.........................
        def delete_user():#  修改用戶信息
            def delete_user_od() : #修改
                cursor = conn.cursor()
                sql='update customer set customer_name="%s" where customer_id="%s"'%(Customer_Entry_name.get(),Customer_Entry_user.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
            if Customer_Entry_user.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "用戶名輸入為空\n")
            elif Customer_Entry_password.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "密碼輸入為空\n")
            else:
                try:
                    remove_Text_purint()   #清空
                    Customer_Text_purint.insert(tkinter.INSERT,'你原用戶信息\n')  # 提示信息
                    Customer_Text_purint.insert(tkinter.INSERT, query_user())  #查詢
                    Customer_Text_purint.insert(tkinter.INSERT, "\n你修改后用戶信息\n")  # 查詢
                    delete_user_od()  #進行修改
                    Customer_Text_purint.insert(tkinter.INSERT, query_user())  # 在查詢
                except:
                    remove_Text_purint()
                    Customer_Text_purint.insert(tkinter.INSERT, "用戶修改失敗\n")
        # ....................修改密碼.........................
        def delete_password():#修改密碼
            def delete_user_od() : #對密碼修改
                cursor = conn.cursor()
                sql='update customer set customer_password="%s" where customer_id="%s"'%(Customer_Entry_password.get(),Customer_Entry_user.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
            def query_user():  # 查詢用戶信息
                cursor = conn.cursor()
                sql = 'select * from customer where customer_id="%s"'% (
                Customer_Entry_user.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                return cursor.fetchall()
            if Customer_Entry_user.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "用戶名輸入為空\n")
            elif Customer_Entry_password.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "密碼輸入為空\n")
            else:
                try:
                    remove_Text_purint()   #清空
                    Customer_Text_purint.insert(tkinter.INSERT,'你原用戶信息\n')  # 提示信息
                    Customer_Text_purint.insert(tkinter.INSERT, query_user())  #查詢
                    Customer_Text_purint.insert(tkinter.INSERT, "\n你修改后的用戶信息\n")  # 查詢
                    delete_user_od()  #進行修改
                    Customer_Text_purint.insert(tkinter.INSERT, query_user())  # 在查詢
                except:
                    remove_Text_purint()
                    Customer_Text_purint.insert(tkinter.INSERT, "用戶修改失敗\n")
            # ....................增加用戶.........................
        def add_user():  #增加用戶
            def delete_user_add() : #增加修改
                cursor = conn.cursor()
                sql='insert into customer values(%s,%s,%s,0)'%(Customer_Entry_user.get(),Customer_Entry_name.get(),Customer_Entry_password.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
            def query_user():  # 查詢用戶信息
                cursor = conn.cursor()
                sql = 'select * from customer where customer_id="%s"'% (
                Customer_Entry_user.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                return cursor.fetchall()
            if Customer_Entry_user.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "用戶名輸入為空\n")
            elif Customer_Entry_password.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "密碼輸入為空\n")
            else:
                try:
                    remove_Text_purint()   #清空
                    Customer_Text_purint.insert(tkinter.INSERT, "你增加的用戶信息\n")  # 查詢
                    delete_user_add()  #進行修改
                    Customer_Text_purint.insert(tkinter.INSERT, query_user())  # 在查詢
                except:
                    remove_Text_purint()
                    Customer_Text_purint.insert(tkinter.INSERT, "用戶已存在,用戶添加失敗\n")
                    Customer_Text_purint.insert(tkinter.INSERT, query_user())  # 在查詢
            # ....................刪除用戶.........................
        def drop_user():  #刪除用戶
            def delete_user_drop() : #刪除修改
                cursor = conn.cursor()
                sql='delete from customer where customer_id="%s" and customer_password="%s"'%(Customer_Entry_user.get(),Customer_Entry_password.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
            def query_user():  # 查詢用戶信息
                cursor = conn.cursor()
                sql = 'select * from customer where customer_id="%s"'% (
                Customer_Entry_user.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                return cursor.fetchall()
            if Customer_Entry_user.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "用戶名輸入為空\n")
            elif Customer_Entry_password.get()=='':
                remove_Text_purint()
                Customer_Text_purint.insert(tkinter.INSERT, "密碼輸入為空\n")
            else:
                try:
                    remove_Text_purint()   #清空
                    Customer_Text_purint.insert(tkinter.INSERT, "你刪除的用戶信息\n")  # 查詢
                    delete_user_drop()  #刪除
                    Customer_Text_purint.insert(tkinter.INSERT, query_user())  # 在查詢
                except:
                    remove_Text_purint()
                    Customer_Text_purint.insert(tkinter.INSERT, "用戶輸入不對,用戶刪除失敗\n")
        tkinter.Label(self.root, text="顧客信息", font=("黑體", 20)).place(x=260, y=0)
        Customer_Text=tkinter.Text(self.root,width=50,height=20,font=("微軟雅黑",10))
        Customer_Text.place(x=0,y=30)
        import_user()
        tkinter.Label(self.root, text="用戶信息修改", font=("黑體", 10)).place(x=500, y=10)
        tkinter.Label(self.root, text="用戶賬號", font=("黑體", 10)).place(x=420, y=50)
        tkinter.Label(self.root, text="密    碼", font=("黑體", 10)).place(x=420, y=100)
        tkinter.Label(self.root, text="用 戶 名", font=("黑體", 10)).place(x=420, y=150)
        tkinter.Label(self.root, text="電    話", font=("黑體", 10)).place(x=420, y=200)
        Customer_Entry_user = tkinter.Entry(self.root, font=("微軟雅黑", 10))  # 顯示框
        Customer_Entry_user.place(x=500,y=50)
        Customer_Entry_password = tkinter.Entry(self.root, font=("微軟雅黑", 10),show='*')  # 顯示框
        Customer_Entry_password.place(x=500,y=100)
        Customer_Entry_name = tkinter.Entry(self.root, font=("微軟雅黑", 10))  # 顯示框
        Customer_Entry_name.place(x=500, y=150)
        Customer_Entry_phon = tkinter.Entry(self.root, font=("微軟雅黑", 10))  # 顯示框
        Customer_Entry_phon.place(x=500, y=200)
        tkinter.Button(self.root,text="修改用戶信息",command=delete_user,font=('微軟雅黑',10)).place(x=420,y=250)
        tkinter.Button(self.root, text="修改密碼", command=delete_password, font=('微軟雅黑', 10)).place(x=420, y=300)
        tkinter.Button(self.root, text="添加用戶", command=add_user, font=('微軟雅黑', 10)).place(x=560, y=250)
        tkinter.Button(self.root, text="刪除用戶", command='1111', font=('微軟雅黑', 10)).place(x=560, y=300)
        Customer_Text_purint=tkinter.Text(self.root,width=30,height=3,font=("微軟雅黑",10))
        Customer_Text_purint.place(x=420, y=350)
        Customer_Text_purint.insert(tkinter.INSERT,"輸入正確的賬號密碼可以修改用戶名\n輸入正確的賬號可以修改密碼\n"
                                                   "輸入沒有的賬號,用戶名,密碼可以添加賬號\n輸入正確的賬號,密碼可以刪除賬號")
class Shop_export(MainForm):#導入導出
    def __init__(self):
        super().__init__()
        tkinter.Label(self.root, text="導入導出顧客商品信息", font=("黑體", 20)).place(x=200, y=0)
        self.prompt=tkinter.Text(self.root,width=55,height=5,font=("微軟雅黑",15))
        self.prompt.place(x=10,y=50)
        #————————————————導入————————————————————————
        tkinter.Label(self.root,text="輸入導入的絕對地址:",font=("微軟雅黑",15)).place(x=70,y=200)
        self.leading_in=tkinter.Entry(self.root,font=("黑體",15))
        self.leading_in.place(x=50,y=250)
        tkinter.Button(self.root, text="導入顧客", command=self.leading_in_customer,font=("微軟雅黑",15)).place(x=100, y=300)
        tkinter.Button(self.root, text="導入商品", command=self.leading_in_commodity, font=("微軟雅黑",15)).place(
            x=100, y=350)
        #————————————————導出————————————————
        tkinter.Label(self.root, text="輸入導出的絕對地址:", font=("微軟雅黑", 15)).place(x=420, y=200)
        self.leading_out = tkinter.Entry(self.root, font=("黑體", 15))
        self.leading_out.place(x=400, y=250)
        tkinter.Button(self.root, text="導出顧客", command=self.leading_out_customer, font=("微軟雅黑",15)).place(x=450, y=300)
        tkinter.Button(self.root, text="導出商品", command=self.leading_out_commodity,font=("微軟雅黑",15)).place(
            x=450, y=350)
        tkinter.Button(self.root, text="查看顧客", command=self.look_customer, font=("微軟雅黑", 15)).place(x=0, y=430)
        tkinter.Button(self.root, text="查看商品", command=self.look_commodity, font=("微軟雅黑", 15)).place(x=300, y=430)
        tkinter.Button(self.root, text="返回商品", command=self.The_store_1,font=("微軟雅黑",15)).place(x=600,y=430)
        self.root.mainloop()
    def The_store_1(self): #返回商品
        self.root.destroy()
        The_store()
    def clean_prompt(self):  #清除提示框
        self.prompt.delete(0.0,tkinter.END)
        self.prompt.update()
    def look_customer(self): #查看顧客
        cursor=conn.cursor()
        cursor.execute("select * from customer")
        conn.commit()
        cursor.close()
        self.clean_prompt()
        for i in cursor.fetchall():
            self.prompt.insert(tkinter.INSERT,i)
    def look_commodity(self): #查看商品
        cursor=conn.cursor()
        cursor.execute("select * from commodity")
        conn.commit()
        cursor.close()
        self.clean_prompt()
        for i in cursor.fetchall():
            self.prompt.insert(tkinter.INSERT,i)
    def leading_in_customer(self):  #導入顧客信息
        global global_id
        self.clean_prompt()
        address=self.leading_in.get()
        df_customer=pd.read_excel(address)
        def go_shopping():  # 查看購物情況
            sql = ' select sum(commodity_amount) from commodity GROUP BY customer_id;'
            cursor.execute(sql)
            conn.commit()
            return cursor.fetchone()
        cursor = conn.cursor()  # 創建游標
        try:
            for co in range(len(df_customer["用戶賬號"])):
                try:
                    sql = 'insert into customer values (%s,%s,%s,%s,%s,%s);'  # 添加數據
                    cursor.execute(sql, (
                        df_customer["用戶賬號"][co],
                        df_customer["密碼"][co],
                        df_customer["用戶名"][co],
                        df_customer["電話"][co],
                        go_shopping(),
                        global_id)
                                   )  # 執行添加數據
                    conn.commit()  # 提交
                except:
                    self.prompt.insert(tkinter.INSERT,"你的用戶賬號已導入\n")
                    self.prompt.insert(tkinter.INSERT,df_customer["用戶賬號"][co])
                    self.prompt.insert(tkinter.INSERT, "\n")
        except:
            self.prompt.insert(tkinter.INSERT, "錯誤:你導入的信息不符合導入格式\n")
        cursor.close()  # 關閉游標
    def leading_in_commodity(self):  #導入顧客信息
        global global_id
        self.clean_prompt()
        address = self.leading_in.get()
        df_commodity = pd.read_excel(address)
        cursor = conn.cursor()  # 創建游標
        try:
            for co in range(len(df_commodity["商品編碼"])):
                try:
                    sql = 'insert into commodity values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'  # 添加數據
                    cursor.execute(sql, (
                        df_commodity["商品編碼"][co],
                        df_commodity["商品名稱"][co],
                        df_commodity["商品售價"][co],
                        df_commodity["商品進價"][co],
                        df_commodity["生產日期"][co],
                        df_commodity["保質期"][co],
                        df_commodity["商品規格"][co],
                        df_commodity["銷售數量"][co],
                        global_id,
                        df_commodity["庫房編號"][co],
                        df_commodity["顧客編號"][co])
                                   )  # 執行添加數據
                    conn.commit()  # 提交
                except:
                    self.prompt.insert(tkinter.INSERT, "你的商品賬號已導入\n")
                    self.prompt.insert(tkinter.INSERT, df_commodity["商品編碼"][co])
                    self.prompt.insert(tkinter.INSERT, "\n")
        except:
            self.prompt.insert(tkinter.INSERT, "錯誤:你導入的信息不符合導入格式\n")
        cursor.close()  # 關閉游標
    def leading_out_customer(self): #導出顧客
        def select_():
            cursor = conn.cursor()
            cursor.execute("select * from customer")
            conn.commit()
            cursor.close()
            return cursor.fetchall()
        b=['顧客帳號','顧客密碼','顧客名稱','顧客電話','消費情況','店鋪帳號']
        c=self.leading_out.get()
        df=pd.DataFrame(select_(),columns=b)
        try:
            df.to_excel(c,index=0)
        except:
            self.prompt.insert(tkinter.INSERT,"地址格式錯誤:")
    def leading_out_commodity(self): #導出顧客
        def select_commoidty():
            cursor = conn.cursor()
            cursor.execute("select * from commodity")
            conn.commit()
            cursor.close()
            return cursor.fetchall()
        b=['商品編號','商品名稱','商品售價','商品進價','生產日期','保質期','商品規格','銷售數量','店鋪編號','庫房編號','顧客編號']
        c=self.leading_out.get()
        df=pd.DataFrame(select_commoidty(),columns=b)
        try:
            df.to_excel(c,index=0)
        except:
            self.prompt.insert(tkinter.INSERT,"地址格式錯誤:")
class Warehouse(MainForm):#庫房
    def __init__(self):
        super().__init__()
        tkinter.Label(self.root, text="庫房", font=("黑體", 20)).place(x=300, y=0)
        #庫房統計查詢
        tkinter.Button(self.root, text="庫存情況", command=self.Warehouse_situation, height=3, width=10).place(x=0, y=430)
        tkinter.Button(self.root, text="庫存導出", command=self.leading_out_warehouse, height=3, width=10).place(x=300, y=430)
        tkinter.Button(self.root, text="返回菜單", command=self.The_store_1, height=3, width=10).place(x=600, y=430)
        self.root.mainloop()
    def The_store_1(self):  #返回菜單
        self.root.destroy()
        The_store()
    def Warehouse_situation(self):  #庫存情況
        tkinter.Label(self.root, text="店鋪帳號:", font=("微軟雅黑", 15)).place(x=100,y=200)
        self.entry_warehouse = tkinter.Entry(self.root, font=("微軟雅黑", 15))
        self.entry_warehouse.place(x=250, y=200)
        tkinter.Label(self.root, text="店鋪密碼:", font=("微軟雅黑", 15)).place(x=100, y=250)
        self.entry_password = tkinter.Entry(self.root, font=("微軟雅黑", 15))
        self.entry_password.place(x=250, y=250)
        tkinter.Button(self.root, text="查詢", command=self.Warehouse_confirm,font=("微軟雅黑", 10)).place(x=600, y=200)
        self.Text_warehouse=tkinter.Text(self.root,width=80,height=7,font=("微軟雅黑", 10))
        self.Text_warehouse.place(x=12,y=30)
        tkinter.Label(self.root, text="導出地址:", font=("微軟雅黑", 15)).place(x=100, y=300)
        self.leading_warehouse_Entry = tkinter.Entry(self.root, font=("微軟雅黑", 15))
        self.leading_warehouse_Entry.place(x=250, y=300)
    def remove_Text_warehouse(self):
        self.Text_warehouse.delete(0.0,tkinter.END)
        self.Text_warehouse.update()
    def Warehouse_confirm(self):  #執行查詢結果
        self.remove_Text_warehouse()
        def selecte_warehouse():
            try:
                cursor = conn.cursor()
                sql=' select commodity_name,count(*),warehouse_id from commodity GROUP BY commodity_name having ' \
                    'warehouse_id=(select warehouse_id from warehouse where warehouse_id="%s"' \
                    ' and warehouse_password="%s")'%(self.entry_warehouse.get(),self.entry_password.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                self.remove_Text_warehouse()
                return cursor.fetchall()
            except:
                pass
        if bool(selecte_warehouse())==True:
            self.Text_warehouse.insert(tkinter.INSERT, "商品名稱,庫存,庫房號:\n")
            for i in selecte_warehouse():
                self.Text_warehouse.insert(tkinter.INSERT,i)
                self.Text_warehouse.insert(tkinter.INSERT,'\n')
        else:
            self.Text_warehouse.insert(tkinter.INSERT,"庫房賬號,或密碼輸入不對\n")
    def leading_out_warehouse(self):  #導出庫存
        self.remove_Text_warehouse()
        try:
            def selecte_warehouse():
                cursor = conn.cursor()
                sql = 'select commodity_name,count(*),warehouse_id from commodity group by commodity_name having warehouse_id="%s"'%(self.entry_warehouse.get())
                cursor.execute(sql)
                conn.commit()
                cursor.close()
                return cursor.fetchall()
            if bool(selecte_warehouse())==True:
                df=pd.DataFrame(selecte_warehouse(),columns=["商品名稱","剩余數量","庫房名稱"])
                df.to_excel(self.leading_warehouse_Entry.get(),index=0)
                self.Text_warehouse.insert(tkinter.INSERT, "庫存導出成功\n")
            else:self.Text_warehouse.insert(tkinter.INSERT,"請先查庫存\n")
        except:
            self.Text_warehouse.insert(tkinter.INSERT,"程序運行錯誤:\n")
if __name__=="__main__":
    conn=pymysql.connect(   #連接MySQL
        host='localhost',   #本地服務器
        port=3306, #服務器端口
        user='root', #用戶名
        password='123456',
        db='cpsim',
        charset='utf8'
        )
    global_id = 0
    The_login()
    conn.close()

讀到這里,這篇“python如何實現商品進銷存管理系統”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

梧州市| 赤峰市| 马尔康县| 滦平县| 保德县| 翁牛特旗| 云和县| 元江| 本溪| 商丘市| 邮箱| 台北市| 江门市| 镇沅| 鄂托克前旗| 贺州市| 黑山县| 绥滨县| 萍乡市| 永新县| 温泉县| 拉孜县| 丹寨县| 茶陵县| 镇平县| 鹤岗市| 清苑县| 通州区| 潮安县| 临海市| 邮箱| 秭归县| 随州市| 黄浦区| 横峰县| 稷山县| 邻水| 西乌珠穆沁旗| 佛教| 琼结县| 五大连池市|