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按任意键继续。

  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;。

相关文档
最新文档