python基于sql实现员工入职信息管理系统全部源代码
全部源代码,包括增删改查等相关功能和界面,实现了注册功能和修改密码功能模块,需要用到几个简单的第三方库可通过pip进行安装,数据库和表的相关信息需要自己创建,非常简单的两个表。
源代码
import tkinter
from tkinter import *
import tkinter.messagebox as messagebox
from tkinter import ttk
import win32com.client
import pymssql
from PIL import ImageTk,Image
import time
server = 'DESKTOP-4TF7JVV'
user ='sa'
userpassword ='123456'
database = 'python'
conn = pymssql.connect(server,user,userpassword,database)
cursor = conn.cursor()
#连接服务器和数据库
cn=win32com.client.Dispatch('ADODB.Connection')
cnstr='Provider=SQLOLEDB.1;Integrated Security=SSPI;Data Source=DESKTOP-4TF7JVV'
cn.Open(cnstr,'sa','123456')
#如果数据库
cn.DefaultDatabase='python'
#打开数据库
cn.Execute('USE python')
rs=win32com.client.Dispatch('ADODB.RecordSet')
#登录界面函数
def ase():
rt = Tk()
rt.title('员工信息管理')
rt.geometry('250x400+200+100')
bj = PhotoImage(file='1.gif')
lb = Label(image=bj)
lb.place(x=0, y=120)
'''time1 = time.strftime("%Y--%m--%d %H:%M", time.localtime(time.time()))
L3 = Label(rt, text=time1, fg='purple')
L3.place(x=80,y=1)
l2=Label(rt,text='北京时间:',fg='purple')
l2.place(x=20,y=1)'''
def gettime():#获取当前时间
var.set(time.strftime("%Y-%m-%d %H:%M:%S")) # 获取当前时间
rt.after(1000, gettime) # 每隔1s调用函数 gettime 自身获取时间
var = StringVar()
lb = Label(rt, textvariable=var, fg='purple',font=('微软雅黑',10))
lb.place(x=70,y=0)
l2 = Label(rt, text='北京时间', fg='purple',font=('微软雅黑',10))
l2.place(x=10, y=0)
gettime()
lb1 = Label(rt, text='')
lb1.grid(row=0, column=1)
lb2 = Label(rt, text='')
lb2.grid(row=1, column=0)
Label(rt, text='用户名:',fg='blue').grid(row=1, stick=W, pady=10, column=8)
Label(rt, text='密码:',fg='blue').grid(row=2, stick=W, pady=10, column=8)
l1 = Entry(rt)
l1.grid(row=1, column=10)
l2 = Entry(rt, show='*')
l2.grid(row=2, column=10)
lb3 = Label(rt, text='')
lb3.grid(row=4, column=1)
def cmtpro():#登录按钮监听函数
s1 = str(l1.get())
s2 = str(l2.get())
rs.LockType = 4
cursor.execute("SELECT * FROM T WHERE USERNAME = '%s' AND password='%s'" % (s1, s2))
s3 = cursor.fetchone()
if s3 is None:
messagebox.showerror('登录失败', '账户不存在')
else:
messagebox.showinfo("成功", "登录成功", )
rt.destroy()
def zhujm():#登录成功主界面函数
global pho
ru=Tk()
ru.geometry('800x400+200+200')
ru.title('员工入职管理')
pw1=PanedWindow(ru)
pw1.pack(fill=BOTH,expand=1)
lb2=Label(pw1,text='')
lb2.pack(fill=BOTH, expand=1)
lb2.config(fg='#00ff00',bg='#999999')
pw1.add(lb2)
lb1 = Label(ru, text='企业员工入职信息管理系统', height=2, font=('微软雅黑', 18, 'bold', 'italic'), fg='blue',bg='#999999')
lb1.place(x=250, y=2)
Lb4 = Label(ru,text='',bg='#999999',width=600,height=300)
Lb4.place(x=140,y=70)
bj = PhotoImage(file='2.gif')
lb = Label(image=bj)
lb.place(x=140, y=70)
'''def get_image(filename, width, height):
im = Image.open(filename).resize((width, height))
return ImageTk.PhotoImage(im)
pho = get_image('背景.gif', 800, 400)
Lb6 = Label(ru, image=pho)
Lb6.place(x=0, y=0)'''
def seek():
Lb4 = Label(ru, text='', bg='#999999', width=600, height=300)
Lb4.place(x=140, y=70)
l1 = Label(ru, text="请输入你要查询的编号:",font=('微软雅黑',12,'bold'),bg='#999999',fg='#D9D919')
time1 = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()))
L3 = Label(ru, text=time1, fg='purple',bg='#999999')
L3.place(x=330, y=75)
l1.place(x=270, y=95)
l1 = Entry(ru, width=20)
l1.place(x=450, y=95)
t_name = StringVar()
t_id = StringVar()
t_sex = StringVar()
t_databoar = StringVar()
t_selfid = StringVar()
t_telephone = StringVar()
t_enrolldate = StringVar()
t_startswitch = StringVar()
t_section = StringVar()
t_salary = StringVar()
l2 = Label(ru,text="编号:",font=('微软雅黑',12,'bold'),bg='#999999',fg='#23238E').place(x=150, y=140)
l3 = Label(ru,text='姓名:',font=('微软雅黑',12,'bold'),bg='#999999',fg='#23238E').place(x=450, y=140)
l4 = Label(ru,text='性别:',font=('微软雅黑',12,'bold'),bg='#999999',fg='#23238E').place(x=150, y=170)
l5 = Label(ru,text='出生日期:',font=('微软雅黑',12,'bold'),bg='#999999',fg='#23238E').place(x=450, y=170)
l6 = Label(ru,text='身份证号:',font=('微软雅黑',12,'bold'),bg='#999999',fg='#23238E').place(x=150, y=200