人事管理系统(课程设计)源码
- 格式:doc
- 大小:77.50 KB
- 文档页数:7
ame1,11;1<2break;forj=1;j<30;j++1j==''1j='\0';e;infi.sex1,4;forj=1;j<30;j++ifinfi.sex1j==''infi.sex1j='\0';e;infi.zhiwu1,11;forj=1;j<30;j++ifinfi.zhiwu1j==''infi.zhiwu1j='\0';e;infi.idemployee1,6;forj=1;j<30;j++ifinfi.idemployee1j==''infi.idemployee1j='\0';e;infi.ID1,21;forj=1;j<30;j++ifinfi.ID1j==''infi.ID1j='\0';e;infi.brithday1,11;infi.address1,31;forj=1;j<30;j++ifinfi.address1j==''infi.address1j='\0';e;infi.tele1,13;forj=1;j<30;j++ifinfi.tele1j==''infi.tele1j='\0';e;infi.money1,6;forj=1;j<30;j++ifinfi.money1j==''infi.money1j='\0';e;}lenth=i;;}classpeopleame1==0break;ift<lenth{cout<<NAME<<"的信息如下:";cout<<"\n姓名:"<<1;cout<<"\n性别:"<<inft.sex1;cout<<"\n工作编号:"<<inft.idemployee1;cout<<"\n身份证号码:"<<inft.ID1;cout<<"\n生日:"<<inft.brithday1;cout<<"\n联系:"<<inft.tele1;cout<<"\n地址:"<<inft.address1;cout<<"\n工资:"<<inft.money1<<endl;ame1==0break; cout<<"请重新输入信息:"<<endl;cout<<"请输入职工姓名:";cin>>1;cout<<"请输入职工性别:";cin>>infi.sex1;cout<<"请输入职工职务:";cin>>infi.zhiwu1;cout<<"请输入职工工作编号:";cin>>infi.idemployee1;cout<<"请输入职工身份证号:";cin>>infi.ID1;cout<<"请输入职工生日YYYY/MM/DD:";cin>>infi.brithday1;cout<<"请输入职工家庭住址:";cin>>infi.address1;cout<<"请输入职工号码:";cout<<"请输入职工月薪:";cin>>infi.money1;ofstreamoutfile"d:\\",ios::in;ifoutfile{cerr<<"openerror"<<endl;exit1;}fori=0;i<lenth;i++{outfile<<setiosflagsios::left<<setw10<<1;outfile<<""<<setw3<<infi.sex1;outfile<<""<<setw10<<infi.zhiwu1;outfile<<""<<setw5<<infi.idemployee1;outfile<<""<<setw20<<infi.ID1;outfile<<""<<setw10<<infi.brithday1;outfile<<""<<setw30<<infi.address1;outfile<<""<<setw12<<infi.tele1;outfile<<""<<setw4<<infi.money1;outfile<<"\n";};elsecout<<"你已经放弃了修改信息"<<endl;}};classguanliyuan:publicpeople{public:voidchange_inforame1==0break;ifi>=lenthcout<<"查无此人\n";else{cout<<"请重新输入信息:"<<endl;cout<<"请输入职工姓名:";cin>>1;cout<<"请输入职工性别:";cin>>infi.sex1;cout<<"请输入职工职务限制5位:";cin>>infi.zhiwu1;cout<<"请输入职工工作编号:";cin>>infi.idemployee1;cout<<"请输入职工身份证号:";cin>>infi.ID1;cin>>infi.brithday1;cout<<"请输入职工家庭住址:";cin>>infi.address1;cout<<"请输入职工号码:";cin>>infi.tele1;cout<<"请输入职工月薪不超过5位:";cin>>infi.money1;ofstreamoutfile"d:\\",ios::in;ifoutfile{cerr<<"openerror"<<endl;exit1;}fori=0;i<lenth;i++{outfile<<setiosflagsios::left<<setw10<<1;outfile<<""<<setw3<<infi.sex1;outfile<<""<<setw10<<infi.zhiwu1;outfile<<""<<setw5<<infi.idemployee1;outfile<<""<<setw20<<infi.ID1;outfile<<""<<setw10<<infi.brithday1;outfile<<""<<setw30<<infi.address1;outfile<<""<<setw5<<infi.money1;outfile<<"\n";};}}voiddeletame1==0break;j=i;ofstreamoutfile"d:\\",ios::trunc;ame1;outfile<<""<<setw3<<infi.sex1;outfile<<""<<setw10<<infi.zhiwu1;outfile<<""<<setw5<<infi.idemployee1;outfile<<""<<setw20<<infi.ID1;outfile<<""<<setw10<<infi.brithday1;outfile<<""<<setw30<<infi.address1;outfile<<""<<setw12<<infi.tele1;outfile<<""<<setw5<<infi.money1;outfile<<"\n";};cout<<"你已经成功删除"<<NAME<<"的信息"<<endl;}cout<<"你已经放弃了删除该信息\n";}voidoneprint入个人的信息\n";cout<<"\t2.显示个人信息\n";cout<<"\t3.修改个人信息\n";cout<<"\t4.查找他人信息\n";cout<<"\t5.显示所有在厂职工\n";cout<<"\t6.返回主菜单\n";cout<<"\t0.退出\n";cout<<"\t------------------------------------------------\n";cout<<"\t\n";}voidmune2{cout<<"\t\n";cout<<"\t------------------------------------------------\n";cout<<"\t1.输入职工的信息\n";cout<<"\t2.显示查找人的信息\n";cout<<"\t3.修改查找人信息\n";cout<<"\t4.删除查找人信息\n";cout<<"\t5.显示所有在厂职工\n";cout<<"\t6.返回主菜单\n";cout<<"\t------------------------------------------------\n";cout<<"\t\n";}intquedingame1==0break;ifi>=lenthcout<<"记录中暂无此人信息.\n";elsept->delet;cout<<"你还想进行何种操作:";break;}ifsl==2{cout<<"请输入查找人姓名:";cin>>NAME;pt->seachNAME;cout<<"你还想进行何种操作:";break;}}case5:{pt->allprint;;cout<<"你还想进行何种操作:";break;}case6:k=0;break;default:cout<<"你的选择错误,请重新选择:";break;}}whilek;}intmain理员\n";cout<<"\t2.普通职工\n";cout<<"\t0.退出\n";do{cout<<"请选择你的身份:";cin>>sl;switchsl{case0:{cout<<"你已经成功退出谢谢使用^_^\n";exit0;}break;case1:{system"cls";switchqueding{case0:{cout<<"你不能以管理员身份进入\n";break;}case1:{cout<<"操作成功你已经以管理员身份成功进入\n";system"cls";mune2;select;break;}}}break;case2:{cout<<"请输入您的姓名:";cin>>employname;tiquxinxi;forinti=0;i<lenth;i++ifstrcmpemployname,1==0break;ifi>=lenthcout<<"记录中暂无您的信息,请首先选择1来输入您的信息.\n";mune1;select;}break;default:{cout<<"错误你只能输入1,2,或0";}}}whilesl>2||sl<0;ifk==0k=1;system"cls";gotob;return0;}。
#include<iostream.h>#include<string.h>#include<iomanip.h>#include<fstream.h>#include<stdio.h>#include<stdlib.h>#include<conio.h>int k=1,i; //定义一个标志变量class birthday{ //定义出生年月日类public:int year;int month;int day;};class people{ //声明人员基类,以后在这个基础上派生出其它类public:people(){}virtual void enter(); //虚基函数,搭成一个框架,以后在此基础上扩充virtual void display();virtual int get_no(){return number;}virtual char * get_name(){return name;}virtual void change_infor(){} //信息修改函数virtual void readfile(){} //从文件中读virtual void write(){} //将信息写入文件people operator = (people p1); //运算符重载int operator == (people p1);virtual ~people(){};protected:char name[12];int number;char sex;birthday bir;char id[15];};people people::operator =(people p1)//定义运算符重载{strcpy(name,); number=p1.number; sex=p1.sex; bir.day=p1.bir.day;bir.month=p1.bir.month; bir.year=p1.bir.year;strcpy(id,p1.id);return p1;}int people::operator ==(people p1){if(id==p1.id) return 1;else return 0;}void people::enter(){ //定义信息输入函数cout<<"输入姓名:"; cin>>name;cout<<"输入编号:"; cin>>number;cout<<"输入性别:"; cin>>sex;cout<<"生日是(年月日):"; cin>>bir.year>>bir.month>>bir.day;cout<<"身份证号:";cin>>id;}void people::display(){ //定义信息显示函数cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(8)<<"性别"<<setw(8)<<"出生日期"<<setw(8)<<"身份证号"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(8)<<sex<<setw(8)<<bir.year<<setw(8)<<bir.mo nth<<setw(8)<<bir.day<<setw(8)<<id<<endl;}class student:virtual public people{ //以公有方式派生出学生类protected:char classnumber[20];public:student(){}virtual void enter(){people::enter();cout<<"输入班级名称:";cin>>classnumber;}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~student(){};};class teacher:virtual public people{ //以公有方式派生出老师类protected:char principalship[16];char department[16];public:teacher(){}virtual void enter(){people::enter();cout<<"输入老师的职务:";cin>>principalship;cout<<"\n 输入老师所在的部门:";cin>>department;}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~teacher(){}};//class graduate:virtual public student{ //以公有方式派生出研究生类protected:char subject[16];teacher adviser;public:graduate(){};virtual void enter(){student::enter();cout<<"输入研究生的专业:";cin>>subject;cout<<"输入导师的情况:"<<endl;adviser.enter();}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~graduate(){};};class teacher_asistant:public teacher,public graduate{ //以公有方式派生出助教类public:teacher_asistant(){};virtual void enter(){graduate::enter();cout<<"请输入助教生所在职务:";cin>>principalship;cout<<"请输入所在部门:";cin>>department;}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~teacher_asistant(){}};void student::display(){ //定义派生类学生的信息显示函数cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(12)<<"身份证号"<<setw(12)<<"班级名称"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(10)<<id<<setw(12)<<classnumber<<endl;}void student::write(){ //定义派生类学生的信息写入文件函数student stu;char ch;ofstream myfile("student.txt",ios::app);do{stu.enter();myfile.write((char *)&stu,sizeof(stu));cout<<"还需要输入下个学生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}void student::readfile(){ //定义派生类学生的读文件函数ifstream myfile("student.txt",ios::nocreate);while(myfile){student stu;if(myfile.read((char*)&stu,sizeof(stu))){if(stu.number!=-1) //删除一个学生的信息,通过不显示来定义删除stu.display();}}myfile.close();}void student::change_infor(){ //定义派生类学生的信息修改函数student stu;int num,p;cout<<"请输入你要修改或者删除的学生的编号:";cin>>num;fstream myfile("student.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&stu,sizeof(stu));if(num==stu.number){myfile.seekg(-sizeof(stu),ios::cur);cout<<"你是要修改还是要删除该学生的记录(1:删除2:修改):";cin>>p;if(p==1){stu.number=-1;break;}else {cout<<"请输入新的信息"<<endl;stu.enter();break;}}}myfile.write((char *)&stu,sizeof(stu));myfile.close();}void teacher::display(){cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(12)<<"身份证号"<<setw(10)<<"职务"<<setw(10)<<"部门"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(12)<<id<<setw(10)<<principalship<<setw(10)<<department<<endl ;}void teacher::readfile(){ifstream myfile("teacher.txt",ios::nocreate);while(myfile){people *p;teacher tec;p=&tec;if(myfile.read((char*)&tec,sizeof(tec))){if(tec.number!=-1)p->display();}}myfile.close();}//void teacher::write(){teacher tec;char ch;ofstream myfile("teacher.txt",ios::app);do{tec.enter();myfile.write((char *)&tec,sizeof(tec));cout<<"还需要输入下个学生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}void teacher::change_infor(){teacher tec;int num,p;cout<<"请输入你要修改或者删除的老师的编号:";cin>>num;fstream myfile("teacher.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&tec,sizeof(tec));if(num==tec.number){myfile.seekg(-sizeof(tec),ios::cur);cout<<"你是要修改还是要删除该老师的记录(1:删除2:修改):";cin>>p;if(p==1){tec.number=-1;break;}else {cout<<"请输入新的信息"<<endl;tec.enter();break;}}}myfile.write((char *)&tec,sizeof(tec));myfile.close();}void graduate::display(){cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(8)<<"身份证号"<<setw(8)<<"班级名称"<<setw(10)<<"专业"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(8)<<id<<setw(8)<<classnumber<<setw(10)<<subject<<endl;cout<<"他的导师的情况是:"<<endl;adviser.display();}void graduate::readfile(){ifstream myfile("graduate.txt",ios::nocreate);while(myfile){people *p;graduate gra;p=&gra;if(myfile.read((char*)&gra,sizeof(gra))){if(gra.number!=-1)p->display();}}myfile.close();}void graduate::write(){graduate gra;char ch;ofstream myfile("graduate.txt",ios::app);do{gra.enter();myfile.write((char *)&gra,sizeof(gra));cout<<"还需要输入下个研究生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}void graduate::change_infor(){graduate gra;int num,p;cout<<"请输入你要修改或者删除的研究生的编号:";cin>>num;fstream myfile("graduate.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&gra,sizeof(gra));if(num==gra.number){myfile.seekg(-sizeof(gra),ios::cur);cout<<"你是要修改还是要删除该研究生的记录(1:删除2:修改):";cin>>p;if(p==1){gra.number=-1;break;}else {cout<<"请输入新的信息"<<endl;gra.enter();break;}}}myfile.write((char *)&gra,sizeof(gra));myfile.close();}void teacher_asistant::display(){cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(12)<<"身份证号"<<setw(8)<<"班级名称"<<setw(10)<<"专业"<<setw(10)<<"职务"<<setw(10)<<"部门"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(8)<<id<<setw(8)<<classnumber<<setw(10)<<subject<<setw(10)<< principalship<<setw(10)<<department<<endl;cout<<"他的导师的情况是:"<<endl;adviser.display();}void teacher_asistant::readfile(){ifstream myfile("tec_asistant.txt",ios::nocreate);while(myfile){people *p;teacher_asistant tec_asis;p=&tec_asis;if(myfile.read((char*)&tec_asis,sizeof(tec_asis))){if(tec_asis.number!=-1)p->display();}}myfile.close();}void teacher_asistant::write(){teacher_asistant tec_asis;char ch;ofstream myfile("tec_asistant.txt",ios::app);do{tec_asis.enter();myfile.write((char *)&tec_asis,sizeof(tec_asis));cout<<"还需要输入下个助教生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}//void teacher_asistant::change_infor(){teacher_asistant tec_asis;int num,p;cout<<"请输入你要修改或者删除的助教生的编号:";cin>>num;fstream myfile("tec_asistant.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&tec_asis,sizeof(tec_asis));if(num==tec_asis.number){myfile.seekg(-sizeof(tec_asis),ios::cur);cout<<"你是要修改还是要删除该助教生的记录(1:删除2:修改):";cin>>p;if(p==1){tec_asis.number=-1;break;}else {cout<<"请输入新的信息"<<endl;tec_asis.enter();break;}}}myfile.write((char *)&tec_asis,sizeof(tec_asis));myfile.close();}void menu(){cout<<"\n\n\t\t**************************************************"<<endl;cout<<"\t\t*\t 人事管理系统\t *"<<endl;cout<<"\t\t*------------------------------------------------*"<<endl;cout<<" \t\t* 1.请输入人事信息 2.显示人事信息*"<<endl;cout<<" \t\t* 3.对信息的修改或删除 4.返回主菜单0.退出*"<<endl;cout<<"\t\t**************************************************"<<endl;cout<<" \t\t\t\t请选择操作(0=======4) "<<endl;cout<<"\t\t\t\t 请选择:";}void select(){people *pt;student st; teacher te; graduate gr; teacher_asistant t_a;if(i==1) pt=&st;else if(i==2) pt=&gr;else if(i==3) pt=&te;else if(i==4) pt=&t_a;do{int ch;cin>>ch;switch(ch){case 0:exit(0);case 1:pt->write();cout<<"你还想进行何种操作:";break;case 2:pt->readfile();cout<<"你还想进行何种操作:";break;case 3:pt->change_infor();cout<<"你还想进行何种操作:";break;case 4:k=0;break;default:cout<<"你的选择错误,请重新选择:";break;}}while(k);}void main(){b:cout<<"\n\n\t\t***************************************************"<<endl;cout<<"\t\t*\t 人事管理系统\t *"<<endl;cout<<"\t\t*-----------------------------------------------------*"<<endl;cout<<"\t\t* 1:学生*"<<endl;cout<<"\t\t* 2:研究生*"<<endl;cout<<"\t\t* 3:教师*"<<endl;cout<<"\t\t* 4:助教*"<<endl;cout<<"\t\t* 0:退出*"<<endl;cout<<"***************************************************"<<endl;cout<<"请选择(0---4):";cin>>i;switch(i){case 0:cout<<"你已经退出系统";getch();exit(0);case 1:{system("cls");menu();select();break;}case 2:{system("cls");menu();select();break;}case 3:{system("cls");menu();select();break;}case 4:{system("cls");menu();select();break;}default :cout<<"你的选择有误,请重新选择:";break;}if(k==0)k=1;system("cls");goto b;}。
摘要随着计算机技术的飞速发展,计算机在企业管理中应用的普及,利用计算机实现企业人事管理势在必行。
本系统结合公司实际的人事管理制度,经过实际的需求分析,采用功能强大的Visual Basic6.0作为开发工具而开发出来的单机版人事管理系统。
整个系统从符合操作简便、界面友好、灵活、实用、安全的要求出发,完成人事管理的全过程,包括新进员工加入时人事档案的建立、老员工的转出、职位等的变动引起职工信息的修改、员工信息查询、统计等人事管理工作以及新进员的新增、老员工修改等管理工作。
经过实际使用证明,本文所设计的人事管理系统可以满足公司人事管理方面的需要。
关键词:VB、数据库、窗体、测试、目录第一章概述 (4)1.1、本课题的来源 (4)1.2、本论文的目的、内容及作者主要贡献 (4)第二章开好发工具的选择 (4)第三章系统调研及可行性分析 (7)3.1、系统调研 (7)3.2、可靠性分析概述 (8)3.3、技术可行性分析 (8)第四章系统分析 (9)4.1、系统需求分析 (9)4.2、数据流程图 (10)第五章系统总体设计 (10)5.1、功能描述 (10)5.2、系统操作流程图 (11)第六章系统详细设计 (12)6.1、数据库设计 (12)6.2、系统主要界面 (13)第七章系统测试 (16)7.1、测试举例 (16)7.2、测试项目 (17)7.3、测试方法 (18)致谢 (19)参考文献 (20)附件:源程序…………………………………………………………………………21第一章概述1、本课题的来源随着计算机技术的飞速发展,计算机在企业管理中应用的普及,利用计算机实现企业人事管理势在必行。
对于大中型企业来说,利用计算机支持企业高效率完成劳动人事管理的日常事务,是适应现代企业制度要求、推动企业劳动人事管理走向科学化、规范化的必要条件;计算机管理所无法比拟的优点检索迅速、查找方便、可靠性高、存储量大、保密性好、寿命长、成本低等。
企业⼈事管理系统java源代码import java.awt.* ;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.border.*;public class A extends JFrame{protected JPanel p = new JPanel();protected JPanel p1 = new JPanel();protected JPanel p2 = new JPanel();protected JPanel p3= new JPanel();JMenuBar M =new JMenuBar();JMenu m1 = new JMenu("基本信息模块");JMenu m2 = new JMenu("考勤考评信息模块");JMenu m3 = new JMenu("系统维护信息模块");JMenuItem mm1 = new JMenuItem("员⼯基本信息"); JMenuItem mm2 = new JMenuItem("员⼯家庭成员基本信息"); JMenuItem mm3 = new JMenuItem("员⼯培训信息"); JMenuItem mm4 = new JMenuItem("员⼯考勤信息"); JMenuItem mm5 = new JMenuItem("员⼯考评信息"); JMenuItem mm6 = new JMenuItem("普通管理员"); JMenuItem mm7 = new JMenuItem("⾼级管理员"); JMenuItem mm8 = new JMenuItem("退出");protected JLabel l1 = new JLabel("员⼯编号:");protected JLabel l2 = new JLabel("姓名:");protected JLabel l3 = new JLabel("性别:");protected JLabel l4 = new JLabel("年龄:");protected JLabel l5 = new JLabel("部门:");protected JTextField t1 = new JTextField(10);protected JTextField t2 = new JTextField(10);protected JTextField t3 = new JTextField(10);protected JTextField t4 = new JTextField(10);protected JTextField t5 = new JTextField(10);private JButton b1 = new JButton("查询");private JButton b2 = new JButton("插⼊");private JButton b3 = new JButton("修改");private JButton b4 = new JButton("删除");private JButton b5 = new JButton("清除");private JButton b6 = new JButton("下⼀条");private Connection c; // @jve:decl-index=0:private Statement s; // @jve:decl-index=0:private ResultSet r; // @jve:decl-index=0:{super("⼈事管理系统");getContentPane().add(p);setJMenuBar(M);M.add(m1);M.add(m2);M.add(m3);m1.add(mm1);m1.add(mm2);m1.add(mm3);m1.addSeparator();m1.add(mm8);m2.add(mm4);m2.add(mm5);m3.add(mm6);m3.add(mm7);p.add(p1,BorderLayout.NORTH);p.add(p2,BorderLayout.CENTER);p.add(p3,BorderLayout.SOUTH);p1.setLayout(new GridLayout(5,2,1,3));p1.add(l1);p1.add(t1);p1.add(l2);p1.add(t2);p1.add(l3);p1.add(t3);p1.add(l4);p1.add(t4);p1.add(l5);p1.add(t5);p2.add(b1);p1.add(b2);p2.add(b3);p1.add(b4);p2.add(b5);p3.add(b6);t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");setSize(350,300);setVisible(true);try{Class.forName("sun.jdbc.odbc.JdbcOdbcDrive");c=DriverManager.getConnection("jdbc:odbc:sd","sa",null);s=c.createStatement();r=s.executeQuery("select * from 员⼯基本信息表");}catch (SQLException e){JOptionPane.showMessageDialog(null ,e.getMessage(),"操作错误!",JOptionPane.ERROR_MESSAGE); System.exit(1);}catch(ClassNotFoundException e)JOptionPane.showMessageDialog(null ,e.getMessage(),"驱动程序找不到!",JOptionPane.ERROR_MESSAGE); System.exit(1);}addWindowListener( new WindowAdapter(){public void windowClosing(WindowEvent event){try {s.close();c.close();catch(SQLException e){JOptionPane.showMessageDialog(null,e.getMessage(),"不能关闭!",JOptionPane.ERROR_MESSAGE); System.exit(1);}}});b1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){try{r=s.executeQuery("select * from 员⼯基本信息表" + "where 员⼯编号='"+t1.getText()+"'");if(r.next()){t1.setText(r.getString(1));t2.setText(r.getString(2));t3.setText(r.getString(3));t4.setText(r.getString(4));t5.setText(r.getString(5));JOptionPane.showMessageDialog(null,"查询成功!","查询操作",JOptionPane.ERROR_MESSAGE);}else{t2.setText("");t3.setText("");t4.setText("");t5.setText("");JOptionPane.showMessageDialog(null,"查询失败!","查询操作",JOptionPane.ERROR_MESSAGE);}catch(NumberFormatException e){System.out.println(e);}catch(SQLException e){System.out.println(e);}});b2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){String v1,v2,v3,v4,v5;v1=t1.getText();v2=t2.getText();v3=t3.getText();v4=t4.getText();v5=t5.getText();if((!v1.equals( "" ))&&(!v2.equals(""))&&(!v3.equals(""))&&(!v4.equals(""))&&(!v5.equals (""))){try{int n1 = Integer.parseInt(v4);int r1 = s.executeUpdate("INSERT INTO 员⼯基本信息表"+ "values('"+v1+"','"+v2+"','"+v3+"',"+n1+",'"+v5+"')"); if(r1!=0){t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");JOptionPane.showMessageDialog(null,"插⼊成功!","插⼊操作",JOptionPane.ERROR_MESSAGE);}}catch (NumberFormatException e ){System.out.println(e);}catch (SQLException e){System.out.println(e);}}else{JOptionPane.showMessageDialog(null,"插⼊失败!","插⼊操作",JOptionPane.ERROR_MESSAGE);}}});b3.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event)try {int r1=s.executeUpdate("update 员⼯基本信息表set 姓名='"+t2.getText()+"'," +"性别='"+t3.getText()+"'," +"年龄="+Integer.parseInt(t4.getText())+"," +"部门='"+t5.getText()+"'"+"where 员⼯编号='"+t1.getText()+"'");if(r1!=0){JOptionPane.showMessageDialog(null,"修改成功!","修改操作",JOptionPane.ERROR_MESSAGE);}else{JOptionPane.showMessageDialog(null,"修改失败!","修改操作",JOptionPane.ERROR_MESSAGE);}} catch (NumberFormatException e ){System.out.println(e);}catch (SQLException e){System.out.println(e);}}});b4.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){try{int r1=s.executeUpdate("delete from 员⼯基本信息表"+"where 员⼯编号='"+t1.getText()+"'");if(r1!=0){t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");JOptionPane.showMessageDialog(null,"删除成功!","删除操作",JOptionPane.ERROR_MESSAGE);}else{JOptionPane.showMessageDialog(null,"删除失败!","删除操作",JOptionPane.ERROR_MESSAGE);}} catch (NumberFormatException e ){System.out.println(e);}catch (SQLException e){System.out.println(e);}}});b5.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");}});b6.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){try{if(r.next())t1.setText(r.getString(1));t2.setText(r.getString(2));t3.setText(r.getString(3));t4.setText(""+r.getInt(4));t5.setText(r.getString(5));}catch (NumberFormatException e ){System.out.println(e);} catch (SQLException e){System.out.println(e);}}});mm8.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){System.exit(0);}});}public static void main(String args[]){new A();}}。
目录新建一个头文件类,名字为:,再建一个源文件,名字随意,代码按顺序粘贴进去即可运行。
错误!未定义书签。
? 头文件:错误!未定义书签。
? 源文件:错误!未定义书签。
新建一个头文件类,名字为:,再建一个源文件,名字随意,代码按顺序粘贴进去即可运行。
头文件:#include <iostream>#include <fstream>using namespace std;dd(n1);i1++;}else if(b==2) dd(n2);i2++;}else if(b==3) dd(n3);i3++;}else if(b==4) dd(n4);i4++;}else if(b==5){break;}else{cout<<"输入有误!请重试!"<<endl;cout<<endl;system ("pause");system ("cls");continue;}}}ave(file);file<<endl;file<<i2<<endl; ave(file); file<<endl;file<<i3<<endl; ave(file); file<<endl;file<<i4<<endl; ave(file);();}Oxz; ead(file);}file>>i2; Ojs;ead(file);}file>>i3; Oyb;ead(file);}file>>i4; Otx;ead(file);}();}Oxz==g){h=g-1;xz[h].show();z=1;editPer(g,z); Ojs==g){h=g-1;js[h].show();z=2;editPer(g,z); Oyb==g){h=g-1;yb[h].show();z=3;editPer(g,z); Otx==g){h=g-1;tx[h].show();z=4;editPer(g,z); ame,nam)==0) {xz[t].show();x=1;editPer(xz[t].NOxz,x); Oxz,x);ame,nam)==0){js[t].show();x=2;editPer(js[t].NOjs,x); Ojs,x);ame,nam)==0){yb[t].show();x=3;editPer(yb[t].NOyb,x); Oyb,x);ame,nam)==0){tx[t].show();x=4;editPer(tx[t].NOtx,x); Otx,x);dd(n1);cout<<endl<<"是否保存(y/n)"<<endl;cin>>su2;if(su2=='y'||su2=='Y'){FileSave();}else break;}if(z==2)js[n2].add(n2);cout<<endl<<"是否保存(y/n)"<<endl; cin>>su2;if(su2=='y'||su2=='Y'){FileSave();}else break;}if(z==3){yb[n3].add(n3);cout<<endl<<"是否保存(y/n)"<<endl; cin>>su2;if(su2=='y'||su2=='Y'){FileSave();}else break;}if(z==4)tx[n4].add(n4);cout<<endl<<"是否保存(y/n)"<<endl;cin>>su2;if(su2=='y'||su2=='Y'){FileSave();}else break;}}else break;break;}}Oxz--; Ojs--; Oyb--; Otx--;职人员 2.党员 3.女性人员 4.高学历高职称人员"<<endl;int r;cin>>r;if(r==1){z=i1+i2+i3;cout<<"在职人员数:"<<z<<endl; }else if(r==2){for(i=0;i<i1;i++){if(strcmp(xz[i].zzmm ,"党员")==0) g++;}for(i=0;i<i2;i++){if(strcmp(js[i].zzmm,"党员")==0) g++;}for(i=0;i<i3;i++){if(strcmp(yb[i].zzmm,"党员")==0) g++;}for(i=0;i<i4;i++){if(strcmp(tx[i].zzmm,"党员")==0) g++;}cout<<"党员数:"<<g<<endl; }else if(r==3){for(i=0;i<i1;i++){if(strcmp(xz[i].sex,"女")==0)g++;}for(i=0;i<i2;i++){if(strcmp(js[i].sex,"女")==0)g++;}for(i=0;i<i3;i++){if(strcmp(yb[i].sex,"女")==0)g++;}for(i=0;i<i4;i++){if(strcmp(tx[i].sex,"女")==0)g++;}cout<<"女性人员数:"<<g<<endl; }else if(r==4){int g=0,h=0,c=0;for(i=0;i<i1;i++){if(strcmp(xz[i].zgxl,"大学")==0)g++;}for(i=0;i<i2;i++){if(strcmp(js[i].zgxl,"大学")==0)g++;}for(i=0;i<i3;i++){if(strcmp(yb[i].zgxl,"大学")==0) g++;}for(i=0;i<i4;i++){if(strcmp(tx[i].zgxl,"大学")==0) g++;}for(i=0;i<i1;i++){if(strcmp(xz[i].zgxl,"高中")==0) h++;}for(i=0;i<i2;i++){if(strcmp(js[i].zgxl,"高中")==0) h++;}for(i=0;i<i3;i++){if(strcmp(yb[i].zgxl,"高中")==0) h++;for(i=0;i<i4;i++){if(strcmp(tx[i].zgxl,"高中")==0) h++;}for(i=0;i<i1;i++){if(strcmp(xz[i].zgxl,"初中")==0) h++;}for(i=0;i<i2;i++){if(strcmp(js[i].zgxl,"初中")==0) h++;}for(i=0;i<i3;i++){if(strcmp(yb[i].zgxl,"初中")==0) h++;}for(i=0;i<i4;i++)if(strcmp(tx[i].zgxl,"初中")==0)h++;}cout<<"大学人数:"<<g<<" 高中人数:"<<h<<" 初中人数:"<<c<<endl; }else{cout<<"统计的类型错误!"<<endl;system("PAUSE");}cout<<"是否继续人事统计:Y继续、其他退出"<<endl;char x;cin>>x;if(x!='y' && x!='Y')break;}}。
C++语言课程设计——人事管理系统目录一、需求分析..................................3二、程序的主要功能............................3三、程序运行平台..............................3四、系统总枢架图..............................3五、程序类的说明..............................4六、源程序....................................5七、模块分析..................................12八、特色函数..................................13九、不足与对策................................13一、需求分析小型公司人员信息的管理用大型软件系统来管理很不现实,而一个小巧玲珑的信息管理系统可能更适于此类公司。
二、程序的主要功能1、添加功能:添加职员的基本信息,包括姓名、编号、级别、工作时间、工作成绩等;2、修改功能:对信息进行修改;3、查找功能:根据要求查找已有人员信息;4、显示功能:显示所存信息的内容。
三、程序运行环境Visual c++6.0四、系统总框架图五、程序类的说明六、源程序//pengfuyuan.cpp#include<iostream.h>#include"employee.h"int main(){manager m1;technician t1;salesmanager sm1;salesman s1;employee *emp[4]={&m1,&t1,&sm1,&s1};//用指针数组的个元素存放各对象的地址int i;for(i=0;i<4;i++){ /*依次调用各派生类对象的成员函数,完成各自不同的升级、计算月薪、显示信息功能。
湘南学院C语言课程设计课程:人事管理系统姓名:学号:系别:计算机科学与技术专业:计算机科学与技术级别:时间:2012年6月5日目录1…………………………………………………成员分工表2…………………………………………………系统功能分析3…………………………………………………函数简介4…………………………………………………系统流程图5…………………………………………………原代码6…………………………………………………各成员总结成员分工表一、系统功能分析人事管理系统的主要任务是对人事档案进行整理,使得能方便快捷地对人事档案进行查询、统计、更新,并且能按一定要求输出报表。
通过该系统,使企业的人事管理工作系统化、规范化、自动化,从而提高企业人事管理的效率。
本系统分为如下的几大模块:档案查询,输入新员工的信息,删除员工信息和浏览员工信息。
其中的主要模块包括:1、主界面模块该模块提供管理系统的主界面,是主系统的唯一入口,该界面提供用户登陆和新用户的注册。
2、查询模块该模块提供查询符合某一条件的人事档案的界面,其中包括两种查询方式,一种是按姓名查找,另一种是按职工号查找。
3、输\插入模块该模块主要功能是输入新员工的信息。
4、删除模块该模块主要是删除员工的信息。
5、浏览模块该模块提供全部人事档案的界面。
6、退出系统二、函数简介该系统运用了三个结构体数组和10个函数,结构体数组包括:denglu数组、yuefen1数组和worker数组,denglu 数组中有两个元素:用户名username[10]和密码key[5];yuefen1数组中只有一个元素:月份,而worker数组中包含有二十个元素:职工号gonghao,姓名xingming[20],应发工资yfgz,实发工资sf,电费df,税金sj,性别sex[4],职位position[10],部门department[10],工作时间wokestate[20],联系电话tel[13],身份证号shenfenzheng[20],银行卡号kahao[10],QQ 号码qq[10],年龄age,邮箱email[20],政治面貌plotical[10],籍贯jiguan[40],婚否ifmarry[5],住址address[40],实发工资sfgz。
人事管理系统源代码第一篇:人事管理系统源代码#include #include #include #define N 100 struct member_info {char xm[7];char xb[3];char sr[15];char whcd[13];char zc[17];char sfzh[19];char lxdh[12];int gl;int nl;};struct member_info member[N+1];int CurrentCount=0;void input(){ char sfjx=1;while(sfjx!=0){if(CurrentCount==N){printf(“n人数已达上限,不能添加!!n”);sfjx=0;}else{CurrentCount++;printf(“n请输入员工信息(姓名性别生日年龄文化程度联系电话身份证号码工龄职称):n”);scanf(“%s%s%s%d%s%s%s%d%s”,member[CurrentCount] .xm,member[CurrentCount].xb,member[CurrentCount].sr,&mem ber[CurrentCount].nl,member[CurrentCount].whcd,member[Curr entCount].lxdh,member[CurrentCount].sfzh,&member[CurrentC ount].gl,member[CurrentCount].zc);printf(“n是否继续(0--结束,其它--继续):”);scanf(“%d”,&sfjx);}} printf(“人员已排序”);int i,j;for(i=1;ifor(j=CurrentCount;j>i;j--)if(strcmp(member[j].sfzh,member[j-1].sfzh)<0){member[0]=member[j];member[j]=member[j-1];member[j-1]=member[0];}printf(“n人事基本信息表n”);printf(“ 序号姓名性别生日年龄文化程度联系电话身份证号码工龄职称n”);for(i=1;i<=CurrentCount;i++)printf(“%4d %6s%3s%11s%3d%8s%12s%20s%3d%5sn”,i, member[i].xm,member[i].xb,member[i].sr,member[i].nl,member[i ].whcd,member[i].lxdh,member[i].sfzh,member[i].gl,member[i].zc );system(“pause”);} voi d save(){FILE *fp;fp=fopen(“ygjbxx.txt”,“w”);if(fp==NULL)printf(“n文件打开不成功,信息无法保存!!n”);else{fprintf(fp,“%d”,CurrentCount);for(int i=1;i<=CurrentCount;i++)fprintf(fp,“n%8s%4s%16s%4d%14s%13s%20s%4d%18s”, member[i].xm,member[i].xb,member[i].sr,member[i].nl,member[i].whcd,member[i].lxdh,member[i].sfzh,member[i].gl,member[i].zc );fclose(fp);printf(“n信息已成功保存!!n”);}system(“pause”);} void read(){FILE *fp;fp=fop en(“ygjbxx.txt”,“r”);if(fp==NULL)printf(“n文件打开不成功,信息无法读取!!n”);else{fscanf(fp,“%d”,&CurrentCount);for(int i=1;i<=CurrentCount;i++){fscanf(fp,“%s%s%s%d%s%s%s%d%s”,member[i].xm,mem ber[i].xb,member[i].sr,&member[i].nl,member[i].whcd,member[i]. lxdh,member[i].sfzh,&member[i].gl,member[i].zc);printf(“姓名:%s 性别:%s 生日:%s 年龄:%d 文化程度: %s 联系电话: %s 身份证号码: %s 工龄: %d 职称: %sn”,member[i].xm,member[i].xb,member[i].sr,member[i].nl, member[i].whcd,member[i].lxdh,member[i].sfzh,member[i].gl,me mber[i].zc);}fclose(fp);p rintf(“n信息已成功读取!!n”);}system(“pause”);} void search(){char dcsfzh[19];int sfjx=1,i;while(sfjx!=0){printf(“n请输入一个待查员工的身份证号码:”);scanf(“%s”,dcsfzh);strcpy(member[0].sfzh,dcsfzh);i=CurrentCount;while(strcmp(member[i].sfzh,dcsfzh)!=0)i--;if(i==0)printf(“查无此人!!n”);else{printf(“n此人详细信息如下:n”);printf(“姓名:%s 性别:%s 生日:%s 年龄:%d 文化程度: %s 联系电话: %s 身份证号码: %s 工龄: %d 职称: %sn”,member[i].xm,member[i].xb,member[i].sr,member[i].nl, member[i].whcd,member[i].lxdh,member[i].sfzh,member[i].gl,me mber[i].zc);}prin tf(“n是否继续(0--结束,其它--继续):”);scanf(“%d”,&sfjx);}system(“pause”);} void del(){char dcsfzh[19];int sfjx=1,i,j;while(sfjx!=0){printf(“n请输入一个待删员工的身份证号码:”);scanf(“%s”,dcsfzh);strcpy(member[0].sfzh,dcsfzh);i=CurrentCount;while(strcmp(member[i].sfzh,dcsfzh)!=0)i--;if(i==0)printf(“查无此人!!n”);else{printf(“n此人详细信息如下:n”);printf(“姓名:%s 性别:%s 生日:%s 年龄:%d 文化程度: %s 联系电话: %s 身份证号码: %s 工龄: %d 职称: %sn”,member[i].xm,member[i].xb,member[i].sr,member[i].nl, member[i].whcd,member[i].lxdh,member[i].sfzh,member[i].gl,me mber[i].zc);printf(“n按任意键开始删除......n”);system(“pause”);for(j=i+1;j<=CurrentCount;j++)member[j-1]=member[j];CurrentCount--;printf(“n已成功删除......n”);system(“pause”);}printf(“n是否继续(0--结束,其它--继续):”);scanf(“%d”,&sfjx);}system(“pause”);} void modify(){char dcsfzh[19];int sfjx=1,i;while(sfjx!=0){printf(“n请输入一个待修改员工的身份证号码:”);scanf(“%s”,dcsfzh);strcpy(member[0].sfzh,dcsfzh);i=CurrentCount;while(strcmp(member[i].sfzh,dcsfzh)!=0)i--;if(i==0)printf(“查无此人!!n”);else{printf(“n此人详细信息如下:n”);printf(“姓名:%s 性别:%s 生日:%s 年龄:%d 文化程度: %s 联系电话: %s 身份证号码: %s 工龄: %d 职称: %sn”,member[i].xm,member[i].xb,memb er[i].sr,member[i].nl, member[i].whcd,member[i].lxdh,member[i].sfzh,member[i].gl,me mber[i].zc);printf(“n请输入新内容......n”);printf(“n请输入人员相关信息(姓名性别生日年龄文化程度联系电话身份证号码工龄职称):”);scanf(“%s%s%s%d%s%s%s%d%s”,member[CurrentCount] .xm,member[CurrentCount].xb,member[CurrentCount].sr,&mem ber[CurrentCount].nl,member[CurrentCount].whcd,member[Curr entCount].lxdh,member[CurrentCount].sfzh,&member[CurrentC ount].gl,member[CurrentCount].zc);printf(“n已成功修改......n”);system(“pause”);}printf(“n是否继续(0--结束,其它--继续):”);scan f(“%d”,&sfjx);}system(“pause”);} int check(){int count=0,name,pass;while(count<=2){printf(“n请输入用户名及密码:”);scanf(“%d%d”,&name,&pass);count++;if((name==1)&&(pass==1))count=10;elseif(count>2)count=5;}if(count==10)return 0;elsereturn 1;} struct mem_gz {float jbgz;float cql;float jj;float kk;float grsd;float sf;};struct mem_gz mem[N+1];void inputgz(){ char sfjx=1;CurrentCount=0;while(sfjx!=0){if(CurrentCount==N){printf(“n工资已添加完毕,无法添加!!n”);sfjx=0;}else{CurrentCount++;printf(“请输入身份证号码为:%s的员工工资资料n”,member[CurrentCount].sfzh);printf(“n请输入员工工资信息(基本工资考勤奖金扣款个人所得税):n”);scanf(“%f%f%f%f%f”,&mem[CurrentCount].jbgz,&mem[C urrentCount].cql,&mem[CurrentCount].jj,&mem[CurrentCount]. kk,&mem[CurrentCount].grsd);mem[CurrentCount].sf=mem[CurrentCount].jbgz*mem[Curr entCount].cql+mem[CurrentCount].jj-mem[CurrentCount].kk-mem[CurrentCount].grsd;}printf(“n是否继续(0--结束,其它--继续):n”);scanf(“%d”,&sfjx);}system(“pause”);} void savegz(){FILE *fq;fq=fopen(“yggzxx.txt”,“w”);if(fq==NULL)printf(“n文件打开不成功,信息无法保存!!n”);else{fprintf(fq,“%d”,CurrentCount);for(int i=1;i<=CurrentCount;i++)fprintf(fq,“n%f %f %f %f %f %f”,mem[i].jbgz,mem[i].cql,m em[i].jj,mem[i].kk,mem[i].grsd,mem[i].sf);fclose(fq);printf(“n信息已成功保存!!n”);}system(“pause”);} void readg z(){FILE *fq;fq=fopen(“yggzxx.txt”,“r”);if(fq==NULL)printf(“n文件打开不成功,信息无法读取!!n”);else{fscanf(fq,“%d”,&CurrentCount);for(int i=1;i<=CurrentCount;i++){fscanf(fq,“%f%f%f%f%f%f”,&mem[i].jbgz,&mem[i].cql,&m em[i].jj,&mem[i].kk,&mem[i].grsd,&mem[i].sf);printf(“基本工资: %f 考勤: %f 奖金: %f 扣款: %f 个人所得税: %f 实发工资:%fn”,mem[i].jbgz,mem[i].cql,mem[i].jj,mem[i].kk,mem[i].grsd ,mem[i].sf);}fclose(fq);printf(“n信息已成功读取!!n”);}system(“pause”);} void searchgz(){int dcbh;int sfjx=1;while(sfjx!=0){printf(“n请输入一个待查员工编号(身份证号从小到大的顺序):”);scanf(“%d”,&dcbh);if(dcbh<1||dcbh>CurrentCount)printf(“查无此人!!n”);else{printf(“n此人工资信息如下:n”);printf(“基本工资: %f 考勤: %f 奖金: %f 扣款: %f 个人所得税: %f实发工资:%fn”,mem[dcbh].jbgz,mem[dcbh].cql,mem[dcbh].jj,mem[dc bh].kk,mem[dcbh].grsd,mem[dcbh].sf);}printf(“n是否继续(0--结束,其它--继续):”);scanf(“%d”,&sfjx);}system(“pause”);} void delgz(){int dcbh;int sfjx=1,j;while(sfjx!=0){printf(“n请输入一个待删工资的编号:”);scanf(“%d”,&dcbh);if(dcbh<1||dcbh>CurrentCount)printf(“查无此人!!n”);else{printf(“n此人工资信息如下:n”);printf(“基本工资: %f 考勤: %f 奖金: %f 扣款: %f 个人所得税: %f 实发工资:%fn”,mem[dcbh].jbgz,mem[dcbh].cql,mem[dcbh].jj,mem[dc bh].kk,mem[dcbh].grsd,mem[dcbh].sf);printf(“n按任意键开始删除......n”);system(“pause”);for(j=dcbh+1;j<=CurrentCount;j++)mem[j-1]=mem[j];CurrentCount--;printf(“n已成功删除......n”);system(“pause”);}printf(“n是否继续(0--结束,其它--继续):”);scanf(“%d”,&sfjx);}system(“pause”);} void modifygz(){int dcbh;int sfjx=1;while(sfjx!=0){printf(“n请输入一个待修改工资员工的编号:”);scanf(“%d”,&dcbh);if(dcbh<1||dcbh>CurrentCount)printf(“查无此人!!n”);else{printf(“n此人工资信息如下:n”);printf(“基本工资: %f 考勤: %f 奖金: %f 扣款: %f 个人所得税: %f 实发工资:%fn”,mem[dcbh].jbgz,mem[dcbh].cql,mem[dcbh].jj,mem[dc bh].kk,mem[dcbh].grsd,mem[dcbh].sf);printf(“n请输入新内容......n”);printf(“n请输入人员工资信息(基本工资考勤奖金扣款个人所得税实发工资):”);scanf(“%f%f%f%f”,&mem[CurrentCount].jbgz,&mem[dcb h].cql,&mem[dcbh].jj,&mem[dcbh].kk,&mem[dcbh].grsd,&mem [dcbh].sf);printf(“n已成功修改......n”);system(“pause”);}printf(“n是否继续(0--结束,其它--继续):”);scanf(“%d”,&sfjx);}system(“pause”);} void lis tgz(){ int i;printf(“n员工工资信息表n”);printf(“ 序号基本工资考勤奖金扣款个人所得税实发工资n”);for(i=1;i<=CurrentCount;i++)printf(“%4d %8f%8f%8f%8f”,i,mem[i].jbgz,mem[i].cql,me m[i].jj,mem[i].kk,mem[i].grsd,mem[i].sf);system(“pause”);}void main(){int xz=1;printf(“*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*n”);printf(“*欢迎使用人事工资管理系统*n”);printf(“***************************************nnn”);if(check()!=0){printf(“n你无权使用本系统......nn”);system(“pause”);}else{while(xz!=0){printf(“n请选择相应功能:n”);printf(“1-录入n2-查询n3-修改n4-删除n5-保存n6-读取n7-输入员工工资n8-保存工资信息n9-读取工资信息n10-修改工资信息n11-删除工资信息n12-工资列表n0-结束n请输入选择:”);scanf(“%d”,&xz);switch(xz){case 1:input();break;case 2:search();break;case 3:modify();break;case 4:del();break;case 5:save();break;case 6:read();break;case 7:inputgz();break;case 8:savegz();break;case 9:readgz();break;case 10:modifygz();break;case 11:delgz();break;case 12:listgz();break;case 0:printf(“nn谢谢使用本系统!nn”);system(“pause”);break;default:printf(“n无此功能,请重新选择......n”);system(“pause”);}}} }第二篇:人事管理系统数据库源代码using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;using System.Xml.Linq;namespace WebApplication1 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){ Res ponse.Redirect(“~/登录.aspx”);}protected void Button2_Click(object sender, EventArgs e){ Response.Redirect(“~/人员信息查询.aspx”);}protected void Button3_Click(object sender, EventArgs e){ Response.Redirect(“~/人员修改.aspx”);}protected void Button4_Click(object sender, EventArgs e){ Response.Redirect(“~/部门信息.aspx”);}protected void Button5_Click(object sender, EventArgs e){ Response.Redirect(“~/工资信息.aspx”);} } }using System;using System.Collections;usingSystem.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1 { public partial class 部门信息: System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){ bool find =false;SqlConnection con=new SqlConnection(“server=localhost;IntegratedSecurity=SSPI;database=人事管理系统”);con.Open();string cmdstr=“select * from 部门表”;SqlDataAdapter da=new SqlDataAdapter(cmdstr,con);DataSet ds=new DataSet();da.Fill(ds);for(int i=0;iTextBox2.Text=ds.T ables[0].Rows[i][“部门代码”].ToString();TextBox3.T ext=ds.Tables[0].Rows[i][“部门名称”].T oString();find=true;}} } if(find == false){ Response.Write(“”);con.Close();} }protected void Button2_Click(object sender, EventArgs e){ Response.Redirect(“~/Default.aspx”);} } }using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;using System.Data.SqlClient;using System.Data.SqlTypes;namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e){}protected void TextBox1_TextChanged(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){SqlConnection con = new SqlConnection(“server=localhost;IntegratedSecurity=SSPI;database=人事管理系统”);string strCount;strCount = “select * from 人事表”;con.Open();SqlCommand com = new SqlCommand(strCount, con);SqlDataReader dr = com.ExecuteReader();string strUsername = “", strPassword = ”“;while(dr.Read()){ if(TextBox1.Text == dr[”编号“].ToString()||TextBox2.Text == dr[”用户密码“].ToString()){ strUsername = dr[”编号“].T oString();strPassword = dr[”用户密码“].ToString();break;} } dr.Close();con.Close();if(strUsername== ”“){ Response.Write(”“);return;}}protected void Button2_Click(object sender, EventArgs e){ Response.Redirect(”~/Default.aspx“);} } }using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;usingSystem.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1 { public partial class 工资信息 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e){}protected void TextBox2_TextChanged(object sender, EventArgs e){}protected void TextBox5_TextChanged(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){ bool find = false;SqlConnection con = new SqlConnection(”server=localhost;IntegratedSecurity=SSPI;database=人事管理系统“);con.Open();string cmdstr = ”select * from 工资表“;SqlDataAdapter da = new SqlDataAdapter(cmdstr, con);DataSet ds = new DataSet();da.Fill(ds);for(int i = 0;i < ds.Tables[0].Rows.Count;i++){ for(int j = 0;j < ds.Tables[0].Columns.Count;j++){ String data =(ds.Tables[0].Rows[i][j].ToString()).Trim();if(data == TextBox1.Text.Trim()){TextBox2.Text = ds.Table s[0].Rows[i][”应发工资“].ToString();TextBox3.Text = ds.Tables[0].Rows[i][”岗位津贴“].ToString();TextBox4.Text = ds.Tables[0].Rows[i][”奖励“].ToString();TextBox5.Text = ds.Tables[0].Rows[i][”保险“].ToString();} } if(find == false){ Response.Write(”“);con.Close();}}protected void Button2_Click(object sender, EventArgs e){ Response.Redirect(”~/Default.aspx“);} } }using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1 { public partial class 人员信息: System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){ Response.Redirect(”~/Default.aspx“);}protected void Button2_Click(object sender, EventArgs e){ bool find =false;SqlConnection con = new S qlConnection(”server=localhost;IntegratedSecurity=SSPI;database=人事管理系统“);con.Open();string cmdstr=”select * from 工资表“;SqlDataAdapter da=new SqlDataAdapter(cmdstr,con);DataSet ds=new DataSet();da.Fill(ds);for(int i=0;iTextBox2.Text=ds.T ables[0].Rows[i][”应发工资“].ToString();TextBox3.Text=ds.Tables[0].Rows[i][”岗位津贴“].ToString();TextBox4.Text=ds.Tables[0].Rows[i][”奖励“].ToString();TextBox5.Text = ds.Tables[0].Rows[i][”保险“].ToString();} } if(find == false){ Response.Write(”“);con.Close();} } } }using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1 { public partial class 人员修改: System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e){}protected void TextBox5_TextChanged(object sender, EventArgs e){}protected void Button2_Click(object sender, EventArgs e){ SqlConnection con=new SqlConnection(”server=localhost;IntegratedSecurity=SSPI;database=人事管理系统“);con.Open();string insert=”insert into 人事表(员工号,姓名,性别,职称,学历)values(“+”“+ TextBox1.Text.Trim()+”“+”,“+”“ + TextBox2.Text.Trim()+”“+”,“+TextBox3.Text.Trim()+ ”,“ +”“+ TextBox4.Text.Trim()+”“+”,“+”“ +TextBox5.Text.Trim()+ ”“+”)“;Response.Write(insert);SqlCommand cmd1=new SqlCommand(insert,con);con.Close();}protected void Button1_Click(object sender, EventArgs e){ Response.Redirect(”~/Default.aspx");}protected void GridView1_SelectedIndexChanged(object sender, EventArgs e){ } } }第三篇:人事管理系统企业人事财务管理系统的开发与设计内容摘要随着Internet的不断发展,传统的管理方式,消耗大量的人力物力,传统的方式已经赶不上时代的脚步,所以开发一个高效的企业人事财务管理系统,是非常必要的。
人事管理系统前言:现代计算机技术的发展为人们的学习、生活、工作提供了很大的帮助, 各行各业都需要特定计算系统的运用, 我们需要了解这些系统是怎么样为我们服务以及他们是怎样编辑出来的。
我们需要学习C语言编程, 根据课堂讲授内容, 做相应的自主练习, 消化课堂所讲解的内容;通过调试典型例题或习题积累调试C程序的经验;通过完成辅导教材中的编程题, 逐渐培养编程能力、用计算机解决实际问题的能力, 能够按照要求编辑一些基本的程序, 提高自己的思维能力。
题目:(1)某高校主要人员有: 在职人员(行政人员、教师、一般员工)、退休人员及临时工。
现在需要储存这些人员的人事档案信息, 内容包括编号、姓名、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间、人员类别。
其中, 人员编号唯一, 不能重复。
(2)添加删除功能:能根据学院人事的变动情况, 添加删除记录。
(3)查询功能: 能根据编号和姓名进行查询。
(4)编辑功能(高级): 根据查询对相应的记录进行修改并记录。
(5)统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人数, 高学历高职称人数), 统计要求同时显示被统计着的信息。
排序功能: 按照年龄、来院时间进行排序。
保存功能: 能对输入的数据进行相应的存储。
分析:我们编辑的程序要能够满足题目的要求, 可以进行这么多的功能的计算!但是在开始我们运行使用程序的时候必须要知道我们要运用这些功能中的哪一个!这就要求我们可以程序中任意选择我们所需要的功能!很显然我们要编辑存储人员的信息自然要运用到文件!而人员的信息必须要以结构体的形式来表示才能够方便我们提取信息!我们选择了要运行的功能分支之后!这些功能是以主函数以外的被调函数!当有需要时被调函数还可以调用其他的被吊函数!例如我们题目中的统计和查询功能, 就可以用这种方式来编辑程序!方便清楚!设计:很显然主程序要用到SWICTH函数, 这样可以选择要运行的那个功能的函数来执行, 而其他的功能函数则不必运行!三、解题思路1.定义结构struct staff{char num[10];char name[20];char sex[10];int age;char title[20];char p_landscape[30];char Qualifications[30];int Service_time;char come_time[30];char category[30];}staff[100];2.主程序进入主菜单函数void main(){menu();}/*******************主菜单函数**********************/void menu(){char w0;do{system("cls");fflush(stdin); /*清除缓冲区输入*/puts("***********************高校人事管理系统**********************\n\n");puts("\t\t\t\t1)增加人员信息\n"); puts("\t\t\t\t2)删除人员信息 \n"); puts("\t\t\t\t3)查询人员信息\n"); puts("\t\t\t\t4)修改人员信息\n"); puts("\t\t\t\t5)统计人员信息\n"); puts("\t\t\t\t6)对人员排序\n");puts("\t\t\t\t7)保存人员信息\n"); puts("\t\t\t\t8)浏览人员信息\n"); puts("\t\t\t\t9)退出\n");printf("\t\t\t\t 请选择 [ ]\b\b"); w0=getchar();}while(w0<'1'||w0>'9'); switch(w0-48){case 1:add();break;case 2:delete_data();break;case 3:search();break;case 4:modify();break; case 5:stastic();break;case 6:sort();break;case 7:save();break;case 8:browse();break;case 9:break;} }(1)查询功能int search_data()/*{int i,flag; char s[30],w0;system("cls");/*清屏*/ n=load(); do{fflush(stdin); /*清除缓冲区输入*/printf(" 通过1)编号 2)姓名 [ ]\b\b"); w0=getchar(); }while(w0<'1'||w0>'2'); if(w0=='1'){/*按编号查找*/ flag=0;puts("输入人员编号:"); scanf("%s",s); for(i=0;i<n;i++){if(strcmp(s,staff[i].num)==0){printf_face();printf_one(staff[i]); flag=1;break;} else continue; }if(flag==0)puts("该人员不存在!"); }else {/*按姓名查找*/ flag=0;puts("输入人员姓名:"); scanf("%s",s); for(i=0;i<n;i++){if(strcmp(s,staff[i].name)==0){printf_face();printf_one(staff[i]);flag=1;break;}else continue;}if(flag==0) puts("该人员不存在!");}return i;void search(){int k;char w1;loop: k=search_data();do{fflush(stdin); /*清除缓冲区输入*/printf("1)回主菜单 2)退出 3)继续查询 [ ]\b\b"); w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')menu();else if(w1=='2')exit(0);void add(){char w0,w1;loop: system("cls");puts("请输入编号(如001):");scanf("%s",s.num);if(test(s.num))goto loop;/*编号重复*/puts("请输入姓名:");scanf("%s",);puts("请输入性别(男,女):");scanf("%s",s.sex);puts("请输入年龄:");scanf("%d",&s.age);puts("请输入职务(教授副教授讲师助教学生后勤人员):");scanf("%s",s.duty);puts("请输入职称 (无初级高级 ):");scanf("%s",s.title);puts("请输入政治面貌( 党员非党员 ):");scanf("%s",s.p_landscape);puts("请输入最高学历(小学初中高中大学硕士学位更高):");scanf("%s",s.Qualifications);puts("请输入任职时间:");scanf("%d",&s.Service_time);puts("请输入来院时间(如20050101):");scanf("%s",e_time);puts("请输入人员类别(行政人员教师一般员工退休人员临时工):");scanf("%s",s.category);do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');switch(w0){case 1:save(s);break;case 2:break;}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续增加人员信息 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')goto loop;else if(w1=='2')menu();else exit(0);}(3)保存信息void save(){char w0;save_all();printf("所有信息已保存!\n");do{fflush(stdin); /*清除缓冲区输入*/printf("1) 回主菜单 2) 退出 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1')menu();else exit(0);}void save_all()/*保存所有数据函数*/{int i;FILE *fp;if((fp=fopen("text.txt","wb"))==NULL){printf("无法打开文件!");exit(0);}for(i=0;i<n;i++){if(staff[i].age!=0)fprintf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",staff[i].num,staff[i].name, staff[i].sex,staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,sta ff[i].Qualifications,staff[i].Service_time,staff[i].come_time,staff[i].category );else continue;}fclose(fp);}(4)删除人员void delete_data(){int k; char w0,w1;loop: k=search_data();if(k<n){do{fflush(stdin); /*清除缓冲区输入*/printf("确认要删除该人员信息? 1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){staff[k].age=0;save_all();puts("该人员信息已被删除!");} } do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续删除数据 2)回主菜单 3)退出w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1') goto loop; else if(w1=='2')menu(); else exit(0); }(5)修改人员信息 void modify() {int k=0,w0,g; char h[30],w1,w2; loop: g=search_data(); if(g<n){ do{puts("\t\t\t 修改: 1)编号"); puts("\t\t\t 2)姓名"); puts("\t\t\t 3)性别"); puts("\t\t\t 4)年龄"); puts("\t\t\t 5)职务"); puts("\t\t\t 6)职称"); puts("\t\t\t 7)政治面貌"); puts("\t\t\t 8)最高学历"); puts("\t\t\t 9)任职时间"); puts("\t\t\t 10)来院时间"); puts("\t\t\t 11)人员类别"); printf(" 请选择 : [ ]\b\b"); scanf("%d",&w0);}while(w0<1||w0>11); switch(w0){case 1:puts("请输入新编号:");scanf("%s",h);strcpy(staff[g].num,h);break; case 2:puts("请输入姓名:");scanf("%s",h);strcpy(staff[g].name,h);break; case 3:puts("请输入性别:");scanf("%s",h);strcpy(staff[g].sex,h);break; case 4:puts("请输入年龄:");scanf("%d",&k);staff[g].age=k;break; case 5:puts("请输入职务:");scanf("%s",h);strcpy(staff[g].duty,h);break; case 6:puts("请输入职称:");scanf("%s",h);strcpy(staff[g].title,h);break;scanf("%s",h);strcpy(staff[g].p_landscape,h);break;case 8:puts("请输入最高学历:");scanf("%s",h);strcpy(staff[g].Qualifications,h);break;case 9:puts("请输入任职时间:");scanf("%d",&k);staff[g].Service_time=k;break;case 10:puts("请输入来院时间:");scanf("%s",h);strcpy(staff[g].come_time,h);break;case 11:puts("请输入人员类别:");scanf("%s",h);strcpy(staff[g].category,h);break;}do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)保存 2)否[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'2');if(w1=='1'){save_all(); puts("保存修改成功!");}}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续修改 2)回主菜单 3)退出[ ]\b\b");w2=getchar();}while(w2<'1'||w2>'3');if(w2=='1')goto loop;else if(w2=='2')menu();else exit(0);}(6)统计人员信息void stastic(){int i,count;char w0,w1;n=load();if(n==0){puts("没有数据!");getchar();menu();}loop: system("cls");do{fflush(stdin); /*清除缓冲区输入*/printf("通过1)在职人员 2)党员\n");printf(" 3)女工人数 4)最高学历 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'4');if(w0=='1'){/*统计在职人员*/printf_face();for(i=0,count=0;i<n&&staff[i].age;i++)if(strcmp(staff[i].category,"退休人员")!=0&&strcmp(staff[i].category,"临时工")!=0){count++; printf_one(staff[i]);} printf("\t\t\t\t 共有%d 条记录",count); }else if(w0=='2'){/*统计党员*/ printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].p_landscape,"党员count++; printf_one(staff[i]);} printf("\t\t\t\t 共有%d 条记录",count);}else if(w0=='3'){/*统计女工人员*/ printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].sex,"女")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t 共有%d 条记录",count);}else {/*统计高学历人员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].Qualifications,"硕士学位")==0||strcmp(staff[i].Qualifications,"更高")==0){count++; printf_one(staff[i]);} printf("\t\t\t\t 共有%d 条记录",count);} do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)继续统计 2)回主菜单 3)退出 [ ]\b\b"); w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1') goto loop; else if(w1=='2')menu(); else exit(0); }(6) 排序功能void sort() {int i,j;char w0,w1; struct staff s1; loop: n=load();system("cls"); do{fflush(stdin); /*清除缓冲区输入*/printf("通过 1)年龄 2)来院时间w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){/*按年龄排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(staff[i].age>staff[j].age){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}else {/*按来院时间排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(strcmp(staff[i].come_time,staff[j].come_time)>0){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}printf_face();for(i=0;i<n;i++) /*显示排序结果*/printf_one(staff[i]);do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)回主菜单 2)继续排序 3)退出[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') menu();else if(w1=='2')goto loop;else exit(0);}四、运行与测试报告*********************************高校人事管理系统******************************1)增加人员信息2)删除人员信息3)查询人员信息4)修改人员信息5)统计人员信息6)对人员排序7)保存人员信息8)浏览人员信息9)退出请选择【 1】请输入编号(如001):20071003335请输入姓名:majianbo请输入性别(男,女):nan请输入年龄:20请输入职务(教授副教授讲师助教学生后勤人员): jiaoshou请输入职称 (无初级高级 ):gaoji请输入政治面貌( 党员非党员 ):danyuan请输入最高学历(小学初中高中大学硕士学位更高): shuoshi请输入任职时间:20070901请输入来院时间(如20050101):20070901请输入人员类别(行政人员教师一般员工退休人员临时工): jiaoshi是否保存?1)是 2)否 [1]该信息已成功保存!1)继续增加人员信息 2)回主菜单 3)退出 [ ]程序:#include<stdlib.h>#include <stdio.h>#include <string.h>struct staff/*定义结构体*/{char num[10];/*编号*/char name[20];/*姓名*/char sex[10];/*性别*/int age;/*年龄*/char duty[20];/*职务*/char title[20];/*职称*/char p_landscape[30];/*政治面貌*/char Qualifications[30];/*学历*/int Service_time;/*任职时间*/char come_time[30];/*来院时间*/char category[30];/*人员类别*/}staff[100];struct staff s;int n;void menu();void printf_face()/*显示数据结构项目函数*/{printf("编号姓名性别年龄职务职称政治面貌学历任职时间来院时间人员类别\n");}void printf_one(struct staff p)/*输出单个数据函数*/{printf("%-4s%-7s%-5s%-3d%-7s%-5s%-8s%-12s%-5d%-12s%-3s\n",p.num,,p.se x,p.age,p.duty,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_tim e,p.category);}int load()/*加载函数*/{int i=0;FILE *fp;if((fp=fopen("text.txt","rb"))==NULL){return 0; exit(0);}for(i=0;!feof(fp);i++){ /*输出数据到结构体*/fscanf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",staff[i].num,staff[i].name,staff [i].sex,&staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,staff[i ].Qualifications,&staff[i].Service_time,staff[i].come_time,staff[i].category);} fclose(fp);return i;}int search_data()/*查找单个数据函数*/{int i,flag;char s[30],w0;system("cls");/*清屏*/n=load();do{fflush(stdin); /*清除缓冲区输入*/printf(" 通过1)编号 2)姓名 [ ]\b\b");w0=getchar(); }while(w0<'1'||w0>'2');if(w0=='1'){/*按编号查找*/flag=0;puts("输入人员编号:");scanf("%s",s);for(i=0;i<n;i++){if(strcmp(s,staff[i].num)==0){printf_face();printf_one(staff[i]);flag=1;break;}else continue;}if(flag==0)puts("该人员不存在!");}else {/*按姓名查找*/flag=0;puts("输入人员姓名:");scanf("%s",s);for(i=0;i<n;i++){if(strcmp(s,staff[i].name)==0){printf_face();printf_one(staff[i]);flag=1;break;}else continue;}if(flag==0) puts("该人员不存在!");}return i;}void save_all()/*保存所有数据函数*/{int i;FILE *fp;if((fp=fopen("text.txt","wb"))==NULL){printf("无法打开文件!");exit(0);}for(i=0;i<n;i++){if(staff[i].age!=0)fprintf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",staff[i].num,staff[i].name, staff[i].sex,staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,sta ff[i].Qualifications,staff[i].Service_time,staff[i].come_time,staff[i].category );else continue;}fclose(fp);}int test(char h[10])/*检查编号是否重复*/{int i;n=load();for(i=0;i<n;i++)if(strcmp(h,staff[i].num)==0){puts("输入的编号有重复!请重新输入编号!");system("pause");return 1;}return 0;}void single_save(struct staff p)/*保存单个数据函数*/{FILE *fp;if((fp=fopen("text.txt","ab+"))==NULL){printf("无法打开文件!");exit(0);}fprintf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",p.num,,p.sex,p.age,p.duty ,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_time,p.category);printf("该信息已成功保存!\n");fclose(fp);}/*********************************修改模块**********************************/ void modify(){int k=0,w0,g;char h[30],w1,w2;loop: g=search_data();if(g<n){do{puts("\t\t\t修改: 1)编号");puts("\t\t\t 2)姓名");puts("\t\t\t 3)性别");puts("\t\t\t 4)年龄");puts("\t\t\t 5)职务");puts("\t\t\t 6)职称");puts("\t\t\t 7)政治面貌");puts("\t\t\t 8)最高学历");puts("\t\t\t 9)任职时间");puts("\t\t\t 10)来院时间");puts("\t\t\t 11)人员类别");printf(" 请选择 : [ ]\b\b");scanf("%d",&w0);}while(w0<1||w0>11);switch(w0){case 1:puts("请输入新编号:");scanf("%s",h);strcpy(staff[g].num,h);break;case 2:puts("请输入姓名:");scanf("%s",h);strcpy(staff[g].name,h);break;case 3:puts("请输入性别:");scanf("%s",h);strcpy(staff[g].sex,h);break;case 4:puts("请输入年龄:");scanf("%d",&k);staff[g].age=k;break;case 5:puts("请输入职务:");scanf("%s",h);strcpy(staff[g].duty,h);break;case 6:puts("请输入职称:");scanf("%s",h);strcpy(staff[g].title,h);break;case 7:puts("请输入政治面貌:");scanf("%s",h);strcpy(staff[g].p_landscape,h);break;case 8:puts("请输入最高学历:");scanf("%s",h);strcpy(staff[g].Qualifications,h);break;case 9:puts("请输入任职时间:");scanf("%d",&k);staff[g].Service_time=k;break;case 10:puts("请输入来院时间:");scanf("%s",h);strcpy(staff[g].come_time,h);break;case 11:puts("请输入人员类别:");scanf("%s",h);strcpy(staff[g].category,h);break;}do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)保存 2)否[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'2');if(w1=='1'){save_all(); puts("保存修改成功!");}}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续修改 2)回主菜单 3)退出[ ]\b\b");w2=getchar();}while(w2<'1'||w2>'3');if(w2=='1')goto loop;else if(w2=='2')menu();else exit(0);}/************************保存模块******************************/void save(){char w0;save_all();printf("所有信息已保存!\n");do{fflush(stdin); /*清除缓冲区输入*/printf("1) 回主菜单 2) 退出 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1')menu();else exit(0);}/*************************查找模块*****************************/ void search(){int k;char w1;loop: k=search_data();do{fflush(stdin); /*清除缓冲区输入*/printf("1)回主菜单 2)退出 3)继续查询 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')menu();else if(w1=='2')exit(0);else goto loop;}/***************************增加模块*****************************/ void add(){char w0,w1;loop: system("cls");puts("请输入编号(如001):");scanf("%s",s.num);if(test(s.num))goto loop;/*编号重复*/puts("请输入姓名:");scanf("%s",);puts("请输入性别(男,女):");scanf("%s",s.sex);puts("请输入年龄:");scanf("%d",&s.age);puts("请输入职务(教授副教授讲师助教学生后勤人员):");scanf("%s",s.duty);puts("请输入职称 (无初级高级 ):");scanf("%s",s.title);puts("请输入政治面貌( 党员非党员 ):");scanf("%s",s.p_landscape);puts("请输入最高学历(小学初中高中大学硕士学位更高):");scanf("%s",s.Qualifications);puts("请输入任职时间:");scanf("%d",&s.Service_time);puts("请输入来院时间(如20050101):");scanf("%s",e_time);puts("请输入人员类别(行政人员教师一般员工退休人员临时工):");scanf("%s",s.category);do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');switch(w0-48){case 1:single_save(s);break;case 2:break;}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续增加人员信息 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')goto loop;else if(w1=='2')menu();else exit(0);}/*******************************删除模块*****************************/void delete_data(){int k; char w0,w1;loop: k=search_data();if(k<n){do{fflush(stdin); /*清除缓冲区输入*/printf("确认要删除该人员信息? 1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){staff[k].age=0;save_all();puts("该人员信息已被删除!");}}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续删除数据 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') goto loop;else if(w1=='2')menu();else exit(0);}/********************************统计模块*******************************/void stastic(){int i,count;char w0,w1;n=load();if(n==0){puts("没有数据!");getchar();menu();}loop: system("cls");do{fflush(stdin); /*清除缓冲区输入*/printf("通过1)在职人员 2)党员\n");printf(" 3)女工人数 4)最高学历 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'4');if(w0=='1'){/*统计在职人员*/printf_face();for(i=0,count=0;i<n&&staff[i].age;i++)if(strcmp(staff[i].category,"退休人员")!=0&&strcmp(staff[i].category,"临时工")!=0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}else if(w0=='2'){/*统计党员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].p_landscape,"党员")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}else if(w0=='3'){/*统计女工人员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].sex,"女")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}else {/*统计高学历人员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].Qualifications,"硕士学位")==0||strcmp(staff[i].Qualifications,"更高")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)继续统计 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') goto loop;else if(w1=='2')menu();else exit(0);}/*******************************排序模块***********************************/ void sort(){int i,j;char w0,w1;struct staff s1;loop: n=load();system("cls");do{fflush(stdin); /*清除缓冲区输入*/printf("通过 1)年龄 2)来院时间 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){/*按年龄排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(staff[i].age>staff[j].age){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}else {/*按来院时间排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(strcmp(staff[i].come_time,staff[j].come_time)>0){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}printf_face();for(i=0;i<n;i++) /*显示排序结果*/printf_one(staff[i]);do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)回主菜单 2)继续排序 3)退出[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') menu();else if(w1=='2')goto loop;else exit(0);}/********************************浏览模块**************************************/void browse(){int i;char w0;n=load();system("cls");printf_face();for(i=0;i<n ;i++)printf_one(staff[i]);printf("\t\t\t\t共有%d条人员记录\n",n);do{fflush(stdin); /*清除缓冲区输入*/printf(" 1)回主菜单 2)退出 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1') menu();if(w0=='2') exit(0);}/********************************主菜单函数*************************************/void menu(){char w0;do{system("cls");fflush(stdin); /*清除缓冲区输入*/puts("*********************************高校人事管理系统*******************************\n\n");puts("\t\t\t\t1)增加人员信息\n");puts("\t\t\t\t2)删除人员信息 \n");puts("\t\t\t\t3)查询人员信息\n");puts("\t\t\t\t4)修改人员信息\n");puts("\t\t\t\t5)统计人员信息\n");puts("\t\t\t\t6)对人员排序\n");puts("\t\t\t\t7)保存人员信息\n");puts("\t\t\t\t8)浏览人员信息\n");puts("\t\t\t\t9)退出\n");printf("\t\t\t\t请选择 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'9');switch(w0-48){case 1:add();break;case 2:delete_data();break;case 3:search();break;case 4:modify();break;case 5:stastic();break;case 6:sort();break;case 7:save();break;case 8:browse();break;case 9:break;}}/***********************************主函数****************************************/void main(){menu();}。
C语言课程设计之人事管理系统简介人事管理系统是一种用于管理组织内人员信息和管理人力资源的系统。
在本文档中,我们将介绍一个使用C语言编写的简单人事管理系统。
该系统可以实现员工信息的添加、删除、修改和查询,以及一些基本的人事管理功能。
功能模块1. 员工信息管理模块•添加员工信息:包括姓名、工号、职位、部门等基本信息。
•删除员工信息:根据工号删除指定员工的信息。
•修改员工信息:根据工号修改指定员工的信息。
•查询员工信息:可以根据姓名、工号等条件查询员工的信息。
2. 薪资管理模块•发放工资:根据员工的工作时长、加班情况等计算工资并发放。
•调整薪资:可以根据员工表现调整薪资水平。
3. 考勤管理模块•打卡记录:记录员工的上下班打卡情况。
•考勤统计:统计员工的出勤情况,包括迟到、早退、旷工等信息。
系统设计1. 数据结构•员工信息结构体:包括姓名、工号、职位、部门等信息。
•薪资结构体:包括基本工资、加班工资等信息。
•考勤记录结构体:包括打卡时间、出勤情况等信息。
2. 功能实现•员工信息管理:使用链表或数组存储员工信息,实现增删改查操作。
•薪资管理:根据员工的工作情况计算薪资并更新薪资信息。
•考勤管理:记录员工的打卡信息并统计考勤情况。
系统实现1. 界面设计•采用控制台界面,通过菜单选择实现各项功能。
•显示员工信息列表、薪资管理界面和考勤记录界面。
2. 代码实现•使用C语言实现各个功能模块,包括管理员工信息、计算薪资、记录考勤等。
•采用函数封装、模块化设计,提高代码的可读性和可维护性。
测试与验证1. 单元测试•对每个功能模块进行单元测试,确保功能的正确性。
•模拟各种情况,包括正常情况和异常情况。
2. 系统测试•综合测试所有功能模块,验证系统的完整性和稳定性。
•模拟真实使用情况,检查系统的性能和可靠性。
总结通过本文档的介绍,我们了解了一个简单的C语言编写的人事管理系统的设计思路和实现方法。
人事管理系统是组织管理中的重要系统之一,对于提高工作效率和管理人力资源具有重要意义。
《数据库应用》课程设计——人事管理系统(java源代码)//用户登陆类package classsource;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;public class Land extends JFrame{JFrame jf ;JTextField textName=new JTextField(); JPasswordField textage=new JPasswordField(); JLabel label = new JLabel("员工管理系统");JLabel labelName=new JLabel("用户名:");JLabel labelage=new JLabel("密码:");JButton buttonEnter=new JButton("登录");JButton buttoncancel=new JButton("清空");public Land(){jf=this;setTitle("登录");Font f = new Font("新宋体",Font.PLAIN,12); Container con = getContentPane();con.setLayout(null);label.setBounds(95,10,110,20);label.setFont(new Font("新宋体",Font.PLAIN,14));con.add(label);labelName.setBounds(45,40,55,20);labelName.setFont(f);con.add(labelName);textName.setBounds(95,40,120,20);con.add(textName);labelage.setBounds(45,70,45,20);con.add(labelage);labelage.setFont(f);textage.setBounds(95,70,120,20);con.add(textage);buttonEnter.setBounds(90,110,60,20);buttonEnter.setFont(f);con.add(buttonEnter);//登陆的鼠标监听buttonEnter.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent me){if(textName.getText().equals("")){new JOptionPane().showMessageDialog(null,"用户名不能为空!"); }else if(textage.getText().equals("")){new JOptionPane().showMessageDialog(null,"密码不能为空!"); }else{String sql="select * from UserInformation where User_Name = '" + textName.getText() + "' and Password = '" + textage.getText()+ "'";System.out.println(sql);Judge(sql);}}});buttoncancel.setBounds(155,110,60,20);buttoncancel.setFont(f);con.add(buttoncancel);//清空按钮的鼠标监听方法buttoncancel.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent me){textName.setText("");textage.setText("");}});setResizable(false);Image img=Toolkit.getDefaultToolkit().getImage("image\\main.gif");setIconImage(img);Toolkit t = Toolkit.getDefaultToolkit();int w = t.getScreenSize().width;int h = t.getScreenSize().height;setBounds(w/2-150,h/2-90,300,180);setVisible(true);}private void Judge(String sqlString) {if (Database.joinDB()) {if (Database.query(sqlString))try{if(Database.rs.isBeforeFirst()) {System.out.println("密码正确");jf.setVisible(false);.close();new Main();}else {System.out.println("错误");new JOptionPane().showMessageDialog(null,"用户名或密码错误!","",JOptionPane.ERROR_MESSAGE);}}catch(Exception ex) {System.out.println(ex.getMessage());}}else{System.out.println("连接数据库不成功");}}public static void main(String args[]){new Land();}}//主函数类,可以独立运行package classsource;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;public class Main extends JFrame implements Runnable{ Thread t=new Thread(this);JDesktopPane deskpane = new JDesktopPane();JPanel p = new JPanel();Label lp1=new Label("欢迎使用员工管理系统 !"); ImageIcon icon1=new ImageIcon("imagetjsc.gif"); ImageIcon icon2=new ImageIcon("imagecxdl.gif"); ImageIcon icon3=new ImageIcon("imagexgmm.gif"); ImageIcon icon4=new ImageIcon("imagetcxt.gif"); ImageIcon icon5=new ImageIcon("imagejj.gif"); ImageIcon icon6=new ImageIcon("imagehelp.gif"); ImageIcon icon7=new ImageIcon("imagecx.gif"); ImageIcon icon8=new ImageIcon("imagegl.gif");ImageIcon icon9=new ImageIcon("imagext.gif");ImageIcon icon10=new ImageIcon("imagexxgl.gif");ImageIcon icon11=new ImageIcon("imagexxcx.gif");ImageIcon icon12=new ImageIcon("imagebz.gif");ImageIcon icon13=new ImageIcon("imagegy.gif");ImageIcon icon14=new ImageIcon("imageglxx.gif");ImageIcon icon15=new ImageIcon("imagecxxx.gif");//完--------------------------------------------------------------------------------public Main(){setTitle("员工管理系统");Container con = getContentPane();con.setLayout(new BorderLayout());con.add(deskpane,BorderLayout.CENTER);Font f =new Font("新宋体",Font.PLAIN,12);JMenuBar mb = new JMenuBar();JMenu systemM = new JMenu("系统管理");systemM.setFont(f);JMenu manageM = new JMenu("信息管理");manageM.setFont(f);JMenu employeeMM = new JMenu("员工信息管理");employeeMM.setFont(f);JMenu selectM = new JMenu("信息查询");selectM.setFont(f);JMenu employeeSM =new JMenu("员工信息查询"); employeeSM.setFont(f);JMenu helpM = new JMenu("帮助");helpM.setFont(f);JMenu aboutM=new JMenu("关于");aboutM.setFont(f);JMenuItem password = new JMenuItem("密码修改"); password.setFont(f);JMenuItem land = new JMenuItem("重新登陆");land.setFont(f);JMenuItem addDelete = new JMenuItem("添加/删除用户"); addDelete.setFont(f);JMenuItem exit = new JMenuItem("退出系统");exit.setFont(f);systemM.add(password);systemM.add(land);systemM.add(addDelete);systemM.add(exit);//为系统管理菜单加事件password.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){System.out.println("AmendPassword");deskpane.add(new AmendPassword());}});land.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("Land");setVisible(false);new Land();}});addDelete.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ deskpane.add(new AddDeleteUser());}});exit.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){//new JOptionPane().showMessageDialog(setVisible(false);}});JMenuItem departmentM = new JMenuItem("部门信息管理"); departmentM.setFont(f);JMenuItem employeeM = new JMenuItem("基本信息管理"); employeeM.setFont(f);JMenuItem trainM = new JMenuItem("培训信息管理");trainM.setFont(f);JMenuItem encouragementPunishM = new JMenuItem("奖罚信息管理"); encouragementPunishM.setFont(f);JMenuItem wageM =new JMenuItem("薪资信息管理");wageM.setFont(f);employeeMM.add(trainM);employeeMM.add(employeeM);employeeMM.add(encouragementPunishM);employeeMM.add(wageM);manageM.add(employeeMM);manageM.add(departmentM);//为管理菜单加事件departmentM.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("Departmentmanage");deskpane.add(new Departmentmanage());}});employeeM.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("Employeemanage");deskpane.add(new Employeemanage());}});trainM.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("Trainmanage");deskpane.add(new Trainmanage());}});encouragementPunishM.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){System.out.println("EncouragementPunish");deskpane.add(new EncouragementPunish());}});wageM.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("WageManage");deskpane.add(new WageManage());}});JMenuItem departmentS = new JMenuItem("部门信息查询"); departmentS.setFont(f);JMenuItem employeeS = new JMenuItem("基本信息查询"); employeeS.setFont(f);JMenuItem trainS = new JMenuItem("培训信息查询");trainS.setFont(f);JMenuItem encouragementPunishS = new JMenuItem("奖罚信息查询"); encouragementPunishS.setFont(f);JMenuItem wageS =new JMenuItem("薪资信息查询");wageS.setFont(f);employeeSM.add(trainS);employeeSM.add(employeeS);employeeSM.add(encouragementPunishS);employeeSM.add(wageS);selectM.add(employeeSM);selectM.add(departmentS);//为查询菜单加事件departmentS.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("DIQ");deskpane.add(new DIQ());}});employeeS.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("BIQ");deskpane.add(new BIQ());}});trainS.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("TIQ");deskpane.add(new TIQ());}});encouragementPunishS.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){System.out.println("EPIQ");deskpane.add(new EPIQ());}});wageS.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("SIQ");deskpane.add(new SIQ());}});JMenuItem help = new JMenuItem("帮助");help.setFont(f);JMenuItem about =new JMenuItem("关于");about.setFont(f);helpM.add(help);aboutM.add(about);//为帮助菜单加事件about.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){deskpane.add(new About());}});mb.add(systemM);mb.add(manageM);mb.add(selectM);mb.add(helpM);mb.add(aboutM);setJMenuBar(mb);Image img=Toolkit.getDefaultToolkit().getImage("imagemain.gif"); setIconImage(img);systemM.setIcon(icon9);manageM.setIcon(icon8);selectM.setIcon(icon7);helpM.setIcon(icon6);addDelete.setIcon(icon1);land.setIcon(icon2);password.setIcon(icon3);exit.setIcon(icon4);employeeMM.setIcon(icon5);employeeSM.setIcon(icon5);departmentM.setIcon(icon10);departmentS.setIcon(icon11);help.setIcon(icon6);aboutM.setIcon(icon13);about.setIcon(icon13);employeeM.setIcon(icon14);trainM.setIcon(icon14); encouragementPunishM.setIcon(icon14); wageM.setIcon(icon14);employeeS.setIcon(icon15);trainS.setIcon(icon15); encouragementPunishS.setIcon(icon15); wageS.setIcon(icon15);JToolBar jToolBar1 = new JToolBar(); jToolBar1.setLayout(new GridLayout(9,1)); JButton jButton1 = new JButton();jButton1.setToolTipText("员工基本信息管理"); JButton jButton2 = new JButton();jButton2.setToolTipText("员工基本信息查询"); JButton jButton3 = new JButton();jButton3.setToolTipText("修改密码");JButton jButton5 = new JButton();jButton5.setToolTipText("计算器");JButton jButton6 = new JButton();jButton6.setToolTipText("退出系统");jToolBar1.setMaximumSize(new java.awt.Dimension(600, 50)); jToolBar1.setMinimumSize(new java.awt.Dimension(600, 50)); //添加工具栏中按钮的方法jButton1.setIcon(new ImageIcon("image1.png"));jButton1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("Employeemanage");deskpane.add(new Employeemanage());}});jToolBar1.add(jButton1);jButton2.setIcon(new ImageIcon("image2.png"));jButton2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){deskpane.add(new BIQ());}});jToolBar1.add(jButton2);jButton3.setIcon(new ImageIcon("image3.png"));jButton3.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){deskpane.add(new AmendPassword());}});jToolBar1.add(jButton3);jButton5.setIcon(new ImageIcon("image5.png"));jButton5.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.out.println("Calculator");deskpane.add(new Calculator());}});jToolBar1.add(jButton5);jButton6.setIcon(new javax.swing.ImageIcon("image6.png")); jButton6.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){System.exit(0);}});jToolBar1.add(jButton6);jToolBar1.setBounds(0, 0, 30, 600);jToolBar1.setEnabled(false);con.add(jToolBar1,BorderLayout.WEST);p.setLayout(new BorderLayout());p.add(lp1,BorderLayout.EAST);t.start();con.add(p,BorderLayout.SOUTH);Toolkit t = Toolkit.getDefaultToolkit();int width = t.getScreenSize().width - 200; int height = t.getScreenSize().height - 100; setSize(width,height);setLocation(150,100);setVisible(true);setResizable(false);}//线程的方法public void run(){System.out.println("线程启动了!");Toolkit t = Toolkit.getDefaultToolkit();int x=t.getScreenSize().width;System.out.println("x=" + x);lp1.setForeground(Color.red);while(true){if(x<-600){x=t.getScreenSize().width;}lp1.setBounds(x,0,700,20);x-=10;try{Thread.sleep(100);}catch(Exception e){} }}public static void main(String[] args){new Main();}}//数据库联接类package classsource;import java.sql.*;public class Database {public static Connection cn;public static Statement st;public static ResultSet rs;public static boolean joinDB() {boolean joinFlag;try {joinFlag = true;Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");cn =DriverManager.getConnection("jdbc:odbc:EmployeeInformationMS","sa"," ");cn.setCatalog("EmployeeInformationMS");System.out.println("数据库连接成功");st = cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);return joinFlag;} catch (SQLException sqlEx) {System.out.println(sqlEx.getMessage());joinFlag = false;return joinFlag;} catch (ClassNotFoundException notfoundEX) { System.out.println(notfoundEX.getMessage());joinFlag = false;return joinFlag;}}public static boolean executeSQL(String sqlString) { boolean executeFlag;try {st.execute(sqlString);executeFlag = true;} catch (Exception e) {executeFlag = false;System.out.println("sql exception:" + e.getMessage()); }return executeFlag;}public static boolean query(String sqlString) {try {rs = null;//System.out.println(sqlString);rs = st.executeQuery(sqlString);} catch (Exception Ex) {System.out.println("sql exception:" + Ex);return false;}return true;}}//添加删除用户类package classsource;import java.awt.event.*;import java.awt.*;import javax.swing.*;import java.sql.*;public class AddDeleteUser extends javax.swing.JInternalFrame { private JButton butACancel,butDCancel,butDelete,butOk;private JComboBox cbUserName;private JLabel jLabel1,jLabel2,jLabel3,jLabel4,jLabel5;private JPasswordField pas1,pas2,pas3;private JTextField txtname;public AddDeleteUser() {initComponents();this.setVisible(true);this.setClosable(true);this.setSize(268,350);}private void initComponents() { jLabel1 = new JLabel();jLabel2 = new JLabel();jLabel3 = new JLabel();txtname = new JTextField();pas1 = new JPasswordField();pas2 = new JPasswordField(); butOk = new JButton();butACancel = new JButton();jLabel4 = new JLabel(); cbUserName = new JComboBox(); jLabel5 = new JLabel();pas3 = new JPasswordField(); butDelete = new JButton(); butDCancel = new JButton(); getContentPane().setLayout(null); jLabel1.setText("新用户名:"); getContentPane().add(jLabel1); jLabel1.setBounds(30, 30, 70, 20); jLabel2.setText("输入密码:");getContentPane().add(jLabel2);jLabel2.setBounds(30, 60, 70, 18); jLabel3.setText("确认密码:"); getContentPane().add(jLabel3);jLabel3.setBounds(30, 90, 60, 18); getContentPane().add(txtname); txtname.setBounds(100, 30, 130, 24); getContentPane().add(pas1);pas1.setBounds(100, 60, 130, 24); getContentPane().add(pas2);pas2.setBounds(100, 90, 130, 24); butOk.setText("添加");getContentPane().add(butOk);butOk.setBounds(80, 130, 70, 27); butACancel.setText("清空"); getContentPane().add(butACancel); butACancel.setBounds(160, 130, 70, 27); jLabel4.setText("已有用户名:"); getContentPane().add(jLabel4);jLabel4.setBounds(30, 180, 80, 18); getContentPane().add(cbUserName); cbUserName.setBounds(100, 180, 130, 24); jLabel5.setText("密码:"); getContentPane().add(jLabel5);jLabel5.setBounds(30, 210, 60, 18);getContentPane().add(pas3);pas3.setBounds(100, 216, 130, 24);butDelete.setText("删除");getContentPane().add(butDelete);butDelete.setBounds(79, 260, 70, 27);butDCancel.setText("清空");getContentPane().add(butDCancel);butDCancel.setBounds(160, 260, 70, 27);//将所有用用户名读出来Database.joinDB();String sql="select * from UserInformation";try{if(Database.query(sql)){while(Database.rs.next()){String name=Database.rs.getString("User_Name");cbUserName.addItem(name);}}}catch(Exception e){}//为添加和取消按钮加事件----------------------------------------- butOk.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if(txtname.getText().equals("")){new JOptionPane().showMessageDialog(null,"用户名不能为空!");}else if(pas1.getText().equals("")){new JOptionPane().showMessageDialog(null,"密码不能为空!");}else if(pas1.getText().equals(pas2.getText())){String sql="insert UserInformation values('"+ txtname.getText() +"','"+ pas1.getText() +"','B')";try{if(Database.executeSQL(sql)){new JOptionPane().showMessageDialog(null,"添加成功!");cbUserName.addItem(txtname.getText());}}catch(Exception ea){}}}});butACancel.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){txtname.setText("");pas1.setText("");pas2.setText("");}});//为删除和取消按钮加事件--------------------------------------- butDelete.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){String name="" + cbUserName.getSelectedItem();String sql="select * from UserInformation where User_Name='"+ name +"'";try{if(Database.query(sql)){Database.rs.next();String pas=pas3.getText();String password=Database.rs.getString("Password");System.out.println(password);if(pas.equals(password)){String sdelete="delete from UserInformation where User_Name='"+ name +"'";if(Database.executeSQL(sdelete)){new JOptionPane().showMessageDialog(null,"删除成功!");pas3.setText("");cbUserName.removeAllItems();String sql1="select * from UserInformation";if(Database.query(sql1)){while(Database.rs.next()){Stringname1=Database.rs.getString("User_Name"); cbUserName.addItem(name1);}}}}else{new JOptionPane().showMessageDialog(null,"密码不正确!");}}}catch(Exception el){System.out.println(el);}}});butDCancel.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){pas3.setText("");}});}}//修改密码类package classsource;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;public class AmendPassword extends JInternalFrame { JLabel lbe1=new JLabel("修改密码");JPanel p=new JPanel();public AmendPassword(){setTitle("修改密码");p.add(lbe1);AmendPanel panel=new AmendPanel();Container contentPane=getContentPane(); contentPane.add(p,"North");contentPane.add(panel,"Center");setBounds(100, 100, 280, 260);this.setClosable(true);setVisible(true);}}class AmendPanel extends JPanel {JButton b1,b2;JLabel lbe2,lbe3,lbe4,lbe5; JPasswordField pas1,pas2,pas3; JComboBox tf;public AmendPanel(){lbe2=new JLabel("用户名:");lbe3=new JLabel("输入旧密码:"); lbe4=new JLabel("输入新密码:"); lbe5=new JLabel("确定新密码:"); tf=new JComboBox();pas1=new JPasswordField();pas2=new JPasswordField();pas3=new JPasswordField();b1=new JButton("确定");b2=new JButton("清空");add(lbe2);lbe2.setBounds(16,10,90,25); this.add(tf);tf.setBounds(100,10,120,25); add(lbe3);lbe3.setBounds(16,45,90,25);add(pas1);pas1.setBounds(100,45,120,25);add(lbe4);lbe4.setBounds(16,80,80,25);add(pas2);pas2.setBounds(100,80,120,25);add(lbe5);lbe5.setBounds(16,115,80,25);add(pas3);pas3.setBounds(100,115,120,25);add(b1);b1.setBounds(100,160,60,30);add(b2);b2.setBounds(160,160,60,30);setLayout(null);//将所有用用户名读出来Database.joinDB();String sql="select * from UserInformation";try{if(Database.query(sql)){while(Database.rs.next()){String name=Database.rs.getString("User_Name"); tf.addItem(name);}}}catch(Exception e){}//为确定取消按钮加事件b1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){String name="" + tf.getSelectedItem();System.out.println(name);String sql="select * from UserInformation where User_Name='"+ name +"'";System.out.println(sql);try{if(Database.query(sql)){Database.rs.next();String ps1=pas1.getText();String password=Database.rs.getString("Password");if(ps1.equals(password)){if(pas2.getText().equals(pas3.getText())){String supdate="update UserInformation set Password='"+pas3.getText()+"' where User_Name='"+ name +"'";Database.executeSQL(supdate);new JOptionPane().showMessageDialog(null,"密码更改成功!");}else{new JOptionPane().showMessageDialog(null,"两次密码不同!");}}else{new JOptionPane().showMessageDialog(null,"旧密码不正确!");}}}catch(Exception el){System.out.println(el);}}});b2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){pas1.setText("");pas2.setText("");pas3.setText("");}});}}//关于类package classsource;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class About extends JInternalFrame {JLabel label = new JLabel("运行环境:Windows");JLabel labe2 = new JLabel("开发语言:JAVA");JLabel labe3 = new JLabel("数据库类型:SqlServer2000"); public About(){setTitle("关于");Container con=getContentPane();con.setLayout(new GridLayout(4,1));con.add(label);con.add(labe2);con.add(labe3);con.setBackground(Color.white);setResizable(false);setSize(380,220);setVisible(true);setClosable(true);}}//员工信息查询类package classsource;import java.awt.*;import javax.swing.*;import javax.swing.table.*;import java.awt.event.*;import java.util.*;import javax.swing.JScrollPane.*;import java.sql.*;public class BIQ extends JInternalFrame{JLabel lbl1=new JLabel("基本信息查询");JLabel lbl2=new JLabel("员工编号:");JLabel lbl3=new JLabel("员工姓名:");JTextField btxtid=new JTextField(10);JTextField btxtname=new JTextField(10);JButton btn1=new JButton("查询");JTable table;DefaultTableModel dtm;String columns[] = {"员工编号","员工姓名"," 性别 ","出生日期","婚姻状况","政治面貌"," 学历 ","进入公司时间","转正时间"," 部门 "," 职务 ","员工状态"," 备注"};public BIQ(){setTitle("基本信息查询");dtm = new DefaultTableModel();table = new JTable(dtm);JScrollPane sl = new JScrollPane();sl.getViewport().add(table);dtm.setColumnCount(5);dtm.setColumnIdentifiers(columns); getContentPane().setLayout(null);lbl1.setBounds(240,10,300,30);lbl1.setFont(new Font("宋体",Font.BOLD,24)); getContentPane().add(lbl1);Font f=new Font("宋体",Font.PLAIN,12);lbl2.setBounds(10,60,80,25);lbl2.setFont(f);getContentPane().add(lbl2);btxtid.setBounds(80,60,80,23);btxtid.setFont(f);getContentPane().add(btxtid);lbl3.setBounds(10,90,80,25);lbl3.setFont(f);getContentPane().add(lbl3);btxtname.setBounds(80,90,80,23);btxtname.setFont(f);getContentPane().add(btxtname);btn1.setBounds(90,130,60,25);btn1.setFont(f);getContentPane().add(btn1);sl.setBounds(180,60,500,370);getContentPane().add(sl);//设置边框btxtid.setBorder(BorderFactory.createLineBorder(Color.black));btxtname.setBorder(BorderFactory.createLineBorder(Color.black));btn1.setBorder(BorderFactory.createRaisedBevelBorder());sl.setBorder(BorderFactory.createLineBorder(Color.black));//----连接数据库--------------------------------------------------------------------------Database.joinDB();String sql="select * from EmployeeInformation";if(Database.query(sql)){System.out.println(sql);try{while(Database.rs.next()){String eNumber=(""+Database.rs.getInt("E_Number"));System.out.println(eNumber);String eName=Database.rs.getString("E_Name");System.out.println(eName);String eSex=Database.rs.getString("E_Sex");System.out.println(eSex);String eBornDate=Database.rs.getString("E_BornDate");System.out.println(eBornDate);String eMarriage=Database.rs.getString("E_Marriage");System.out.println(eMarriage);StringePoliticsVisage=Database.rs.getString("E_PoliticsVisage"); System.out.println(ePoliticsVisage);String eSchoolAge=Database.rs.getString("E_SchoolAge"); System.out.println(eSchoolAge);String eEnterDate=Database.rs.getString("E_EnterDate"); System.out.println(eEnterDate);String eInDueFormDate=Database.rs.getString("E_InDueFormDate"); System.out.println(eInDueFormDate);String eDepartment=Database.rs.getString("E_Department"); System.out.println(eDepartment);String eHeadship=Database.rs.getString("E_Headship");System.out.println(eHeadship);String eEstate=Database.rs.getString("E_Estate");System.out.println(eEstate);String eRemark=Database.rs.getString("E_Remark");System.out.println(eRemark);Vector v=new Vector();v.add(eNumber);v.add(eName);v.add(eSex);v.add(eBornDate);v.add(eMarriage);v.add(ePoliticsVisage);v.add(eSchoolAge);v.add(eEnterDate);v.add(eInDueFormDate);v.add(eDepartment);v.add(eHeadship);v.add(eEstate);v.add(eRemark);dtm.addRow(v);}}catch(Exception eBIQ){System.out.println("初始化数据失败!");}}//为查询按钮加事件btn1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent eBIQ){ System.out.println("按钮事件");String esql;int rc=dtm.getRowCount();for(int i=0;i<rc;i++){dtm.removeRow(0);}if(btxtid.getText().equals("")&&btxtname.getText().equals("")){ esql="select * from EmployeeInformation";}else if(btxtname.getText().equals("")){esql="select * from EmployeeInformation where E_Number = '" + btxtid.getText() +"'";}else{esql="select * from EmployeeInformation where E_Number = '" + btxtid.getText() +"' or E_Name like '%"+ btxtname.getText() +"%'";}System.out.println(esql);if(Database.query(esql)){try{while(Database.rs.next()){String eNumber=(""+Database.rs.getInt("E_Number"));System.out.println(eNumber);String eName=Database.rs.getString("E_Name");System.out.println(eName);。
附录:毕业设计程序清单设计题目人事管理系统教学班:学生姓名:学号:指导教师:完成日期:Option ExplicitDim Bupdata As BooleanDim i As IntegerPrivate Sub Cmbdegree_Click()If Cmbdegree.Text = "定制" ThenFrmTable.ShowCmbdegree.ListIndex = 0End IfEnd SubPrivate Sub Cmbdepart_Click()If Cmbdepart.Text = "定制" ThenFrmTable.ShowCmbdepart.ListIndex = 0End IfEnd SubPrivate Sub CmdAddNew_Click()If CmdAddNew.Caption = "添加" ThenCmdAddNew.Caption = "确认"CmdDel.Enabled = FalseCmdOK.Enabled = FalseDataA.ReadOnly = FalseFor i = 1 To 12If Txt(i).Text = "" Then Txt(i).Text = 0 'DataA.Recordset.Fields(i) = 0Next iDataA.Recordset.AddNewTxt(0).Locked = FalseIf FrmMain.cutable = "employee" ThenDataA.Recordset.Fields(13) = frmLogin.EmploIDDataA.Recordset.Fields(14) = NowIf Opsex(0) ThenDataA.Recordset.Fields(4) = "男"ElseDataA.Recordset.Fields(4) = "女"End IfDataA.Recordset.Fields(7) = Cmbdegree.TextDataA.Recordset.Fields(8) = Cmbdepart.TextElseIf FrmMain.cutable = "leave" ThenDataA.Recordset.Fields(8) = frmLogin.EmploIDDataA.Recordset.Fields(9) = NowElseDataA.Recordset.Fields(13) = frmLogin.EmploIDDataA.Recordset.Fields(14) = NowEnd IfTxt(0).SetFocusElse 'OKIf Txt(0).Text = "" ThenMsgBox "不可以为空"Txt(0).SetFocusExit SubEnd IfFor i = 1 To 12If Txt(i).Text = "" Then Txt(i).Text = 0 'DataA.Recordset.Fields(i) = 0 Next iIf FrmMain.cutable = "employee" ThenDataB.Recordset.FindFirst "职工编号=" + Txt(0).TextIf Not DataB.Recordset.NoMatch ThenMsgBox "职员编号重复"Txt(0).Text = ""Txt(0).SetFocusExit SubEnd IfElseIf FrmMain.cutable = "leave" ThenDataB.Recordset.FindFirst "假条编号=" + Txt(0).TextIf Not DataB.Recordset.NoMatch ThenMsgBox "假条编号重复"Txt(0).Text = ""Txt(0).SetFocusExit SubEnd IfElseFor i = 4 To 10If Not IsNumeric(Txt(i).Text) ThenMsgBox "not a number"Txt(i).SetFocusExit SubEnd IfNext iDataB.Recordset.FindFirst "工资编号=" + Txt(0).TextIf Not DataB.Recordset.NoMatch ThenMsgBox "工资编号重复"Txt(0).Text = ""Txt(0).SetFocusExit SubEnd IfEnd IfDataA.Recordset.UpdateDataA.Recordset.MoveLastFrmMain.DataA.RefreshFrmMain.DataB.RefreshDataB.RefreshCmdAddNew.Caption = "添加"CmdDel.Enabled = TrueCmdOK.Enabled = TrueEnd IfEnd SubPrivate Sub CmdCacel_Click()If CmdAddNew.Caption = "确认" ThenDataA.Recordset.CancelUpdateEnd IfFrmMain.Enabled = TrueFrmMain.SetFocusUnload MeFrmMain.DataA.RefreshIf FrmMain.cutable = "employee" ThenFrmMain.DBGA.Columns("性别").Button = TrueFrmMain.DBGA.Columns("学历").Button = TrueFrmMain.DBGA.Columns("部门").Button = True End IfEnd SubPrivate Sub CmdDel_Click()DataA.ReadOnly = FalseDataA.Recordset.DeleteDataA.Recordset.MoveNextIf DataA.Recordset.EOF ThenDataA.Recordset.MoveLastEnd IfFrmMain.DataA.RefreshEnd SubPrivate Sub cmdOK_Click()If Txt(0).Text = "" ThenMsgBox "不可以为空"Txt(0).SetFocusExit SubEnd IfBupdata = FalseDataA.Recordset.EditIf FrmMain.cutable = "leave" ThenDataA.Recordset.Fields(8) = frmLogin.EmploIDDataA.Recordset.Fields(9) = NowElseIf FrmMain.cutable = "employee" ThenDataA.Recordset.Fields(13) = frmLogin.EmploIDDataA.Recordset.Fields(14) = NowIf Opsex(0) ThenDataA.Recordset.Fields(4) = "男"ElseDataA.Recordset.Fields(4) = "女"End IfDataA.Recordset.Fields(7) = Cmbdegree.TextDataA.Recordset.Fields(8) = Cmbdepart.TextDataA.Recordset.Fields(13) = frmLogin.EmploIDDataA.Recordset.Fields(14) = NowElseFor i = 4 To 10If Not IsNumeric(Txt(i).Text) ThenMsgBox "not a number"Txt(i).SetFocusExit SubEnd IfNext iDataA.Recordset.Fields(13) = frmLogin.EmploIDDataA.Recordset.Fields(14) = NowEnd IfFor i = 1 To 12If Txt(i).Text = "" Then Txt(i).Text = 0 'DataA.Recordset.Fields(i) = 0 Next iDataA.Recordset.UpdateFrmMain.DataA.RefreshDataB.RefreshEnd SubPrivate Sub DataA_V alidate(Action As Integer, Save As Integer)If Action = 11 And Bupdata ThenSave = 0End IfEnd SubPrivate Sub Lab_Click(Index As Integer)End SubPrivate Sub Txt_KeyPress(Index As Integer, KeyAscii As Integer)If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> vbKeyBack And Index = 0 Then KeyAscii = 0Exit SubEnd IfIf FrmMain.cutable = "leave" And Index = 1 ThenIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> vbKeyBack ThenKeyAscii = 0Exit SubEnd IfEnd IfIf FrmMain.cutable = "salary" ThenIf Index <= 3 ThenIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> vbKeyBack ThenKeyAscii = 0Exit SubEnd IfEnd IfIf Index = 13 Then Exit SubIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> vbKeyBack And KeyAscii <> 46 ThenKeyAscii = 0Exit SubEnd IfEnd IfEnd SubPrivate Sub Txt_change(Index As Integer)If Bupdata = False Then Bupdata = TrueIf FrmMain.cutable = "salary" ThenIf Txt(Index).Text = "" Then Exit SubIf Index >= 4 And Index <= 6 ThenTxt(7).Text = V al(Txt(4).Text) + V al(Txt(5).Text) + V al(Txt(6).Text)Txt(12).Text = V al(Txt(7).Text) - V al(Txt(11).Text)End IfIf Index >= 8 And Index <= 10 ThenTxt(11).Text = V al(Txt(8).Text) + V al(Txt(9).Text) + V al(Txt(10).Text)Txt(12).Text = V al(Txt(7).Text) - V al(Txt(11).Text)End IfEnd IfEnd SubPrivate Sub Form_Load()DataA.DatabaseName = App.Path + "\sm.mdb"DataB.DatabaseName = App.Path + "\sm.mdb"DataA.Caption = FrmMain.cutableDataA.RecordSource = "select * from " + FrmMain.cutableDataB.RecordSource = "select * from " + FrmMain.cutableDataA.RefreshTxt(0).Locked = True'If FrmMain.DBGA.Row = 0 Then Exit SubIf FrmMain.cutable = "employee" Then 'employeeFor i = 0 To 12Lab(i).Caption = DataA.Recordset.Fields(i).NameNext iTxt(0).DataField = DataA.Recordset.Fields(0).NameTxt(1).DataField = DataA.Recordset.Fields(1).NameTxt(2).DataField = DataA.Recordset.Fields(2).NameTxt(3).DataField = DataA.Recordset.Fields(3).NameTxt(4).V isible = FalseTxt(5).DataField = DataA.Recordset.Fields(5).NameTxt(6).DataField = DataA.Recordset.Fields(6).NameTxt(7).V isible = FalseTxt(8).V isible = FalseTxt(9).DataField = DataA.Recordset.Fields(9).NameTxt(10).DataField = DataA.Recordset.Fields(10).NameTxt(11).DataField = DataA.Recordset.Fields(11).NameTxt(12).DataField = DataA.Recordset.Fields(12).NameTxt(13).DataField = DataA.Recordset.Fields(15).NameIf FrmMain.cuAp > -1 ThenDataA.Recordset.Move (FrmMain.cuAp)ElseDataA.Recordset.MoveFirstEnd IfIf DataA.Recordset.Fields(4) = "男" ThenOpsex(0).V alue = TrueElseOpsex(1).V alue = TrueEnd If'设置lsdegree的显示项For i = 0 To FrmMain.LsDegree.ListCount - 2Cmbdegree.AddItem FrmMain.LsDegree.List(i)If FrmMain.LsDegree.List(i) = DataA.Recordset.Fields(7) ThenCmbdegree.ListIndex = iEnd IfNext iIf Cmbdegree.ListIndex = -1 ThenCmbdegree.AddItem DataA.Recordset.Fields(7)Cmbdegree.ListIndex = Cmbdegree.ListCount - 1End IfCmbdegree.AddItem "定制"'设置lsdepart的显示项For i = 0 To FrmMain.LsDepart.ListCount - 2Cmbdepart.AddItem FrmMain.LsDepart.List(i)If FrmMain.LsDepart.List(i) = DataA.Recordset.Fields(8) ThenCmbdepart.ListIndex = iEnd IfNext iIf Cmbdepart.ListIndex = -1 ThenCmbdepart.AddItem DataA.Recordset.Fields(8)Cmbdepart.ListIndex = Cmbdepart.ListCount - 1End IfCmbdepart.AddItem "定制"'设置完毕ElseIf FrmMain.cutable = "leave" Then 'leaveTxt(7).V isible = TrueCmbdegree.V isible = FalseCmbdepart.V isible = FalseFrame1.V isible = FalseFor i = 8 To 12Lab(i).Visible = FalseTxt(i).V isible = FalseNext iFor i = 0 To 7Lab(i).Caption = DataA.Recordset.Fields(i).NameTxt(i).DataField = DataA.Recordset.Fields(i).NameNext iTxt(13).DataField = DataA.Recordset.Fields(10).NameIf FrmMain.cuAp > -1 ThenDataA.Recordset.Move (FrmMain.cuAp)ElseDataA.Recordset.MoveFirstEnd IfElse 'salaryFrame1.V isible = FalseCmbdegree.V isible = FalseCmbdepart.V isible = FalseFor i = 0 To 12Lab(i).Caption = DataA.Recordset.Fields(i).NameTxt(i).DataField = DataA.Recordset.Fields(i).NameNext iTxt(13).DataField = DataA.Recordset.Fields(15).NameTxt(7).Locked = TrueTxt(11).Locked = TrueTxt(12).Locked = TrueIf FrmMain.cuAp > -1 ThenDataA.Recordset.Move (FrmMain.cuAp)ElseDataA.Recordset.MoveFirstEnd IfEnd IfEnd SubPrivate Sub Form_Unload(Cancel As Integer)FrmMain.Enabled = TrueFrmMain.SetFocusUnload MeFrmMain.DataB.RefreshEnd SubOption ExplicitConst MxUser = 100Public EmploID As IntegerPublic CurUser As StringPublic CurId As StringPublic CurPsw As StringDim user(MxUser), pws(MxUser), state(MxUser), Emplo(MxUser) As StringPrivate Sub Form_Load()Dim i As IntegerIf App.PrevInstance ThenMsgBox ("程序已经运行,不能再次装载。
#include "stdio.h" /*标准输入输出函数库*/#include "stdlib.h" /*标准函数库*/#include "string.h" /*字符串函数库*/#include "conio.h" /*屏幕操作函数库*/#define HEADER1 " -------------------------------RSDA---------------------------------------- \n"#define HEADER2 "| number| name | jbgz | jj | kk | yfgz | sk | sfgz | \n"#define HEADER3 "|--------|-----------|--------|--------|--------|--------|--------|--------| \n"#define FORMAT "|%-8s|%-10s |%8.2f|%8.2f|%8.2f|%8.2f|%8.2f|%8.2f| \n" #define DATA p->num,p->name,p->jbgz,p->jj,p->kk,p->yfgz,p->sk,p->sfgz#define END "---------------------------------------------------------------------------- \n"#define N 60int saveflag=0; /*是否需要存盘的标志变量*//*定义与职工有关的数据结构*/typedef struct employee /*标记为employee*/{char num[10]; /*职工编号*/char name[15]; /*职工姓名*/float jbgz; /*基本工资*/float jj; /*奖金*/float kk; /*扣款*/float yfgz; /*应发工资*/float sk; /*税款*/float sfgz; /*实发工资*/}RSDA;void menu() /*主菜单*/{system("cls"); /*调用DOS命令,清屏.与clrscr()功能相同*/printf(" The Employee Management System \n");printf("*************************Menu********************************\n");printf(" * 1 input record 2 delete record *\n");printf(" * 3 search record 4 modify record *\n");printf(" * 5 insert record 6 count record *\n");printf(" * 7 sort record 8 save record *\n");printf(" * 9 display record 0 quit system *\n");printf("*************************************************************\n");/*printf()送格式化输出至屏幕中*/}void printheader() /*格式化输出表头*/{printf(HEADER1);printf(HEADER2);printf(HEADER3);}void printdata(RSDA pp) /*格式化输出表中数据*/{RSDA* p;p=&pp;printf(FORMAT,DATA);}void Disp(RSDA tp[],int n) /*显示数组tp[]中存储的记录,内容为employee 结构中定义的内容*/{int i;if(n==0) /*表示没有职工工资记录*/{printf("\n=====>Not employee record!\n");while(getchar()!='\n')continue;getchar();}printf("\n\n");printheader(); /*输出表格头部*/i=0;while(i<n) /*逐条输出数组中存储的职工信息*/{printdata(tp[i]);i ;printf(HEADER3);}while(getchar()!='\n')continue;getchar();}void Wrong() /*输出按键错误信息*/{printf("\n\n\n\n\n***********Error:input has wrong! press any key to continue**********\n");while(getchar()!='\n')continue;getchar();}void Nofind() /*输出未查找到此职工的信息*/{printf("\n=====>Not find this employee record!\n");}/*************************************************************作用:用于定位数组中符合要求的记录,并返回保存该记录的数组元素下标值参数:findmess[]保存要查找的具体内容; nameornum[]保存按什么在数组中查找**************************************************************/int Locate(RSDA tp[],int n,char findmess[],char nameornum[]){int i=0;if(strcmp(nameornum,"num")==0) /*按职工编号查询*/{while(i<n)if(strcmp(tp[i].num,findmess)==0) /*若找到findmess值的职工编号*/return i;i ;}}else if(strcmp(nameornum,"name")==0) /*按职工姓名查询*/{while(i<n){if(strcmp(tp[i].name,findmess)==0) /*若找到findmess值的姓名*/ return i;i ;}}return -1; /*若未找到,返回一个整数-1*/}/*输入字符串,并进行长度验证(长度<lens)*/void stringinput(char *t,int lens,char *notice){char n[255];do{printf(notice); /*显示提示信息*/scanf("%s",n); /*输入字符串*/if(strlen(n)>lens) printf("\n exceed the required length! \n"); /*进行长度校验,超过lens值重新输入*/}while(strlen(n)>lens);strcpy(t,n); /*将输入的字符串复制到字符串t中*/}/*输入数值,0<=数值)*/float numberinput(char *notice){float t=0.00;do{printf(notice); /*显示提示信息*/scanf("%f",&t); /*输入如工资等数值型的值*/if(t<0) printf("\n score must >=0! \n"); /*进行数值校验*/}while(t<0);return t;}/*增加职工工资记录*/int Add(RSDA tp[],int n){char ch,num[10];int i,flag=0;system("cls");Disp(tp,n); /*先打印出已有的职工工资信息*/while(1) /*一次可输入多条记录,直至输入职工编号为0的记录结束添加操作*/ {while(1) /*输入职工编号,保证该编号没有被使用,若输入编号为0,则退出添加记录操作*/{stringinput(num,10,"input number(press '0'return menu):"); /*格式化输入编号并检验*/flag=0;if(strcmp(num,"0")==0) /*输入为0,则退出添加操作,返回主界面*/{return n;}i=0;while(i<n) /*查询该编号是否已经存在,若存在则要求重新输入一个未被占用的编号*/{if(strcmp(tp[i].num,num)==0){flag=1;break;}i ;}if(flag==1) /*提示用户是否重新输入*/{ getchar();printf("==>The number %s is existing,try again?(y/n):",num);scanf("%c",&ch);if(ch=='y'||ch=='Y')continue;elsereturn n;}else{break;}}strcpy(tp[n].num,num); /*将字符串num复制到tp[n].num中*/stringinput(tp[n].name,15,"Name:");tp[n].jbgz=numberinput("jbgz:"); /*输入并检验基本工资*/tp[n].jj=numberinput("jiangjin:"); /*输入并检验奖金*/tp[n].kk=numberinput("koukuan:"); /*输入并检验扣款*/tp[n].yfgz=tp[n].jbgz tp[n].jj-tp[n].kk; /*计算应发工资*/tp[n].sk=tp[n].yfgz*0.12; /*计算税金,这里取应发工资的12%*/tp[n].sfgz=tp[n].yfgz-tp[n].sk; /*计算实发工资*/saveflag=1;n ;}return n;}/*按职工编号或姓名,查询记录*/void Qur(RSDA tp[],int n){int select; /*1:按编号查,2:按姓名查,其他:返回主界面(菜单)*/char searchinput[20]; /*保存用户输入的查询内容*/int p=0;if(n<=0) /*若数组为空*/{system("cls");printf("\n=====>No employee record!\n");getchar();return;}system("cls");printf("\n =====>1 Search by number =====>2 Search by name\n"); printf(" please choice[1,2]:");scanf("%d",&select);if(select==1) /*按编号查询*/{stringinput(searchinput,10,"input the existing employee number:");p=Locate(tp,n,searchinput,"num");/*在数组tp中查找编号为searchinput 值的元素,并返回该数组元素的下标值*/if(p!=-1) /*若找到该记录*/{printheader();printdata(tp[p]);printf(END);printf("press any key to return");getchar();}elseNofind();getchar();}else if(select==2) /*按姓名查询*/{stringinput(searchinput,15,"input the existing employee name:");p=Locate(tp,n,searchinput,"name");if(p!=-1){printheader();printdata(tp[p]);printf(END);printf("press any key to return");getchar();}elseNofind();getchar();}elseWrong();getchar();}/*删除记录:先找到保存该记录的数组元素的下标值,然后在数组中删除该数组元素*/int Del(RSDA tp[],int n){int sel;char findmess[20];int p=0,i=0;if(n<=0){ system("cls");printf("\n=====>No employee record!\n");getchar();return n;}system("cls");Disp(tp,n);printf("\n =====>1 Delete by number =====>2 Delete by name\n"); printf(" please choice[1,2]:");scanf("%d",&sel);if(sel==1){stringinput(findmess,10,"input the existing employee number:");p=Locate(tp,n,findmess,"num");getchar();if(p!=-1){for(i=p 1;i<n;i ) /*删除此记录,后面记录向前移*/{strcpy(tp[i-1].num,tp[i].num);strcpy(tp[i-1].name,tp[i].name);tp[i-1].jbgz=tp[i].jbgz;tp[i-1].jj=tp[i].jj;tp[i-1].kk=tp[i].kk;tp[i-1].yfgz=tp[i].yfgz;tp[i-1].jbgz=tp[i].sk;tp[i-1].sfgz=tp[i].sfgz;}printf("\n==>delete success!\n");n--;getchar();saveflag=1;}elseNofind();getchar();}else if(sel==2) /*先按姓名查询到该记录所在的数组元素的下标值*/{stringinput(findmess,15,"input the existing employee name:");p=Locate(tp,n,findmess,"name");getchar();if(p!=-1){for(i=p 1;i<n;i ) /*删除此记录,后面记录向前移*/{strcpy(tp[i-1].num,tp[i].num);strcpy(tp[i-1].name,tp[i].name);tp[i-1].jbgz=tp[i].jbgz;tp[i-1].jj=tp[i].jj;tp[i-1].kk=tp[i].kk;tp[i-1].yfgz=tp[i].yfgz;tp[i-1].jbgz=tp[i].sk;tp[i-1].sfgz=tp[i].sfgz;}printf("\n=====>delete success!\n");n--;getchar();saveflag=1;}elseNofind();getchar();}return n;}/*修改记录:先按输入的职工编号查询到该记录,然后提示用户修改编号之外的值,编号不能修改*/void Modify(RSDA tp[],int n){char findmess[20];int p=0;if(n<=0){ system("cls");printf("\n=====>No employee record!\n");getchar();return ;}system("cls");printf("modify employee recorder");Disp(tp,n);stringinput(findmess,10,"input the existing employee number:"); /*输入并检验该编号*/p=Locate(tp,n,findmess,"num"); /*查询到该数组元素,并返回下标值*/if(p!=-1) /*若p!=-1,表明已经找到该数组元素*/{printf("Number:%s,\n",tp[p].num);printf("Name:%s,",tp[p].name);stringinput(tp[p].name,15,"input new name:");printf("jbgz:%8.2f,",tp[p].jbgz);tp[p].jbgz=numberinput("jbgz:");printf("jiangjin:%8.2f,",tp[p].jj);tp[p].jj=numberinput("jiangjin:");printf("koukuan:%8.2f,",tp[p].kk);tp[p].kk=numberinput("koukuan:");tp[n].yfgz=tp[n].jbgz tp[n].jj-tp[n].kk;tp[n].sk=tp[n].yfgz*0.12;tp[n].sfgz=tp[n].yfgz-tp[n].sk;printf("\n=====>modify success!\n");getchar();Disp(tp,n);getchar();saveflag=1;}else{Nofind();getchar();}return ;}/*插入记录:按职工编号查询到要插入的数组元素的位置,然后在该编号之后插入一个新数组元素。
C#实验报告(人事管理系统)学号149074353姓名程裕博班级物141指导教师夏敏安徽工业大学计算机学院2016年12月一.程序步骤先设置一个登录界面(连接数据库),登录时进行判断,根据不同的错误信息进行报错,如密码错误。
登陆成功后,进入主界面。
主界面通过树和表格来显示数据。
可以对人员,班组,部门进行增删改查操作,数据保存在数据库中。
二.程序源码1.数据库表结构2、登录界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using CCWin;using System.Data.SqlClient;namespace实验__人事管理系统{public partial class Form_login : CCSkinMain{public Form_login(){InitializeComponent();}string src = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\博博\documents\visual studio 2013\Projects\实验——人事管理系统\实验——人事管理系统\MyData.mdf;Integrated Security=True";private void Form1_Load(object sender, EventArgs e){}private void button_login_Click(object sender, EventArgs e){string user = this.skinTextBox.Text;string password = this.skinTextBox2.Text;int sign1 = 0;int sign2 = 0;if (user == "" || password == "")MessageBox.Show("您输入的数据不完整!");else{string sql1 = string.Format("select USERNAME from [Table_login] where USERNAME=N'{0}';", user);using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql1, coon);coon.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){sign1++;}}}if (sign1 == 0)MessageBox.Show("未查询到您的用户信息!");if (sign1 != 0){string sql2 = string.Format("select PASSWORD from [Table_login] where USERNAME=N'{0}';", user);using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql2, coon);coon.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){if (password == dr["PASSWORD"].ToString())sign2++;}}}}if (sign1 != 0 && sign2 == 0)MessageBox.Show("您的密码输入错误!");if (sign2 != 0){Form_show f1 = new Form_show(user, this);f1.Show();this.Visible = false;}}}}}3、主界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Timers;using System.Data.SqlClient;using CCWin;namespace实验__人事管理系统{public partial class Form_show : Form{public Form_show(){InitializeComponent();}public Form_show(string name1,Form_login f){login_name=name1;fl = f;InitializeComponent();}string login_name="xx";Form_login fl =null ;TreeNode t = new TreeNode();int ID=-1;public List<person> list = new List<person>();string name;string birth;string sex;string education;string adminisitrator;string manegetime;// string category_name;string src = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\博博\documents\visual studio 2013\Projects\实验——人事管理系统\实验——人事管理系统\MyData.mdf;Integrated Security=True";private void Form_show_Load(object sender, EventArgs e){toolStripStatusLabel_name.Text = "管理员:" + this.login_name; toolStripStatusLabel_time.Text = "登录时间:" +DateTime.Now.ToLongTimeString();Addparent();this.dataGridView1.ClearSelection();}private void toolStripStatusLabel_name_Click(object sender, EventArgs e) {}private void Form_show_FormClosed(object sender, FormClosedEventArgs e) {fl.Close();}public void Addparent(){string sql = "select * from [Table_tree] where PR_NUMBER=-1";using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql, coon);coon.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){string name = dr["NAME"].ToString();string number = dr["NUMBER"].ToString();// string category=dr["CATEGORY"].ToString();TreeNode tn = new TreeNode();tn.Text = name;tn.Tag = number;tn.ImageIndex = 1;AddChild(number, tn);treeView_jiegou.Nodes.Add(tn);// skinTreeView1.Nodes.Add(tn);}}}}private void AddChild(string pnumber, TreeNode pnode){if (Convert.ToInt32(pnode.Tag) == 0 || (pnode.Parent!=null &&Convert.ToInt32(pnode.Parent.Tag) == 0)){string sql = "select * from [Table_tree] where PR_NUMBER=" + pnumber + "order by NAME desc;";using (SqlConnection conn = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){string name = dr["NAME"].ToString();string number = dr["NUMBER"].ToString();// string category = dr["CATEGORY"].ToString();TreeNode tn = new TreeNode();tn.Text = name;tn.Tag = number;tn.ImageIndex = 1;AddChild(number, tn);pnode.Nodes.Add(tn);}}}}else{string sql = "select * from [Table_tree] where PR_NUMBER=" + pnumber + "order by NAME desc;";using (SqlConnection conn = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){string name = dr["NAME"].ToString();string number = dr["NUMBER"].ToString();// string category = dr["CATEGORY"].ToString();TreeNode tn = new TreeNode();tn.Text = name;tn.Tag = number;tn.ImageIndex = 0;AddChild(number, tn);pnode.Nodes.Add(tn);}}}}}private void skinButton_add_Click(object sender, EventArgs e)//无用的按钮{}private void skinButton_add_Click_1(object sender, EventArgs e){//MessageBox.Show("添加!");if (t.Parent.Parent!=null && t.Parent!=null){Form_Addperson fp = new Form_Addperson(t, toolStripStatusLabel_name.Text, DateTime.Now.ToString());fp.Owner = this;fp.Show();list.Clear();}elseMessageBox.Show("请到班组添加人员!");// reshow();}private void treeView_jiegou_AfterSelect(object sender, TreeViewEventArgs e){string sql = "select * from Table_person where CATEGORY_NUMBER="+ e.Node.Tag;List<person> list = new List<person>();using (SqlConnection conn = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){person p = new person();p.Person_name = dr["PERSON_NAME"].ToString();p.Category_name = dr["CATEGORY_NAME"].ToString();p.Sex = dr["SEX"].ToString();string []dt=dr["BIRTH"].ToString().Split(' ');p.Birth = dt[0];cation = dr["EDUCATION"].ToString();p.Adminisitrator = dr["ADMINISITRATOR"].ToString();p.Manegetime=dr["MANEGETIME"].ToString();list.Add(p);}}this.dataGridView1.ClearSelection();this.dataGridView1.DataSource = list;ID = -1;}}private void添加部门ToolStripMenuItem_Click(object sender, EventArgs e){if (t.Parent == null || t.Parent.Parent == null){Form_Add fa = new Form_Add(t);fa.Owner = this;fa.Show();}else{Form_Addperson fp = new Form_Addperson(t, toolStripStatusLabel_name.Text, DateTime.Now.ToString());fp.Owner = this;fp.Show();list.Clear();this.dataGridView1.DataSource = list;}}private void treeView_jiegou_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e){this.t = e.Node;// MessageBox.Show();}public void reshow(){treeView_jiegou.Nodes.Clear();Addparent();}private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) {//string name;//string birth;////string education;//string adminisitrator;//string manegetime;if (e.RowIndex != -1){name = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();birth = this.dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();education =this.dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();adminisitrator =this.dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();manegetime =this.dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();sex = this.dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();//MessageBox.Show(name+birth+education+adminisitrator+manegetime+sex);string sql = string.Format("select ID from Table_person wherePERSON_NAME=N'{0}' and BIRTH=N'{1}' and ADMINISITRATOR=N'{2}' and MANEGETIME=N'{3}'", name, birth, adminisitrator, manegetime);// MessageBox.Show(sql);using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql, coon);coon.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){ID = (int)dr["ID"];}}}}}private void skinButton_delete_Click(object sender, EventArgs e){if (ID != -1){string sql = "delete from Table_person where ID="+ID.ToString()+";";using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql,coon);coon.Open();int n=cmd.ExecuteNonQuery();if(n==1){MessageBox.Show("删除成功!");reshowview();reshow();}//foreach (person p in list)//{// if (p.Adminisitrator == adminisitrator && p.Birth == birth && p.Person_name == name && p.Manegetime == manegetime)// {// list.Remove(p);// }//}//this.dataGridView1.DataSource = list;}}else{MessageBox.Show("未选定行!");}}private void skinButton_rewrite_Click(object sender, EventArgs e){if (ID != -1){Form_rewrite fr = new Form_rewrite(name, sex, birth, education, toolStripStatusLabel_name.Text, manegetime, ID);fr.Owner = this;fr.Show();}elseMessageBox.Show("未选定行!");//list.Clear();// this.dataGridView1.DataSource=list;}private void skinButton1_search_Click(object sender, EventArgs e){string sql = "select * from Table_person where 1=1";List<person> list1 = new List<person>();// list1.Clear();if (this.textBox1.Text.Trim() != "")sql = sql + " and PERSON_NAME like N'%"+ this.textBox1.Text.Trim()+ "%'";if (this.textBox2.Text.Trim() != "")sql = sql + " and CATEGORY_NAME like N'%"+ this.textBox2.Text.Trim()+ "%'"; sql += ";";using (SqlConnection conn = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();using (SqlDataReader dr = cmd.ExecuteReader()){while (dr.Read()){person p = new person();p.Person_name = dr["PERSON_NAME"].ToString();p.Category_name = dr["CATEGORY_NAME"].ToString();p.Sex = dr["SEX"].ToString();string[] dt = dr["BIRTH"].ToString().Split(' ');p.Birth = dt[0];cation = dr["EDUCATION"].ToString();p.Adminisitrator = dr["ADMINISITRATOR"].ToString();p.Manegetime = dr["MANEGETIME"].ToString();list1.Add(p);}}this.dataGridView1.ClearSelection();this.dataGridView1.DataSource = list1;}}private void skinButton_reset_Click(object sender, EventArgs e){this.textBox1.Text = "";this.textBox2.Text = "";List<person> list1 = new List<person>();this.dataGridView1.DataSource = list1;}public void reshowview(){List<person> list1 = new List<person>();list1.Clear();this.dataGridView1.DataSource = list1;}private void删除部门ToolStripMenuItem_Click(object sender, EventArgs e) {Form_delete fm_delete = new Form_delete(t);fm_delete.Owner = this;fm_delete.Show();}private void修改单位ToolStripMenuItem_Click(object sender, EventArgs e) {Form_rename rename = new Form_rename(t, t.Text.ToString());rename.Owner = this;rename.Show();}}}4、人员类using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace实验__人事管理系统{public class person{private string person_name;public string Person_name{get { return person_name; }set { person_name = value; } }private string category_name;public string Category_name{get { return category_name; }set { category_name = value; } }private string birth;public string Birth{get { return birth; }set { birth = value; }}private string sex;public string Sex{get { return sex; }set { sex = value; }}private string education;public string Education{get { return education; }set { education = value; }}private string adminisitrator;public string Adminisitrator{get { return adminisitrator; }set { adminisitrator = value; }}private string manegetime;public string Manegetime{get { return manegetime; }set { manegetime = value; }}}}5、删除界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Data.SqlClient;using CCWin;namespace实验__人事管理系统{public partial class Form_delete : CCSkinMain{public Form_delete(){InitializeComponent();}public Form_delete(TreeNode node){InitializeComponent();this.t = node;}TreeNode t = new TreeNode();string src = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\博博\documents\visual studio 2013\Projects\实验——人事管理系统\实验——人事管理系统\MyData.mdf;Integrated Security=True";private void Form_delete_Load(object sender, EventArgs e){}private void skinButton_sure_Click(object sender, EventArgs e){if (t != null && t.Parent != null){if (t.Parent.Tag.ToString() == "0"){// /ox.Show(t.Tag.ToString()+":"+t.Text);string sql1 = "delete from Table_person where CATEGORY_NUMBERin(select NUMBER from Table_tree where PR_NUMBER in(select NUMBER from Table_tree where NAME=N'" + t.Text + "'));";// MessageBox.Show(sql1);using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql1, coon);coon.Open();int n = cmd.ExecuteNonQuery();// MessageBox.Show("您已经删除了" + n.ToString() + "条数据!");}string sql2 = "delete from Table_tree where PR_NUMBER in(select NUMBER from Table_tree where NAME=N'" + t.Text + "');";// MessageBox.Show(sql2);using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql2, coon);coon.Open();int n = cmd.ExecuteNonQuery();// MessageBox.Show("您已经删除了" + n.ToString() + "条数据!");}string sql3 = "delete from Table_tree where NAME=N'" + t.Text + "';";// MessageBox.Show(sql3);using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql3, coon);coon.Open();int n = cmd.ExecuteNonQuery();// MessageBox.Show("您已经删除了" + n.ToString() + "条数据!"); }}else{string sql4 = "delete from Table_person where CATEGORY_NUMBER ="+ t.Tag + ";";string sql5 = "delete from Table_tree where NUMBER =" + t.Tag + ";";// MessageBox.Show(sql4);using (SqlConnection coon = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql4, coon);coon.Open();int n = cmd.ExecuteNonQuery();// MessageBox.Show("您已经删除了" + n.ToString() + "条数据!");SqlCommand cmd1 = new SqlCommand(sql5, coon);int n1 = cmd1.ExecuteNonQuery();// MessageBox.Show("您已经删除了" + n.ToString() + "条数据!");}}}Form_show ff = new Form_show();ff = (Form_show)this.Owner;ff.reshow();this.Close();}private void skinButton_giveup_Click(object sender, EventArgs e){this.Close();}}}5、添加界面(部门,班组)using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using CCWin;using System.Data.SqlClient;namespace实验__人事管理系统{public partial class Form_Add : CCSkinMain{public Form_Add(){InitializeComponent();}public Form_Add(TreeNode t1){this.t = t1;InitializeComponent();}int ID;TreeNode t = new TreeNode();string src = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\博博\documents\visual studio 2013\Projects\实验——人事管理系统\实验——人事管理系统\MyData.mdf;Integrated Security=True";private void Form_Add_Load(object sender, EventArgs e){}private void skinButton_add_Click(object sender, EventArgs e){if (this.textBox_categoryname.Text != ""){string sql = ";";string sql1 = "select ID from Table_tree where ID=(select MAX(ID) from Table_tree);";using (SqlConnection conn = new SqlConnection(src)){SqlCommand cmd = new SqlCommand(sql1, conn);conn.Open();SqlDataReader dr = cmd.ExecuteReader();while (dr.Read()){ID = (int)dr["ID"];}// MessageBox.Show(ID.ToString());//MessageBox.Show("添加成功,数据库。
using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;namespace WebApplication1{public partial class WebForm1 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e) {Response.Redirect("~/登录.aspx");}protected void Button2_Click(object sender, EventArgs e) {Response.Redirect("~/人员信息查询.aspx");}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("~/人员修改.aspx");}protected void Button4_Click(object sender, EventArgs e) {Response.Redirect("~/部门信息.aspx");}protected void Button5_Click(object sender, EventArgs e) {Response.Redirect("~/工资信息.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class部门信息 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){bool find =false;SqlConnection con=new SqlConnection("server=localhost;Integrated Security=SSPI;database=人事管理系统");con.Open();string cmdstr="select * from 部门表";SqlDataAdapter da=new SqlDataAdapter(cmdstr,con);DataSet ds=new DataSet();da.Fill(ds);for(int i=0;i<ds.Tables[0].Rows.Count;i++){for(int j=0;j<ds.Tables[0].Columns.Count;j++){String data=(ds.Tables[0].Rows[i][j].ToString()).Trim();if(data==TextBox1.Text.Trim()){TextBox2.Text=ds.Tables[0] .Rows[i]["部门代码"].ToString();TextBox3.Text=ds.Tables[0] .Rows[i]["部门名称"].ToString();find=true;}}}if (find == false){Response.Write("<script>window.alert('没有有关记录!')</script>"); con.Close();}}protected void Button2_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;using System.Data.SqlTypes;namespace WebApplication1{public partial class_Default : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void TextBox1_TextChanged(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){SqlConnection con = new SqlConnection("server=localhost;IntegratedSecurity=SSPI;database=人事管理系统");string strCount;strCount = "select * from 人事表"; con.Open();SqlCommand com = new SqlCommand(strCount, con);SqlDataReader dr = com.ExecuteReader();string strUsername = "", strPassword = "";while (dr.Read()){if (TextBox1.Text == dr["编号"].ToString()||TextBox2.Text == dr["顾客密码"].ToString()){strUsername = dr["编号"].ToString();strPassword = dr["顾客密码"].ToString();break;}}dr.Close();con.Close();if (strUsername == ""){Response.Write("<script language=javascript>alert('登录成功!');</script>");return;}}protected void Button2_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class工资信息 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void TextBox2_TextChanged(object sender, EventArgs e){}protected void TextBox5_TextChanged(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){bool find = false;SqlConnection con = new SqlConnection("server=localhost;Integrated Security=SSPI;database=人事管理系统");con.Open();string cmdstr = "select * from 工资表";SqlDataAdapter da = new SqlDataAdapter(cmdstr, con);DataSet ds = new DataSet();da.Fill(ds);for (int i = 0; i < ds.Tables[0].Rows.Count; i++){for (int j = 0; j < ds.Tables[0].Columns.Count; j++){String data = (ds.Tables[0].Rows[i][j].ToString()).Trim();if (data == TextBox1.Text.Trim()){TextBox2.Text = ds.Tables[0].Rows[i]["应发工资"].ToString(); TextBox3.Text = ds.Tables[0].Rows[i]["岗位津贴"].ToString(); TextBox4.Text = ds.Tables[0].Rows[i]["奖励"].ToString();TextBox5.Text = ds.Tables[0].Rows[i]["保险"].ToString();find = true;}}}if (find == false){Response.Write("<script>window.alert('没有有关记录!')</script>");con.Close();}}protected void Button2_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class人员信息 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}protected void Button2_Click(object sender, EventArgs e){bool find =false;SqlConnection con = new SqlConnection("server=localhost;Integrated Security=SSPI;database=人事管理系统");con.Open();string cmdstr="select * from 工资表";SqlDataAdapter da=new SqlDataAdapter(cmdstr,con);DataSet ds=new DataSet();da.Fill(ds);for(int i=0;i<ds.Tables[0].Rows.Count;i++){for(int j=0;j<ds.Tables[0].Columns.Count;j++){String data=(ds.Tables[0].Rows[i][j].ToString()).Trim();if(data==TextBox1.Text.Trim()){TextBox2.Text=ds.Tables[0] .Rows[i]["应发工资"].ToString();TextBox3.Text=ds.Tables[0] .Rows[i]["岗位津贴"].ToString();TextBox4.Text=ds.Tables[0] .Rows[i]["奖励"].ToString();TextBox5.Text = ds.Tables[0].Rows[i]["保险"].ToString();find=true;}}}if (find == false){Response.Write("<script>window.alert('没有有关记录!')</script>"); con.Close();}}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class人员修改 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void TextBox5_TextChanged(object sender, EventArgs e){}protected void Button2_Click(object sender, EventArgs e){SqlConnection con=new SqlConnection("server=localhost;IntegratedSecurity=SSPI;database=人事管理系统");con.Open();string insert="insert into 人事表(员工号,姓名,性别,职称,学历) values("+""+ TextBox1.Text.Trim() +""+","+"" + TextBox2.Text.Trim() +""+","+ TextBox3.Text.Trim() + "," +""+ TextBox4.Text.Trim() +""+","+"" +TextBox5.Text.Trim() + ""+")";Response.Write(insert);SqlCommand cmd1=new SqlCommand(insert,con);con.Close();}protected void Button1_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) {}}}。
人事管理系统一.系统需求分析: (2)(1)系统的功能设计 (2)(2)系统功能结构 (2)(3)数据库设计 (2)二.功能模块开发 (3)(1)查询人员信息界面 (3)(2)添加员工界面 (3)(3)修改员工信息界面 (4)(4)删除员工界面 (5)(5)员工考核界面 (5)(6)员工考核历史记录界面 (6)三.各个类说明 (6)四.程序代码 (9)(1)Manager (9)(2)CardEmploy (11)(3)SelEmploy (12)(4)AddEmploy (14)(5)ReviseEmploy (16)i UpdDialog (18)(6)DelEmploy (21)(7)AllEmploy (23)(8)Examine (23)(9)History (27)(10)EmployModel (29)(11)AppraisalModel (30)(12)SqlHelper (33)一.系统需求分析:(1)系统的功能设计i员工信息管理:员工信息管理包括对员工基本信息和情况进行查询、添加、删除和修改及部门管理ii员工考核管理:包括对员工的考核情况进行操作,还可以对历史考核情况进行浏览(2)系统功能结构人事管理的系统结构功能结构如图所示:(3)数据库设计考核历史记录(History)二. 功能模块开发(1)查询人员信息界面实例一个SelEmploy类,当点击“查询”时调用EmployModel类的queryEmploy方法实现查询(2)添加员工界面实例一个AddEmploy类当点击“添加”时调用EmployModel 类的updEmploy方法实现添加功能(3)修改员工信息界面实例一个ReviseEmploy类当点击“修改”时,先调用UpdDialo弹跳出一个修改信息对话框,信息修改完毕后,调用EmployModel类的updEmploy方法实现修改功能(4)删除员工界面实例一个DelEmploy类当点击“删除”时调用EmployModel类的updEmploy方法实现删除功能(5)员工考核界面实例一个Examine类当点击“确认”时调用AppraisalModel类的updAppraisal方法来完成考核功能(6)员工考核历史记录界面实例一个History类当点击时调用AppraisalModel类的updAppraisal方法来完成考核功能三.各个类说明类之间的关系图:1.M anager类Manager类的一个实例,从而生成了人事管理系统的界面,用JSplitPane类将整个界面分为左右两个部分。
附录:源程序代码1).default.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head id="Head1" runat="server"><title>无标题页</title><style type="text/css">#form1{height: 213px;}.style2{width: 100%;height: 211px;}.style6{width: 99px;}.style3{text-align: center;}</style></head><body bgcolor="#ccffcc"><form id="form1" runat="server"><table class="style2"><tr><td class="style4" colspan="2"><span class="Apple-style-span"style="color: rgb(0, 0, 0); font-family: 楷体_GB2312; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust:auto; -webkit-text-stroke-width: 0px; ">人事信息管理系统</span></td><td rowspan="5"><img alt="" src="images/4ce6a7a5e39e3e49156444f3e340dc21.jpg"style="width: 853px; height: 193px" /> </td></tr><tr><td class="style6">用户名:</td><td class="style3"><asp:TextBox ID="TextBox1" runat="server" Height="22px" Width="128px"></asp:TextBox></td></tr><tr><td class="style6">用户密码:</td><td class="style3"><asp:TextBox ID="TextBox2" runat="server" Height="22px" TextMode="Password"Width="128px"></asp:TextBox></td></tr><tr><td class="style5" colspan="2"><asp:CheckBox ID="CheckBox1" runat="server" Text="记住用户" /> </td></tr><tr><td class="style3" colspan="2"><asp:Button ID="Button1" runat="server" Height="31px" onclick="Button1_Click"style="text-align: center" Text="登录" Width="50px" /></td></tr></table></form></body></html>2)Default.aspx.csusing System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.OleDb;public partial class Default2 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){this.Title = "学生信息管理系统-----登录";}protected void Button1_Click(object sender, EventArgs e){OleDbConnection conn = new OleDbConnection();string Id = TextBox1.Text;conn.ConnectionString = "provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/student.mdb");string StrSel = "Select * from message where id='" + TextBox1.Text + "'and pwd='" + TextBox2.Text + "'";conn.Open();OleDbCommand com = new OleDbCommand(StrSel, conn);OleDbDataReader dr = com.ExecuteReader();dr.Read();if (dr.HasRows){Session["pass"] = TextBox1.Text;Server.Transfer("glxt.aspx");Response.Redirect("glxt.aspx");}else{Response.Redirect("Default.aspx");}conn.Close();}}3)Glxt.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="glxt.aspx.cs" Inherits="glxt" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head id="Head1" runat="server"><title>无标题页</title><style type="text/css">body {margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;background-color:#CCFFCC;}.STYLE1 {font-size: 12px;color: #FFFFFF;}.STYLE3 {font-size: 12px;color: #033d61;text-decoration:none;background-image:login_2.jpg;}#left{float:left;width:177px;}.STYLE4{float:left;clear:right;width:804px;background-image:content_1.jpg;height: 1032px;}.style2{width: 788px;height: 23px;}.style3{width: 817px;}.style4{height: 26px;}.style5{height: 91px;}p.p0{margin:0pt;margin-bottom:0.0001pt;margin-bottom:0pt;margin-top:0pt;text-align:justify;font-size:10.5000pt; font-family:'Times New Roman'; }.style6{width: 285px;height: 43px;}.style7{width: 100px;height: 43px;}.style9{width: 6px;}#form1{height: 307px;width: 1321px;}.style10{height: 43px;}</style></head><body bgcolor="White" ><form id="form1" runat="server"><div><table border="0" cellpadding="0" cellspacing="0"style="height: 303px; width: 130px"><tr><td height="70"><table bgcolor="#CCFFCC" border="0" cellpadding="0" cellspacing="0"width="100%"><tr><td bgcolor="White" class="style5"><table border="0" cellpadding="0" cellspacing="0"style="height: 265px; width: 1141px;"><tr><td bgcolor="White" style="width: 291px" width="270"><img alt="" src="images/6b5f60fc09e584574192f873acda8d85.jpg"style="width: 1392px; height: 252px; margin-top: 0px;" /><span class="STYLE3"><tableborder="0" cellpadding="0" cellspacing="0"style="height: 47px; width: 1389px;"><trbgcolor="#CCFFCC"><td class="style6" bgcolor="#CCFFCC"><spanclass="STYLE3"> <asp:Label ID="Label2" runat="server"></asp:Label><br /> <asp:Label ID="Label1" runat="server"></asp:Label></span></td><td class="style7" bgcolor="#CCFFCC"><spanclass="STYLE3"><asp:LinkButton ID="LinkButton6" runat="server" onclick="LinkButton6_Click"Font-Size="Large" Height="26px" Width="93px"><spanclass="style3">公司简介</span></spanclass="style3"></asp:LinkButton></span></td><tdclass="style10"><asp:LinkButton ID="LinkButton7" runat="server" onclick="LinkButton7_Click"Font-Size="Large" Height="26px" Width="72px"><spanclass="style3">信息查询</span></spanclass="style3"></asp:LinkButton><asp:LinkButton ID="LinkButton18" runat="server" onclick="LinkButton18_Click"Font-Size="Large" Height="26px" Width="80px"><spanclass="style3">信息修改</spanclass="style3"></asp:LinkButton><asp:LinkButton ID="LinkButton20" runat="server" Font-Size="Large"Height="26px" PostBackUrl="add.aspx" Width="80px" onclick="LinkButton20_Click">添加信息</asp:LinkButton><asp:LinkButton ID="LinkButton17" runat="server" onclick="LinkButton17_Click"Font-Size="Medium" Height="26px" Width="100px" style="margin-left: 108px">密码修改</asp:LinkButton> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default.aspx"Font-Size="Medium" Height="26px" Width="91px">退出</asp:HyperLink></td></tr></table></span></td></tr></table></td></tr><tr><td height="8" style="line-height: 8px;"> </td></tr></table></td></tr></table></div><div id="left"><table border="0" cellpadding="0" cellspacing="0" height="100%" width="165"> <tr><td height="28"><table border="0" cellpadding="0" cellspacing="0" width="100%"bgcolor="#CCFFCC"><tr><td width="19%"><spanclass="STYLE3"> <br /><br /></span></td></tr></table></td></tr><tr><td valign="top"><table align="center" bgcolor="White" border="0" cellpadding="0"cellspacing="0" width="151"><tr><td><table border="0" cellpadding="0" cellspacing="0"style="width: 118%; height: 379px"><tr><td height="23" bgcolor="#CCFFCC"><table border="0" cellpadding="0" cellspacing="0" width="100%"bgcolor="#CCFFCC"><tr><td class="style9"> </td><td class="STYLE3" width="82%"><tablealign="center" border="0" cellpadding="0" cellspacing="0"width="90%"style="height: 217px" bgcolor="#CCFFCC"><tr><td height="25"><div align="center"></div></td><td height="23" width="84%"><table border="0" cellpadding="0" cellspacing="0" style="width: 95%"><tr><td height="20"> </td></tr></table></td></tr><tr><td height="23"><div align="center"></div></td><td height="23"><table border="0" cellpadding="0" cellspacing="0"style="height: 40px; width: 122%"><tr><td height="20"> </td></tr></table></td></tr><tr><td height="23"><div align="center"></div></td><td height="23"><table border="0" cellpadding="0" cellspacing="0" width="95%"><tr><td height="20"> </td></tr></table></td></tr><tr><td height="23"><div align="center"></div></td><td height="23"><table border="0" cellpadding="0" cellspacing="0" width="95%"><tr><td height="20"></span></td></tr></table></td></tr></table><br /><br /><br /><br /><br /><br /><br /><br /></td></tr></table></td></tr><tr><td id="submenu1" bgcolor="#CCFFCC"><div class="sec_menu"></div></td></tr></table></td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="23" bgcolor="#CCFFCC"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="18%"> </td><td class="STYLE1" width="82%"><div align="center" style="width: 149px"></div></td></tr></table></td></tr><tr><td id="submenu2" bgcolor="#CCFFCC"><div></div></td></tr></table></td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" style="width: 118%"><tr><td height="23" bgcolor="#CCFFCC"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="18%"> </td><td class="STYLE1" width="82%"> </td></tr></table></td></tr><tr><td bgcolor="#CCFFCC"><div><asp:Panel ID="Panel3" runat="server"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><tablealign="center" border="0" cellpadding="0" cellspacing="0" width="90%"><tr><td height="25" style="width: 100%" width="16%"><div align="center"></div><table border="0" cellpadding="0" cellspacing="0" width="95%"><tr><td height="20"> </td></tr></table></td></tr></table></td></tr></table></asp:Panel></div></td></tr><tr><td class="style4" bgcolor="#CCFFCC"></td></tr><tr><td bgcolor="#CCFFCC"><div><table border="0" cellpadding="0" cellspacing="0" style="width: 100%"><tr><asp:Panel ID="Panel4" runat="server"><td><tablealign="center" border="0" cellpadding="0" cellspacing="0" width="90%"><tr><td height="25" width="16%"><div align="center"></div></td><td height="23" width="84%"><table border="0" cellpadding="0" cellspacing="0" width="95%"><tr><td height="20"><asp:LinkButton ID="LinkButton15" runat="server"><span class="STYLE3"></span></asp:LinkButton></td></tr></table></td></tr><tr><td height="23"><div align="center"></div></td><td height="23"><table border="0" cellpadding="0" cellspacing="0" width="95%"><tr><td height="20"><asp:LinkButton ID="LinkButton16" runat="server"><span class="STYLE3">登录记录</span></asp:LinkButton></td></tr></table></td></tr></table></td></asp:Panel></tr><tr><td height="5"> </td></tr></table></div></td></tr></table></td></tr></table></td></tr></table></div><div class="STYLE4"><asp:Panel ID="Panel5" runat="server" BackColor="#CCFFCC"><table bgcolor="Gray"><tr><td bgcolor="White" class="style3"><table><tr><td bgcolor="White" class="style2"><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman'; "> xx<font face="宋体">商贸有限公司是国家外经贸局,海关总署批注的有进出口权的公司,公司有雄厚的经济基础,强大的关系网络,完备的技术和人员配置,随着我国加入</font><fontface="Times New Roman">WTO</font><font face="宋体">,进出口贸易的日益增长,为了进一步满足贸易商、进出口商的需求,我公司为商家精心打造了门到门的一站式服务。
急需一个公司的人事管理系统源代码(vc++编程)悬赏分:100 |解决时间:2008-1-8 09:58 |提问者:klak1某小型公司,主要有两类人员:经理、员工。
现在,需要存储这些人员的姓名、编号、身份证号码、业绩、级别(经理包括总经理、经理、副经理级别,员工包括高级员工、普通员工和临时工级别)、家庭住址、开始工作日期、所在部门、薪水等信息,并可以对这些信息进行检索。
要求:1)人员编号在生成人员信息时同时生成,每输入一个人员信息编号顺序加1;2)根据业绩的大小具有自动升降级别的功能;3)输入员工身份证号码号码后自动获取员工生日;4)输入员工开始工作日期后自动获取员工工龄;5)能按姓名或者编号显示、查找、增加、删除和保存各类人员的信息最佳答案#include <iostream.h>#include <iomanip.h>#include <string.h>#include <fstream.h>const int Maxr=100;class Employee //职工类{int tag;//删除标记int no;//职工编号char name[20];char zw[20];//职工姓名int salary;//职工工资public:Employee(){}char *getname() {return name;}//获取名字int gettag() {return tag;}//获取标记int getno() {return no;}//获取编号int getsalary(){return salary;}void setzw(char q[])//设置名字{strcpy(zw,q);}void setname(char na[])//设置名字{strcpy(name,na);}void getsalary(int sa){salary=sa;}void delna(){tag=1;}//删除void addemp(int n,int sa,char *na,char *q)//增加{tag=0;no=n;salary=sa;strcpy(name,na);strcpy(zw,q);}void disp()//显示职工信息{cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<salary <<"│"<<setw(10)<<zw<<"│"<<endl;cout<<"├—————┼—————┼—————┼—————┤"<<endl;}};class Database//职工数据类{int top;Employee read[Maxr];public:Database()//将职工信息从employee.txt读取到read[]中{ Employee s;top=-1;fstream file("employee.txt",ios::in);while (1){file.read((char *)&s,sizeof(s));if (!file) break;top++;read[top]=s;}file.close();}void clear()//删除所有top=-1;}int addemp (int n, int sa,char *na,char*q) //增加职工{Employee *p=query(n);if (p==NULL){top++;read[top].addemp(n,sa,na,q);return 1;}return 0;}Employee *query(int empid){for (int i=0;i<=top;i++)if (read[i].getno()==empid && read[i].gettag()==0) return &read[i];return NULL;}Employee *query1(char empna[20]){for (int i=0;i<=top;i++)if ((read[i].getname()==empna) && read[i].gettag()==0) return &read[i];return NULL;}void disp() //职工信息显示{for (int i=0;i<=top;i++)read[i].disp();}void empdata();~Database() //将read[]中的信息读如到employee.txt中{fstream file("employee.txt",ios::out);for (int i=0;i<=top;i++)if (read[i].gettag()==0)file.write((char *)&read[i],sizeof(read[i]));file.close();}void Database::empdata()//职工维护{int choice=1;int m=1;int b=1;char rname[20];int empid; int empsa;char q[20];Employee *r;while (choice!=0){cout<<"职工维护1:新增2:更改3:删除4:查找5:显示6:全删0:退出=>";cin>>choice;switch (choice){case 1:cout<<setw(50)<<" ┌—————————————┐\n";cout<<setw(50)<<" │ 请选择您所需的操作│\n";cout<<setw(50)<<" │ 经理:1,并按回车键│\n";cout<<setw(50)<<" │ 业务经理:2,并按回车键│\n";cout<<setw(50)<<" │ 普通职工:3,并按回车键│\n";cout<<setw(50)<<" └—————————————┘\n";cin>>m;while(m!=0){switch(m){case 1:cout<<"输入经理编号:";cin>>empid;cout<<"输入奖金: ";cin>>empsa;cout<<"输入经理姓名:";cin>>rname;addemp(empid,8000+empsa,rname,"经理");break;case 2:cout<<"输入业务经理编号:";cin>>empid;cout<<"输入月提成: ";cin>>empsa;cout<<"输入业务经理姓名:";cin>>rname;addemp(empid,4000+empsa,rname,"业务经理"); break;case 3:cout<<"输入职工编号:";cin>>empid;cout<<"输入工资: ";cin>>empsa;cout<<"输入职工姓名:";cin>>rname;addemp(empid,empsa,rname,"普通职工"); break;}break;}break;case 2:cout<<"输入职工编号:";cin>>empid;r=query(empid);if (r==NULL){cout<<"该职工不存在"<<endl;break;}cout<<"输入新的工资:"<<endl;cin>>empsa;r->getsalary(empsa);cout<<"请输入新的职务"<<endl;cin>>q;r->setzw(q);addemp(empid,empsa,rname,q);break;case 3:cout<<"输入职工编号:";cin>>empid;r=query(empid);if (r==NULL){cout<<"该读者不存在"<<endl;break;}break;case 4:cout<<setw(50)<<" ┌—————————————┐\n";cout<<setw(50)<<" │ 请选择您所需的操作│\n";cout<<setw(50)<<" │ 按编号查找1,并按回车键│\n";cout<<setw(50)<<" │ 返回2,并按回车键│\n";cout<<setw(50)<<" └—————————————┘\n";cin>>b;while(b!=0){switch(b){case 1:cout<<"输入职工编号:";cin>>empid;r=query(empid);if (r==NULL){cout<<"该职工不存在"<<endl;break;}cout<<"├—————┼—————┼—————┼—————┤"<<endl;cout<<"│"<<setw(10)<<"编号"<<"│"<<setw(10)<<"姓名"<<"│"<<setw(10)<<"工资"<<"│"<<setw(10)<<"职务"<<"│"<<endl;cout<<"├—————┼—————┼—————┼—————┤"<<endl; r->disp();break;case 2:break;}break;}break;case 5:cout<<"├—————┼—————┼—————┼—————┤"<<endl;cout<<"│"<<set w(10)<<"编号"<<"│"<<setw(10)<<"姓名"<<"│"<<setw(10)<<"工资"<<"│"<<setw(10)<<"职务"<<"│"<<endl;cout<<"├—————┼—————┼—————┼—————┤"<<endl; disp();break;clear();break;}}}void main(){int choice=1;Database EmpDB;while(choice!=0){cout<<"******************************************************************************** "<<endl;cout<<endl;cout<<endl;cout<<setw(20)<<"******************************欢迎使用职工管理系统******************************"<<endl;cout<<endl;cout<<endl;cout<<setw(50)<<" ┌—————————————┐\n";cout<<setw(50)<<" │ 请选择您所需的操作│\n";cout<<setw(50)<<" │ │\n";cout<<setw(50)<<" │ 操作1,并按回车键│\n";cout<<setw(50)<<" │ │\n";cout<<setw(50)<<" │ 返回0,并按回车键│\n";cou t<<setw(50)<<" └—————————————┘\n";cin>>choice;switch(choice){case 1:while(1){cout<<setw(20);EmpDB.empdata();break;break;}}}}。