Python简易员工信息管理系统

功能:
1.添加员工
2.修改员工信息
3.删除员工信息

一共两个界面,分别实现登录注册和员工管理

项目结构

LoginPage.py

from MainPage import *


# 登录界面
class LoginPage(object):
    def __init__(self, parent_window):
        parent_window.destroy()  # 销毁界面
        self.window = tk.Tk()
        # 禁止拉伸窗口
        self.window.resizable(width=False, height=False)
        self.window.title('员工信息管理系统')
        # 窗口大小
        self.window.geometry('650x400')
        bt = tk.Label(self.window,
                      text='登录界面',
                      font=('宋体', 32),
                      width=20,
                      height=2)
        bt.pack()
        # 账号
        zh = tk.Label(self.window,
                      text='账号:',
                      font=('宋体', 14),
                      width=10,
                      height=1)
        zh.place(x=150, y=200, anchor='nw')
        # 账号输入框
        self.zh1 = tk.Entry(self.window,
                            show=None,
                            font=('Arial', 14))
        self.zh1.place(x=230, y=200, anchor='nw')
        # 密码
        mm = tk.Label(self.window,
                      text='密码:',
                      font=('宋体', 14),
                      width=10,
                      height=1)
        mm.place(x=150, y=230, anchor='nw')
        # 密码输入框
        self.mm1 = tk.Entry(self.window,
                            show='*',
                            font=('Arial', 14))
        self.mm1.place(x=230, y=230, anchor='nw')
        # 按钮
        # 清除按钮
        zhb = tk.Button(self.window,
                        text='清除',
                        font=('宋体', 10),
                        width=5,
                        height=1,
                        command=self.z_clear)
        zhb.place(x=500, y=200, anchor='nw')
        mmb = tk.Button(self.window,
                        text='清除',
                        font=('宋体', 10),
                        width=5,
                        height=1,
                        command=self.m_clear)
        mmb.place(x=500, y=230, anchor='nw')
        # 登录按钮
        login_button = tk.Button(self.window,
                                 text='登录',
                                 font=('宋体', 14),
                                 width=5,
                                 height=1,
                                 command=self.login)
        login_button.place(x=500, y=340, anchor='nw')
        # 注册按钮
        login_button = tk.Button(self.window,
                                 text='注册',
                                 font=('宋体', 14),
                                 width=5,
                                 height=1,
                                 command=self.register)
        login_button.place(x=570, y=340, anchor='nw')
        self.window.mainloop()
        # 注册按钮

    def register(self):
        # 获取用户名输入框的信息
        register_zh1 = self.zh1.get()
        # 获取密码输入框的信息
        register_mm1 = self.mm1.get()
        obj_r = MysqlSearch()  # 连接数据库
        obj_r.insert_userinfo(register_zh1, register_mm1)  # 注册

    def login(self):
        # 获取用户名和密码
        obj = MysqlSearch()
        result = obj.get_userinfo()
        name = self.zh1.get()
        pwd = self.mm1.get()
        ulist = []
        plist = []
        for item in result:
            ulist.append(item['用户名'])
            plist.append(item['密码'])
        deter = True
        for i in range(len(ulist)):
            while True:
                if name == ulist[i] and pwd == plist[i]:
                    messagebox.showinfo(title='提示', message='登录成功')
                    # 登录成功则执行begin函数
                    deter = False
                    # 登录成功,跳转下一个页面
                    MainPage(self.window)  # 进入主菜单
                    break
                else:
                    break
        while deter:
            messagebox.showerror(title='警告', message='用户或密码名错误')
            break

    def z_clear(self):
        # 清除输入框中的值
        self.zh1.delete(0, tk.END)

    def m_clear(self):
        # 清除输入框中的值
        self.mm1.delete(0, tk.END)

MainPage.py

from MysqlSearch import *
import tkinter as tk
from tkinter import ttk


# 主界面
class MainPage(object):
    def __init__(self, parent_window):
        # 员工信息
        parent_window.destroy()

        # 主界面,4个按钮
        # 1.添加职工信息
        # 2.修改职工信息
        # 3.删除职工信息
        # 4.退出
        self.window = tk.Tk()
        self.window.title('员工信息管理系统')
        self.window.geometry('800x700')

        self.left = tk.Frame(width=300,height=350)
        self.right = tk.Frame(width=200,height=350)
        self.center = tk.Frame(width=700,height=300)
        self.bottom = tk.Frame(width=800,height=50)
        tk.Label(self.center,text='员工信息',font=('宋体', 14),width=10,height=1).pack()
        area = ('员工号','姓名','年龄','性别','邮箱','电话','生日','地址','职位','工资')
        obj = MysqlSearch()
        # 获取员工数据
        data 
  • 7
    点赞
  • 94
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值