怎样用Python搭建一个管理系统

这篇具有很好参考价值的文章主要介绍了怎样用Python搭建一个管理系统。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

最近有不少小伙伴问我,Python 怎么学,我的统一回答:就是实战,多练。无论做什么,都逃不过熟能生巧。其次就是从自己的兴趣出发,做一些实战小项目。往往一些小项目都藏着很多基础,这周在家闲着的时候给大家用Python写了一个疫苗管理系统的小项目。很适合新手练习,主要涉及的知识有Python、tkinter、数据库存储等。(资料点这里)

怎样用Python搭建一个管理系统

整体结构图

怎样用Python搭建一个管理系统

连接数据库

def connect_DBS(self, database, content):
    db = pymysql.connect(host="localhost", user="root", password="pwd", database=database)
    cursor = db.cursor()
    cursor.execute(content)
    data = cursor.fetchone()
    db.commit()
    db.close()
    return data

主界面

怎样用Python搭建一个管理系统

def main_window(self):
    tk.Button(app, text='登录', bg='white', font=("Arial,12"), width=12, height=1, command=self.login).place(x=260,                                                                                                      y=200)
    tk.Button(app, text='注册', bg='white', font=("Arial,12"), width=12, height=1, command=self.register).place(x=260,                                                                                                                y=240)
    tk.Button(app, text='退出', bg='white', font=("Arial,12"), width=12, height=1, command=self.quit_mainloop).place(x=260, y=280)

注册界面

怎样用Python搭建一个管理系统

def register(self):
    register = tk.Toplevel(app)
    register.title('用户注册')
    register.geometry("600x400")
    tk.Label(register, text="欢迎注册", font=("KaiTi", 40)).place(x=200, y=20)
    tk.Label(register, text='添加管理员姓名:', font=("Arial", 9)).place(x=80, y=120)
    tk.Label(register, text='确认管理员编号:', font=('Arial', 9)).place(x=80, y=150)
    entry1 = tk.Entry(register, font=("Arial, 9"), width=46, )
    entry2 = tk.Entry(register, font=("Arial, 9"), width=46, )
    entry1.pack()
    entry2.pack()
    entry1.place(x=180, y=120, width=350, height=25)
    entry2.place(x=180, y=150, width=350, height=25)

    def user_register():
        user_name = entry1.get()
        user_code = entry2.get()
        if user_name == "" or user_code == "":
            tkinter.messagebox.showwarning(title="警告", message="用户名或密码不能为空!")
        else:
            content = "INSERT INTO user_info (user_name, user_code) VALUES ('%s', '%s');" % (user_name, user_code)
            self.connect_DBS(database="vaccine_info", content=content)
            tkinter.messagebox.showinfo(title="信息", message="注册成功!")
    tk.Button(register, text="注册", bg='white', font=("Arial,9"), width=12, height=0, command=user_register).place(x=250, y=250)

登陆界面

怎样用Python搭建一个管理系统

def login(self):
    login = tk.Toplevel(app)
    login.title('用户登录')
    login.geometry("600x400")
    tk.Label(login, text="欢迎登录", font=("KaiTi", 40)).place(x=200, y=20)
    tk.Label(login, text='管理员姓名:', font=("Arial", 9)).place(x=80, y=120)
    tk.Label(login, text='管理员编号:', font=('Arial', 9)).place(x=80, y=150)
    entry1 = tk.Entry(login, font=("Arial, 9"), width=46)
    entry2 = tk.Entry(login, font=("Arial, 9"), width=46, show="*")
    entry1.pack()
    entry2.pack()
    entry1.place(x=180, y=120, width=350, height=25)
    entry2.place(x=180, y=150, width=350, height=25)

    def user_check():
        user_name = entry1.get()
        user_code = entry2.get()
        content = "SELECT * FROM user_info WHERE user_name = '%s';" % user_name
        data = self.connect_DBS(database="vaccine_info", content=content)
        try:
            if user_name == data[1] and user_code == data[2]:
                tkinter.messagebox.showinfo(title="信息", message="欢迎登录!")
                self.options()
            elif user_name != data[1]:
                tkinter.messagebox.showerror(title="错误", message="请注册后再进行登录!")
            elif user_name == data[1] and user_code != data[2]:
                tkinter.messagebox.showerror(title="错误", message="密码错误!")
        except TypeError:
            tkinter.messagebox.showerror(title="错误", message="请注册后再进行登录!")
    tk.Button(login, text="登录", bg='white', font=("Arial,9"), width=12, height=0, command=user_check).place(x=250, y=250)

功能选项

功能区主界面

怎样用Python搭建一个管理系统

def options(self):
    options = tk.Toplevel(app)
    options.title('功能选项')
    options.geometry("600x500")
    tk.Label(options, text="欢迎使用!", font=("KaiTi", 40)).place(x=180, y=15)
    tk.Button(options, text='新建疫苗信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.add_vacc_info).place(x=100, y=100)
    tk.Button(options, text='新建疫苗分配信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.add_vaccine_distr_info).place(x=100, y=160)
    tk.Button(options, text='新建疫苗养护信息', bg='white', font=("Arial,12"), width=20, height=2,              command=self.add_vaccine_maintenance_info).place(x=100, y=220)
    tk.Button(options, text='新建接种人员信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.add_vaccination_person_info).place(x=100, y=280)
    tk.Button(options, text='查询疫苗分配信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.vaccine_distr_info_query).place(x=100, y=340)
    tk.Button(options, text='查询疫苗养护信息', bg='white', font=("Arial,12"), width=20, height=2,           command=self.vaccination_maintenance_info_query).place(x=320, y=100)
    tk.Button(options, text='查询接种人员信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.vaccination_person_info_query).place(x=320, y=160)
    tk.Button(options, text='查询疫苗信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.vaccine_info_query).place(x=320, y=220)
    tk.Button(options, text='修改疫苗信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.modify_vaccine_info).place(x=320, y=280)
    tk.Button(options, text='删除疫苗信息', bg='white', font=("Arial,12"), width=20, height=2,command=self.del_vaccine_info).place(x=320, y=340)

新建疫苗信息

怎样用Python搭建一个管理系统

  def add_vacc_info(self):
        add_vacc_info = tk.Toplevel(app)
        add_vacc_info.title('添加疫苗信息')
        add_vacc_info.geometry("600x400")
        tk.Label(add_vacc_info, text='疫苗批号:', font=("Arial", 9)).place(x=80, y=60)
        tk.Label(add_vacc_info, text='疫苗名称:', font=('Arial', 9)).place(x=80, y=90)
        tk.Label(add_vacc_info, text='企业名称:', font=('Arial', 9)).place(x=80, y=120)
        tk.Label(add_vacc_info, text='企业编号:', font=('Arial', 9)).place(x=80, y=150)
        tk.Label(add_vacc_info, text='    规格:', font=('Arial', 9)).place(x=80, y=180)
        tk.Label(add_vacc_info, text='    进价:', font=('Arial', 9)).place(x=80, y=210)
        tk.Label(add_vacc_info, text='  预售价:', font=('Arial', 9)).place(x=80, y=240)
        tk.Label(add_vacc_info, text='企业上限:', font=('Arial', 9)).place(x=80, y=270)
        tk.Label(add_vacc_info, text='企业下限:', font=('Arial', 9)).place(x=80, y=300)
        entry1 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry2 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry3 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry4 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry5 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry6 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry7 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry8 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry9 = tk.Entry(add_vacc_info, font=("Arial, 9"), width=46)
        entry1.pack()
        entry2.pack()
        entry3.pack()
        entry4.pack()
        entry5.pack()
        entry6.pack()
        entry7.pack()
        entry8.pack()
        entry9.pack()
        entry1.place(x=180, y=60, width=350)
        entry2.place(x=180, y=90, width=350)
        entry3.place(x=180, y=120, width=350)
        entry4.place(x=180, y=150, width=350)
        entry5.place(x=180, y=180, width=350)
        entry6.place(x=180, y=210, width=350)
        entry7.place(x=180, y=240, width=350)
        entry8.place(x=180, y=270, width=350)
        entry9.place(x=180, y=300, width=350)

        def add():
            text1 = entry1.get()
            text2 = entry2.get()
            text3 = entry3.get()
            text4 = entry4.get()
            text5 = entry5.get()
            text6 = entry6.get()
            text7 = entry7.get()
            text8 = entry8.get()
            text9 = entry9.get()
            content = "INSERT INTO vaccine_info (" \
                      "vaccine_num, vaccine_name, company_name, company_num, size, buy_price, pre_sale_price, limit_up, limit_down" \
                      ")" \
                      " VALUES (%s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');" % (
                      text1, text2, text3, text4, text5, text6, text7, text8, text9)
            self.connect_DBS(database="vaccine_info", content=content)
            tkinter.messagebox.showinfo(title="信息", message="数据添加成功!")

        def clear():
            entry1.delete(0, "end")
            entry2.delete(0, "end")
            entry3.delete(0, "end")
            entry4.delete(0, "end")
            entry5.delete(0, "end")
            tkinter.messagebox.showinfo(title="信息", message="数据已清空,请继续添加!")
        tk.Button(add_vacc_info, text="添加", bg='white', font=("Arial,9"), width=9, height=0, command=add).place(x=400,                                                                                                       y=360)
        tk.Button(add_vacc_info, text="清空", bg='white', font=("Arial,9"), width=9, height=0, command=clear).place(x=160,                                                                                                             y=360)

新建疫苗分配信息

怎样用Python搭建一个管理系统

def add_vaccine_distr_info(self):
add_vaccine_distr_info = tk.Toplevel(app)
add_vaccine_distr_info.title(‘添加疫苗分配信息’)
add_vaccine_distr_info.geometry(“600x400”)
tk.Label(add_vaccine_distr_info, text=‘疫苗分配单号:’, font=(“Arial”, 9)).place(x=80, y=60)
tk.Label(add_vaccine_distr_info, text=’ 日期:’, font=(‘Arial’, 9)).place(x=80, y=90)
tk.Label(add_vaccine_distr_info, text=’ 疫苗批号:’, font=(‘Arial’, 9)).place(x=80, y=120)
tk.Label(add_vaccine_distr_info, text=’ 疫苗名称:’, font=(‘Arial’, 9)).place(x=80, y=150)
tk.Label(add_vaccine_distr_info, text=’ 企业编号:’, font=(‘Arial’, 9)).place(x=80, y=180)
tk.Label(add_vaccine_distr_info, text=’ 质检员编号:’, font=(‘Arial’, 9)).place(x=80, y=210)
tk.Label(add_vaccine_distr_info, text=’ 数量:’, font=(‘Arial’, 9)).place(x=80, y=240)
entry1 = tk.Entry(add_vaccine_distr_info, font=(“Arial, 9”), width=46)
entry2 = tk.Entry(add_vaccine_distr_info, font=(“Arial, 9”), width=46)
entry3 = tk.Entry(add_vaccine_distr_info, font=(“Arial, 9”), width=46)
entry4 = tk.Entry(add_vaccine_distr_info, font=(“Arial, 9”), width=46)
entry5 = tk.Entry(add_vaccine_distr_info, font=(“Arial, 9”), width=46)
entry6 = tk.Entry(add_vaccine_distr_info, font=(“Arial, 9”), width=46)
entry7 = tk.Entry(add_vaccine_distr_info, font=(“Arial, 9”), width=46)
entry1.pack()
entry2.pack()
entry3.pack()
entry4.pack()
entry5.pack()
entry6.pack()
entry7.pack()
entry1.place(x=180, y=60, width=350)
entry2.place(x=180, y=90, width=350)
entry3.place(x=180, y=120, width=350)
entry4.place(x=180, y=150, width=350)
entry5.place(x=180, y=180, width=350)
entry6.place(x=180, y=210, width=350)
entry7.place(x=180, y=240, width=350)

def add():
    text1 = entry1.get()
    text2 = entry2.get()
    text3 = entry3.get()
    text4 = entry4.get()
    text5 = entry5.get()
    text6 = entry6.get()
    text7 = entry7.get()
    content = "INSERT INTO vaccine_distr_info (" \
              "vaccine_distr_num, date, vaccine_num, vaccine_name, company_num, operator_num, num" \
              ")" \
              " VALUES (%s, '%s', '%s', '%s', '%s', '%s', '%s');" % (
                  text1, text2, text3, text4, text5, text6, text7)
    self.connect_DBS(database="vaccine_info", content=content)
    tkinter.messagebox.showinfo(title="信息", message="数据添加成功!")

def clear():
    entry1.delete(0, "end")
    entry2.delete(0, "end")
    entry3.delete(0, "end")
    entry4.delete(0, "end")
    entry5.delete(0, "end")
    entry6.delete(0, "end")
    entry7.delete(0, "end")
    tkinter.messagebox.showinfo(title="信息", message="数据已清空,请继续添加!")
tk.Button(add_vaccine_distr_info, text="添加", bg='white', font=("Arial,9"), width=9, height=0,command=add).place(x=400,y=360)
tk.Button(add_vaccine_distr_info, text="清空", bg='white', font=("Arial,9"), width=9, height=0,command=clear).place(x=160,y=360)

新建疫苗养护信息

怎样用Python搭建一个管理系统

def add_vaccine_maintenance_info(self):
    vaccine_maintenance_info = tk.Toplevel(app)
    vaccine_maintenance_info.title('添加疫苗养护信息')
    vaccine_maintenance_info.geometry("600x400")
    tk.Label(vaccine_maintenance_info, text='养护疫苗批号:', font=("Arial", 9)).place(x=80, y=60)
    tk.Label(vaccine_maintenance_info, text='养护疫苗名称:', font=('Arial', 9)).place(x=80, y=90)
    tk.Label(vaccine_maintenance_info, text=' 管理员编号:', font=('Arial', 9)).place(x=80, y=120)
    tk.Label(vaccine_maintenance_info, text=' 管理员姓名:', font=('Arial', 9)).place(x=80, y=150)
    tk.Label(vaccine_maintenance_info, text='   养护时间:', font=('Arial', 9)).place(x=80, y=180)
    tk.Label(vaccine_maintenance_info, text=' 冷藏室温度:', font=('Arial', 9)).place(x=80, y=210)
    tk.Label(vaccine_maintenance_info, text=' 冷冻室温度:', font=('Arial', 9)).place(x=80, y=240)
    tk.Label(vaccine_maintenance_info, text='设备运转情况:', font=('Arial', 9)).place(x=80, y=270)
    tk.Label(vaccine_maintenance_info, text='    是否报警:', font=('Arial', 9)).place(x=80, y=300)
    entry1 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry2 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry3 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry4 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry5 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry6 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry7 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry8 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry9 = tk.Entry(vaccine_maintenance_info, font=("Arial, 9"), width=46)
    entry1.pack()
    entry2.pack()
    entry3.pack()
    entry4.pack()
    entry5.pack()
    entry6.pack()
    entry7.pack()
    entry8.pack()
    entry9.pack()
    entry1.place(x=180, y=60, width=350)
    entry2.place(x=180, y=90, width=350)
    entry3.place(x=180, y=120, width=350)
    entry4.place(x=180, y=150, width=350)
    entry5.place(x=180, y=180, width=350)
    entry6.place(x=180, y=210, width=350)
    entry7.place(x=180, y=240, width=350)
    entry8.place(x=180, y=270, width=350)
    entry9.place(x=180, y=300, width=350)

    def add():
        text1 = entry1.get()
        text2 = entry2.get()
        text3 = entry3.get()
        text4 = entry4.get()
        text5 = entry5.get()
        text6 = entry6.get()
        text7 = entry7.get()
        text8 = entry8.get()
        text9 = entry9.get()
        content = "INSERT INTO vaccine_maintenance_info (" \
                  "vaccine_maintenance_num, vaccine_maintenance_name, admin_num, admin_name, maintenance_time, cold_storage_temp, freezer_temp, equipment_operation, alter_info" \
                  ")" \
                  " VALUES (%s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');" % (
                      text1, text2, text3, text4, text5, text6, text7, text8, text9)
        self.connect_DBS(database="vaccine_info", content=content)
        tkinter.messagebox.showinfo(title="信息", message="数据添加成功!")

    def clear():
        entry1.delete(0, "end")
        entry2.delete(0, "end")
        entry3.delete(0, "end")
        entry4.delete(0, "end")
        entry5.delete(0, "end")
        entry6.delete(0, "end")
        entry7.delete(0, "end")
        entry8.delete(0, "end")
        entry9.delete(0, "end")
        tkinter.messagebox.showinfo(title="信息", message="数据已清空,请继续添加!")
    tk.Button(vaccine_maintenance_info, text="添加", bg='white', font=("Arial,9"), width=9, height=0,command=add).place(x=400,y=360)
    tk.Button(vaccine_maintenance_info, text="清空", bg='white', font=("Arial,9"), width=9, height=0,command=clear).place(x=160,y=360)

新建接种人员信息

怎样用Python搭建一个管理系统

def add_vaccination_person_info(self):
    add_vaccination_person_info = tk.Toplevel(app)
    add_vaccination_person_info.title('添加接种人员信息')
    add_vaccination_person_info.geometry("600x400")
    tk.Label(add_vaccination_person_info, text='姓名:', font=("Arial", 9)).place(x=80, y=60)
    tk.Label(add_vaccination_person_info, text='性别:', font=('Arial', 9)).place(x=80, y=90)
    tk.Label(add_vaccination_person_info, text='年龄:', font=('Arial', 9)).place(x=80, y=120)
    tk.Label(add_vaccination_person_info, text='身份证号:', font=('Arial', 9)).place(x=80, y=150)
    tk.Label(add_vaccination_person_info, text='家庭住址:', font=('Arial', 9)).place(x=80, y=180)
    tk.Label(add_vaccination_person_info, text='是否过敏:', font=('Arial', 9)).place(x=80, y=210)
    tk.Label(add_vaccination_person_info, text='接种时间:', font=('Arial', 9)).place(x=80, y=240)
    entry1 = tk.Entry(add_vaccination_person_info, font=("Arial, 9"), width=46)
    entry2 = tk.Entry(add_vaccination_person_info, font=("Arial, 9"), width=46)
    entry3 = tk.Entry(add_vaccination_person_info, font=("Arial, 9"), width=46)
    entry4 = tk.Entry(add_vaccination_person_info, font=("Arial, 9"), width=46)
    entry5 = tk.Entry(add_vaccination_person_info, font=("Arial, 9"), width=46)
    entry6 = tk.Entry(add_vaccination_person_info, font=("Arial, 9"), width=46)
    entry7 = tk.Entry(add_vaccination_person_info, font=("Arial, 9"), width=46)
    entry1.pack()
    entry2.pack()
    entry3.pack()
    entry4.pack()
    entry5.pack()
    entry6.pack()
    entry7.pack()
    entry1.place(x=180, y=60, width=350)
    entry2.place(x=180, y=90, width=350)
    entry3.place(x=180, y=120, width=350)
    entry4.place(x=180, y=150, width=350)
    entry5.place(x=180, y=180, width=350)
    entry6.place(x=180, y=210, width=350)
    entry7.place(x=180, y=240, width=350)

    def add():
        text1 = entry1.get()
        text2 = entry2.get()
        text3 = entry3.get()
        text4 = entry4.get()
        text5 = entry5.get()
        text6 = entry6.get()
        text7 = entry7.get()
        content = "INSERT INTO vaccination_person_info (" \
                  "name, sexy, age, ID_num, address, allergy, date" \
                  ")" \
                  " VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s');" % (
                      text1, text2, text3, text4, text5, text6, text7)
        self.connect_DBS(database="vaccine_info", content=content)
        tkinter.messagebox.showinfo(title="信息", message="数据添加成功!")

    def clear():
        entry1.delete(0, "end")
        entry2.delete(0, "end")
        entry3.delete(0, "end")
        entry4.delete(0, "end")
        entry5.delete(0, "end")
        entry6.delete(0, "end")
        entry7.delete(0, "end")
        tkinter.messagebox.showinfo(title="信息", message="数据已清空,请继续添加!")
    tk.Button(add_vaccination_person_info, text="添加", bg='white', font=("Arial,9"), width=9, height=0,command=add).place(x=400, y=360)
    tk.Button(add_vaccination_person_info, text="清空", bg='white', font=("Arial,9"), width=9, height=0,command=clear).place(x=160, y=360)

查询疫苗分配信息

怎样用Python搭建一个管理系统

def vaccine_distr_info_query(self):
    query = tk.Toplevel(app)
    query.title('信息查询')
    query.geometry("600x400")
    entry = tk.Entry(query, width=30)
    entry.pack()
    entry.place(x=200, y=80)
    tk.Label(query, text="请输入疫苗分配单号:", font=("Arial", 9)).place(x=50, y=80)
    tk.Label(query, text='查询结果:', font=('Arial', 9)).place(x=50, y=120)
    text1 = tk.Text(query, width=50, height=20)
    text1.pack()
    text1.place(x=150, y=120)

    def base_query():
        vaccine_distr_num = entry.get()
        print(vaccine_distr_num)
        content = "SELECT * FROM vaccine_distr_info WHERE vaccine_distr_num = %s;" % vaccine_distr_num
        data = self.connect_DBS(database="vaccine_info", content=content)
        text1.delete(1.0, "end")
        text1.insert(chars="{}".format(data), index="insert")
    tk.Button(query, text='查询', bg='white', font=("Arial,12"), width=9, height=0, command=base_query).place(x=450,
                  
                                                                                                            y=75)

查询疫苗养护信息

怎样用Python搭建一个管理系统

  def vaccination_maintenance_info_query(self):
        query = tk.Toplevel(app)
        query.title('疫苗养护信息查询')
        query.geometry("600x400")
        entry = tk.Entry(query, width=30)
        entry.pack()
        entry.place(x=200, y=80)
        tk.Label(query, text="请输入疫苗养护批号:", font=("Arial", 9)).place(x=50, y=80)
        tk.Label(query, text='查询结果:', font=('Arial', 9)).place(x=50, y=120)
        text1 = tk.Text(query, width=50, height=20)
        text1.pack()
        text1.place(x=150, y=120)

        def base_query():
            vaccine_maintenance_num = entry.get()
            print(vaccine_maintenance_num)
            content = "SELECT * FROM vaccine_maintenance_info WHERE vaccine_maintenance_num = %s;" % vaccine_maintenance_num
            data = self.connect_DBS(database="vaccine_info", content=content)
            text1.delete(1.0, "end")
            text1.insert(chars="{}".format(data), index="insert")
        tk.Button(query, text='查询', bg='white', font=("Arial,12"), width=9, height=0, command=base_query).place(x=450,
                                                                                                                y=75)
    def vaccine_distr_info_query(self):
        query = tk.Toplevel(app)
        query.title('信息查询')
        query.geometry("600x400")
        entry = tk.Entry(query, width=30)
        entry.pack()
        entry.place(x=200, y=80)
        tk.Label(query, text="请输入疫苗分配单号:", font=("Arial", 9)).place(x=50, y=80)
        tk.Label(query, text='查询结果:', font=('Arial', 9)).place(x=50, y=120)
        text1 = tk.Text(query, width=50, height=20)
        text1.pack()
        text1.place(x=150, y=120)

        def base_query():
            vaccine_distr_num = entry.get()
            print(vaccine_distr_num)
            content = "SELECT * FROM vaccine_distr_info WHERE vaccine_distr_num = %s;" % vaccine_distr_num
            data = self.connect_DBS(database="vaccine_info", content=content)
            text1.delete(1.0, "end")
            text1.insert(chars="{}".format(data), index="insert")
        tk.Button(query, text='查询', bg='white', font=("Arial,12"), width=9, height=0, command=base_query).place(x=450,
                                                                                                                y=75)

查询接种人员信息

怎样用Python搭建一个管理系统

 def vaccination_person_info_query(self):
        query = tk.Toplevel(app)
        query.title('接种人员信息查询')
        query.geometry("600x400")
        entry = tk.Entry(query, width=30)
        entry.pack()
        entry.place(x=200, y=80)
        tk.Label(query, text="请输入接种人员身份证号:", font=("Arial", 9)).place(x=50, y=80)
        tk.Label(query, text='查询结果:', font=('Arial', 9)).place(x=50, y=120)
        text1 = tk.Text(query, width=50, height=20)
        text1.pack()
        text1.place(x=150, y=120)

        def base_query():
            ID_num = entry.get()
            content = "SELECT * FROM vaccination_person_info WHERE ID_num = %s;" % ID_num
            data = self.connect_DBS(database="vaccine_info", content=content)
            text1.delete(1.0, "end")
            text1.insert(chars="{}".format(data), index="insert")
        tk.Button(query, text='查询', bg='white', font=("Arial,12"), width=9, height=0, command=base_query).place(x=450,                                                                                                          y=75)

查询疫苗信息

怎样用Python搭建一个管理系统

 def vaccine_info_query(self):
        query = tk.Toplevel(app)
        query.title('疫苗信息查询')
        query.geometry("600x400")
        entry = tk.Entry(query, width=30)
        entry.pack()
        entry.place(x=200, y=80)
        tk.Label(query, text="请输入疫苗批号:", font=("Arial", 9)).place(x=50, y=80)
        tk.Label(query, text='查询结果:', font=('Arial', 9)).place(x=50, y=120)
        text1 = tk.Text(query, width=50, height=20)
        text1.pack()
        text1.place(x=150, y=120)

        def base_query():
            vaccine_num = entry.get()
            content = "SELECT * FROM vaccine_info WHERE vaccine_num = %s;" % vaccine_num
            data = self.connect_DBS(database="vaccine_info", content=content)
            text1.delete(1.0, "end")
            text1.insert(chars="{}".format(data), index="insert")
        tk.Button(query, text='查询', bg='white', font=("Arial,12"), width=9, height=0, command=base_query).place(x=450,                                                                                                          y=75)

修改疫苗信息

怎样用Python搭建一个管理系统

def modify_vaccine_info(self):
    modify_info = tk.Toplevel(app)
    modify_info.title('疫苗信息修改')
    modify_info.geometry("600x400")
    entry = tk.Entry(modify_info, width=30)
    entry.pack()
    entry.place(x=200, y=60)
    tk.Label(modify_info, text="请输入疫苗分配单号:", font=("Arial", 9)).place(x=50, y=60)
    tk.Label(modify_info, text='疫苗批号:', font=("Arial", 9)).place(x=80, y=100)
    tk.Label(modify_info, text='疫苗名称:', font=('Arial', 9)).place(x=80, y=130)
    tk.Label(modify_info, text='企业名称:', font=('Arial', 9)).place(x=80, y=160)
    tk.Label(modify_info, text='企业编号:', font=('Arial', 9)).place(x=80, y=190)
    tk.Label(modify_info, text='    规格:', font=('Arial', 9)).place(x=80, y=220)
    tk.Label(modify_info, text='    进价:', font=('Arial', 9)).place(x=80, y=250)
    tk.Label(modify_info, text='  预售价:', font=('Arial', 9)).place(x=80, y=280)
    tk.Label(modify_info, text='企业上限:', font=('Arial', 9)).place(x=80, y=310)
    tk.Label(modify_info, text='企业下限:', font=('Arial', 9)).place(x=80, y=340)
    text1 = tk.Text(modify_info, width=50, height=1)
    text2 = tk.Text(modify_info, width=50, height=1)
    text3 = tk.Text(modify_info, width=50, height=1)
    text4 = tk.Text(modify_info, width=50, height=1)
    text5 = tk.Text(modify_info, width=50, height=1)
    text6 = tk.Text(modify_info, width=50, height=1)
    text7 = tk.Text(modify_info, width=50, height=1)
    text8 = tk.Text(modify_info, width=50, height=1)
    text9 = tk.Text(modify_info, width=50, height=1)
    text1.pack()
    text2.pack()
    text3.pack()
    text4.pack()
    text5.pack()
    text6.pack()
    text7.pack()
    text8.pack()
    text9.pack()
    text1.place(x=150, y=100)
    text2.place(x=150, y=130)
    text3.place(x=150, y=160)
    text4.place(x=150, y=190)
    text5.place(x=150, y=220)
    text6.place(x=150, y=250)
    text7.place(x=150, y=280)
    text8.place(x=150, y=310)
    text9.place(x=150, y=340)

    def base_query():
        vaccine_modify_num = entry.get()
        content = "SELECT * FROM vaccine_info WHERE vaccine_num = %s;" % vaccine_modify_num
        data = self.connect_DBS(database="vaccine_info", content=content)
        text1.delete(1.0, "end")
        text2.delete(1.0, "end")
        text3.delete(1.0, "end")
        text4.delete(1.0, "end")
        text5.delete(1.0, "end")
        text6.delete(1.0, "end")
        text7.delete(1.0, "end")
        text8.delete(1.0, "end")
        text9.delete(1.0, "end")
        text1.insert(chars="{}".format(data[0]), index="insert")
        text2.insert(chars="{}".format(data[1]), index="insert")
        text3.insert(chars="{}".format(data[2]), index="insert")
        text4.insert(chars="{}".format(data[3]), index="insert")
        text5.insert(chars="{}".format(data[4]), index="insert")
        text6.insert(chars="{}".format(data[5]), index="insert")
        text7.insert(chars="{}".format(data[6]), index="insert")
        text8.insert(chars="{}".format(data[7]), index="insert")
        text9.insert(chars="{}".format(data[8]), index="insert")

    def update_info():
        vaccine_del_num = entry.get()
        str_ls = [text1.get("1.0", "end")[0:-1], text2.get("1.0", "end")[0:-1], text3.get("1.0", "end")[0:-1],
                  text4.get("1.0", "end")[0:-1], text5.get("1.0", "end")[0:-1], text6.get("1.0", "end")[0:-1],
                  text7.get("1.0", "end")[0:-1], text8.get("1.0", "end")[0:-1], text9.get("1.0", "end")[0:-1]]
        str_ls = [str(i) for i in str_ls]
        content = "UPDATE vaccine_info  SET vaccine_num='%s', vaccine_name='%s', company_name='%s', vaccine_num='%s'" \
                  ", size='%s', buy_price='%s', pre_sale_price='%s', limit_up='%s', limit_down='%s' WHERE " \
                  "vaccine_num = '%s';" % (
                  str_ls[0], str_ls[1], str_ls[2], str_ls[3], str_ls[4], str_ls[5], str_ls[6], str_ls[7], str_ls[8],vaccine_del_num)
        self.connect_DBS(database="vaccine_info", content=content)
        tkinter.messagebox.showinfo(title="信息", message="疫苗分配单号:{}数据修改成功!".format(vaccine_modify_num)
        return None
    tk.Button(modify_info, text='查询', bg='white', font=("Arial,12"), width=9, height=0, command=base_query).place(x=450,y=55)
    tk.Button(modify_info, text='修改', bg='white', font=("Arial,12"), width=9, height=0, command=update_info).place(x=260,y=370)

删除疫苗信息

怎样用Python搭建一个管理系统

在这里插入图片描述](https://img-blog.csdnimg.cn/d4206216a4214630b3fa681dd987a82d.gif)
  def del_vaccine_info(self):
        del_info = tk.Toplevel(app)
        del_info.title('疫苗信息删除')
        del_info.geometry("600x500")
        entry = tk.Entry(del_info, width=30)
        entry.pack()
        entry.place(x=200, y=80)
        tk.Label(del_info, text="请输入疫苗批号:", font=("Arial", 9)).place(x=50, y=80)
        tk.Label(del_info, text='查询结果:', font=('Arial', 9)).place(x=50, y=120)
        text1 = tk.Text(del_info, width=50, height=20)
        text1.pack()
        text1.place(x=150, y=120)

        def base_query():
            vaccine_del_num = entry.get()
            print(vaccine_del_num)
            content = "SELECT * FROM vaccine_info WHERE vaccine_num = %s;" % vaccine_del_num
            data = self.connect_DBS(database="vaccine_info", content=content)
            text1.delete(1.0, "end")
            text1.insert(chars="{}".format(data), index="insert")

        def del_infor():
            vaccine_del_num = entry.get()
            print(vaccine_del_num)
            content = "DELETE FROM vaccine_info  WHERE vaccine_num = %s;" % vaccine_del_num
            data = self.connect_DBS(database="vaccine_info", content=content)
            tkinter.messagebox.showinfo(title="信息", message="疫苗批号:{}数据已删除!".format(vaccine_del_num))
            return None
        tk.Button(del_info, text='查询', bg='white', font=("Arial,12"), width=9, height=0, command=base_query).place(x=450,y=75)
        tk.Button(del_info, text='删除', bg='white', font=("Arial,12"), width=9, height=0, command=del_infor).place(x=280,
                                                                                                                  y=400)

数据库

怎样用Python搭建一个管理系统

create table vaccine_info(
    vaccine_num    char(50) not null primary key,
    vaccine_name   char(50) not null,
    company_name   char(50) not null,
    company_num    char(50) not null,
    size           char(50) null,
    buy_price      char(50) not null,
    pre_sale_price char(20) not null,
    limit_up       char(50) not null,
    limit_down     char(50) not null
);

create table user_info(
 id int auto_increment primary key,
    user_name char(50) NOT NULL ,
    user_code char(50) NOT NULL
);
                        
create table if not exists vaccine_distr_info (
    vaccine_distr_num char(50) primary key,
    date date not null ,
    vaccine_num char(50) not null ,
    vaccine_name char(50) not null ,
    company_num char(50) not null ,
    operator_num char(50) not null ,
    num int not null 
);

create table if not exists vaccine_maintenance_info (
    vaccine_maintenance_num char(50) primary key ,
    vaccine_maintenance_name char(50) not null ,
    admin_num char(50) not null ,
    admin_name char(50) not null ,
    maintenance_time date,
    cold_storage_temp char(20) not null ,
    freezer_temp char(20) not null ,
    equipment_operation char(50) not null ,
    alter_info char(50) not null 
);

create table if not exists vaccination_person_info(
    id int auto_increment primary key,
    name char(20) not null ,
    sexy char(10) not null ,
    age char(10) not null ,
    ID_num char(50) not null ,
    address char(70) not null ,
    allergy char(10) not null ,
    date date
);

看起来是不是很多,源码跟教程都放在上面了,相信有很多小伙伴已经跃跃欲试了,动手吧。这一篇到这里就没有了,记得点个赞支持一下下。

怎样用Python搭建一个管理系统文章来源地址https://www.toymoban.com/news/detail-497581.html

到了这里,关于怎样用Python搭建一个管理系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 一步步完整搭建一个图纸管理系统(Django+Vue3)

    需要将终端改成虚拟环境的解释器后,简单试运行: 由于我们把子项目都放在apps里面了(方便统一管理)所以注册要加入一段配置 一定要注意格式 (1)安装pymysql (2)gveInformationSystem/settings中进行相关配置 (3)需要在init.py导入pymysql (在:apps/DrawingManagementSystem/models.py)

    2024年02月06日
    浏览(48)
  • 使用vue3搭建一个CRM(客户关系管理)系统

    目录 1. 需求分析 2. 设计 3. 技术选型 4. 开发环境搭建 5. 前端开发 6. 后端开发 7. 数据库搭建 8. 测试 9. 部署 10. 维护和迭代 总结 搭建一个CRM(客户关系管理)系统是一个复杂的项目,涉及到需求分析、设计、开发、测试和部署等多个阶段。以下是一个简化的指南,帮

    2024年04月16日
    浏览(53)
  • Vue3 + Element-UI 搭建一个后台管理系统框架模板

    本文将介绍如何基于Vue3和element-ui搭建一个后台管理系统框架模板。我们将详细讲解代码流程,并提供详细的说明。 Vue3 Element-ui Axios 本文假设读者已经熟悉Vue3和Element-ui的基本使用方法,并且对Axios有一定的了解。 步骤1:创建Vue3项目 我们可以使用Vue CLI来创建一个Vue3项目,

    2023年04月26日
    浏览(122)
  • 用Python实现一个图书管理系统(附带源码)

    目录 一、题目信息 二、分析 三、主函数 四、总结 实现一个图书管理系统,要求有学生信息管理、图书信息管理和图书借阅管理三大功能。 创建一个LMS类 1.学生信息管理:具有添加学生和删除学生两个功能,并将学生存在Student列表中。在删除学生时,如果学生还有未归还书

    2024年02月11日
    浏览(43)
  • 【python基础知识】14.图书管理系统的搭建(类与对象实操)

    通过这个项目希望你可以学会用类与实例的方法编写程序,掌握面向对象编程的基本思维,为日后能处理更复杂的代码结构打牢基础。 我曾跟你提过,学Python,做项目是进步最快的。我没说的是:做项目总会遇到种种困难,想不通的逻辑,频频报错的代码。 所以,如果你在今

    2024年02月02日
    浏览(51)
  • Python爬虫进阶(1),Django+Selenium+Mysql+SimpleUI,从零开始搭建自己的爬虫后台管理系统

    如果爬虫做完的话都会发现每个文件要么保存到csv或者是其他格式的文件中,这样做多少会有些麻烦,所以需要将这些内容保存起来方便自己管理和查看内容。 相对于flask而言Django有着相对成熟的一个后台管理系统配合上其他一些插件就可以做到即插即用的效果而不用自己再

    2024年02月08日
    浏览(44)
  • 【腾讯云 TDSQL-C Serverless 产品体验】 使用 Python 和 TDSQL-C 实现一个线上图书管理系统

    TDSOL是腾讯云自家研发的超级厉害的云原生关系型数据库!它将传统数据库、云计算和最新的硬件技术融合在一起,完美兼容MySQL,并为用户提供了绝对牛逼的弹性、高性能、高可用、高可靠和安全的数据库服务。你绝对想不到,它的吞吐量可以达到超过百万次查询每秒!而且

    2024年02月10日
    浏览(39)
  • 用JAVA实现一个学生管理系统和登录系统

    目录 一、学生管理系统: 1.创建学生对象Student的javabean类: 2.创建出学生管理系统 StudentSystem类: 1.addStudent方法:添加学生 2.ifOne方法,用来判断我们输入的学生id是否唯一(如果存在学生就不用再添加此学生): 3.queryStudent方法,把我们表中的所有学生显示出来 4.getIndex()如果

    2024年02月11日
    浏览(48)
  • 图书管理系统的搭建

    流程图 页面跳转: 代码整体布局: 导入框架和包: 实现效果: 在innodb存储引擎下,会到自增断层,如下(pid=4): 不适用拼接,正常插入: 代码部分: 创建数据库: 创建表: BaseDAO: Books: IBooksDAO: BooksDAOImpl: IBooksService: BooksServiceImpl: bookList.jsp: add.jsp: update.jsp: Bo

    2024年02月09日
    浏览(55)
  • 使用Vue完成一个户籍管理系统

    ```js template   div     h2学籍管理系统/h2     div       姓名:       input v-model=\\\"user.name\\\" /     /div     div       年龄:       input v-model=\\\"user.age\\\" /     /div     div       性别:       input v-model=\\\"user.sex\\\" /     /div     div       手机:       input v-model=\\\"user.tel\\\" /     /div    

    2024年02月05日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包