毕设/大作业:用 Python 开发一个疫苗管理系统

不少小伙伴问我,Python 怎么学,我的统一回答:实战,多练。其实就是从自己的兴趣出发,做一些实战小项目

正好,周末在家摸鱼的时候,在网上看到了一个不错的小项目,用 Python 写一个疫苗管理系统的小项目。

很基础,适合新手学习,主要涉及 Python、Tkinter、数据库存储等知识。

整体结构图

图片

源码获取

获取前记得收藏、点赞支持一下。

方式①、微信搜索公众号:Python学习与数据挖掘,后台回复: 疫苗管理系统
方式②、添加微信号:dkl88194,备注:来自CSDN +疫苗管理系统

毕设/大作业系列

连接数据库

    def connect_DBS(self, database, content):
        db = pymysql.connect(host="localhost", user="root", psd="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 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 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)

修改疫苗信息

图片

删除疫苗信息

图片

数据库

图片

好了,就是这些内容,感兴趣的小伙伴,可以动手试一试。

  • 25
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值