java 职工信息管理系统源代码

合集下载

Java实现员工信息管理系统

Java实现员工信息管理系统

Java实现员⼯信息管理系统在Java SE中,对IO流与集合的操作在应⽤中⽐较重要。

接下来,我以⼀个⼩型项⽬的形式,演⽰IO流、集合等知识点在实践中的运⽤。

该项⽬名称为“员⼯信息管理系统”(或“员⼯收录系统”),主要是通过输⼊员⼯的id、姓名信息,实现简单的增删改查功能。

该项⽬主要在DOS窗⼝的控制台或者Eclipse的控制台上进⾏操作。

操作界⾯如下:该项⽬的⽂件结构如下:Step 1:⼊⼝类SystemMain的代码为:package empsystem;import java.util.Scanner;/*** 主界⾯* ⼀个Scanner录⼊对象* Employ类* ⽂件路径* 查重SearchID* @author 李章勇**/public class SystemMain {private Scanner sc=new Scanner(System.in);public SystemMain() {showWelcome();}public void showWelcome(){System.out.println("----员⼯收录系统");System.out.println("1.增加员⼯功能");System.out.println("2.查看员⼯功能");System.out.println("3.修改员⼯功能");System.out.println("4.删除员⼯功能");System.out.println("5.退出系统");String choice=sc.nextLine();switch(choice){case "1":System.out.println("您选择了增加⽤户功能");//Addnew Add();break;case "2":System.out.println("您选择了查看⽤户功能");//Searchnew ShowEmp();break;case "3":System.out.println("您选择了修改⽤户功能");//Modifynew Modify();break;case "4":System.out.println("您选择了删除⽤户功能");//删除⽤户Deletenew Delete();break;case "5":System.out.println("您选择了退出系统");return;default:System.out.println("⽆此功能");break;}}}Step 2:写⽂件路径FilePath接⼝。

java 职工信息管理系统源代码

java 职工信息管理系统源代码

源代码package lesson2;import java。

sql。

*;public class employee{public String num;public String name;public String sex;public String age;public String edu;public String sla;public String add;public String tel;public void init(String x1,String x2,String x3,String x4,String x5,String x6,String x7,String x8){num=x1;name=x2;sex=x3;age=x4;edu=x5;sla=x6;add=x7;tel=x8;}public void load(String f){try{Class。

forName(”com.microsoft.sqlserver.jdbc。

SQLServerDriver”);String url=”jdbc:sqlserver://localhost:1433;DatabaseName=employee";String userName=”sa”;String password="xhw";Connection conn=DriverManager.getConnection (url,userName,password);if(conn!=null)System.out。

println(”已成功地与SQL Server 2005数据库建立连接!");Statement stmt=conn.createStatement();stmt.executeUpdate(f);stmt。

close();}catch(Exception e){e。

职工信息管理系统源代码

职工信息管理系统源代码

职工信息管理系统源代码intnum;/*定义一个职工信息的结构体*/charname[20];/*定义一个职工信息的结构体*/charsex[10];//用字符串存放职工的性别数据charbirth[20];//用字符串存放职工的出生年月数据chardeta[20];//用字符串存放职工的工作年月数据chareducation[20];//用字符串存放职工的学历数据doublesalary;//用字符串存放职工的性别数据charwork[30];//用字符串存放职工的职务数据charaddr[20];//用字符串存放职工的地址数据chartel[20];//用字符串存放职工的电话数据}worker[100];//用结构体数组存放职工的所有信息voidmenu; voidinput;voidsave;voidread;voiddisplay;voidadd;voidsearch;voidsearch_education;voidsearch_num;voiddel;voidmodify;voidmain{chars;system("color3f");printf("\n\n");printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");printf("\t┃************************************************ **********┃\n");printf("\t┃***┏━━━━━━━━━━━━━━━━━━━━━━━━┓***┃\n");printf("\t┃***┃******************************************* *****┃***┃\n");printf("\t┃***┃*******┃***┃\n");printf("\t┃***┃***欢迎使用职工信息管理系统****┃***┃\n");printf("\t┃***┃*******┃***┃\n");printf("\t┃***┃*******┃***┃\n");printf("\t┃***┃***制作人吴青伶****┃***┃\n");printf("\t┃***┃*******┃***┃\n");printf("\t┃***┃***2013.12.28****┃***┃\n");printf("\t┃***┃*******┃***┃\n");printf("\t┃***┃******************************************* *****┃***┃\n");printf("\t┃***┗━━━━━━━━━━━━━━━━━━━━━━━━┛***┃\n");printf("\t┃************************************************ **********┃\n");printf ("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");do{menu;printf("doyouwanttocontinue。

简单的JAVA员工信息管理系统源码

简单的JAVA员工信息管理系统源码

据库连结 3.查问 4.增、 5 删 6 改 (操作数据库)import .*;public class EmpManageSys implements ActionListener { Connection con;Statement stmt;String sql;ResultSet rs;StringBuffer sb = new StringBuffer();JTextField jtf2 = new JTextField("张飞 ",10); JTextField jtf3 = new JTextField(10);JTextField jtf4 = new JTextField(10);JTextField jtf7 = new JTextField(10);JTextField jtf5 = new JTextField(10);JTextField jtf6 = new JTextField(10);JTextField jtf8 = new JTextField(10);JTextField jtf9 = new JTextField(10);JTextArea jta10 = new JTextArea(50, 40);public void actionPerformed(ActionEvent e) {String str = ();if ("查问 ".equals(str)) {quals(str)) {quals(str)) {quals(str)) {EmpManageSys() {createGUI();connectToDataBase();}public void searchEmp() {("");try {stmt = ();oLowerCase().trim() + "or id="+().toLowerCase().trim() + "or engName="+().toLowerCase().trim() + "or UNIT="+().toLowerCase().trim() + "or TEAM="+().toLowerCase().trim() + "or Phone="+().toLowerCase().trim() + "or region="+().toLowerCase().trim() + "or busStation="+().toLowerCase().trim();(sql);rs = ();ResultSetMetaData meta = ();int cols = ();while ()) {for (int i = 1; i <= cols; i++) {(" " + (i) + " =");(i));}("\n");());}} catch (SQLException e11){ ();}}public void addEmp() {try {stmt = ();sql = "update Mstar values(" + () + ()+()+()+()+()+()+()+")"; inti = ();if (() != null) && () != null)&&() != null) && () != null)){ (sql);("增添记录成功 " + i + "条"); } else {("带 * 号项为增添记录时不可以为空 ");}} catch (SQLException e1) {();}}public void deleteEmp() {searchEmp();try {stmt = ();sql = "delete from Mstar where chineseName=" +().toLowerCase().trim() + "or id="+().toLowerCase().trim() + "or engName="+().toLowerCase().trim() + "or UNIT="+().toLowerCase().trim() + "or TEAM="+().toLowerCase().trim() + "or Phone="+().toLowerCase().trim() + "or region="+().toLowerCase().trim() + "or busStation="+().toLowerCase().trim();(sql);int i = ();("撤掉操作成功 " + i + "条");} catch (SQLException e){ ();}}public void alterEmp(){ searchEmp();sql = "update Mstar set chineseName="+().toLowerCase().trim() + "and id="+().toLowerCase().trim() + "and engName="+().toLowerCase().trim() + "and UNIT="+().toLowerCase().trim() + "and TEAM="+().toLowerCase().trim() + "and Phone="+().toLowerCase().trim() + "and region="+().toLowerCase().trim() + "and busStation="+().toLowerCase().trim();int i = 0;try {(sql);i = ();} catch (SQLException e){ ();}("改正操作成功 " + i + "条");}public void createGUI() {JFrame jf = new JFrame("职工信息管理系统 "); (new GridLayout(2, 1));// (new GridLayout(10,2));JPanel jp00 = new JPanel(new GridLayout(5, 4)); JPanel jp1 = new JPanel();JButton jb11 = new JButton("查问 ");(this);JButton jb12 = new JButton("增添 ");(this);(jb11);(jb12);(jp1);JPanel jp11 = new JPanel();JButton jb111 = new JButton("改正 "); (this);JButton jb112 = new JButton("撤掉 "); (this);(jb111);(jb112);(jp11);JPanel jp2 = new JPanel();JLabel jl2 = new JLabel("中文名 * "); (jl2);(jtf2);(jp2);JPanel jp3 = new JPanel();JLabel jl3 = new JLabel("工号 ");(jl3);(jtf3);(jp3);JPanel jp4 = new JPanel();JLabel jl4 = new JLabel("EngName*"); (jl4);(jtf4);(jp4);JPanel jp5 = new JPanel();JLabel jl5 = new JLabel("UNIT ");(jl5);(jtf5);(jp5);JPanel jp6 = new JPanel();JLabel jl6 = new JLabel("TEAM* "); (jl6);(jtf6);(jp6);JPanel jp7 = new JPanel();JLabel jl7 = new JLabel("Phone* "); (jl7);(jtf7);(jp7);JPanel jp8 = new JPanel();JLabel jl8 = new JLabel("地区 ");(jl8);(jtf8);(jp8);JPanel jp9 = new JPanel();JLabel jl9 = new JLabel("公交站");(jl9);(jtf9);(jp9);(jp00);JPanel jp01 = new JPanel();("--用户使用手册 -- \n1、查问:选择一个字段,如 EngName 在文本框中输入相应内容,点击查问 \n2 、增添:在各个文本框中输入相应内容后,点击增添。

(完整版)职工信息管理系统java源代码

(完整版)职工信息管理系统java源代码
case 5:read(staffOne);break ;
case 6:save(staffOne);break ;
}
}
while (choice!=0);
}
void creat(staffI nfo staffO ne[])
{
InputStreamReader(System. in));
System. out .print("请输入职工信息(以0结束)\n");
for(int j=0;j<100;j++)
staffOne[j]=new staffInfo();
final ways staffTwo= new ways(); staffTwo.caidan(staffOne); staffTwo.creat(staffOne);
staffTwo.output(staffOne); staffTwo.search(staffOne);
staffTwo.delete(staffOne);
}
}
class ways//方法类,主要实现职工信息的建立,显示,查找,删除,信息的保存与读取;这个类是整个程序的操作类。
public int i=0;//i用来存放职工的人数public String filename="Infomation.txt" BufferedReader buf =new
package exercise;
import java.io.*;
class staffInfo//职工类{
public
String
name;
public
String
num;
public

企业人事管理系统java源代码

企业人事管理系统java源代码

"where 员 工 编 号
JOptionPane.showMessageDialog(null,"修改成功! ","修改操作",JOptionPane.ERROR_MESSAGE);
}
else{JOptionPane.showMessageDialog(null," 修 改 失 败!","修改操作",JOptionPane.ERROR_MESSAGE);}}
{
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("考勤考评信息模块");
入操作",JOptionPane.ERROR_MESSAGE);
}
}
}
);
b3.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
try {
int r1=s.executeUpdate("update 员 工 基 本 信 息 表
if((!v1.equals( "" ))&&(!v2.equals(""))&&(!v3.equals(""))&&(!v4.equals(""))&&(!v5.equals ("")))

职工信息管理系统源代码

职工信息管理系统源代码

#include <malloc.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#define ALLMAX 100 //总共统计的职工的人数typedef struct Node{long int born_date,work_date,tele_num;charsex,name[ALLMAX],degree[ALLMAX],job[ALLMAX],address[ALLMAX];struct Node *next;}SLNode;typedef struct{long int born_date,work_date,tele_num;charname[ALLMAX],sex,degree[ALLMAX],job[ALLMAX],address[ALLMAX];}DataType;void ListInitiate(SLNode **head)//链表初始化{if((*head=(SLNode *)malloc(sizeof(SLNode)))==NULL) exit(1);//动态分配存储空间(*head)->next=NULL;}SLNode *ListInsert(SLNode *head,DataType x)//职工信息的插入姓名并按照升序排列{SLNode *p,*q,*s;p=head->next;if((q=(SLNode *)malloc(sizeof(SLNode)))==NULL) exit(1);//动态分配存储空间q->born_date=x.born_date;q->work_date=x.work_date;q->tele_num=x.tele_num;strcpy(q->name,);q->sex=x.sex;strcpy(q->degree,x.degree);strcpy(q->job,x.job);strcpy(q->address,x.address);if(head->next==NULL){//如果只有链表的头结点,没有其他的结点,直接插入在头结点后面head->next=q;head->next->next=NULL;}else{//链表非空for(;p;p=p->next){if(p->next!=NULL){if(strcmp(p->name,)<0&&strcmp(p->next->name,)>0){//位于两个结点之间s=p->next;p->next=q;q->next=s;break;}//else if(strcmp(p->name,)==0)break; //如果姓名相同则不插入信息}else if(strcmp(p->name,)<0&&p->next==NULL){//链表非空,并且在排序中是最后一个p->next=q;q->next=NULL;break;}if(strcmp(p->name,)>0){//位于链表头结点之后的位置s=head->next;head->next=q;q->next=s;break;}}}return head;}void ListDelete(SLNode *head)//职工信息的删除{SLNode *p,*s;char x[20];s=head;p=head->next;if(head->next==NULL){//链表为空,输出:名单中无职工信息,无须删除!printf("名单中无此职工信息,无须删除!\n");return;}printf("请输入要删除职工的姓名:\n"); //输入要删除的人的姓名scanf("%s",x);for(p;p;p=p->next){//在链表中从头到尾查找输入的人的姓名if(strcmp(p->name,x)==0){ //如果存在,则删除,否则输出:名单中无职工信息,无须删除!s->next=p->next;free(p);printf("删除成功!请继续操作!\n");break;}s=p;}if(p==NULL){//链表本身为空printf("名单中无此职工信息,无须删除!\n");}}void ListModify(SLNode *head)//职工信息的修改{DataType x;SLNode *p;p=head->next;if(p==NULL){//链表本身为空printf("职工名单无职工信息,无须修改!\n");return;}printf("请输入要修改的职工姓名:\n");scanf("%s",);for(;p;p=p->next){if(strcmp(,p->name)==0){//查找到了该职工的信息printf("依次写入该职工的新信息:\n");printf("请输入职工信息:\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");scanf("%s %c %d %d %s %s %s %d",p->name,&p->sex,&p->born_date,&p->work_ date,p->degree,p->job,p->address,&p->tele_num);printf("修改成功!请继续操作!\n");break;}}if(p==NULL)//如果链表为空printf("此职工不存在,无法修改其信息!\n");}void put(SLNode *head,FILE *fp)//职工信息的保存{SLNode *p;if((fp=fopen("Employee.txt","w"))==NULL){//printf("无法打开'Employee.txt'!\n");exit(0);}for(p=head->next;p;p=p->next){fprintf(fp,"%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_ date,p->degree,p->job,p->address,p->tele_num);}if(fclose(fp)){printf("无法关闭'Employee.txt'!\n"); exit(0);}}void Listfind(SLNode head)//职工信息的查找{int i,j;SLNode *p;DataType x;if(head.next==NULL){//链表为空printf("名单中无职工信息,查询失败!\n");return;}//返回主菜单printf("\n");printf("\t*********************************\n");printf("\t*职工信息查询操作*\n");printf("\t**\n");printf("\t*0.退出查询系统,回到主菜单\t\t 1.对姓名进行查询\t*\n\t * 2.对出生年月进行查询\t\t 3.对学历进行查询\t*\n\t* 4.对工作年月进行查询\t\t 5.对职务进行查询\t*\n\t* 6.对住址进行查询\t\t 7.对电话进行查询\t*\n");printf("\t*********************************\n");while(1){printf("请输入您要选择的操作:");scanf("%d",&i);if(i==0)//输入0,退出查询系统,回到主菜单break;else if(i==1){//输入1,对姓名进行查询p=head.next;printf("请输入姓名:");scanf("%s",);j=0;for(p;p;p=p->next){if(strcmp(p->name,)==0){//如果存在这个人,那么j自加++j;printf("\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}}if(j==0)//表示没有找到输入的信息printf("职工名单中不存在此人!\n");else printf("查询成功!继续操作!\n");}else if(i==2){//输入2,对出生年月进行查询p=head.next;printf("请输入出生年月:");scanf("%d",&x.born_date);j=0;for(p;p;p=p->next){if(p->born_date==x.born_date){//输入的出生年月在链表中存在++j;//如果存在这个人,那么j自加printf("\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}}if(j==0)//表示没有找到输入的信息printf("职工名单中没有这个时间出生的!\n");else printf("查询成功!请继续操作!\n");}else if(i==4){//输入4,对工作年月进行查询p=head.next;printf("请输入工作年月:");scanf("%d",&x.work_date);j=0;for(p;p;p=p->next){if(p->work_date==x.work_date){++j;//如果存在这个人,那么j自加printf("\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}}if(j==0)//表示没有找到输入的信息printf("职工名单中没有这个时间工作的!\n");else printf("查询成功!请继续操作!\n");}else if(i==3){//输入3,对学历进行查询p=head.next;printf("请输入学历:");scanf("%s",x.degree);j=0;for(p;p;p=p->next){if(strcmp(p->degree,x.degree)==0){++j;//如果存在这个人,那么j自加printf("\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}}if(j==0)//表示没有找到输入的信息printf("职工名单中没有这种学历的!\n");else printf("查询成功!请继续操作!\n");}else if(i==5){//输入5,对职务进行查询p=head.next;printf("请输入职务:");scanf("%s",x.job);j=0;for(p;p;p=p->next){if(strcmp(p->job,x.job)==0){++j;//如果存在这个人,那么j自加printf("\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}}if(j==0)//表示没有找到输入的信息printf("职工名单中没有这种职务的!\n");else printf("查询成功!请继续操作!\n");}else if(i==6){//输入6,对住址进行查询p=head.next;printf("请输入住址:");scanf("%s",x.address);j=0;for(p;p;p=p->next){if(strcmp(p->address,x.address)==0){++j;//如果存在这个人,那么j自加printf("\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}}if(j==0)//表示没有找到输入的信息printf("职工名单中没有住这的!\n");else printf("查询成功!请继续操作!\n");}else if(i==7){//输入7,对电话号码进行查询p=head.next;printf("请输入电话:");scanf("%d",&x.tele_num);j=0;for(p;p;p=p->next){if(p->tele_num==x.tele_num){++j;//如果存在这个人,那么j自加printf("\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}}if(j==0)//表示没有找到输入的信息printf("职工名单中没人用这个号码!\n");else printf("查询成功!请继续操作!\n");}else if(i!=0 && i!=1 && i!=2 && i!=3 && i!=4 && i!=5 && i!=6 && i!=7)//输入任意不是上述数字的,那么久显示输入错误printf("输入出错!请再次输入!\n");printf("\n");printf("\t*********************************\n");printf("\t*职工信息查询系统*\n");printf("\t**\n");printf("\t*0.退出查询系统,回到主菜单\t\t 1.对姓名进行查询\t*\n\t* 2.对出生年月进行查询\t\t 3.对学历进行查询\t*\n\t*4.对工作年月进行查询\t\t 5.对职务进行查询\t*\n\t* 6.对住址进行查询\t\t 7.对电话进行查询\t*\n");printf("\t*********************************\n");//printf("0.退出查询系统,回到主菜单\n1.对姓名进行查询\n2.对出生年月进行查询\n3.对工作年月进行查询\n4.对学历进行查询\n5.对职务进行查询\n6.对住址进行查询\n7.对电话号码进行查询\n");}}void print(SLNode *head)//职工信息的显示{SLNode *p;for(p=head->next;p!=NULL;p=p->next)//输出所有职工的信息printf("%s %c %d %d %s %s %s %d\n",p->name,p->sex,p->born_date,p->work_date ,p->degree,p->job,p->address,p->tele_num);}void printLink(SLNode *head)//职工信息的显示{printf("职工名单:\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");print(head);}void Listpaixu(SLNode *head)//职工信息的排序{int i,n=0,m,flag=1;SLNode *p,*q,*s;if(head->next==NULL){//职工链表为空printf("名单中无职工信息,无法排序!\n\n");return;}// printf("输入出错!请再次输入!\n\n");printf("\t\t~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~\n");printf("\t\t~.~ 职工信息排序操作~.~\n");printf("\t\t~.~ ~.~\n");printf("\t\t~.~\t0.退出排序系统,回到主菜单~.~\n\t\t~.~\t1.对性别进行排序~.~\n\t\t~.~\t2.对出生年月进行排序~.~\n\t\t~.~\t3.对工作年月进行排序~.~\n\t\t~.~\t4.对姓名进行排序~.~\n");printf("\t\t~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~\n");while(1){printf("请输入您要选择的操作:");scanf("%d",&i);if(i==0)//输入0,退出排序系统,回到主菜单break;else if(i==1){//输入1,对性别进行排序n=0,m,flag=1;for(p=head;NULL!=p;p=p->next)//统计职工人数n++;for(m=1;flag&&m<=n;m++){flag=0;for(q=head->next,p=head,s=p;q;s=p,p=q,q=q->next){if(p->sex>q->sex)//p为当前节点,p的性别>p的后继节点的性别{if(head==p)//p为头结点{head->next=q->next;head=q;q->next=p;//交换节点信息q=head->next;p=head;}else{p->next=q->next;q->next=p;s->next=q;p=q;q=p->next;}flag=1;}}}printf("排好序的信息如下:\n");printLink(head);//输出所有节点的信息return;}else if(i==2){//输入2,对出生年月进行排序n=0,m,flag=1;for(p=head;NULL!=p;p=p->next)//统计职工人数n++;for(m=1;flag&&m<=n;n++)//循环{flag=0;for(q=head->next,p=head,s=p;q;s=p,p=q,q=q->next){if(p->born_date>q->born_date)//对出生年月进行排序{if(head==p){head->next=q->next;head=q;q->next=p;q=head->next;p=head;}else{p->next=q->next;q->next=p;s->next=q;p=q;q=p->next;}flag=1;}}}printf("排好序的信息如下:\n");printLink(head);return;}else if(i==3){//输入3,按工作时间进行排序n=0,m,flag=1;for(p=head;NULL!=p;p=p->next)n++;for(m=1;flag&&m<=n;n++){flag=0;for(q=head->next,p=head,s=p;q;s=p,p=q,q=q->next){ if(p->work_date>q->work_date){if(head==p){head->next=q->next;head=q;q->next=p;q=head->next;p=head;}else{p->next=q->next;q->next=p;s->next=q;p=q;q=p->next;}flag=1;}}}printf("排好序的信息如下:\n");printLink(head);return;}else if(i==4){n=0,m,flag=1;for(p=head;NULL!=p;p=p->next)n++;for(m=1;flag&&m<=n;n++){flag=0;for(q=head->next,p=head,s=p;q;s=p,p=q,q=q->next){if(p->name[0]>q->name[0]){if(head==p){head->next=q->next;head=q;q->next=p;q=head->next;p=head;}else{p->next=q->next;q->next=p;s->next=q;p=q;q=p->next;}flag=1;}}}printf("排好序的信息如下:\n");printLink(head);return;}else if(i!=0&&i!=1&&i!=2&&i!=3&&i!=4)printf("输入出错!请再次输入!\n\n");printf("\t\t~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~\n");printf("\t\t~.~ 职工信息排序系统~.~\n");printf("\t\t~.~~.~\n");printf("\t\t~.~\t0.退出排序系统,回到主菜单~.~\n\t\t~.~\t1.对性别进行排序~.~\n\t\t~.~\t2.对出生年月进行排序~.~\n\t\t~.~\t3.对工作年月进行排序~.~\n\t\t~.~\t4.显示全部职工信息~.~\n");printf("\t\t~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~\n");//printf("0.退出排序系统,回到主菜单\n1.对性别进行排序\n2.对出生年月进行排序\n3.对工作年月进行排序\n");}}void main(){DataType x;SLNode *head;int i,n;FILE *fp;ListInitiate(&head);//初始化链表printf("\n");printf("*************************************************************** ****************\n");printf("************************ 欢迎使用职工管理系统***************************\n");printf("*************************************************************** ****************\n");printf("请输入要录入的职工人数n:");//输入要录入的职工人数scanf("%d",&n);if(n==0) goto aa;printf("请输入职工信息:\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");for(i=0;i<n;i++)//职工信息的输入{scanf("%s %c %d %d %s %s %s %d",,&x.sex,&x.born_date,&x.work_date,x. degree,x.job,x.address,&x.tele_num);head=ListInsert(head,x);}if((fp=fopen("Employeetxt","a"))==NULL){printf("\t无法打开'Employee.txt'!\n");exit(0);}put(head,fp);if(fclose(fp)){printf("\t无法关闭'Employee.txt'!\n"); exit(0);}printLink(head);aa: printf("\n");printf("\t★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★☆☆★\n");printf("\t☆* 主菜单* ☆\n");printf("\t★********** ★\n");printf("\t☆☆\n");printf("\t★\t0.结束管理系统\t\t\t1.新增职工信息\t\t★\n\t☆\t2.删除职工信息\t\t\t3.查询职工信息\t\t☆\n\t★\t4.修改职工信息\t\t\t5.职工信息排序\t\t★\n");printf("\t☆☆\n");printf("\t★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★☆☆★\n");while(1){printf("请输入您要选择的操作:");scanf("%d",&i);if(i==0)//输入0,结束系统{printf("\t\t您已经成功退出职工管理系统,谢谢使用!\n");break;}else if(i==1){//输入1,新增一名职工printf("请输入职工信息:\n姓名、性别、出生年月、工作年月、学历、职务、住址、电话\n");scanf("%s %c %d %d %s %s %s %d",,&x.sex,&x.born_date,&x.work_date,x. degree,x.job,x.address,&x.tele_num);head=ListInsert(head,x);printf("新增成功!请继续操作!\n");printLink(head);put(head,fp);//保存在文件中else if(i==2){//输入2,删除一名职工ListDelete(head);if((fp=fopen("Employee.txt","w"))==NULL){printf("无法打开'职工名单.txt'!\n");exit(0);}put(head,fp);//保存在文件中if(fclose(fp)){printf("无法关闭'Employee.txt'!\n"); exit(0);}}else if(i==3)//输入3,查找一名职工Listfind(*head);else if(i==4){//输入4,修改职工信息ListModify(head);if((fp=fopen("Employee.txt","w"))==NULL){printf("无法打开'Employee.txt'!\n");exit(0);}put(head,fp);//保存在文件中if(fclose(fp)){printf("无法关闭'Employee.txt'!\n"); exit(0);}}else if(i==5){//输入5,对职工信息进行排序SLNode *p=head;Listpaixu(p);}//如果出入的不是上述任何一种情况就输出:输入出错else printf("输入出错!请再次输入!\n");printf("\n");printf("\t★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★☆☆★\n");printf("\t☆* 主菜单* ☆\n");printf("\t★********** ★\n");printf("\t☆☆\n");printf("\t★0.结束管理系统\t\t\t\t1.新增职工信息\t★\n\t☆ 2.删除职工信息\t\t\t\t3.查询职工信息\t☆\n\t★ 4.修改职工信息\t\t\t\t5.职工信息排序\t★\n");printf("\t☆☆\n");printf("\t★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★★☆☆★☆☆★☆☆★☆☆★\n");//printf("0.结束系统\n1.新增一名职工\n2.删除一名职工\n3.查询职工信息\n4.修改职工信息\n5.对职工信息进行排序\n");}}。

职工信息管理系统源代码

职工信息管理系统源代码

#include <stdio.h>#include <string.h>#include <stdlib.h>#include<conio.h>struct Date /*日期*/{int year;int month;int day;};struct Info{char num[15]; /*职工号*/char name[15]; /*姓名*/char sex[10]; /*性别*/struct Date birthday; /*出生年月*/char education[10]; /*学历*/char duty[15]; /*职务*/double wage; /*工资*/char addr[30]; /*地址*/char phone[15]; /*电话*/};/*************************菜单选择函数******************************/ char menu(){char n; /*n记录选择的菜单*/int system(const char *string); /*清屏*/system("cls"); /*清屏*/puts("\t\t 欢迎使用职工信息管理系统");puts("\t\t*********************MENU*******************\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********************************************\n");printf("选择你要使用的功能(1-6):[ ]\b\b");while(1){n=getchar();getchar();if(n<'1'||n>'6')printf("输入错误,请重新选择你要使用的功能(1-6):[ ]\b\b");elsebreak;}return n;}/****************************信息输入函数****************************/void append(){struct Info info;FILE * fp;char ch;char temp[10];if((fp=fopen("inform.txt","ab"))==NULL){printf("\t文件打开错误!");getch();exit(1);}do{printf("\t号码:");gets(info.num);printf("\t姓名:");gets();printf("\t性别:");gets(info.sex);printf("\t出生日期(yyyy/mm/dd):");scanf("%d/%d/%d",&info.birthday.year,&info.birthday.month,&info.birthday.day);getchar();printf("\t学历:");gets(cation);printf("\t职务:");gets(info.duty);printf("\t工资:");gets(temp); info.wage=atof(temp);printf("\t地址:");gets(info.addr);printf("\t电话:");gets(info.phone);fwrite(&info,sizeof(info),1,fp);printf("\t还有更多的吗?(Y/N):[ ]\b\b");ch=getchar();getchar();}while(ch=='Y'||ch=='y');fclose(fp);}void print1(){printf("%-10s%-10s%-10s%-12s%-10s%-10s%-15s%-30s%-15s%\n","号码","姓名","性别","出生日期","学历","职务","工资","地址","电话");}void print2(struct Info info){;printf("%-10s%-10s%-10s",info.num,,info.sex);printf("%-4d/%-2d/%-4d",info.birthday.year,info.birthday.month,info.birthday.day);printf("%-10s%-10s%-15.2lf",cation,info.duty,info.wage);printf("%-30s%-15s\n",info.addr,info.phone);}/***********************职工信息显示函数**************************/ void display(){struct Info info;FILE * fp;int total=0;if((fp=fopen("inform.txt","rb"))==NULL){printf("\t文件打开错误!");getch();exit(1);}while(fread(&info, sizeof(info),1,fp)==1){total++;if(total==1)print1();print2(info);if((total!=0)&&(total%10==0)){printf("\n\n\t按任意键继续。

职工信息管理系统 附源代码

职工信息管理系统 附源代码

第一章问题定义在当今社会,互联网空间的发展,给人们的工作和生活带来了极大的便利和高效,信息化,电子化已经成为节约运营成本,提高工作效率的首选。

当前大量企业的职工管理尚处于手工作业阶段,不但效率低下,还常常因为管理的不慎而出现纰漏。

随着信息技术在管理上越来越深入而广泛的应用,管理信息系统的实施在技术上已逐步成熟。

管理信息系统是一个不断发展的新型学科,任何一个单位要生存要发展,要高效率地把内部活动有机地组织起来,就必须建立与自身特点相适应的管理信息系统。

本程序是一个关于职工信息管理的系统通过这个系统用户可以简捷、方便的对职工信息进行增加、修改、添加、查询、浏览等功能,它不仅可以帮助企业单位达到员工管理办公自动化、节约管理成本、更能达到提高企业单位工作效率的目的。

2.1 技术可行性分析此系统是职工信息管理系统,用visual c++ 6.0结合windows 7操作系统开发而成的,大家都知道这项技术已经相当成熟了,因此从技术方面讲开发此职工信息管理系统是可行的。

2.2 社会可行性分析社会可行性研究是对系统投入使用后对社会可能带来的影响进行分析,比如是否为人们所接受,是否为社会带来收益。

2.3 经济可行性分析软件工程课程设计主要是对项目的经济效益进行评价,一方面是支出的费用,其中包括设备购置费,软件开发费,管理和维护费,人员工资和培训费等。

另一方面是取得的收益中可以用钱来衡量的那部分(收益的另一部分难以用钱来表示)。

基于企业的现有计算机及配套设备,建设MIS系统。

不但能大大坚守重复性书面报告,降低办公费用,提高办公室效率,而且能提高监测数据效用。

由于职工信息管理系统是一个比较小型的系统,所以从人力、物力、财力等方面来说都是可行的。

3.1设计目的要求熟练掌握C语言的基本知识和编辑技能;基本掌握结构化程序设计的基本思路和方法。

3.2 设计要求要求:设计一个职工信息管理系统,使之能提供以下功能:1、应提供一个界面来调用各个功能,调用界面和各个功能的操作界面应尽可能清晰美观!2、输入功能:职工信息录入(职工信息用文件保存),可以一次完成若干条记录的输入。

职工信息管理系统java源代码

职工信息管理系统java源代码

职工信息管理系统j a v a源代码Document number:NOCG-YUNOO-BUYTT-UU986-1986UTpackage exercise;import .*;class staffInfo 入职工信息★★★┃");"┃★★★ 2.预览职工信息★★★┃");"┃★★★ 3.查找职工信息★★★┃");"┃★★★ 4.删除职工信息★★★┃");"┃★★★ 5.读取已存数据★★★┃");"┃★★★ 6.安全退出系统★★★┃");"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛");" 请输入您需要的功能代号(1--6):");choice=());switch(choice){case 1:creat(staffOne);break;case 2:output(staffOne);break;case 3:search(staffOne);break;case 4:delete(staffOne);break;case 5:read(staffOne);break;case 6:save(staffOne);break;}}while(choice!=0);}void creat(staffInfo staffOne[]) throws IOException{final BufferedReader buf=new BufferedReader(new InputStreamReader);"请输入职工信息(以0结束)\n");"姓名:");staffOne[i].name=(); "0")!=0) um=();"性别:");staffOne[i].sex=();"年龄:");staffOne[i].age=();"学历:");staffOne[i].record=();"职位:");staffOne[i].position=();"工资:");staffOne[i].wanges=();"电话:");staffOne[i].tel=();"住址:");staffOne[i].addr=();i++;"请输入下一个职工信息:");staffOne[i].name=();}}void output(staffInfo staffOne[]) throws IOExceptionum+"\t"+staffOne[j].sex+"\t"+staffOne[j].age+"\t"+staffOne[j]. record+"\t"+staffOne[j].position+"\t\t"+staffOne[j].wanges+"\t "+staffOne[j].tel+"\t"+staffOne[j].addr+"\n");"-------------------------------------------------------------------------------------------------");}else"没有职工信息!");}}void search(staffInfo staffOne[]) throws IOException{final BufferedReader buf=new BufferedReader(new InputStreamReader);"请输入您要查找的职工工号:");recordkey=();boolean flg=true;for(int j=0;j<i;j++){if(staffOne[j].num))um+"\t"+staffOne[j].sex+"\t"+staffOne[j].age+"\t"+staffOne[j]. record+"\t"+staffOne[j].position+"\t\t"+staffOne[j].wanges+"\t "+staffOne[j].tel+"\t"+staffOne[j].addr+"\n");flg=false;}}if(flg)"对不起,查无此人!");}void delete(staffInfo staffOne[]) throws IOException{final BufferedReader buf=new BufferedReader(new InputStreamReader);"请输入您要删除的职工工号:");recordkey=();boolean flg=true;for(int j=0;j<i;j++){"输入的工号为:"+recordkey);if(staffOne[j].num)){for(int k=j;k<=i-1;k++) ame=staffOne[k+1].name ; staffOne[k].num=staffOne[k+1].num ;staffOne[k].sex=staffOne[k+1].sex;staffOne[k].age=staffOne[k+1].age ;staffOne[k].record=staffOne[k+1].record ;staffOne[k].position=staffOne[k+1].position ; staffOne[k].wanges=staffOne[k+1].wanges ;staffOne[k].tel=staffOne[k+1].tel ;staffOne[k].addr=staffOne[k+1].addr ;}i--;ame+"\n");( staffOne[k].num+"\n");( staffOne[k].sex+"\n" );( staffOne[k].age+"\n");( staffOne[k].record+"\n");( staffOne[k].position+"\n") ;( staffOne[k].wanges+"\n");( staffOne[k].tel+"\n");( staffOne[k].addr+"\n");}();"系统已经安全退出!感谢您的使用!");(0);}void read(staffInfo staffOne[]) throws IOException{final FileReader fr=new FileReader(filename);final BufferedReader bfr=new BufferedReader(fr);if((recordkey=())!=null)i=(recordkey);for(int j=0;j<i;j++){staffOne[j].name=();staffOne[j].num=();staffOne[j].sex=();staffOne[j].age=();staffOne[j].record=();staffOne[j].position=() ;staffOne[j].wanges=();staffOne[j].tel=();staffOne[j].addr=();}();"\n数据已经成功读取!");}}。

简单的员工信息管理系统源码

简单的员工信息管理系统源码

据库连接3.查询4.增、5删6改(操作数据库)import .*;import .*;import .*;import .*;public class EmpManageSys implements ActionListener { Connection con;Statement stmt;String sql;ResultSet rs;StringBuffer sb = new StringBuffer();JTextField jtf2 = new JTextField("张飞",10);JTextField jtf3 = new JTextField(10);JTextField jtf4 = new JTextField(10);JTextField jtf7 = new JTextField(10);JTextField jtf5 = new JTextField(10);JTextField jtf6 = new JTextField(10);JTextField jtf8 = new JTextField(10);JTextField jtf9 = new JTextField(10);JTextArea jta10 = new JTextArea(50, 40);public void actionPerformed(ActionEvent e) {String str = ();if ("查询".equals(str)) {quals(str)) {quals(str)) {quals(str)) {EmpManageSys() {createGUI();connectToDataBase();public Connection connectToDataBase() { con = ();(con);return con;}public void searchEmp() {("");try {stmt = ();oLowerCase().trim() + "or id="+ ().toLowerCase().trim() + "or engName=" + ().toLowerCase().trim() + "or UNIT="+ ().toLowerCase().trim() + "or TEAM="+ ().toLowerCase().trim() + "or Phone="+ ().toLowerCase().trim() + "or region="+ ().toLowerCase().trim() + "or busStation=" + ().toLowerCase().trim();(sql);rs = ();ResultSetMetaData meta = ();int cols = ();while ()) {for (int i = 1; i <= cols; i++) {(" " + (i) + " =");(i));}("\n");());}} catch (SQLException e11) {();}}public void addEmp() {try {stmt = ();sql = "update Mstar values(" + () + ()+ () + () + ()+ () + () + () + ")";int i = ();if (() != null) && () != null)&& () != null) && () != null)) {(sql);("添加记录成功" + i + "条");} else {("带*号项为添加记录时不能为空");}} catch (SQLException e1) {();}}public void deleteEmp() {searchEmp();try {stmt = ();sql = "delete from Mstar where chineseName=" + ().toLowerCase().trim() + "or id="+ ().toLowerCase().trim() + "or engName="+ ().toLowerCase().trim() + "or UNIT="+ ().toLowerCase().trim() + "or TEAM="+ ().toLowerCase().trim() + "or Phone="+ ().toLowerCase().trim() + "or region="+ ().toLowerCase().trim() + "or busStation=" + ().toLowerCase().trim();(sql);int i = ();("撤除操作成功" + i + "条");} catch (SQLException e) {();}}public void alterEmp() {searchEmp();sql = "update Mstar set chineseName="+ ().toLowerCase().trim() + "and id="+ ().toLowerCase().trim() + "and engName=" + ().toLowerCase().trim() + "and UNIT="+ ().toLowerCase().trim() + "and TEAM="+ ().toLowerCase().trim() + "and Phone="+ ().toLowerCase().trim() + "and region="+ ().toLowerCase().trim() + "and busStation="+ ().toLowerCase().trim();int i = 0;try {(sql);i = ();} catch (SQLException e) {();}("修改操作成功" + i + "条");}public void createGUI() {JFrame jf = new JFrame("员工信息管理系统"); (new GridLayout(2, 1));;public class JdbcUtil{//load driver from filestatic{try{String driverName ="";(driverName);}catch(Exception e){();}}//establish connectionpublic static Connection getConnection(){Connection con = null;try{String url ="jdbc:oracle:thinString usr = "openlab";String pwd = "open123";con = (url,usr,pwd);}catch(Exception e){();}return con;}//close resultSet,statement and connectionpublic static void close(ResultSet rs,Statement stmt,Connection con){try{if(rs!=null) ();}catch(Exception ex){ ();}try{if(stmt!=null) ();}catch(Exception ex){ ();}try{if(con!=null) ();}catch(Exception ex){ ();}}}。

java员工管理系统代码

java员工管理系统代码

Java员工管理系统代码简介Java员工管理系统是一种基于Java编程语言的应用程序,旨在帮助管理人员更有效地管理员工信息。

该系统提供了一些常见的功能,例如添加、查看、编辑和删除员工信息,以及统计汇总员工数据等。

通过这个系统,管理人员可以轻松地管理组织中的员工,提高工作效率和准确性。

功能模块1. 添加员工信息该功能允许管理员向系统中添加新的员工信息。

管理员可以输入员工的姓名、年龄、性别、职位等基本信息,并将其保存在系统的数据库中。

2. 查看员工信息管理员可以通过该功能查看系统中已有的员工信息。

系统将以列表或表格的形式展示员工的姓名、年龄、性别、职位等信息,便于管理员进行浏览和查找。

3. 编辑员工信息当员工的信息发生变化时,管理员可以通过该功能对员工信息进行编辑。

管理员可以选择要编辑的员工,并可以修改员工的姓名、年龄、性别、职位等信息。

4. 删除员工信息如果某个员工离职或信息有误,管理员可以通过该功能删除员工的信息。

管理员需要选择要删除的员工,并确认删除操作,系统将从数据库中删除该员工的信息。

5. 统计汇总员工数据该功能可以为管理员生成统计汇总员工数据的报表。

管理员可以选择统计的条件,例如按部门、按性别、按职位等进行统计,并以图表或表格的形式展示统计结果,帮助管理员更好地了解员工信息和组织结构。

技术实现1. 数据库设计系统通过使用关系型数据库管理员工信息。

数据库中创建员工表,包含员工的姓名、年龄、性别、职位等字段。

可以使用MySQL、Oracle等数据库管理系统来创建和管理员工表。

2. Java编程系统使用Java编写,通过面向对象的方法来实现各个功能模块。

使用Java的JDBC库来连接数据库,实现对数据库的增删改查操作。

使用Swing或JavaFX等图形界面库来实现系统的用户界面,使其更友好和易用。

3. 数据校验在添加、编辑和删除员工信息时,系统需要对输入的数据进行校验。

例如,保证姓名字段不为空、年龄字段为合法的数字、性别字段为男或女等。

职工信息管理系统java源代码

职工信息管理系统java源代码

package exercise;.;class staffInfo入职工信息★★★┃";"┃★★★2.预览职工信息★★★┃";"┃★★★3.查找职工信息★★★┃";"┃★★★4.删除职工信息★★★┃";"┃★★★ 5.读取已存数据★★★┃";"┃★★★6.安全退出系统★★★┃";"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"; "请输入您需要的功能代号1--6:";choice=;switch choice{case1:creatstaffOne;break;case2:outputstaffOne;break;case3:searchstaffOne;break;case4:deletestaffOne;break;case5:readstaffOne;break;case6:savestaffOne;break;}}while choice=0;}void creatstaffInfostaffOne throws IOException{final BufferedReaderbuf=new BufferedReader new InputStreamReader;"请输入职工信息以0结束\n";"姓名:";staffOne =;"0"=0um=;"性别:";staffOne i.sex=;"年龄:";staffOne i.age=;"学历:";staffOne i.record=;"职位:";staffOne i.position=;"工资:";staffOne i.wanges=;"电话:";staffOne i.tel=;"住址:";staffOne i.addr=;i++;"请输入下一个职工信息:";staffOne =;}}void outputstaffInfostaffOne throws IOException um+"\t"+staffOnej.sex+"\t"+staffOnej.age+"\t" +staffOnej.record+"\t"+staffOnej.position+"\t\t"+staffOnej.wanges+"\t"+staffOnej.tel+"\t" +staffOnej.addr+"\n";"-------------------------------------------------------------------------------------------------";}"没有职工信息";}}void searchstaffInfostaffOne throws IOException{final BufferedReaderbuf=new BufferedReader new InputStreamReader;"请输入您要查找的职工工号:";recordkey=;boolean flg=true;forint j=0;j<i;j++{if staffOnej.numum+"\t"+staffOnej.sex+"\t"+staffOnej.age+"\t"+staffOnej.record+"\t"+st affOnej.position+"\t\t"+staffOnej.wanges+"\t"+staffOnej.tel+"\t"+staffOnej.addr+"\n";flg=false;}}if flg"对不起,查无此人";}void deletestaffInfostaffOne throws IOException{final BufferedReaderbuf=new BufferedReader new InputStreamReader;"请输入您要删除的职工工号:";recordkey=;boolean flg=true;forint j=0;j<i;j++{"输入的工号为:"+recordkey;if staffOnej.num{forint k=j;k<=i-1;k++ame=staffOnek+;staffOnek.num=staffOnek+1.num;staffOnek.sex=staffOnek+1.sex;staffOnek.age=staffOnek+1.age;staffOnek.record=staffOnek+1.record; staffOnek.position=staffOnek+1.position; staffOnek.wanges=staffOnek+1.wanges; staffOnek.tel=staffOnek+1.tel;staffOnek.addr=staffOnek+1.addr;}i--;ame+"\n";staffOnek.num+"\n";staffOnek.sex+"\n";staffOnek.age+"\n";staffOnek.record+"\n";staffOnek.position+"\n";staffOnek.wanges+"\n";staffOnek.tel+"\n";staffOnek.addr+"\n";};"系统已经安全退出感谢您的使用";0;}void readstaffInfostaffOne throws IOException{final FileReaderfr=new FileReader filename;final BufferedReaderbfr=new BufferedReaderfr;if recordkey==nulli=recordkey;forint j=0;j<i;j++{=;staffOnej.num=;staffOnej.sex=;staffOnej.age=;staffOnej.record=;staffOnej.position=;staffOnej.wanges=;staffOnej.tel=;staffOnej.addr=;};"\n数据已经成功读取";}}。

java管理系统设计代码

java管理系统设计代码

在Java中设计一个管理系统通常涉及多个类和接口,下面是一个简单的例子,展示了如何设计一个基本的“员工”管理系统。

首先,我们定义一个`Employee`类,它包含员工的基本信息:```javapublic class Employee {private String name;private int id;private String department;public Employee(String name, int id, String department) { = name;this.id = id;this.department = department;}public String getName() {return name;}public int getId() {return id;}public String getDepartment() {return department;}// getter and setter methods...}```然后,我们定义一个`EmployeeManager`类,用于管理`Employee`对象:```javaimport java.util.ArrayList;import java.util.List;public class EmployeeManager {private List<Employee> employees;public EmployeeManager() {this.employees = new ArrayList<>();}public void addEmployee(Employee employee) {this.employees.add(employee);}public void removeEmployee(int id) {this.employees.removeIf(e -> e.getId() == id);}public Employee findEmployee(int id) {return this.employees.stream().filter(e -> e.getId() == id).findFirst().orElse(null);}public void printAllEmployees() {for (Employee e : this.employees) {System.out.println("Name: " + e.getName() + ", ID: " + e.getId() + ", Department: " + e.getDepartment());}}}```最后,我们在`main`方法中测试这个系统:```javapublic class Main {public static void main(String[] args) {EmployeeManager manager = new EmployeeManager();manager.addEmployee(new Employee("John Doe", 1, "IT"));manager.addEmployee(new Employee("Jane Doe", 2, "HR"));manager.addEmployee(new Employee("Alex Johnson", 3, "Sales"));manager.printAllEmployees(); // Prints all employeesmanager.removeEmployee(2); // Removes employee with ID 2manager.printAllEmployees(); // Prints allremaining employees}}```这只是一个非常基础的例子,实际的系统可能需要包含更多的功能,例如更新员工信息,搜索员工等。

Information java员工信息管理代码

Information java员工信息管理代码
Information.java import java.util.*; public class Information {
public static void main(String[] args){ Scanner in=new Scanner(System.in); System.out.println("--------请定义员工人数---------"); Person personArr[]=new Person[in.nextInt()]; Adson adsonPer=new Adson(); while(true){ System.out.println("请选择你要执行的功能"); System.out.println("1:添加一个员工"); System.out.println("2:根据编号查找一个员工"); System.out.println("3:根据编号更新员工的基本信息"); System.out.println("4:根据编号删除员工---"); System.out.println("5:根据编号输入员工的各项信息"); System.out.println("6:根据绩效进行排序"); System.out.println("8:退出系统"); String di=in.next(); if(di.equals("1")){ System.out.println("请输入员工的姓名"); String name=in.next(); System.out.println("请输入员工的年龄"); int age=in.nextInt(); adsonPer.create(name,age,personArr); }else if(di.equals("2")){ System.out.println("正在执行根据编号查找一个员工

用数组实现职员管理java代码

用数组实现职员管理java代码

1、职员类 Clerk1)成员变量:编号、姓名、工资等(设为私有)2)成员方法:(1)构造方法;(2)成员的Set和Get方法;(3)toString()(输出职员信息的时候,调用此方法很方便)。

public class Clerk{private int num;private String name;private double salary;public Clerk(int a,String b,double c){num=a;name=b;salary=c;}public Clerk(){this(0,"",0);}public void setNum(int a){num=a;}public void setName(String b){name=b;}public void setSalary(double c){salary=c;}public int getNum(){return this.num;}public String getName(){return ;}public double getSalary(){return this.salary;}public String toString(){return ("姓名:"++" 编号:"+this.num+" 工资:"+this.salary);}}2、职员管理类 ClerkManage1) 成员变量:一个存放职员的数组2)成员方法:(1)构造方法;(2)增、删、改、查等方法。

public class ClerkManage{static Clerk[] clerk=new Clerk[100];public ClerkManage(){int i=0;for(i=0;i<clerk.length;i++){this.clerk[i]=new Clerk();}}public void add(Clerk a){int i=0;for(i=0;i<clerk.length;i++){if(clerk[i].getNum()==a.getNum()){System.out.println("此编号已存在!");}elseif(clerk[i].getNum()==0){clerk[i]=a;System.out.println("添加成功!");break;}}}public void delete(int num){int i=0;int t=0;for(i=0;i<clerk.length;i++){if(clerk[i].getNum()==num){clerk[i]=clerk[i+1];System.out.println("删除成功!");t=1;}}if(t==0){System.out.println("您要删除的编号不存在!");}}public void xiugai(int num,double salary){int i=0;int t=0;for(i=0;i<clerk.length;i++){if(clerk[i].getNum()==num){clerk[i].setSalary(salary);System.out.println("修改成功!");t=1;}}if(t==0){System.out.println("您要修改的编号不存在!");}}public void sort(int num){int i=0;int t=0;for(i=0;i<clerk.length;i++){if(clerk[i].getNum()==num){System.out.println(clerk[i]);t=1;}}if(t==0){System.out.println("您要查找的编号不存在!");}}}3、界面类(测试类) ClerkTesterimport java.io.*;public class ClerkTester{public static void main(String args[])throws IOException{ClerkManage clerk=new ClerkManage();BufferedReader br=new BufferedReader(new InputStreamReader(System.in));while(true){System.out.println("——————欢迎使用职员管理系统————————");System.out.println("请选择你要进行的操作:");System.out.println("1.添加一个职员:");System.out.println("2.查找一个职员:");System.out.println("3.修改一个职员的工资:");System.out.println("4.删除一个职员:");System.out.println("5.退出!");String operType=br.readLine();if(operType.equals("1")){System.out.println("请输入职员的编号:");int no=Integer.parseInt(br.readLine());System.out.println("请输入职员的姓名:");String name=br.readLine();System.out.println("请输入职员的工资:");double sla=Double.parseDouble(br.readLine());Clerk ck=new Clerk(no,name,sla);clerk.add(ck);} elseif(operType.equals("2")){System.out.println("请输入要查找的职工编号:");int no=Integer.parseInt(br.readLine());clerk.sort(no);}elseif(operType.equals("3")){System.out.println("请输入要修改的职工编号:");int no=Integer.parseInt(br.readLine());System.out.println("请输入修改后的工资:");double sla=Double.parseDouble(br.readLine());clerk.xiugai(no,sla);}elseif(operType.equals("4")){System.out.println("请输入要删除的职工编号:");int no=Integer.parseInt(br.readLine());clerk.delete(no);}elseif(operType.equals("5")){System.exit(0);}}}}。

职工管理系统源代码

职工管理系统源代码

#include<iostream>#include<string>#include<fstream>using namespace std;const N=50; // 定义系统可录入的员工最大数值long Enum[N];string Ename[N];char Esex[N];int Etime[N];string Etitle[N];int Edegree[50];float Epay[N];char Emarriage[N];class Employee{public:long Employeenum;string Employeename;char Employeesex;int Employeetime;string Employeetitle;int Employeedegree;float Employeepay;char Employeemarriage;static long EmployeeMaxNum;static float EmployeeBasePay;void NewInfo();void ShowInfo();void showall();void showtitle(string title);void showtimebehind(int time);void showtimebefore(int time);void showmarriage(char x);void shownum(long number);void RefreshInfo();void DeleteInfo();static int MaxNum();};class DBOperate{public:long Employeenum;string Employeename;char Employeesex;int Employeetime;string Employeetitle;int Employeedegree;float Employeepay;char Employeemarriage;static long EmployeeMaxNum;static float EmployeeBasePay;void WriteIn(int iflag);void ReadOut();void RefreshMaxNum(int iflag); //i=1 or -1 or 0};long Employee::EmployeeMaxNum = 1000;float Employee::EmployeeBasePay = 1500;int Employee::MaxNum(){ //返回系统已经存储的人数int MN = 0;ifstream myf;myf.open("EmployeeMaxNum.txt");myf>>MN;myf.close();return MN;}void Employee::NewInfo(){ //添加新成员函数Employee::Employeenum = EmployeeMaxNum + Employee::MaxNum()+1;cout<<"新员工姓名: ";cin>>Employee::Employeename;cout<<"新员工性别(F为女性,M为男性): ";cin>>Employee::Employeesex;cout<<"出生年月(如2010年3月:201003): ";cin>>Employee::Employeetime;cout<<"职工职称: ";cin>>Employee::Employeetitle;cout<<"新员工学历,请输入相应学历的序号: ";cout<<" [1:初中2:高中3:本科4:硕士5:博士] ";cin>>Employee::Employeedegree;cout<<"职工工资: ";cin>>Employee::Employeepay;cout<<"新员工婚姻状况(Y为已婚,N为未婚): ";cin>>Employee::Employeemarriage;DBOperate dbo;dbo.ReadOut();int MaxNum = Employee::MaxNum();Enum[MaxNum] = Employee::Employeenum;Ename[MaxNum] = Employee::Employeename;Esex[MaxNum] = Employee::Employeesex;Etime[MaxNum] = Employee::Employeetime;Etitle[MaxNum]= Employee::Employeetitle;Edegree[MaxNum] = Employee::Employeedegree;Epay[MaxNum] = Employee::Employeepay;Emarriage[MaxNum] = Employee::Employeemarriage;dbo.WriteIn(1);cout<<" 添加新成员成功!"<<endl;return;}void Employee::ShowInfo(){ //程序主体数据输出函数int choice1,time;char x;string title;Employee e;cout<<" 请选择查询方式:"<<endl;cout<<"★★★★★★★★★★★★★★★★★★★★★★★★★★★★★"<<endl;cout<<"* 输出全体职工信息列表--------------------------------- 1"<<endl;cout<<"* 输出某职称的职工信息列表----------------------------- 2"<<endl;cout<<"* 输出某年月以后出生的职工信息列表--------------------- 3"<<endl;cout<<"* 输出某年月以前出生的职工信息列表--------------------- 4"<<endl;cout<<"* 输出某婚姻状况的职工信息刘表------------------------- 5"<<endl;cout<<"★★★★★★★★★★★★★★★★★★★★★★★★★★★★★"<<endl;cin>>choice1;switch(choice1){case 1: showall();break;case 2: cout<<"请输入要查询的职工职称:";cin>>title;e.showtitle(title);break;case 3: cout<<"请输入要查询的出生日期,查询该日期后出生的职工(如2010年3月:201003):";cin>>time;e.showtimebehind(time);break;case 4: cout<<"请输入要查询的出生日期,查询该日期前出生的职工(如2010年3月:201003):";cin>>time;e.showtimebefore(time);break;case 5: cout<<"输入要查询职工的婚姻状况(Y为已婚,N为未婚):";cin>>x;e.showmarriage(x);break;default: cout<<"出错啦! "<<endl;break;}}void Employee::showall(){ //全体员工输出函数int i;for(i=0;i<Employee::MaxNum();i++){long number = Enum[i];shownum(number);}}void Employee::showtitle(string title){ //按职工职称输出函数int i;for(i=0;i<Employee::MaxNum();i++){if(Etitle[i]==title){long number = Enum[i];shownum(number);}else continue;}}void Employee::showtimebehind(int time){ //按员工年龄输出函数int i;for(i=0;i<Employee::MaxNum();i++){if(Etime[i]>=time){long number = Enum[i];shownum(number);}else continue;}}void Employee::showtimebefore(int time){ //按员工年龄输出函数int i;for(i=0;i<Employee::MaxNum();i++){if(Etime[i]<=time){long number = Enum[i];shownum(number);}else continue;}}void Employee::showmarriage(char x){ //按员工婚姻情况输出函数int i;for(i=0;i<Employee::MaxNum();i++){if(Emarriage[i]==x) {long number = Enum[i];shownum(number);}else continue;}}void Employee::shownum(long number){ //按员工编号输出函数int i;for(i=0;i<Employee::MaxNum();i++){if(Enum[i] == number){cout<<"∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl;cout<<" 员工编号>"<<Enum[i]<<endl;cout<<" 姓名>"<<Ename[i]<<endl;cout<<" 性别>";if(Esex[i]=='F') cout<<"女"<<endl;else if(Esex[i]=='M') cout<<"男"<<endl;cout<<" 出生年月"<<Etime[i]<<endl;cout<<" 职称>"<<Etitle[i]<<endl;cout<<" 学历>";switch (Edegree[i]){case 1:cout<<" 初中"<<endl;break;case 2:cout<<" 高中"<<endl;break;case 3:cout<<" 本科"<<endl;break;case 4:cout<<" 硕士"<<endl;break;case 5:cout<<" 博士"<<endl;break;}cout<<" 额定工资>"<<Epay[i]<<"元"<<endl;cout<<" 婚姻情况>";if(Emarriage[i]=='Y') cout<<"已婚"<<endl;else if(Emarriage[i]=='N') cout<<"未婚"<<endl;cout<<"∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"<<endl;}else continue;}}void Employee::RefreshInfo(){ //修改员工信息的函数int cNum = 1000;DBOperate dbo;dbo.ReadOut();void Employee::shownum(long number);cout<<"请输入您要修改的员工编号:>";cin>>cNum;int MN;MN = Employee::MaxNum();for(int i=0;i<MN;i++){ //遍历数据文件,查找要修改的员工数据if(Enum[i] == cNum){Employee::shownum(cNum);cout<<"请输入该员工的新信息: "<<endl;cout<<"新员工姓名: "; //录入员工的新的数据,员工号保持不变cin>>Employee::Employeename;Ename[i] = Employee::Employeename;cout<<"新员工性别: [F为女性,M为男性]: ";cin>>Employee::Employeesex;Esex[i] = Employee::Employeesex;cout<<"新员工出生年月: ";cin>>Employee::Employeetime;Etime[i] = Employee::Employeetime;cout<<"新员工的职称:";cin>>Employee::Employeetitle;Etitle[i]=Employee::Employeetitle;cout<<"新员工学历,请输入相应学历的序号:";cout<<" [1:初中2:高中3:本科4:硕士5:博士] ";cin>>Employee::Employeedegree;Edegree[i] = Employee::Employeedegree;cout<<"职工工资: ";cin>>Employee::Employeepay;Epay[i] = Employee::Employeepay;cout<<"新员工婚姻状况(Y为已婚,N为未婚): ";cin>>Employee::Employeemarriage;Emarriage[i] = Employee::Employeemarriage;break;}}dbo.WriteIn(0);}void Employee::DeleteInfo(){ //删除员工数据的函数char tmp;int cNum = 1000;DBOperate dbo;dbo.ReadOut();void Employee::shownum(long number);cout<<"请输入您要删除的员工编号>:";cin>>cNum;int MN;MN = Employee::MaxNum();for(int i=0;i<MN;i++){ //遍历数据文件,查找要删除的员工if(Enum[i] == cNum)Employee::shownum(cNum);}cout<<"确认要删除该员工信息?(Y为确认N为放弃):";cin>>tmp;if(tmp=='Y'){if(i==MN-1)dbo.WriteIn(-1);else{for(int j=i;j<MN-1;j++){ Enum[j] = Enum[j+1]; }dbo.WriteIn(-1);}cout<<" 删除操作成功! "<<endl;}}void DBOperate::WriteIn(int iflag){ //数据操作函数写入DBOperate::RefreshMaxNum(iflag);ofstream myf("Employee.txt");Employee e;int MN;MN = e.MaxNum();for(int i=0;i<MN;i++){myf<<Enum[i]<<'\n'<<Ename[i]<<'\n'<<Esex[i]<<'\n'<<Etime[i]<<'\n'<<Etitle[i]<<'\n'<<Edegree[i]<<'\n' <<Epay[i]<<'\n'<<Emarriage[i]<<'\n';}myf.close();return;}void DBOperate::ReadOut(){ //数据操作函数读出ifstream myf("Employee.txt");Employee e;int MN;MN = e.MaxNum();for(int i=0 ;i<MN;i++){myf>>DBOperate::Employeenum>>DBOperate::Employeename>>DBOperate::Employeese x>>DBOperate::Employeetime>>DBOperate::Employeetitle>>DBOperate::Employeedegree>>D BOperate::Employeepay>>DBOperate::Employeemarriage;Enum[i] = DBOperate::Employeenum;Ename[i] = DBOperate::Employeename;Esex[i] = DBOperate::Employeesex;Etime[i] = DBOperate::Employeetime;Etitle[i]=DBOperate::Employeetitle;Edegree[i] = DBOperate::Employeedegree;Epay[i] = DBOperate::Employeepay;Emarriage[i] = DBOperate::Employeemarriage;}myf.close();}void DBOperate::RefreshMaxNum(int iflag){ //更新系统中员工计数文件的函数int MaxNum = 0;ifstream myif("EmployeeMaxNum.txt");myif>>MaxNum;myif.close();MaxNum = MaxNum+iflag;ofstream myof("EmployeeMaxNum.txt");myof<<MaxNum;myof.close();}int main(){ //主函数int select = 0;while(select!=5){cout<<" ☆☆☆☆^-^天天好心情^-^☆☆☆☆"<<endl;cout<<" ▽▽▽▽▽《主菜单》▽▽▽▽▽▽"<<endl;cout<<" ⊙请选择功能⊙"<<endl;cout<<" ⊙㎜㎜㎜㎜㎜㎜㎜㎜㎜㎜㎜㎜㎜㎜⊙"<<endl;cout<<" ⊙①.新建并输入职工数据⊙"<<endl;cout<<" ⊙②.按条件输出职工数据⊙"<<endl;cout<<" ⊙③.修改指定职工的数据⊙"<<endl;cout<<" ⊙④.删除数据⊙"<<endl;cout<<" ⊙⑤.退出⊙"<<endl;cout<<" △△△△△△△△△△△△△△△△"<<endl;cout<<" -------▉计科1301 谭鑫▉------"<<endl;cout<<" 请选择您要服务的类别: " ;cin>>select;Employee e;DBOperate dbo;switch(select){case 1:e.NewInfo(); break;case 2:dbo.ReadOut();e.ShowInfo(); break;case 3:e.RefreshInfo(); break;case 4:e.DeleteInfo(); break;case 5: break;default:cout<<"命令错误!"<<endl;}if(select == 5)break;}exit(1);return 0;}。

职工信息管理系统代码

职工信息管理系统代码

1、定义职工类:public class Employee implements java.io.Serializable {String number,name,discipling,grade,borth,sex;public Employee(){}public void setNumber(String number){this.number=number;}public String getNumber(){return number;}public void setName(String name){=name;}public String getName(){return name;}public void setDiscipling(String discipling){this.discipling=discipling;}public String getDisciping(){return discipling;}public void setGrade(String grade){this.grade=grade;}public String getGrade(){return grade;}public void setBorth(String borth){this.borth=borth;}public String getBorth(){return borth;}public void setSex(String sex){this.sex=sex;}public String getSex(){return sex;}}2、主程序:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.Hashtable;public class EmployeeManager extends JFrame implements ActionListener {EmployeeSituation 基本信息录入=null;ModifySituation 基本信息修改=null;Inquest 基本信息查询=null;Delete 基本信息删除=null;JMenuBar bar;JMenu fileMenu;JMenuItem 录入,修改,查询,删除;Container con=null;Hashtable 基本信息=null;File file=null;CardLayout card=null;JLabel label=null;JPanel pCenter;public EmployeeManager(){录入=new JMenuItem("录入职工基本信息");修改=new JMenuItem("修改职工基本信息");查询=new JMenuItem("查询职工基本信息");删除=new JMenuItem("删除职工基本信息");bar=new JMenuBar();fileMenu=new JMenu("菜单选项");fileMenu.add(录入);fileMenu.add(修改);fileMenu.add(查询);fileMenu.add(删除);bar.add(fileMenu);setJMenuBar(bar);label=new JLabel("欢迎进入职工信息管理系统",JLabel.CENTER);label.setFont(new Font("SansSerif",Font.BOLD+Font.ITALIC,25));label.setForeground(Color.red);基本信息=new Hashtable();录入.addActionListener(this);修改.addActionListener(this);查询.addActionListener(this);删除.addActionListener(this);card=new CardLayout();con=getContentPane();pCenter=new JPanel();pCenter.setLayout(card);pCenter.setBackground(Color.yellow);file=new File("基本信息.txt");if(!file.exists()){try{FileOutputStream out=new FileOutputStream(file);ObjectOutputStream objectOut=new ObjectOutputStream(out);objectOut.writeObject(基本信息);objectOut.close();out.close();}catch(IOException e){}}基本信息录入=new EmployeeSituation(file);基本信息修改=new ModifySituation(file);基本信息查询=new Inquest(this,file);基本信息删除=new Delete(file);pCenter.add("欢迎语界面",label);pCenter.add("录入界面",基本信息录入);pCenter.add("修改界面",基本信息修改);pCenter.add("删除界面",基本信息删除);con.add(pCenter,BorderLayout.CENTER);con.validate();addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});setVisible(true);setBounds(100,50,420,380);validate();}public void actionPerformed(ActionEvent e){if(e.getSource()==录入){card.show(pCenter,"录入界面");}else if(e.getSource()==修改){card.show(pCenter,"修改界面");}else if(e.getSource()==查询){基本信息查询.setVisible(true);}else if(e.getSource()==删除){card.show(pCenter,"删除界面");}}public static void main(String args[]){new EmployeeManager();}}3、实现职工信息的录入:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;public class EmployeeSituation extends JPanel implements ActionListener {Hashtable 基本信息表=null;JTextField 职工号,姓名,工资;Choice 部门;JRadioButton 男,女;Employee 职工=null;ButtonGroup group=null;JButton 录入,重置;FileInputStream inOne=null;ObjectInputStream inTwo=null;FileOutputStream outOne=null;ObjectOutputStream outTwo=null;File file=null; public EmployeeSituation(File file){this.file=file;职工号=new JTextField(10);姓名=new JTextField(10);部门=new Choice();部门.add("请选择");部门.add("研发部");部门.add("销售部");部门.add("人事部");部门.add("安全部");工资=new JTextField(10);group=new ButtonGroup();男=new JRadioButton("男",true);女=new JRadioButton("女",false);group.add(男);group.add(女);录入=new JButton("录入");重置=new JButton("重置");录入.addActionListener(this);重置.addActionListener(this);Box box1=Box.createHorizontalBox();box1.add(new JLabel("职工号:",JLabel.CENTER));box1.add(职工号);Box box2=Box.createHorizontalBox();box2.add(new JLabel("姓名:",JLabel.CENTER));box2.add(姓名);Box box3=Box.createHorizontalBox();box3.add(new JLabel("性别:",JLabel.CENTER));box3.add(男);box3.add(女);Box box4=Box.createHorizontalBox();box4.add(new JLabel("部门:",JLabel.CENTER));box4.add(部门);Box box6=Box.createHorizontalBox();box6.add(new JLabel(" ",JLabel.CENTER));Box box5=Box.createHorizontalBox();box5.add(new JLabel("工资:",JLabel.CENTER));box5.add(工资);Box boxH=Box.createVerticalBox();boxH.add(box1);boxH.add(box2);boxH.add(box3);boxH.add(box5);boxH.add(box6);boxH.add(box4);boxH.add(Box.createVerticalGlue());JPanel pCenter=new JPanel();pCenter.add(boxH);pCenter.setBackground(Color.yellow);setLayout(new BorderLayout());add(pCenter,BorderLayout.CENTER);JPanel pSouth=new JPanel();pSouth.add(录入);pSouth.add(重置);pSouth.setBackground(Color.yellow);add(pSouth,BorderLayout.SOUTH);validate();}public void actionPerformed(ActionEvent e){if(e.getSource()==录入){String number="";number=职工号.getText();if(number.length()>0){try{inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);基本信息表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){}if(基本信息表.containsKey(number)){String warning="该职工基本信息已存在,请到修改页面修改!"; JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);}else{String m="基本信息将被录入!";int ok=JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,RMATION_MESSAGE);if(ok==JOptionPane.YES_OPTION){String name=姓名.getText();String discipling=部门.getSelectedItem();String grade=工资.getText();String sex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}职工=new Employee();职工.setNumber(number);职工.setName(name);职工.setDiscipling(discipling);职工.setGrade(grade);职工.setSex(sex);try{outOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);基本信息表.put(number,职工);outTwo.writeObject(基本信息表);outTwo.close();outOne.close();职工号.setText(null);姓名.setText(null);工资.setText(null);}catch(Exception ee){System.out.println(ee);}}}}else{String warning="必须要输入职工号!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);}}if(e.getSource()==重置){职工号.setText(null);姓名.setText(null);部门.remove(部门.getSelectedIndex());工资.setText(null);}}}4、实现职工信息的修改:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;public class ModifySituation extends JPanel implements ActionListener {Hashtable 基本信息表=null;JTextField 职工号,姓名,工资;Choice 部门;JRadioButton 男,女;ButtonGroup group=null;JButton 开始修改,录入修改,重置;FileInputStream inOne=null;ObjectInputStream inTwo=null;FileOutputStream outOne=null;ObjectOutputStream outTwo=null;File file=null;public ModifySituation(File file){this.file=file;职工号=new JTextField(10);姓名=new JTextField(10);部门=new Choice();部门.add("请选择");部门.add("研发部");部门.add("销售部");部门.add("人事部");部门.add("安全部");工资=new JTextField(10);group=new ButtonGroup();男=new JRadioButton("男",true);女=new JRadioButton("女",false);group.add(男);group.add(女);开始修改=new JButton("开始修改");录入修改=new JButton("录入修改");录入修改.setEnabled(false);重置=new JButton("重置");职工号.addActionListener(this);开始修改.addActionListener(this);录入修改.addActionListener(this);重置.addActionListener(this);Box box1=Box.createHorizontalBox();box1.add(new JLabel("输入要修改信息的职工号:",JLabel.CENTER));box1.add(职工号);box1.add(开始修改);Box box2=Box.createHorizontalBox();box2.add(new JLabel("姓名:",JLabel.CENTER));box2.add(姓名);Box box3=Box.createHorizontalBox();box3.add(new JLabel("性别:",JLabel.CENTER));box3.add(男);box3.add(女);Box box4=Box.createHorizontalBox();box4.add(new JLabel("部门:",JLabel.CENTER));box4.add(部门);Box box6=Box.createHorizontalBox();box6.add(new JLabel(" ",JLabel.CENTER));Box box5=Box.createHorizontalBox();box5.add(new JLabel("工资:",JLabel.CENTER));box5.add(工资);Box boxH=Box.createVerticalBox();boxH.add(box1);boxH.add(box2);boxH.add(box3);boxH.add(box5);boxH.add(box6);boxH.add(box4);boxH.add(Box.createVerticalGlue());JPanel pCenter=new JPanel();pCenter.add(boxH);pCenter.setBackground(Color.yellow);setLayout(new BorderLayout());add(pCenter,BorderLayout.CENTER);JPanel pSouth=new JPanel();pSouth.add(录入修改);pSouth.add(重置);pSouth.setBackground(Color.yellow);add(pSouth,BorderLayout.SOUTH);validate();}public void actionPerformed(ActionEvent e){if(e.getSource()==开始修改||e.getSource()==职工号){String number="";number=职工号.getText();if(number.length()>0){try {inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);基本信息表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){}if(基本信息表.containsKey(number)){录入修改.setEnabled(true);Employee stu=(Employee)基本信息表.get(number);姓名.setText(stu.getName());部门.getSelectedItem();工资.setText(stu.getGrade());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}}else{录入修改.setEnabled(false);String warning="该职工号不存在!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);职工号.setText(null);姓名.setText(null);部门.remove(部门.getSelectedItem());工资.setText(null);}}else{录入修改.setEnabled(false);String warning="必须要输入职工号!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);职工号.setText(null);姓名.setText(null);部门.remove(部门.getSelectedItem());工资.setText(null);}}else if(e.getSource()==录入修改){String number="";number=职工号.getText();if(number.length()>0){try {inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);基本信息表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){}if(基本信息表.containsKey(number)){String question="该职工基本信息已存在,您想修改他(她)的基本信息吗?";JOptionPane.showMessageDialog(this,question,"警告",JOptionPane.QUESTION_MESSAGE);String m="基本信息将被修改!";int ok=JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,RMATION_MESSAGE);if(ok==JOptionPane.YES_OPTION){String name=姓名.getText();String discipling=部门.getSelectedItem();String grade=工资.getText();String sex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}Employee 职工=new Employee();职工.setNumber(number);职工.setName(name);职工.setDiscipling(discipling);职工.setGrade(grade);职工.setSex(sex);try{outOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);基本信息表.put(number,职工);outTwo.writeObject(基本信息表);outTwo.close();outOne.close();职工号.setText(null);姓名.setText(null);部门.remove(部门.getSelectedItem());工资.setText(null);}catch(Exception ee){System.out.println(ee);}录入修改.setEnabled(false);}else if(ok==JOptionPane.NO_OPTION){录入修改.setEnabled(true);}}else{String warning="该职工号没有基本信息,不能修改!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);录入修改.setEnabled(false);}}else{String warning="必须要输入职工号!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);录入修改.setEnabled(false);}}if(e.getSource()==重置){职工号.setText(null);姓名.setText(null);部门.remove(部门.getSelectedItem());工资.setText(null);}}}5、实现职工信息的查询:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;public class Inquest extends JDialog implements ActionListener {Hashtable 基本信息表=null;JTextField 职工号,姓名,部门,工资;JRadioButton 男,女;JButton 查询;ButtonGroup group=null;FileInputStream inOne=null;ObjectInputStream inTwo=null;File file=null;public Inquest(JFrame f,File file){super(f,"查询对话框",false);this.file=file;职工号=new JTextField(10);查询=new JButton("查询");职工号.addActionListener(this);查询.addActionListener(this);姓名=new JTextField(10);姓名.setEditable(false);部门=new JTextField(10);部门.setEditable(false);工资=new JTextField(10);工资.setEditable(false);男=new JRadioButton("男",false);女=new JRadioButton("女",false);group=new ButtonGroup();group.add(男);group.add(女);Box box1=Box.createHorizontalBox();box1.add(new JLabel("输入要查询的职工号:",JLabel.CENTER));box1.add(职工号);box1.add(查询);Box box2=Box.createHorizontalBox();box2.add(new JLabel("姓名:",JLabel.CENTER));box2.add(姓名);Box box3=Box.createHorizontalBox();box3.add(new JLabel("性别:",JLabel.CENTER));box3.add(男);box3.add(女);Box box4=Box.createHorizontalBox();box4.add(new JLabel("部门:",JLabel.CENTER));box4.add(部门);Box box5=Box.createHorizontalBox();box5.add(new JLabel("工资:",JLabel.CENTER));box5.add(工资);Box boxH=Box.createVerticalBox();boxH.add(box1);boxH.add(box2);boxH.add(box3);boxH.add(box5);boxH.add(box4);boxH.add(Box.createVerticalGlue());JPanel pCenter=new JPanel();pCenter.add(boxH);pCenter.setBackground(Color.green);Container con=getContentPane();con.add(pCenter,BorderLayout.CENTER);con.validate();setVisible(false);setBounds(100,200,360,270);addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){setVisible(false);} });}public void actionPerformed(ActionEvent e){姓名.setText(null);部门.setText(null);工资.setText(null);if(e.getSource()==查询||e.getSource()==职工号){String number="";number=职工号.getText();if(number.length()>0){try {inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);基本信息表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){}if(基本信息表.containsKey(number)){Employee stu=(Employee)基本信息表.get(number);姓名.setText(stu.getName());部门.setText(stu.getDisciping());工资.setText(stu.getGrade());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);} }else{String warning="该职工号不存在!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);}}else{String warning="必须要输入职工号!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);}}}6、实现职工信息的删除:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;public class Delete extends JPanel implements ActionListener {Hashtable 基本信息表=null;JTextField 职工号,姓名,部门,工资;JRadioButton 男,女;JButton 删除;ButtonGroup group=null;FileInputStream inOne=null;ObjectInputStream inTwo=null;FileOutputStream outOne=null;ObjectOutputStream outTwo=null;File file=null;public Delete(File file){this.file=file;职工号=new JTextField(10);删除=new JButton("删除");职工号.addActionListener(this);删除.addActionListener(this);姓名=new JTextField(10);姓名.setEditable(false);部门=new JTextField(10);部门.setEditable(false);工资=new JTextField(10);工资.setEditable(false);男=new JRadioButton("男",false);女=new JRadioButton("女",false);group=new ButtonGroup();group.add(男);group.add(女);Box box1=Box.createHorizontalBox();box1.add(new JLabel("输入要删除的职工:",JLabel.CENTER));box1.add(职工号);box1.add(删除);Box box2=Box.createHorizontalBox();box2.add(new JLabel("姓名:",JLabel.CENTER));box2.add(姓名);Box box3=Box.createHorizontalBox();box3.add(new JLabel("性别:",JLabel.CENTER));box3.add(男);box3.add(女);Box box4=Box.createHorizontalBox();box4.add(new JLabel("部门:",JLabel.CENTER));box4.add(部门);Box box6=Box.createHorizontalBox();box6.add(new JLabel(" ",JLabel.CENTER));Box box5=Box.createHorizontalBox();box5.add(new JLabel("工资:",JLabel.CENTER));box5.add(工资);Box boxH=Box.createVerticalBox();boxH.add(box1);boxH.add(box2);boxH.add(box3);boxH.add(box5);boxH.add(box6);boxH.add(box4);boxH.add(Box.createVerticalGlue());JPanel pCenter=new JPanel();pCenter.add(boxH);pCenter.setBackground(Color.yellow);setLayout(new BorderLayout());add(pCenter,BorderLayout.CENTER);validate();}public void actionPerformed(ActionEvent e){if(e.getSource()==删除||e.getSource()==职工号){String number="";number=职工号.getText();if(number.length()>0){try{inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);基本信息表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){}if(基本信息表.containsKey(number)){Employee stu=(Employee)基本信息表.get(number);姓名.setText(stu.getName());部门.setText(stu.getDisciping());工资.setText(stu.getGrade());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}String m="确定要删除该职工号及全部信息吗?";int ok=JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if(ok==JOptionPane.YES_OPTION){基本信息表.remove(number);try{outOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);outTwo.writeObject(基本信息表);outTwo.close();outOne.close();职工号.setText(null);姓名.setText(null);部门.setText(null);工资.setText(null);}catch(Exception ee){System.out.println(ee);}}else if(ok==JOptionPane.NO_OPTION){职工号.setText(null);姓名.setText(null);部门.setText(null);工资.setText(null);}}else{String warning="该职工号不存在!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);}}else{String warning="必须要输入职工号!";JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);}}}}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

源代码package lesson2;import java.sql.*;public class employee{public String num;public String name;public String sex;public String age;public String edu;public String sla;public String add;public String tel;public void init(String x1,String x2,String x3,String x4,String x5,String x6,String x7,String x8) {num=x1;name=x2;sex=x3;age=x4;edu=x5;sla=x6;add=x7;tel=x8;}public void load(String f){try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");String url="jdbc:sqlserver://localhost:1433;DatabaseName=employee";String userName="sa";String password="xhw";Connection conn=DriverManager.getConnection(url,userName,password);if(conn!=null)System.out.println("已成功地与SQL Server 2005数据库建立连接!"); Statement stmt=conn.createStatement();stmt.executeUpdate(f);stmt.close();}catch(Exception e){e.printStackTrace();}}}package lesson2;import java.awt.*; import java.awt.event.*; import java.sql.*;public class lesson2_1{static Frame f;CardLayout myCard;Panel p1;Panel p2;Panel p3;Panel p4;Panel p5;Panel p6;Panel p7;Panel p8;public static void main(String[] args) {lesson2_1 test=new lesson2_1();test.go1();test.go2();test.go3();test.go4();test.go5();test.go6();test.go7();test.go8();}public void go1(){f=new Frame("呵呵 !!!");myCard=new CardLayout();f.setLayout(myCard);p1=new Panel();Button b1,b2,b3;Label L1;TextField te1;final TextField te2;p1.setLayout(new GridBagLayout());GridBagConstraints c=new GridBagConstraints();Panel p1_1=new Panel();p1_1.setLayout(new GridBagLayout());GridBagConstraints x=new GridBagConstraints();b1=new Button(" 请输入用户名 ");b1.setBackground(Color.CYAN);x.insets=new Insets(50,50,50,50);x.gridx=0;x.gridy=0;x.gridwidth=1;x.gridheight=1;p1_1.add(b1,x);b2=new Button(" 请输入密码 ");b2.setBackground(Color.CYAN); x.gridx=0;x.gridy=5;x.gridwidth=1;x.gridheight=1;p1_1.add(b2,x);te1=new TextField(15);c.insets=new Insets(40,0,40,0);x.gridx=5;x.gridy=0;x.gridwidth=1;x.gridheight=1;p1_1.add(te1,x);te2=new TextField(15);x.gridx=5;x.gridy=5;x.gridwidth=1;x.gridheight=1;p1_1.add(te2,x);L1=new Label(" * * * * * * * * * *欢迎进入职工管理系统* * * * * * * * * * * * * *");L1.setBackground(Color.CYAN);c.gridx=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p1.add(L1,c);b3=new Button(" 登录 ");b3.setBackground(Color.CYAN);c.gridx=0;c.gridy=10;c.gridwidth=5;c.gridheight=5;p1.add(b3,c);c.gridx=0;c.gridy=20;c.gridwidth=5;c.gridheight=5;p1.add(p1_1,c);p1.setBackground(Color.green);f.add(p1,"First");myCard.show(f,"First");f.setSize(600,600);f.setVisible(true);f.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});b3.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){String x=te2.getText();int y=Integer.parseInt(x);if(y==106)myCard.show(f,"Second");}});}public void go2(){p2=new Panel();Button b1,b2,b3,b4,b5,b6;Label L1;p2.setLayout(new GridBagLayout());GridBagConstraints c=new GridBagConstraints();c.insets=new Insets(50,0,8,0);b1 = new Button("1 职工信息录入");b1.setBackground(Color.CYAN);c.gridx=1;c.gridy=50;c.gridwidth=5;c.gridheight=50;p2.add(b1,c);b2=new Button("2 职工信息浏览"); b2.setBackground(Color.CYAN);c.gridx=1;c.gridy=100;c.gridwidth=5;c.gridheight=50;p2.add(b2,c);b3=new Button("3 职工信息查询"); b3.setBackground(Color.CYAN);c.gridx=1;c.gridy=150;c.gridwidth=5;c.gridheight=50;p2.add(b3,c);b4=new Button("4 职工信息排序"); b4.setBackground(Color.CYAN);c.gridx=1;c.gridwidth=5;c.gridheight=50;p2.add(b4,c);b5=new Button("5 职工信息修改");b5.setBackground(Color.CYAN);c.gridx=1;c.gridy=250;c.gridwidth=5;c.gridheight=50;p2.add(b5,c);b6=new Button("6 职工信息删除");b6.setBackground(Color.CYAN);c.gridx=1;c.gridy=300;c.gridwidth=5;c.gridheight=50;p2.add(b6,c);L1=new Label(" * * * * * * * *欢迎进入职工管理系统* * * * * * * * * *");L1.setBackground(Color.CYAN);c.gridy=0;c.gridwidth=5;c.gridheight=10;p2.add(L1,c);p2.setBackground(Color.green);f.add(p2,"Second");b1.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){myCard.show(f,"Third");}});b2.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){myCard.show(f,"Fourth");}});b3.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){myCard.show(f,"Fifth");}});b4.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){myCard.show(f,"Sixth");}});b5.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){myCard.show(f,"Seventh");}});b6.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){myCard.show(f,"Eighth");}});}public void go3(){p3=new Panel();p3.setLayout(new GridBagLayout());GridBagConstraints c=new GridBagConstraints();Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b10;final TextField te1,te2,te3,te4,te5,te6,te7,te8;Label L1;c.insets=new Insets(60,50,0,0);L1=new Label("* * * * * * * * * * * * * * * 请输入下面信息 * * * * * * * * * * * * * * * *");L1.setBackground(Color.CYAN);c.gridx=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p3.add(L1,c);b1=new Button(" 工号 ");b1.setBackground(Color.CYAN);c.gridx=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(b1,c);b2=new Button(" 姓名 "); b2.setBackground(Color.CYAN);c.gridx=35;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(b2,c);b3=new Button(" 性别 "); b3.setBackground(Color.CYAN);c.gridx=0;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(b3,c);b4=new Button(" 年龄 "); b4.setBackground(Color.CYAN);c.gridx=35;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(b4,c);b5=new Button(" 学历 "); b5.setBackground(Color.CYAN);c.gridx=0;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(b5,c);b6=new Button(" 工资 "); b6.setBackground(Color.CYAN);c.gridx=35;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(b6,c);b7=new Button(" 住址 ");b7.setBackground(Color.CYAN);c.gridx=0;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(b7,c);b8=new Button(" 电话 ");b8.setBackground(Color.CYAN);c.gridx=35;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(b8,c);b9=new Button(" 提交 "); b9.setBackground(Color.CYAN);c.gridx=10;c.gridy=100;c.gridwidth=1;c.gridheight=1;p3.add(b9,c);b10=new Button(" 返回 "); b10.setBackground(Color.CYAN);c.gridx=35;c.gridy=100;c.gridwidth=1;c.gridheight=1;p3.add(b10,c);te1=new TextField(10);c.gridx=10;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(te1,c);te2=new TextField(10);c.gridx=37;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(te2,c);te3=new TextField(10);c.gridx=10;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(te3,c);te4=new TextField(10);c.gridx=37;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(te4,c);te5=new TextField(10);c.gridx=10;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(te5,c);te6=new TextField(10);c.gridx=37;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(te6,c);te7=new TextField(10);c.gridx=10;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(te7,c);te8=new TextField(10);c.gridx=37;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(te8,c);p3.setBackground(Color.green);f.add(p3,"Third");b9.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){employee e1=new employee();e1.init(te1.getText(),te2.getText(),te3.getText(),te4.getText(),te5.getText(),te6.getText(),te7.getText(),te8.getText());String x="'";String y="'";String z=",";String w=")";String sql="insert into xhw values(";sql=sql+x+e1.num+y+z+x++y+z+x+e1.sex+y+z+x+e1.age+y+z+x++y+z +x+e1.sla+y+z+x+e1.add+y+z+x+e1.tel+y+w;e1.load(sql);te1.setText("");te2.setText("");te3.setText("");te4.setText("");te5.setText("");te6.setText("");te7.setText("");te8.setText("");}});b10.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){myCard.show(f,"Second");}});}public void go4(){p4=new Panel();p4.setLayout(new GridBagLayout());GridBagConstraints c=new GridBagConstraints();Button b1,b2;Label L1;final TextArea ta;c.insets=new Insets(60,0,0,0);L1=new Label("* * * * * * * * * * * * * * * 欢迎进入信息浏览界面 * * * * * * * * * * * * * * * *");L1.setBackground(Color.CYAN);c.gridx=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p4.add(L1,c);b1=new Button(" 浏览 ");b1.setBackground(Color.CYAN);c.gridx=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p4.add(b1,c);b2=new Button(" 返回 ");b2.setBackground(Color.CYAN);c.gridx=0;c.gridy=20;c.gridwidth=1;c.gridheight=1;p4.add(b2,c);ta= new TextArea(15,50);c.gridx=0;c.gridy=11;c.gridwidth=1;c.gridheight=1;p4.add(ta,c);p4.setBackground(Color.green);f.add(p4,"Fourth");b1.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");String url="jdbc:sqlserver://localhost:1433;DatabaseName=employee";String userName="sa";String password="xhw";Connection conn=DriverManager.getConnection(url,userName,password);Statement stmt=conn.createStatement();ResultSet rs=stmt.executeQuery("select * from xhw");employee[] em =new employee[10];int i=0;while(rs.next()){employee em1=new employee();em1.num=rs.getString("工号");=rs.getString("姓名");em1.sex=rs.getString("性别");em1.age=rs.getString("年龄");=rs.getString("学历");em1.sla=rs.getString("工资");em1.add=rs.getString("住址");em1.tel=rs.getString("电话");em[i]=em1;i++;}String s = "工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n";for(int j=0;j<i;j++){s=s+em[j].num+"\t"+em[j].name+"\t"+em[j].sex+"\t"+em[j].age+"\t"+em[j].edu+"\t"+em[j].sla+"\t"+em[j].add+"\t"+em[j].tel+"\n\n";}ta.setText(s);rs.close();stmt.close();}catch(Exception e1){ e1.printStackTrace();}}});b2.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){ta.setText("");myCard.show(f,"Second");}});}public void go5(){p5=new Panel();p5.setLayout(new GridBagLayout());GridBagConstraints c=new GridBagConstraints();c.insets=new Insets(40,0,0,0);Panel p5_2=new Panel();p5_2.setLayout(new GridBagLayout());GridBagConstraints x=new GridBagConstraints();x.insets=new Insets(30,60,0,80);Button b1,b2,b3,b4;final TextField t1;final TextField t2;final TextArea ta;Label L1;b1=new Button(" 查询名称 ");b1.setBackground(Color.CYAN);x.gridx=0;x.gridy=0;x.gridwidth=2;x.gridheight=1;p5_2.add(b1,x);b2=new Button(" 查询范围 "); b2.setBackground(Color.CYAN);x.gridx=0;x.gridy=5;x.gridwidth=2;x.gridheight=1;p5_2.add(b2,x);b3=new Button(" 查询 "); b3.setBackground(Color.CYAN);x.gridx=0;x.gridy=10;x.gridwidth=2;x.gridheight=1;p5_2.add(b3,x);b4=new Button(" 返回 ");b4.setBackground(Color.CYAN);x.gridx=20;x.gridy=10;x.gridwidth=1;x.gridheight=1;p5_2.add(b4,x);t1 = new TextField(10);x.gridx=20;x.gridy=0;x.gridwidth=1;x.gridheight=1;p5_2.add(t1,x);t2=new TextField(10);x.gridx=20;x.gridy=5;x.gridwidth=1;x.gridheight=1;p5_2.add(t2,x);L1=new Label(" * * * * * * * * * * * 欢迎进入职工信息查询界面 * * * * * * * * * * *");L1.setBackground(Color.CYAN);c.gridx=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p5.add(L1,c);c.gridx=0;c.gridy=5;c.gridwidth=1;c.gridheight=1;p5.add(p5_2,c);ta= new TextArea(10,65);c.gridx=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p5.add(ta,c);p5.setBackground(Color.green);f.add(p5,"Fifth");b4.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){t1.setText("");t2.setText("");ta.setText("");myCard.show(f,"Second");}});b3.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");String url="jdbc:sqlserver://localhost:1433;DatabaseName=employee";String userName="sa";String password="xhw";Connection conn=DriverManager.getConnection(url,userName,password);Statement stmt=conn.createStatement();String sql="select * from xhw where ";String sql1=t1.getText();String sql2=t2.getText();sql=sql+sql1+"'"+sql2+"'";ResultSet rs=stmt.executeQuery(sql);employee[] em =new employee[10];int i=0;while(rs.next()){employee em1=new employee();em1.num=rs.getString("工号");=rs.getString("姓名");em1.sex=rs.getString("性别");em1.age=rs.getString("年龄");=rs.getString("学历");em1.sla=rs.getString("工资");em1.add=rs.getString("住址");em1.tel=rs.getString("电话");em[i]=em1;i++;}String s = " 工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n";for(int j=0;j<i;j++){s=s+" "+em[j].num+"\t"+em[j].name+"\t"+em[j].sex+"\t"+em[j].age+"\t"+em[j].edu+"\t"+em[j].sla+"\t"+em[j].add+"\t"+em[j].tel+"\n\n";}ta.setText(s);rs.close();stmt.close();}catch(Exception e1){ e1.printStackTrace();}}});}public void go6(){p6=new Panel();p6.setLayout(new GridBagLayout()); GridBagConstraints c=new GridBagConstraints();c.insets=new Insets(60,0,30,0);Panel p6_1=new Panel();p6_1.setLayout(new GridBagLayout()); GridBagConstraints x=new GridBagConstraints(); x.insets=new Insets(0,40,0,40);Label L1;Button b1,b2,b3;final TextArea ta;b1=new Button("按年龄排序");x.gridx=0;x.gridy=0;x.gridwidth=1;x.gridheight=1;p6_1.add(b1,x);b2=new Button("按工资排序");x.gridx=10;x.gridy=0;x.gridheight=1;p6_1.add(b2,x);b3=new Button(" 返回 ");x.gridx=15;x.gridy=0;x.gridwidth=1;x.gridheight=1;p6_1.add(b3,x);L1=new Label(" * * * * * * * * * * * 欢迎进入职工信息查询界面 * * * * * * * * * * *");L1.setBackground(Color.CYAN);c.gridx=0;c.gridy=0;c.gridwidth=1;c.gridheight=1;p6.add(L1,c);c.gridx=0;c.gridy=5;c.gridwidth=1;p6.add(p6_1,c);ta=new TextArea(10,65);c.gridx=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p6.add(ta,c);p6.setBackground(Color.green);f.add(p6,"Sixth");b1.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");String url="jdbc:sqlserver://localhost:1433;DatabaseName=employee";String userName="sa";String password="xhw";Connection conn=DriverManager.getConnection(url,userName,password);Statement stmt=conn.createStatement();ResultSet rs=stmt.executeQuery("select * from xhw");employee[] em =new employee[10];int i=0;while(rs.next()){employee em1=new employee();em1.num=rs.getString("工号");=rs.getString("姓名");em1.sex=rs.getString("性别");em1.age=rs.getString("年龄");=rs.getString("学历");em1.sla=rs.getString("工资");em1.add=rs.getString("住址");em1.tel=rs.getString("电话");em[i]=em1;i++;}employee zz ;int x,y;for(int f=1;f<i-1;f++)for(int k=f+1;k<i;k++){x=Integer.parseInt(em[f].age);y=Integer.parseInt(em[k].age);if(x>y){zz=em[f];em[f]=em[k];em[k]=zz;}}String s = " "+"工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n"; for(int j=0;j<i;j++){s=s+" "+em[j].num+"\t"+em[j].name+"\t"+em[j].sex+"\t"+em[j].age+"\t"+em[j].edu+"\t"+em[j].sla+"\t"+em[j].add+"\t"+em[j].tel+"\n\n";}ta.setText(s);rs.close();stmt.close();}catch(Exception e1){ e1.printStackTrace();}}});b2.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");String url="jdbc:sqlserver://localhost:1433;DatabaseName=employee"; String userName="sa";String password="xhw";Connection conn=DriverManager.getConnection(url,userName,password);Statement stmt=conn.createStatement();ResultSet rs=stmt.executeQuery("select * from xhw");employee[] em =new employee[10];int i=0;while(rs.next()){employee em1=new employee();em1.num=rs.getString("工号");=rs.getString("姓名");em1.sex=rs.getString("性别");em1.age=rs.getString("年龄");=rs.getString("学历");em1.sla=rs.getString("工资");em1.add=rs.getString("住址");em1.tel=rs.getString("电话");em[i]=em1;i++;}employee zz ;int x,y;for(int f=1;f<i-1;f++)for(int k=f+1;k<i;k++){x=Integer.parseInt(em[f].sla);y=Integer.parseInt(em[k].sla);if(x>y){zz=em[f];em[f]=em[k];em[k]=zz;}}String s = " "+"工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n";for(int j=0;j<i;j++){s=s+" "+em[j].num+"\t"+em[j].name+"\t"+em[j].sex+"\t"+em[j].age+"\t"+em[j].edu+"\t"+em[j].sla+"\t"+em[j].add+"\t"+em[j].tel+"\n\n";}ta.setText(s);rs.close();stmt.close();}catch(Exception e1){ e1.printStackTrace();}}});b3.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){ta.setText("");myCard.show(f,"Second");}});}public void go7(){p7=new Panel();p7.setLayout(new GridBagLayout());GridBagConstraints c=new GridBagConstraints();c.insets=new Insets(40,0,50,0);Panel p7_1=new Panel();p7_1.setLayout(new GridBagLayout());GridBagConstraints x=new GridBagConstraints();x.insets=new Insets(30,60,0,80);Label L1;Button b1,b2,b3,b4,b5,b6,b7;final TextField t1;final TextField t2;final TextField t3;b1=new Button(" 信息编号 ");b1.setBackground(Color.CYAN);x.gridx=0;x.gridy=0;x.gridwidth=1;x.gridheight=1;p7_1.add(b1,x);b2=new Button(" 修改名称");b2.setBackground(Color.CYAN);x.gridx=0;x.gridy=5;x.gridwidth=1;x.gridheight=1;p7_1.add(b2,x);b3=new Button(" 修改值"); b3.setBackground(Color.CYAN);x.gridx=0;x.gridy=10;x.gridwidth=1;x.gridheight=1;p7_1.add(b3,x);b4=new Button(" 修改 "); b4.setBackground(Color.CYAN);x.gridx=0;x.gridy=15;x.gridwidth=1;x.gridheight=1;p7_1.add(b4,x);b5=new Button(" 返回"); b5.setBackground(Color.CYAN);x.gridx=10;x.gridy=15;x.gridwidth=1;x.gridheight=1;p7_1.add(b5,x);b6=new Button(" 查询");b6.setBackground(Color.CYAN);x.gridx=0;x.gridy=20;x.gridwidth=1;x.gridheight=1;p7_1.add(b6,x);b7=new Button(" 继续"); b7.setBackground(Color.CYAN);x.gridx=10;x.gridy=20;x.gridwidth=1;x.gridheight=1;p7_1.add(b7,x);t1=new TextField(16);x.gridx=10;x.gridy=0;x.gridwidth=1;x.gridheight=1;p7_1.add(t1,x);t2=new TextField(16);x.gridx=10;x.gridy=5;x.gridwidth=1;x.gridheight=1;p7_1.add(t2,x);t3=new TextField(16);x.gridx=10;x.gridy=10;x.gridwidth=1;x.gridheight=1;p7_1.add(t3,x);L1=new Label(" * * * * * * * * * * * 欢迎进入职工信息修改界面 * * * * * * * * * * *");L1.setBackground(Color.CYAN);c.gridx=0;c.gridy=0;c.gridwidth=1;c.gridheight=1;p7.add(L1,c);c.gridx=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p7.add(p7_1,c);p7.setBackground(Color.green);f.add(p7,"Seventh");b4.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e){employee e1=new employee();String sql;sql="update xhw set "+t2.getText()+"="+"'"+t3.getText()+"'"+"where 工号='"+t1.getText()+"'";System.out.println(sql);e1.load(sql);t1.setText("");t2.setText("");t3.setText("");}});b5.addMouseListener(new MouseAdapter(){public void mouseClicked(MouseEvent e)myCard.show(f,"Second");}});b6.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){myCard.show(f,"Fifth");}});b7.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){t1.setText("");t2.setText("");t3.setText("");}}public void go8(){p8=new Panel();p8.setLayout(new GridBagLayout());GridBagConstraints c=new GridBagConstraints();c.insets=new Insets(10,0,70,0);Panel p8_1=new Panel();p8_1.setLayout(new GridBagLayout());GridBagConstraints x=new GridBagConstraints();x.insets=new Insets(80,60,0,80);Button b1,b2,b3;Label L1;final TextField t1;b1=new Button(" 工号 ");b1.setBackground(Color.CYAN);x.gridx=0;x.gridy=0;。

相关文档
最新文档