From 2783dc43e3f66f74e572d17c4fd641144951c1b8 Mon Sep 17 00:00:00 2001 From: pi9xgbk8w Date: Fri, 31 May 2024 19:21:23 +0800 Subject: [PATCH] ADD file via upload --- HR员工管理系统.py | 237 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 HR员工管理系统.py diff --git a/HR员工管理系统.py b/HR员工管理系统.py new file mode 100644 index 0000000..14682a3 --- /dev/null +++ b/HR员工管理系统.py @@ -0,0 +1,237 @@ +import tkinter as tk +import tkinter.messagebox +import pymysql +from tkinter import ttk + + +def HR_in(): + global win + win = tk.Tk() + win.title('HR登陆页面') + win.geometry('600x300') + tk.Label(win).place(x=0, y=300) + tk.Label(win, text='你好,HR!', font=30, bg='green').place(x=250, y=15) + tk.Label(win, text='账号 :', font=10).place(x=130, y=60) + tk.Label(win, text='密码 :', font=10).place(x=130, y=100) + hr_id = tk.Entry(win, width=20, font=10) + hr_id.place(x=230, y=60) + hr_pwd = tk.Entry(win, width=20, font=10, show='*') + hr_pwd.place(x=230, y=100) + + def main1(): + get_hrid = hr_id.get() + get_hrpwd = hr_pwd.get() + sql = "select HRID,password from hraccount where HRID= %s and password = %s" + conn = pymysql.connect(host="127.0.0.1", user="root", password="WWWW1111", database="position_system", charset="utf8") + cursor = conn.cursor(cursor=pymysql.cursors.DictCursor) + rows = cursor.execute(sql, (get_hrid, get_hrpwd)) + + if get_hrid == '' or get_hrpwd == '': + tk.messagebox.showerror('Error', message='用户名或者密码为空') + else: + if rows != 0: + hr_manage_job() + else: + tk.messagebox.showerror('Error', message='HR用户名或者密码错误') + + tk.Button(win, text='登陆职位系统', width=28, command=main1).place(x=230, y=160) + + win.mainloop() + + +# hr职位管理界面 +def hr_manage_job(): + win_seeJob = tk.Toplevel() # 不能二次用tk.Tk(),否则下面的style变不了 + win_seeJob.title('职位管理') + win_seeJob.geometry('1600x1000') + tk.Label(win_seeJob, text='职位编号').place(x=45, y=20) + tk.Label(win_seeJob, text='职位名称').place(x=45, y=55) + + # treeview行高,供22行Treeview组件使用 + s = ttk.Style() + s.configure('MyStyle.Treeview', rowheight=200) + + # 表格,供22行Treeview组件使用 + frame1 = tk.Frame(win_seeJob) + frame1.place(x=10, y=100, width=1500, height=700) + + # 滚动条,供22行Treeview组件使用 + scrollBar = tk.Scrollbar(frame1) + scrollBar.pack(side=tkinter.RIGHT, fill=tk.Y) + + columns = ( + 'Jno', 'Jname', 'Jclass', 'Jaddress', 'Jsalaryin1month(k)', 'Salarynoin1Year', 'HighestEdu', 'Recruitingno', + 'Deadline', 'Jdescription') + treeview = ttk.Treeview(frame1, height=20, show='headings', columns=columns, yscrollcommand=scrollBar.set, + style='MyStyle.Treeview') + + # 设置表的宽度 + treeview.column('Jno', width=80, anchor='center') + treeview.column('Jname', width=230, anchor='center') + treeview.column('Jclass', width=100, anchor='center') + treeview.column('Jaddress', width=100, anchor='center') + treeview.column('Jsalaryin1month(k)', width=70, anchor='center') + treeview.column('Salarynoin1Year', width=70, anchor='center') + treeview.column('HighestEdu', width=70, anchor='center') + treeview.column('Recruitingno', width=70, anchor='center') + treeview.column('Deadline', width=75, anchor='center') + treeview.column('Jdescription', width=600, anchor='center') + + # 显示表头 + treeview.heading('Jno', text='职位编号') + treeview.heading('Jname', text='职位名称') + treeview.heading('Jclass', text='职位类别') + treeview.heading('Jaddress', text='工作地点') + treeview.heading('Jsalaryin1month(k)', text='月薪(K)') + treeview.heading('Salarynoin1Year', text='一年几薪') + treeview.heading('HighestEdu', text='最高学历') + treeview.heading('Recruitingno', text='招聘人数') + treeview.heading('Deadline', text='截至日期') + treeview.heading('Jdescription', text='工作描述') + treeview.pack(side=tk.LEFT, fill=tk.Y) + scrollBar.config(command=treeview.yview) + + def sql_conn(sql): + conn = pymysql.connect(host="127.0.0.1", user="root", password="WWWW1111", database="position_system", charset="utf8") + cursor = conn.cursor(cursor=pymysql.cursors.DictCursor) + cursor.execute(sql) + ret = cursor.fetchall() + cursor.close() + conn.commit() + conn.close() + return ret + + def delete_tab(treeview): + items = treeview.get_children() + [treeview.delete(item) for item in items] + + def Jname_select(): + delete_tab(treeview) + sql = "select * from job where Jname like '%" + e2.get() + "%' " + list_job = sql_conn(sql) + for i in range(len(list_job)): + treeview.insert('', i, values=( + list_job[i]['Jno'], list_job[i]['Jname'], list_job[i]['Jclass'], list_job[i]['Jaddress'], + list_job[i]['Jsalaryin1month(k)'], list_job[i]['Salarynoin1Year'], list_job[i]['HighestEdu'], + list_job[i]['Recruitingno'], list_job[i]['Deadline'], list_job[i]['Jdescription'])) + + def Jno_select(): + delete_tab(treeview) + sql = "select * from job where Jno = '" + e1.get() + "' " + list_job = sql_conn(sql) + for i in range(len(list_job)): + treeview.insert('', i, values=( + list_job[i]['Jno'], list_job[i]['Jname'], list_job[i]['Jclass'], list_job[i]['Jaddress'], + list_job[i]['Jsalaryin1month(k)'], list_job[i]['Salarynoin1Year'], list_job[i]['HighestEdu'], + list_job[i]['Recruitingno'], list_job[i]['Deadline'], list_job[i]['Jdescription'])) + + def all_job(): + delete_tab(treeview) + sql = 'select * from job' + list_job = sql_conn(sql) + for i in range(len(list_job)): + treeview.insert('', i, values=( + list_job[i]['Jno'], list_job[i]['Jname'], list_job[i]['Jclass'], list_job[i]['Jaddress'], + list_job[i]['Jsalaryin1month(k)'], list_job[i]['Salarynoin1Year'], list_job[i]['HighestEdu'], + list_job[i]['Recruitingno'], list_job[i]['Deadline'], list_job[i]['Jdescription'])) + + e1 = tk.Entry(win_seeJob, ) + e1.place(x=100, y=20) + e2 = tk.Entry(win_seeJob, ) + e2.place(x=100, y=55) + tk.Button(win_seeJob, text='根据职位编号搜索', width=15, height=1, command=Jno_select).place(x=280, y=20) + tk.Button(win_seeJob, text='根据职位名搜索', width=15, height=1, command=Jname_select).place(x=280, y=55) + tk.Button(win_seeJob, text='显示所有', width=15, height=1, command=all_job).place(x=450, y=55) + tk.Button(win_seeJob, text='职位变更管理', width=15, height=1, bg='green', command=manage_job).place(x=620, y=55) + + win_seeJob.mainloop() + + +# 职位变更管理 +def manage_job(): + win_addResume = tk.Tk() + win_addResume.title('职位变更管理') + win_addResume.geometry('1200x800') + tk.Label(win_addResume, text='职位变更管理', font=60).place(x=10, y=10) + + tk.Label(win_addResume, text='职位编号').place(x=220, y=70) + tk.Label(win_addResume, text='职位名称', ).place(x=220, y=130) + tk.Label(win_addResume, text='职位类别', ).place(x=220, y=190) + tk.Label(win_addResume, text='工作地点', ).place(x=220, y=250) + tk.Label(win_addResume, text='月薪(千)').place(x=220, y=310) + tk.Label(win_addResume, text='一年几薪', ).place(x=220, y=370) + tk.Label(win_addResume, text='工作描述', ).place(x=220, y=430) + tk.Label(win_addResume, text='最高学历', ).place(x=220, y=500) + tk.Label(win_addResume, text='招聘人数', ).place(x=220, y=570) + tk.Label(win_addResume, text='截止日期', ).place(x=220, y=630) + tk.Label(win_addResume, text='对于工作描述内容,可提前编辑好复制粘贴!', font=30, ).place(x=500, y=600) + + e1 = tk.Entry(win_addResume) + e1.place(x=300, y=70) + e2 = tk.Entry(win_addResume) + e2.place(x=300, y=130) + e3 = tk.Entry(win_addResume) + e3.place(x=300, y=190) + e4 = tk.Entry(win_addResume) + e4.place(x=300, y=250) + e5 = tk.Entry(win_addResume) + e5.place(x=300, y=310) + e6 = tk.Entry(win_addResume) + e6.place(x=300, y=370) + e7 = tk.Entry(win_addResume) + e7.place(x=300, y=430) + e8 = tk.Entry(win_addResume) + e8.place(x=300, y=500) + e9 = tk.Entry(win_addResume) + e9.place(x=300, y=565) + e10 = tk.Entry(win_addResume) + e10.place(x=300, y=625) + + def sql_conn(sql): + conn = pymysql.connect(host="127.0.0.1", user="root", password="WWWW1111", database="position_system", charset="utf8") + cursor = conn.cursor(cursor=pymysql.cursors.DictCursor) + cursor.execute(sql) + ret = cursor.fetchall() + cursor.close() + conn.commit() + conn.close() + return ret + + # 修改职位功能 + def alter(): + if e1.get() == '' or e9.get() == '' or e10.get() == '': + tk.messagebox.showerror('警告', '请填写完整职位编号、招聘人数、截止日期!') + else: + sql = "update Job set Recruitingno = '" + e9.get() + "',Deadline = '" + e10.get() + "' where Jno='" + e1.get() + "';" + ret = sql_conn(sql) + tk.messagebox.showinfo('', '修改成功!') + + # 删除职位功能 + def delete(): + sql = "delete from Job where Jno='" + e1.get() + "';" + ret = sql_conn(sql) + tk.messagebox.showinfo('', '删除成功!') + + # 插入(增加职位)功能 + def insert(): + if e1.get() == '' or e2.get() == '' or e3.get() == '' or e4.get() == '' or e5.get() == '' or e6.get() == '' or e7.get() == '' or e8.get() == '' or e9.get() == '' or e10.get() == '': + tk.messagebox.showerror('警告', '请填写完整!') + else: + try: + sql = "insert into Job values ('" + e1.get() + "','" + e2.get() + "','" + e3.get() + "','" + e4.get() + "','" + e5.get() + "','" + e6.get() + "','" + e7.get() + "','" + e8.get() + "','" + e9.get() + "','" + e10.get() + "')" + ret = sql_conn(sql) + tk.messagebox.showinfo('', '增加成功!') + except: + tk.messagebox.showerror('警告', '职位号已存在!') + + tk.Button(win_addResume, text='增加职位', width=30, font=('KaiTi', 20), height=3, bg='green', command=insert).place( + x=600, y=100) + tk.Button(win_addResume, text='输入职位编号,删除职位', width=30, font=('KaiTi', 20), height=3, + command=delete).place(x=600, y=220) + tk.Button(win_addResume, text='修改招聘人数和截止日期', width=30, font=('KaiTi', 20), height=3, + command=alter).place(x=600, y=340) + win_addResume.mainloop() + + +# 调用 +HR_in() \ No newline at end of file