백엔드 개발 파이썬 튜토리얼 Python으로 상품 구매, 판매 및 재고 관리 시스템을 구현하는 방법

Python으로 상품 구매, 판매 및 재고 관리 시스템을 구현하는 방법

May 19, 2023 pm 01:52 PM
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으로 상품 구매, 판매 및 재고 관리 시스템을 구현하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

MySQL은 지불해야합니다 MySQL은 지불해야합니다 Apr 08, 2025 pm 05:36 PM

MySQL에는 무료 커뮤니티 버전과 유료 엔터프라이즈 버전이 있습니다. 커뮤니티 버전은 무료로 사용 및 수정할 수 있지만 지원은 제한되어 있으며 안정성이 낮은 응용 프로그램에 적합하며 기술 기능이 강합니다. Enterprise Edition은 안정적이고 신뢰할 수있는 고성능 데이터베이스가 필요하고 지원 비용을 기꺼이 지불하는 응용 프로그램에 대한 포괄적 인 상업적 지원을 제공합니다. 버전을 선택할 때 고려 된 요소에는 응용 프로그램 중요도, 예산 책정 및 기술 기술이 포함됩니다. 완벽한 옵션은없고 가장 적합한 옵션 만 있으므로 특정 상황에 따라 신중하게 선택해야합니다.

PS 페더 링은 어떻게 전환의 부드러움을 제어합니까? PS 페더 링은 어떻게 전환의 부드러움을 제어합니까? Apr 06, 2025 pm 07:33 PM

깃털 통제의 열쇠는 점진적인 성격을 이해하는 것입니다. PS 자체는 그라디언트 곡선을 직접 제어하는 ​​옵션을 제공하지 않지만 여러 깃털, 일치하는 마스크 및 미세 선택으로 반경 및 구배 소프트를 유연하게 조정하여 자연스럽게 전이 효과를 달성 할 수 있습니다.

설치 후 MySQL을 사용하는 방법 설치 후 MySQL을 사용하는 방법 Apr 08, 2025 am 11:48 AM

이 기사는 MySQL 데이터베이스의 작동을 소개합니다. 먼저 MySQLworkBench 또는 명령 줄 클라이언트와 같은 MySQL 클라이언트를 설치해야합니다. 1. MySQL-Uroot-P 명령을 사용하여 서버에 연결하고 루트 계정 암호로 로그인하십시오. 2. CreateABase를 사용하여 데이터베이스를 작성하고 데이터베이스를 선택하십시오. 3. CreateTable을 사용하여 테이블을 만들고 필드 및 데이터 유형을 정의하십시오. 4. InsertInto를 사용하여 데이터를 삽입하고 데이터를 쿼리하고 업데이트를 통해 데이터를 업데이트하고 DELETE를 통해 데이터를 삭제하십시오. 이러한 단계를 마스터하고 일반적인 문제를 처리하는 법을 배우고 데이터베이스 성능을 최적화하면 MySQL을 효율적으로 사용할 수 있습니다.

PS 페더 링을 설정하는 방법? PS 페더 링을 설정하는 방법? Apr 06, 2025 pm 07:36 PM

PS 페더 링은 이미지 가장자리 블러 효과로, 가장자리 영역에서 픽셀의 가중 평균에 의해 달성됩니다. 깃털 반경을 설정하면 흐림 정도를 제어 할 수 있으며 값이 클수록 흐려집니다. 반경을 유연하게 조정하면 이미지와 요구에 따라 효과를 최적화 할 수 있습니다. 예를 들어, 캐릭터 사진을 처리 할 때 더 작은 반경을 사용하여 세부 사항을 유지하고 더 큰 반경을 사용하여 예술을 처리 할 때 흐릿한 느낌을줍니다. 그러나 반경이 너무 커서 가장자리 세부 사항을 쉽게 잃을 수 있으며 너무 작아 효과는 분명하지 않습니다. 깃털 효과는 이미지 해상도의 영향을받으며 이미지 이해 및 효과 파악에 따라 조정해야합니다.

MySQL 다운로드 파일이 손상되어 설치할 수 없습니다. 수리 솔루션 MySQL 다운로드 파일이 손상되어 설치할 수 없습니다. 수리 솔루션 Apr 08, 2025 am 11:21 AM

MySQL 다운로드 파일은 손상되었습니다. 어떻게해야합니까? 아아, mySQL을 다운로드하면 파일 손상을 만날 수 있습니다. 요즘 정말 쉽지 않습니다! 이 기사는 모든 사람이 우회를 피할 수 있도록이 문제를 해결하는 방법에 대해 이야기합니다. 읽은 후 손상된 MySQL 설치 패키지를 복구 할 수있을뿐만 아니라 향후에 갇히지 않도록 다운로드 및 설치 프로세스에 대해 더 깊이 이해할 수 있습니다. 파일 다운로드가 손상된 이유에 대해 먼저 이야기합시다. 이에 대한 많은 이유가 있습니다. 네트워크 문제는 범인입니다. 네트워크의 다운로드 프로세스 및 불안정성의 중단으로 인해 파일 손상이 발생할 수 있습니다. 다운로드 소스 자체에도 문제가 있습니다. 서버 파일 자체가 고장 났으며 물론 다운로드하면 고장됩니다. 또한 일부 안티 바이러스 소프트웨어의 과도한 "열정적 인"스캔으로 인해 파일 손상이 발생할 수 있습니다. 진단 문제 : 파일이 실제로 손상되었는지 확인하십시오

다운로드 후 MySQL을 설치할 수 없습니다 다운로드 후 MySQL을 설치할 수 없습니다 Apr 08, 2025 am 11:24 AM

MySQL 설치 실패의 주된 이유는 다음과 같습니다. 1. 권한 문제, 관리자로 실행하거나 Sudo 명령을 사용해야합니다. 2. 종속성이 누락되었으며 관련 개발 패키지를 설치해야합니다. 3. 포트 충돌, 포트 3306을 차지하는 프로그램을 닫거나 구성 파일을 수정해야합니다. 4. 설치 패키지가 손상되어 무결성을 다운로드하여 확인해야합니다. 5. 환경 변수가 잘못 구성되었으며 운영 체제에 따라 환경 변수를 올바르게 구성해야합니다. 이러한 문제를 해결하고 각 단계를 신중하게 확인하여 MySQL을 성공적으로 설치하십시오.

MySQL 설치 후 데이터베이스 성능을 최적화하는 방법 MySQL 설치 후 데이터베이스 성능을 최적화하는 방법 Apr 08, 2025 am 11:36 AM

MySQL 성능 최적화는 설치 구성, 인덱싱 및 쿼리 최적화, 모니터링 및 튜닝의 세 가지 측면에서 시작해야합니다. 1. 설치 후 innodb_buffer_pool_size 매개 변수와 같은 서버 구성에 따라 my.cnf 파일을 조정해야합니다. 2. 과도한 인덱스를 피하기 위해 적절한 색인을 작성하고 Execution 명령을 사용하여 실행 계획을 분석하는 것과 같은 쿼리 문을 최적화합니다. 3. MySQL의 자체 모니터링 도구 (showprocesslist, showstatus)를 사용하여 데이터베이스 건강을 모니터링하고 정기적으로 백업 및 데이터베이스를 구성하십시오. 이러한 단계를 지속적으로 최적화함으로써 MySQL 데이터베이스의 성능을 향상시킬 수 있습니다.

고로드 애플리케이션의 MySQL 성능을 최적화하는 방법은 무엇입니까? 고로드 애플리케이션의 MySQL 성능을 최적화하는 방법은 무엇입니까? Apr 08, 2025 pm 06:03 PM

MySQL 데이터베이스 성능 최적화 안내서 리소스 집약적 응용 프로그램에서 MySQL 데이터베이스는 중요한 역할을 수행하며 대규모 트랜잭션 관리를 담당합니다. 그러나 응용 프로그램 규모가 확장됨에 따라 데이터베이스 성능 병목 현상은 종종 제약이됩니다. 이 기사는 일련의 효과적인 MySQL 성능 최적화 전략을 탐색하여 응용 프로그램이 고 부하에서 효율적이고 반응이 유지되도록합니다. 실제 사례를 결합하여 인덱싱, 쿼리 최적화, 데이터베이스 설계 및 캐싱과 같은 심층적 인 주요 기술을 설명합니다. 1. 데이터베이스 아키텍처 설계 및 최적화 된 데이터베이스 아키텍처는 MySQL 성능 최적화의 초석입니다. 몇 가지 핵심 원칙은 다음과 같습니다. 올바른 데이터 유형을 선택하고 요구 사항을 충족하는 가장 작은 데이터 유형을 선택하면 저장 공간을 절약 할 수있을뿐만 아니라 데이터 처리 속도를 향상시킬 수 있습니다.

See all articles