ITeye博客

Python Mysql 实现人员信息系统

唐美好 · 2014-07-21 11:30 · Linux Python · 编程语言 · Markdown

| id | bigint(12) | NO | PRI | 0 | | | name | varchar(20) | NO | | NULL | | | sex | enum('M','W') | NO | | NULL | | | birthday | varchar(20) | NO | | NULL | | | age | int(4) | NO | | NULL | | | tel | bigint(12) | YES | | NULL | | | department | varchar(6) | NO | | NULL | | | salary | float | NO | | NULL | | |

2.部分代码: Company.py

#!/usr/bin/python #-- coding:utf-8 -- ######################################################################

Filename: company.py

Copyright (C) 2014.6

Author: TangMeiHao@760209035@qq.com

Description: python 实现企业人事管理系统

###################################################################### import mysql import os

import sys import time

class company:

id=''

thisyear=int(time.strftime("%Y"))

birthday=''

name=''

age=''

	department=''
opt=''
def __Menu__(self):
		menus="""\033
		    
		    
		    
		    
		    
		    	
		\033\033\033数据库读出来的ID进行比较
		Addinstance=mysql.cur
		Addconn=mysql.conn
		MysqlId=Addinstance.execute('select id from staff')
		MysqlIds=Addinstance.fetchmany(1000)
		flag=False	#flag为False,表示这个编号不存在,为True存在,进行再一次输入
		for i in MysqlIds:
			if i==intId:	#判断是否已经存在这个Id,Id为主键
				flag=True
				break
			else:				
				continue
		if flag==True:
			print "\t\t\t\033\033
			Addinstance=mysql.cur
			Addconn=mysql.conn
			Addinstance.execute('insert into staff values(%s,%s,%s,%s,%s,%s,%s,%s)',value)
			Addconn.commit()
			break
		else:
			continue
		
	

def __FIND__(self):
	while True:
		Id=int(raw_input("\t\t\t\033\033==Id:	#判断是否已经存在这个Id,Id为主键
				flag=True
				break
			else:				
				continue
		if flag==False:
			print "\t\t\t\033\033
			name=r
			sex=r
			birthday=r
			age=r
			tel=r
			dep=r
			salary=r
			value=(Id,name,sex,birthday,age,tel,dep,salary)			
		result="""
		    编号:%s
		    姓名:%s
		    性别:%s
		    出生:%s
		    年龄:%s
		    电话:%s
		    部门:%s
		    薪水:%s					
			""" % value
		print "\t\t\t\033\033
		name=r
		sex=r
		birthday=r
		age=r
		tel=r
		dep=r
		salary=r
		value=(Id,name,sex,birthday,age,tel,dep,salary)			
		result="""
		    编号:%s
		    姓名:%s
		    性别:%s
		    出生:%s
		    年龄:%s
		    电话:%s
		    部门:%s
		    薪水:%s					
			""" % value
		print "\t\t\t\033\033\033==Id:
				flag=True
				break
			else:				
				continue
		if flag==False:
			print "\t\t\t\033\033
			name=r
			sex=r	
			birthday=r
			age=r
			tel=r
			dep=r
			salary=r
			value=(Id,name,sex,birthday,age,tel,dep,salary)			
			result="""
		   	    编号:%s
		    	    姓名:%s
		    	    性别:%s
		            出生:%s
		            年龄:%s
		            电话:%s
		            部门:%s
		            薪水:%s					
				""" % value
			print "\t\t\t\033\033\033\033\033
		name=r
		sex=r
		birthday=r
		age=r
		tel=r
		dep=r
		salary=r
		value=(Id,name,sex,birthday,age,tel,dep,salary)			
		result="""
		    编号:%s
		    姓名:%s
		    性别:%s
		    出生:%s
		    年龄:%s
		    电话:%s
		    部门:%s
		    薪水:%s					
			""" % value
		print "\t\t\t\033\033\033\033

项目截图:(随便截了两个图,太麻烦了) 1. 2.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。