数据库结课设计(采用Python tkinter)

职工管理系统

初接触Python所写,可能代码、功能实现存在很多问题~~可以运行可行

  1. 系统介绍:所设计的系统为职工管理系统,主要作用是存储某企业人员信息,主要信息包括员工号(独一无二)、姓名、年龄、性别、职位、学历、薪资,主要功能有查询、更新、删除、增添、排序。
  2. 主要界面展示:
    主界面显示
    点击查询后(如未输入查询信息,则显示所有信息)
  3. 主要代码展示:(仅有部分代码…树的构造过程未展示)
#查询
def inquiry():
    cursor=conn.cursor()
    tmpName=emname.get().strip()
    tmpeno=emeno.get().strip()
    tmpnum=emage.get().strip()

    sql=''
    if(len(tmpName)==0 and len(tmpeno)==0 and len(tmpnum)!=11):
        sql="select * from employee"
    elif(len(tmpeno)==0 and len(tmpnum)!=11):
        sql="select * from employee where Ename like "+"'%"+tmpName+"%'"
    elif(len(tmpName)==0 and len(tmpnum)!=11):
        sql="select * from employee where Eno="+""+tmpeno+""
    elif(len(tmpName)==0 and len(tmpeno)==0):
        sql="select * from employee where Enum="+""+tmpnum+""
    cursor.execute(sql)
    list=cursor.fetchall()    
    def tree_view_sort_column(tv,col,reverse):
        l=[(tv.set(k,col),k) for k in tv.get_children
        l.sort(reverse=reverse)                
        for index,(val,k) in enumerate(l):           
        tv.move(k,'',index)            
        #print(k)        
    tv.heading(col,command=lambda:tree_view_sort_column(tv,col,not reverse))    f
    or col in columns:        tree_view.heading(col,text=col,command=lambda _col=col:tree_view_sort_column(tree_view,_col,False))
    
#增加
def getadd():
    cursor=conn.cursor()
    Eno=str(emeno.get()) 
    Ename=str(emname.get()) 
    Esex=str(emsex.get())    
    Eage=eval(emage.get())    
    Enum=str(emnum.get())    
    Pname=str(posname.get())    
    educated=str(Educate.get())    
    salary=eval(sassalary.get())    
    sql1="select * from employee "    
    cursor.execute(sql1)    
    list=cursor.fetchall()    
    #print(sql1)    
    conn.commit()    
    i=0    
    #查找是否有重复的编号    
    for row in list:        
    if Eno==row[0].strip():
           i=1
           break
     else: 
           i=0    
     if i==1:
            messagebox.showerror('警告',message="该员工号已存在,请重新录入!")   
      else:        
             try:            
             sql="insert into employee(Eno,Ename,Eage,Esex,Enum,Pname,educated,salary)\                values('%s','%s',%d,'%s','%s','%s','%s',%d)"%\                    (Eno,Ename,Eage,Esex,Enum,Pname,educated,salary)                   
     cursor.execute(sql)            
         #cursor.fetchall()            
      conn.commit()           
      messagebox.showinfo('提示',message="信息成功录入!")    except:            
      messagebox.showerror('提示',message="信息录入失败")
#删除
def getdelete(): 
   cursor=conn.cursor()   
   if(len(emeno.get())==0):
           messagebox.showinfo("提示",message="未检测到相关信息,请重试!")
    else: 
           try: 
                cursor.execute("delete from employee where Eno='%s'"%str(emeno.get()))            
                #cursor.fetchall()            
                 conn.commit()            
                 messagebox.showinfo("提示",message="删除成功!")        
             except:            
                  messagebox.showerror("提示",message="删除失败!")
#排序
def order():
    messagebox.showinfo("提示",message="单击列标题进行排序")

#更新
def getupdate():
    cursor=conn.cursor()
    Eno=str(emeno.get())
    if(len(Eno)==0):
        messagebox.showinfo("提示",message="请输入员工号再进行更新!")
    else:
        try:
            sql="update employee set Ename='%s',Eage=%d,Esex='%s',Enum='%s',Pname='%s',salary=%d,educated='%s' where Eno='%s'"%\
                (str(emname.get()),eval(emage.get()),str(emsex.get()),str(emnum.get()),str(posname.get()),eval(sassalary.get()),str(Educate.get()),Eno)
            cursor.execute(sql)
            conn.commit()
            messagebox.showinfo("提示",message="修改成功!")
        except:
            messagebox.showerror("提示",message="修改失败!")

#清除
def clear():
    E1.delete(0,"end")
    E2.delete(0,"end")
    E3.delete(0,"end")
    E4.delete(0,"end")
    E5.delete(0,"end")
    E6.delete(0,"end")
    E7.delete(0,"end")
    E8.delete(0,"end")
  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值