主頁 > 後端開發 > Python如何搭建疫苗管理系統

Python如何搭建疫苗管理系統

2022-03-23 07:34:55 後端開發

最近有不少小伙伴問我,Python 怎么學,我的統一回答:就是實戰,多練,無論做什么,都逃不過熟能生巧,其次就是從自己的興趣出發,做一些實戰小專案,往往一些小專案都藏著很多基礎,這周在家閑著的時候給大家用Python寫了一個疫苗管理系統的小專案,很適合新手練習,主要涉及的知識有Python、tkinter、資料庫存盤等,(https://jq.qq.com/?_wv=1027&k=EBXZ9r6u)

在這里插入圖片描述

整體結構圖

在這里插入圖片描述

連接資料庫

 
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

 

主界面

在這里插入圖片描述

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)

 

注冊界面

在這里插入圖片描述





#   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)

 

登陸界面

在這里插入圖片描述

#   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)

 






功能選項

功能區主界面

在這里插入圖片描述

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)

 

新建疫苗資訊

在這里插入圖片描述

#    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)

新建疫苗分配資訊

在這里插入圖片描述





#   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)

 

新建疫苗養護資訊

在這里插入圖片描述





#   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)

 

新建接種人員資訊

在這里插入圖片描述




#   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)

 

查詢疫苗分配資訊

在這里插入圖片描述

#   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)

 

查詢疫苗養護資訊

在這里插入圖片描述

#     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)

 








查詢接種人員資訊

在這里插入圖片描述






#   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)

查詢疫苗資訊

在這里插入圖片描述

 
#    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)

修改疫苗資訊

在這里插入圖片描述




#   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)

 

洗掉疫苗資訊

在這里插入圖片描述

在這里插入圖片描述](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)

 

資料庫

在這里插入圖片描述








#   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
);

 

看起來是不是很多,原始碼跟教程都放在上面了,相信有很多小伙伴已經躍躍欲試了,動手吧,這一篇到這里就沒有了,記得點個贊支持一下下,

在這里插入圖片描述

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/447006.html

標籤:Python

上一篇:SpringCloud-Consul

下一篇:如何用Python實作大學座位預約

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more