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

合集下载

员工管理系统java课程设计代码

员工管理系统java课程设计代码

员工管理系统java课程设计代码员工管理系统是一个非常广泛的课程设计主题,它涉及到许多方面,包括数据库设计、用户界面设计、业务逻辑等等。

由于篇幅限制,我将简要介绍员工管理系统的Java课程设计代码的一般架构和关键功能,希望能够帮助你理解和实现这样一个系统。

首先,员工管理系统通常需要一个数据库来存储员工信息,包括员工的个人信息、工资、部门等。

在Java中,你可以使用JDBC 来连接数据库,执行SQL语句来实现数据的增删改查操作。

你需要创建一个数据库连接类来管理数据库连接,以及实现员工信息的增删改查功能。

其次,员工管理系统需要一个用户界面来实现用户与系统的交互。

你可以使用Swing或JavaFX等GUI库来创建界面,包括登录界面、员工信息管理界面等。

在界面上,你需要实现各种按钮、文本框等组件来实现用户的操作,比如添加员工、删除员工、修改员工信息等。

另外,员工管理系统还需要实现一些业务逻辑,比如计算员工的工资、根据部门查询员工信息等。

你可以创建一个业务逻辑类来实现这些功能,然后在界面上调用这些方法来实现相应的功能。

此外,为了保证系统的安全性和稳定性,你还需要进行异常处理、输入验证等工作。

在Java中,你可以使用try-catch语句来捕获异常,并使用正则表达式等方法来验证用户的输入。

最后,为了保证代码的可维护性和可扩展性,你可以将不同的功能模块分别封装成不同的类,采用面向对象的编程思想来设计代码结构。

总的来说,员工管理系统的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课程设计代码

员工管理系统Java课程设计代码一、需求分析在公司中,员工管理是一个至关重要的环节。

为了提高管理效率,我们需要一个员工管理系统。

本系统可以实现员工信息的录入、查询、修改和删除等功能,同时能够根据不同的需求输出相应的报表。

本文将介绍员工管理系统的Java课程设计代码实现。

二、系统架构1. 数据库设计我们将使用MySQL数据库存储员工信息。

数据库中将包含一个employee表,用于存储员工的基本信息,如员工号、姓名、性别、职位、入职日期等字段。

2. 后台逻辑后台逻辑部分将采用Java语言进行编码。

我们将使用JDBC连接数据库,实现数据的增删改查操作。

同时,我们将采用面向对象的编程思想,设计Employee类来表示员工信息,EmployeeDAO类用于实现数据库操作。

3. 前端界面前端界面将采用简单的控制台界面。

用户可以通过控制台界面输入操作指令,实现员工信息的录入、查询、修改和删除操作。

三、功能实现1. 员工信息录入用户可以输入员工的基本信息,程序将会将信息保存到数据库中。

2. 员工信息查询用户可以通过员工号或者姓名进行查询,程序将会从数据库中检索相应的员工信息,并输出到控制台。

3. 员工信息修改用户可以输入员工号和需要修改的信息,程序将会更新数据库中对应员工的信息。

4. 员工信息删除用户可以输入员工号,程序将会从数据库中删除对应员工的信息。

5. 输出报表系统提供了不同的报表输出选项,如按照职位统计员工人数、按照性别统计员工平均工资等。

四、代码示例public class Employee {private int empId;private String empName;private String gender;private String position;private Date hireDate;// 省略getter和setter方法}public class EmployeeDAO {public void addEmployee(Employee emp) {// 实现员工信息添加逻辑}public Employee findEmployeeById(int empId) {// 实现根据员工号查询员工信息逻辑}public void updateEmployee(Employee emp) {// 实现员工信息更新逻辑}public void deleteEmployee(int empId) {// 实现员工信息删除逻辑}}// 程序入口public class Main {public static void main(String[] args) {// 主程序逻辑,包括界面交互和调用DAO方法}}五、总结通过本文的介绍,我们可以看到员工管理系统的Java课程设计代码实现是一个比较完整的系统,涵盖了从数据库设计到后台逻辑再到前端界面的全方位内容。

企业人事管理系统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<stdio.h>/*人员信息管理系统*/#include<string.h>#include<malloc.h>#include<stdlib.h>#define Max 10000typedef struct Node{int NO; // 编号char name[30]; // 姓名char sex[10]; // 性别int age; // 年龄char ZhiWu[30]; // 职务char Zhicheng[30]; //职称char ZZMM[30]; // 政治面貌char XueLi[30]; // 最高学历int OnTime; // 任职时间int CTime; // 来院时间char RenLB[30]; // 人员类别}Worker;Worker Q[Max];int top;int cnt = 0;int Insert() //输入人员信息{Worker *q;if( ( q = (Worker *)malloc( sizeof( Worker) ) ) == NULL )exit(0); printf( "请依次输入:编号,姓名,性别,年龄,职务,职称,政治面貌,最高学历,任职时间,来院时间,人员类别\n" );scanf( "%d %s %s %d %s %s %s %s %d %d %s", &(q->NO), q->name, q->sex, &(q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, &(q->OnTime), &(q->CTime), q->RenLB );Q[top++] = (*q);printf( "已加入\n" );return top;}int Delete() //按编号删除人员信息{int NO;int i, j, ok = 0;printf( "请依次输入: 编号\n" );scanf( "%d", &NO );for( i = 0; i < top; i++ ){if( Q[i].NO ==NO ){for( j = i+1; j < top; j++ ){Q[j-1] = Q[j];}top--;ok = 1;break;}}if( ok == 0 )printf( "无此人\n" );else printf( "已删除\n" );return top;}void Search() //搜索人员信息{int NO;char name[30];int i, ok = 0;Worker *q;printf( "请依次输入: 编号和姓名\n" );scanf( "%d %s", &NO, name );for( i = 0; i < top; i++ ){if( Q[i].NO ==NO && strcmp( Q[i].name, name ) == 0 ) {ok = 1;break;}}q = &(Q[i]);if( ok == 0 )printf( "无此人\n" );else{printf( "该人信息为:\n" );printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi,(q->OnTime), (q->CTime), q->RenLB );}}void Sort(Worker *Q) //按要求进行排序分类{int way,i,j,flag=1;Worker temp;printf( "输入按什么排序:1 --- 年龄; 2 ---- 来院时间\n" );scanf( "%d", &way );if( way == 1 ){for(i=1;i<top&&flag==1;i++){flag=0;for(j=0;j<top-i;j++){if(Q[j].age>Q[j+1].age){flag=1;temp=Q[j];Q[j]=Q[j+1];Q[j+1]=temp;}}for(i=0;i<cnt;i++)printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (Q[i].NO),Q[i].name, Q[i].sex, (Q[i].age),Q[i].ZhiWu, Q[i].Zhicheng, Q[i].ZZMM, Q[i].XueLi, (Q[i].OnTime), (Q[i].CTime), Q[i].RenLB );}}else if( way == 2 ){for(i=1;i<top&&flag==1;i++){flag=0;for(j=0;j<top-i;j++){if(Q[j].CTime>Q[j+1].CTime){flag=1;temp=Q[j];Q[j]=Q[j+1];Q[j+1]=temp;}}for(i=0;i<cnt;i++)printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (Q[i].NO),Q[i].name, Q[i].sex, (Q[i].age),Q[i].ZhiWu, Q[i].Zhicheng, Q[i].ZZMM, Q[i].XueLi, (Q[i].OnTime), (Q[i].CTime), Q[i].RenLB );}for(i=0;i<cnt;i++)printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (Q[i].NO),Q[i].name, Q[i].sex, (Q[i].age),Q[i].ZhiWu, Q[i].Zhicheng, Q[i].ZZMM, Q[i].XueLi, (Q[i].OnTime), (Q[i].CTime), Q[i].RenLB );}}void COUNT_1() //统计在职人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].RenLB, "退休人员" ) != 0 &&strcmp( Q[i].RenLB, "临时工" ) != 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}}printf( "共有%d 在职人数\n", cnt );}void COUNT_2() //统计党员人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].ZZMM, "党员" ) == 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}}printf( "共有%d 党员\n", cnt );}void COUNT_3() // 统计女工人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].sex, "女" ) == 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}}printf( "共有%d 女性员工\n", cnt );}void COUNT_4() //统计高学历人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].XueLi, "研究生" ) == 0|| strcmp( Q[i].XueLi, "副教授" ) == 0|| strcmp( Q[i].XueLi, "教授" ) == 0|| strcmp( Q[i].XueLi, "院士" ) == 0|| strcmp( Q[i].XueLi, "博士" ) == 0|| strcmp( Q[i].XueLi, "博士后" ) == 0|| strcmp( Q[i].XueLi, "助理教授" ) == 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}printf( "共有%d 高学历员工\n", cnt );}void Count() //统计函数{int way;printf( "输入按什么统计:1 --- 在职人数; 2 --- 党员人数;3 --- 女工人数;4 --- 高学历高职称人数: \n" );printf( "输入统计关键字:" );scanf( "%d", &way );switch( way ){case 1: COUNT_1(); break;case 2: COUNT_2(); break;case 3: COUNT_3(); break;case 4: COUNT_4(); break;}}void Edit() // 编辑存储功能{}int main(){int way;top = 0;printf( "\n\n" );printf( "****************************************************************** **\n" );printf( " * 1:添加人员,输入人员相关信息*\n" );printf( " * 2: 删除人员,提供职工号*\n" );printf( " * 3: 查询提供编号和姓名*\n" );printf( " * 4: 统计提供相应方式对应输入*\n" );printf( " * 5: 排序,按程序要求提供相应的关键字*\n" );printf( " * 6: 编辑存储*\n" );printf( "****************************************************************** **\n" );while( 1 ){printf( "输入需要操作:way = " ); // 选择功能if( scanf( "%d", &way ) == EOF )break; // 以 ctrl + Z 结束输入switch(way){case 1: Insert(); break;case 2: Delete(); break;case 3: Search(); break;case 4: Count(); break;case 5: Sort(Q); break;case 6: Edit(); break;}}return 0;}。

简单的职工管理系统源代码

简单的职工管理系统源代码
q->next=p->next;
p->next=q;
printf(".^_^.录入成功!.^_^.\n");
return -1;
}
/*按姓名查询*/
PLINK findname(PLINK p,char *name)
{
message();
printf("按姓名查询\n");
printf("职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n");
printf("职工性别:%s\n",curr->w.sex);
printf("职工年龄:%d\n",curr->w.age);
printf("职工学历:%s\n",curr->);
printf("职工工资:%d\n",curr->w.wages);
printf("职工住址:%s\n",curr->w.adr);
return -1;
}
printf("请输入职工号(数字):");
scanf("%d",&q->w.id);
h=p->next;
while(h)
{
if(h->w.id==q->w.id)
{
free(q);
printf("录入失败提示:此职工号已经存在!\n");
return -1;
}
h=h->next;
scanf("%d",&l);
if(l>0&&l<4)

人力资源管理系统源代码

人力资源管理系统源代码

1)登陆窗体代码设计窗体代码主要实现了连接数据库的功能,这里用于连接用户信息表。

其程序如下:Private Sub Form_Load()Dim i As IntegerIf App.PrevInstance ThenMsgBox ("程序已经运行,不能再次装载。

"), vbExclamationUnload MeEnd If'本段代码用于判定本程序是否已经装载于内存中,以避免程序的多重启动i = 0Open App.Path + "\user.ini" For Input As #1Do While Not EOF(1)Input #1, user(i), pws(i), state(i), Emplo(i)If state(i) = "A" ThenCombo1.AddItem user(i)End Ifi = i + 1Loop Close #1Combo1.ListIndex = 1'在窗口装载阶段读取用户设置文件获取用户信息并装载于用户列表框中End Sub(2)“取消”按钮是退出登录界面,退出系统的。

其代码如下:Private Sub CmdCancel_Click()Unload MeEndEnd Sub(3)“确定”按钮代码设计“确定”按钮代码主要实现了用户登陆时,用户名和密码的认证,当用户名或密码错误时,系统提示错误。

其程序如下:Private Sub cmdOK_Click()If txtPassword = pws(Combo1.ListIndex) ThenCurId = Combo1.ListIndexEmploID = Emplo(CurId)CurUser = user(CurId)CurPsw = pws(CurId)Me.Hide'Load FrmMainFrmMain.ShowElse MsgBox "Invalid Password, try again!", , "Login"txtPassword.SetFocusSendKeys "{Home}+{End}"End If End Sub(1)窗体选择的单击事件代码设计窗体选择的单击事件代码主要实现了进入本系统所有模块的功能,这里有以下几个模块,它们分别是员工信息模块,假条信息模块,工资管理模块,用户设置模块等/其程序如下:Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.IndexCase 1Call showemployee ‘显示员工信息模块Case 2Call showleave ‘显示假条信息模块Case 3Call showsalary ‘显示工资信息模块Case 4If frmLogin.CurUser = "root" ThenFrmSys.ShowElseFrmPsw.ShowPwin = "Frmmain"FrmMain.Enabled = FalseEnd IfEnd SelectEnd Sub(2)命令按钮的单击事件代码设计命令按钮的代码主要实现了进入本系统部分主要模块的功能,这里有以下几个功能,它们分别是编辑,删除,查询,设置。

java员工管理系统排序代码

java员工管理系统排序代码

java员工管理系统排序代码摘要:1.引言2.员工管理系统的需求和功能3.Java 中常用的排序算法4.冒泡排序算法介绍5.冒泡排序Java 实现代码6.选择排序算法介绍7.选择排序Java 实现代码8.插入排序算法介绍9.插入排序Java 实现代码10.快速排序算法介绍11.快速排序Java 实现代码12.归并排序算法介绍13.归并排序Java 实现代码14.希尔排序算法介绍15.希尔排序Java 实现代码16.堆排序算法介绍17.堆排序Java 实现代码18.总结正文:1.引言在Java 开发中,员工管理系统是一个常见的应用场景。

为了提高系统的效率,对员工信息进行排序是一个关键环节。

本文将介绍几种Java 中常用的排序算法,并给出相应的实现代码。

2.员工管理系统的需求和功能员工管理系统通常包括员工信息的添加、删除、修改、查询等基本功能。

在这些功能中,对员工信息进行排序可以提高查询和显示的效率。

3.Java 中常用的排序算法在Java 中,常用的排序算法包括冒泡排序、选择排序、插入排序、快速排序、归并排序、希尔排序和堆排序等。

这些排序算法有不同的特点和适用场景。

4.冒泡排序算法介绍冒泡排序是一种简单的排序算法,它通过相邻元素的比较和交换,使较大(或较小)的元素逐渐从前往后(或从后往前)移动。

经过n-1 轮比较后,最大(或最小)的元素就会移动到数组的最后一个位置。

5.冒泡排序Java 实现代码```javapublic void bubbleSort(int[] array) {int n = array.length;for (int i = 0; i < n - 1; i++) {for (int j = 0; j < n - 1 - i; j++) {if (array[j] > array[j + 1]) {int temp = array[j];array[j] = array[j + 1];array[j + 1] = temp;}}}}```6.选择排序算法介绍选择排序是一种简单的排序算法,它每次从待排序的数据元素中选出最大(或最小)的一个元素,将其与待排序的数据序列的最前面(或最后面)的元素进行交换,然后缩小待排序数据序列的范围,直到全部待排序的数据元素都排好序为止。

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

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

package exercise;import java.io.*;class staffInfo //职工类{public String name;public String num;public String sex;public String age;public String record;public String position;public String wanges;public String tel;public String addr;}public class StaffInfomation //实现部分{public static void main(final String[] args) throws IOException {staffInfo staffOne[]=new staffInfo[100];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 String recordkey;public int i=0;//i用来存放职工的人数public String filename="Infomation.txt";BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));void caidan(staffInfo staffOne[]) throws IOException{final BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); //此处是JAVA语言中输入数据的基本格式,功能有如C中的scanf函数int choice;do{System.out.println("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓");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.读取已存数据★★★┃");System.out.println("┃★★★ 6.安全退出系统★★★┃");System.out.println("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛");System.out.print(" 请输入您需要的功能代号(1--6):");choice=Integer.parseInt(buf.readLine());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(System.in));System.out.print("请输入职工信息(以0结束)\n");System.out.print("姓名:");staffOne[i].name=buf.readLine(); //用数组staffOne[i]来暂存职工的相关信息while(staffOne[i]pareTo("0")!=0) //用compareTo方法拟定鉴定是否应当写入新信息{System.out.print("工号:");staffOne[i].num=buf.readLine();System.out.print("性别:");staffOne[i].sex=buf.readLine();System.out.print("年龄:");staffOne[i].age=buf.readLine();System.out.print("学历:");staffOne[i].record=buf.readLine();System.out.print("职位:");staffOne[i].position=buf.readLine();System.out.print("工资:");staffOne[i].wanges=buf.readLine();System.out.print("电话:");staffOne[i].tel=buf.readLine();System.out.print("住址:");staffOne[i].addr=buf.readLine();i++;System.out.println("请输入下一个职工信息:");staffOne[i].name=buf.readLine();}}void output(staffInfo staffOne[]) throws IOException //这里是实现“输出(预览)职工信息”output的模块{for(int j=0;j<i;j++){if(i!=0){System.out.println("------------------------------------------------------------------------------------------------");System.out.println(" *职工信息表* ");System.out.println("-------------------------------------------------------------------------------------------------");System.out.println("姓名\t工号\t\t性别\t年龄\t学历\t职位\t\t工资\t电话号码 \t\t住址");System.out.println("-------------------------------------------------------------------------------------------------");System.out.print(staffOne[j].name+"\t"+staffOne[j].num+"\t"+staff One[j].sex+"\t"+staffOne[j].age+"\t"+staffOne[j].record+"\t"+staf fOne[j].position+"\t\t"+staffOne[j].wanges+"\t"+staffOne[j].tel+" \t"+staffOne[j].addr+"\n");System.out.println("-------------------------------------------------------------------------------------------------");}else System.out.println("没有职工信息!");}}void search(staffInfo staffOne[]) throws IOException{final BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));System.out.print("请输入您要查找的职工工号:");recordkey=buf.readLine();boolean flg=true;for(int j=0;j<i;j++){if(recordkey.equals(staffOne[j].num)) //equals是字符串比较函数相等返回true{System.out.println("-------------------------------------------------------------------------------------");System.out.println(" *职工信息表* ");System.out.println("--------------------------------------------------------------------------------------");System.out.println("姓名\t工号\t\t性别\t年龄\t学历\t职位 \t\t 工资\t电话号码 \t\t住址");System.out.println("--------------------------------------------------------------------------------------");System.out.println(staffOne[j].name+"\t"+staffOne[j].num+"\t"+sta ffOne[j].sex+"\t"+staffOne[j].age+"\t"+staffOne[j].record+"\t"+st affOne[j].position+"\t\t"+staffOne[j].wanges+"\t"+staffOne[j].tel +"\t"+staffOne[j].addr+"\n");flg=false;}}if(flg)System.out.println("对不起,查无此人!");}void delete(staffInfo staffOne[]) throws IOException{final BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));System.out.print("请输入您要删除的职工工号:");recordkey=buf.readLine();boolean flg=true;for(int j=0;j<i;j++){System.out.println("输入的工号为:"+recordkey);if(recordkey.equals(staffOne[j].num)){for(int k=j;k<=i-1;k++) //运用顺序表的删除算法,删除值之后,再把后面的值往前移位,从而实现删除{staffOne[k].name=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--;//职工人数减一flg=false;}}if(flg)System.out.println("对不起,查无此人!。

Java实现简单员工管理系统

Java实现简单员工管理系统

Java实现简单员⼯管理系统本⽂实例为⼤家分享了Java实现简单员⼯管理系统的具体代码,供⼤家参考,具体内容如下代码如下:import java.util.*;public class Demo {public static void main(String[] args) {EmpManage em = new EmpManage();while (true) {System.out.println("==================员⼯管理系统====================");System.out.println("==================0.加载原有信息==================");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("==================7.打印全体员⼯信息==============");System.out.println("==================8.退出系统=====================");System.out.print("请选择功能【0~8】:");Scanner reader = new Scanner(System.in);int x;x = reader.nextInt();switch (x) {case 0:Employee e1 = new Employee("2001","轩辕⼽",2002f);Employee f = new Employee("2002","季长风",4500f);Employee g = new Employee("2003","鱼幼薇",2560f);Employee h = new Employee("2004","李⼩龙",1604f);em.addEmp(e1);em.addEmp(f);em.addEmp(g);em.addEmp(h);System.out.println("加载完毕!");break;case 1:System.out.println("请输⼊要增加员⼯的信息(编号,姓名,薪⽔中间⽤空格隔开)");String a, b;float c;a = reader.next();b = reader.next();c = reader.nextFloat();Employee e = new Employee(a, b, c);em.addEmp(e);System.out.println("加⼊成功!");break;case 2:System.out.print("请输⼊要刪除員⼯的编号:");String y;y=reader.next();em.deleteEmp(y);System.out.println("删除成功!");break;case 3:System.out.print("请输⼊要查询員⼯的编号:");String z;z=reader.next();em.showinfo(z);break;case 4:System.out.print("请输⼊要修改員⼯的编号:");String w;w=reader.next();System.out.print("请输⼊要修改成的⼯资数⽬:");float v;v=reader.nextFloat();em.changesal(w, v);System.out.println("修改成功!");break;case 5:System.out.println("1.按薪⽔从⾼到低的顺序排序");System.out.println("2.按薪⽔从低到⾼的顺序排序");System.out.print("请选择功能【1~2】:");int t;t=reader.nextInt();if(t==1){em.sorthl();}if(t==2){em.sortlh();}break;case 6:em.hlsal();break;case 7:em.showAll();break;case 8:System.out.println("程序已经运⾏结束,下次见!");System.exit(0);break;default:System.out.print("数字范围只能在1~8之间!");}}}}//雇员管理类class EmpManage{private ArrayList al=null;//构造⽅法public EmpManage() {al=new ArrayList();}//加⼊员⼯⽅法public void addEmp(Employee e){al.add(e);}//刪除员⼯public void deleteEmp(String x){int i;for(i=0;i<al.size();i++){Employee temp=(Employee)al.get(i);if(temp.getEmNo().equals(x))break;}al.remove(i-1);}//根据员⼯号显⽰该员⼯的信息public void showinfo(String emNo){//遍历整个ArrayListfor(int i=0;i<al.size();i++){Employee em=(Employee)al.get(i);if(em.getEmNo().equals(emNo)){System.out.println("编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"⼯资:"+em.getSal()); }}}//修改员⼯的薪⽔public void changesal(String x,float y){for(int i=0;i<al.size();i++){Employee em=(Employee) al.get(i);if(em.getEmNo().equals(x)){em.setSal(y);}}}//根据员⼯的薪⽔进⾏排序(从⾼到低) public void sorthl(){String a,b;float c;for(int i=0;i<al.size()-1;i++){Employee e=(Employee)al.get(i);for(int j=i+1;j<al.size();j++){Employee m=(Employee)al.get(j); if(e.getSal()<m.getSal()){a=e.getEmNo();e.setEmNo(m.getEmNo());m.setEmNo(a);b=e.getName();e.setName(m.getName());m.setName(b);c=e.getSal();e.setSal(m.getSal());m.setSal(c);}}}System.out.println("排序成功!");System.out.println("打印信息如下:"); showAll();}//根据员⼯的薪⽔进⾏排序(从低到⾼) public void sortlh(){String a,b;float c;for(int i=0;i<al.size()-1;i++){Employee e=(Employee)al.get(i);for(int j=i+1;j<al.size();j++){Employee m=(Employee)al.get(j); if(e.getSal()>m.getSal()){a=e.getEmNo();e.setEmNo(m.getEmNo());m.setEmNo(a);b=e.getName();e.setName(m.getName());m.setName(b);c=e.getSal();e.setSal(m.getSal());m.setSal(c);}}}System.out.println("排序成功!");System.out.println("打印信息如下:"); showAll();}//平均⼯资、最⾼与最低⼯资public void hlsal(){float x=0,h,l=0;for(int i=0;i<al.size();i++){Employee e=(Employee)al.get(i);x=x+e.getSal();}System.out.println("平均⼯资:"+x/al.size());Employee s=(Employee)al.get(0);h=s.getSal();l=s.getSal();for(int i=0;i<al.size();i++){Employee v=(Employee)al.get(i);if(v.getSal()>h)h=v.getSal();if(v.getSal()<l)l=v.getSal();}System.out.println("最⾼⼯资:"+h);System.out.println("最低⼯资:"+l);}//显⽰所有员⼯的信息public void showAll(){for(int i=0;i<al.size();i++){Employee em=(Employee)al.get(i);System.out.println("第"+(i+1)+"个员⼯: "+"编号:"+em.getEmNo()+" "+"姓名:"+em.getName()+" "+"⼯资:"+em.getSal()); }}}//员⼯类class Employee {private String emNo;private String name;private float sal;// 构造⽅法public Employee(String emNo, String name, float sal) {super();this.emNo = emNo; = name;this.sal = sal;}// 所有的getter和setter⽅法public String getEmNo() {return emNo;}public void setEmNo(String emNo) {this.emNo = emNo;}public String getName() {return name;}public void setName(String name) { = name;}public float getSal() {return sal;}public void setSal(float sal) {this.sal = sal;}}运⾏⽰例:以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

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

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

java职工信息管理系统源代码(精)源代码packageleon2;importjava.ql.某;publicclaemployee{publicStringnum;publicStringname;publicStringe某;publicStringage;publicStringedu;publicStringla;publicStringad d;publicStringtel;publicvoidinit(String某1,String某2,String某3,String某4,String某5,String某6,String某7,String某8{num=某1;name=某2;e某=某3;age=某4;edu=某5;la=某6;add=某7;tel=某8;} publicvoidload(Stringf{try{Cla.forName(\;Stringurl=\;StringuerName=\;Stringpaword=\;Connectionconn=DriverManager.getConnection(url,uerName,pawor d;if(conn!=nullSytem.out.println(\已成功地与SQLServer2005数据库建立连接!\;Statementtmt=conn.createStatement(;tmt.e某ecuteUpdate(f;tmt.cloe(;}catch(E某ceptione{e.printStackTrace(;}}}packageleon2;importjava.awt.某;importjava.awt.event.某;importjava.ql.某;publicclaleon2_1{taticFramef;CardLayoutmyCard;Panelp1;Panelp2;Panelp3;Panelp4 ;Panelp5;Panelp6;Panelp7;Panelp8;publictaticvoidmain(String[]arg{leon2_1tet=newleon2_1(;tet.go1(;tet.go2(;tet.go3(;tet.go4(;t et.go5(;tet.go6(;tet.go7(;tet.go8(;}publicvoidgo1({f=newFrame(\呵呵!!!\myCard=newCardLayout(;f.etLayout(myCard;p1=newPanel(;Butto nb1,b2,b3;LabelL1;Te某tFieldte1;finalTe某tFieldte2;p1.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;Panelp1_1=newPanel(;p1_1.etLayout(newGridBagLayout(;GridBagContraint某=newGridBagContraint(;b1=newButton(\请输入用户名\b1.etBackground(Color.CYAN;某.inet=newInet(50,50,50,50;某.grid某=0;某.gridy=0;某.gridwidth=1;某.gridheight=1;p1_1.add(b1,某;b2=newButton(\请输入密码\b2.etBackground(Color.CYAN;某.grid 某=0;某.gridy=5;某.gridwidth=1;某.gridheight=1;p1_1.add(b2,某;te1=newTe某tField(15;c.inet=newInet(40,0,40,0;某.grid某=5;某.gridy=0;某.gridwidth=1;某.gridheight=1;p1_1.add(te1,某;te2=newTe某tField(15;某.grid某=5;某.gridy=5;某.gridwidth=1;某.gridheight=1;p1_1.add(te2,某;L1=newLabel(\欢迎进入职工管理系统某某某某某某某某某某某某某某\L1.etBackground(Color.CYAN;c.grid某=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p1.add(L1,c;b3=newButton(\登录\b3.etBackground(Color.CYAN;c.grid某=0;c.gridy=10;c.gridwidth=5;c.gridheight=5;p1.add(b3,c;c.grid某=0;c.gridy=20;c.gridwidth=5;c.gridheight=5;p1.add(p1_1,c;p1.etBackground(Color.green;f.add(p1,\myCard.how(f,\f.etSize (600,600;f.etViible(true;f.addWindowLitener(newWindowAdapter({ publicvoidwindowCloing(WindowEvente{Sytem.e某it(0;}};b3.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{String某=te2.getTe某t(;inty=Integer.pareInt(某;if(y==106 myCard.how(f,\}};}publicvoidgo2({p2=newPanel(;Buttonb1,b2,b3,b4,b5,b6;LabelL1;p2.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;c.inet=newInet(50,0,8 ,0;b1=newButton(\职工信息录入\b1.etBackground(Color.CYAN;c.grid 某=1;c.gridy=50;c.gridwidth=5;c.gridheight=50;p2.add(b1,c;b2=newButton(\职工信息浏览\b2.etBackground(Color.CYAN;c.grid 某=1;c.gridy=100;c.gridwidth=5;c.gridheight=50;p2.add(b2,c;b3=newButton(\职工信息查询\b3.etBackground(Color.CYAN;c.grid 某=1;c.gridy=150;c.gridwidth=5;c.gridheight=50;p2.add(b3,c;b4=newButton(\职工信息排序\b4.etBackground(Color.CYAN;c.grid 某=1;c.gridy=200;c.gridwidth=5;c.gridheight=50;p2.add(b4,c;b5=newButton(\职工信息修改\b5.etBackground(Color.CYAN;c.grid 某=1;c.gridy=250;c.gridwidth=5;c.gridheight=50;p2.add(b5,c;b6=newButton(\职工信息删除\b6.etBackground(Color.CYAN;c.grid 某=1;c.gridy=300;c.gridwidth=5;c.gridheight=50;p2.add(b6,c;L1=newLabel(\欢迎进入职工管理系统某某某某某某某某某某\L1.etBackground(Color.CYAN;c.grid某=1;c.gridy=0;c.gridwidth=5;c.gridheight=10;p2.add(L1,c;p2.etBackground(Color.green;f.add(p2,\b1.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};b2.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};b3.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};b4.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};b5.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};b6.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};}publicvoidgo3({p3=newPanel(;p3.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;Buttonb1,b2,b3,b4,b5, b6,b7,b8,b9,b10;finalTe某tFieldte1,te2,te3,te4,te5,te6,te7,te8;LabelL1;c.inet=newInet(60,50,0,0;L1=newLabel(\请输入下面信息某某某某某某某某某某某某某某某某\ L1.etBackground(Color.CYAN;c.grid某=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p3.add(L1,c;b1=newButton(\工号\b1.etBackground(Color.CYAN;c.grid某=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(b1,c;b2=newButton(\姓名\b2.etBackground(Color.CYAN;c.grid某=35;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(b2,c;b3=newButton(\性别\b3.etBackground(Color.CYAN;c.grid某=0;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(b3,c;b4=newButton(\年龄\b4.etBackground(Color.CYAN;c.grid某=35;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(b4,c;b5=newButton(\学历\b5.etBackground(Color.CYAN;c.grid某=0;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(b5,c;b6=newButton(\工资\b6.etBackground(Color.CYAN;c.grid某=35;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(b6,c;b7=newButton(\住址\b7.etBackground(Color.CYAN;c.grid某=0;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(b7,c;b8=newButton(\电话\b8.etBackground(Color.CYAN;c.grid某=35;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(b8,c;b9=newButton(\提交\b9.etBackground(Color.CYAN;c.grid某=10;c.gridy=100;c.gridwidth=1;c.gridheight=1;p3.add(b9,c;b10=newButton(\返回\b10.etBackground(Color.CYAN;c.grid某=35;c.gridy=100;c.gridwidth=1;c.gridheight=1;p3.add(b10,c;te1=ne wTe某tField(10;c.grid某=10;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(te1,c;te2=newTe某tField(10;c.grid某=37;c.gridy=10;c.gridwidth=1;c.gridheight=1;p3.add(te2,c;te3=new Te某tField(10;c.grid某=10;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(te3,c;te4=new Te某tField(10;c.grid某=37;c.gridy=30;c.gridwidth=1;c.gridheight=1;p3.add(te4,c;te5=new Te某tField(10;c.grid某=10;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(te5,c;te6=new Te某tField(10;c.grid某=37;c.gridy=50;c.gridwidth=1;c.gridheight=1;p3.add(te6,c;te7=new Te某tField(10;c.grid某=10;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(te7,c;te8=new Te某tField(10;c.grid某=37;c.gridy=70;c.gridwidth=1;c.gridheight=1;p3.add(te8,c;p3.etBackground(Color.green;f.add(p3,\b9.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{employeee1=newemployee(;e1.init(te1.getTe某t(,te2.getTe某t(,te3.getTe某t(,te4.getTe某t(,te5.getTe某t(,te6.getTe某t(,te7.getTe某t(,te8.getTe某t(;String某=\Stringy=\Stringz=\Stringw=\Stringql=\ql=ql+某+e1.num+y+z+某++y+z+某+e1.e某+y+z+某+e1.age+y+z+某++y+z+某++y+z+某+e1.add+y+z+某+e1.tel+y+w;e1.load(ql;te1.etTe某t(\te2.etTe某t(\te3.etTe某t(\te4.etTe某t(\te5.etTe某t(\te6.etTe某t(\te7.etTe某t(\te8.etTe某t(\}};eEvente{myCard.how(f,\}};}publicvoidgo4({p4=newPanel(;p4.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;Buttonb1,b2;LabelL1;f inalTe某tAreata;c.inet=newInet(60,0,0,0;L1=newLabel(\欢迎进入信息浏览界面某某某某某某某某某某某某某某某某\L1.etBackground(Color.CYAN;c.grid某=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p4.add(L1,c;b1=newButton(\浏览\b1.etBackground(Color.CYAN;c.grid某=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p4.add(b1,c;b2=newButton(\返回\b2.etBackground(Color.CYAN;c.grid某=0;c.gridy=20;c.gridwidth=1;c.gridheight=1;p4.add(b2,c;ta=newTe某tArea(15,50;c.grid某=0;c.gridy=11;c.gridwidth=1;c.gridheight=1;p4.add(ta,c;p4.etBackground(Color.green;f.add(p4,\Evente{try{Cla.forName(\Stringurl=\StringuerName=\Stringpaword=\Connectionconn=DriverManager.getConnection(url,uerName,pawor d;Statementtmt=conn.createStatement(;ReultSetr=tmt.e某ecuteQuery(\employee[]em=newemployee[10];inti=0;while(r.ne某t({ =+em[j].num+\em[j].edu+\}ta.etTe某t(;r.cloe(;tmt.cloe(;}catch(E某ceptione1{e1.printStackTrace(;}}};b2.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{ta.etTe某t(\myCard.how(f,\}};}publicvoidgo5({p5=newPanel(;p5.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;c.inet=newInet(40,0,0 ,0;Panelp5_2=newPanel(;p5_2.etLayout(newGridBagLayout(;GridBagContraint某=newGridBagContraint(;某.inet=newInet(30,60,0,80;Buttonb1,b2,b3,b4;finalTe某tFieldt1;finalTe某tFieldt2;finalTe某tAreata;LabelL1;b1=newButton(\查询名称\b1.etBackground(Color.CYAN;某.grid某=0;某.gridy=0;某.gridwidth=2;某.gridheight=1;p5_2.add(b1,某;b2=newButton(\查询范围\b2.etBackground(Color.CYAN;某.grid某=0;某.gridy=5;某.gridwidth=2;某.gridheight=1;p5_2.add(b2,某;b3=newButton(\查询\b3.etBackground(Color.CYAN;某.grid某=0;某.gridy=10;某.gridwidth=2;某.gridheight=1;p5_2.add(b3,某;b4=newButton(\返回\b4.etBackground(Color.CYAN;某.grid某=20;某.gridy=10;某.gridwidth=1;某.gridheight=1;p5_2.add(b4,某;t1=newTe某tField(10;某.grid某=20;某.gridy=0;某.gridwidth=1;某.gridheight=1;p5_2.add(t1,某;t2=newTe某tField(10;某.grid某=20;某.gridy=5;某.gridwidth=1;某.gridheight=1;p5_2.add(t2,某;L1=newLabel(\欢迎进入职工信息查询界面某某某某某某某某某某某\ L1.etBackground(Color.CYAN;c.grid某=0;c.gridy=0;c.gridwidth=0;c.gridheight=1;p5.add(L1,c;c.grid某=0;c.gridy=5;c.gridwidth=1;c.gridheight=1;p5.add(p5_2,c;ta=newTe某tArea(10,65;c.grid某=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p5.add(ta,c;p5.etBackground(Color.green;f.add(p5,\b4.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{t1.etTe某t(\t2.etTe某t(\ta.etTe某t(\myCard.how(f,\}};b3.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{try{Cla.forName(\Stringurl=\StringuerName=\Stringpaword=\Connectionconn=DriverManager.getConnection(url,uerName,pawor d;Statementtmt=conn.createStatement(;Stringql=\Stringql1=t1.getT e某t(;Stringql2=t2.getTe某t(;ql=ql+ql1+\ReultSetr=tmt.e某ecuteQuery(ql;employee[]em=newemployee[10];inti=0;while(r.ne某t({employeeem1=newemployee(;em1.num=r.getString(\工号\=r.getString(\姓名\em1.e某=r.getString(\性别\ =+\em[j].edu+\}ta.etTe某t(;r.cloe(;tmt.cloe(;}catch(E某ceptione1{e1.printStackTrace(;}}};}publicvoidgo6({p6=newPanel(;p6.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;c.inet=newInet(60,0,3 0,0;Panelp6_1=newPanel(;p6_1.etLayout(newGridBagLayout(;GridBagContraint某=newGridBagContraint(;某.inet=newInet(0,40,0,40;LabelL1;Buttonb1,b2,b3;finalTe某tAreata;b1=newButton(\按年龄排序\某.grid某=0;某.gridy=0;某.gridwidth=1;某.gridheight=1;p6_1.add(b1,某;b2=newButton(\按工资排序\某.grid某=10;某.gridy=0;某.gridwidth=1;某.gridheight=1;p6_1.add(b2,某;b3=newButton(\返回\某.grid某=15;某.gridy=0;某.gridwidth=1;某.gridheight=1;p6_1.add(b3,某;L1=newLabel(\欢迎进入职工信息查询界面某某某某某某某某某某某\ L1.etBackground(Color.CYAN;c.grid某=0;c.gridy=0;c.gridwidth=1;c.gridheight=1;p6.add(L1,c;c.grid某=0;c.gridy=5;c.gridwidth=1;c.gridheight=1;p6.add(p6_1,c;ta=newTe某tArea(10,65;c.grid某=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p6.add(ta,c;p6.etBackground(Color.green;f.add(p6,\b1.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{try{Cla.forName(\Stringurl=\StringuerName=\Stringpaword=\Connectionconn=DriverManager.getConnection(url,uerName,pawor d;Statementtmt=conn.createStatement(;ReultSetr=tmt.e某ecuteQuery(\employee[]em=newemployee[10];inti=0;while(r.ne某t({ employeeem1=newemployee(;em1.num=r.getString(\工号\=r.getString(\姓名\em1.e某=r.getString(\性别\em1.age=r.getString(\年龄\=r.getString(\学历\=r.getString(\工资\em1.add=r.getString(\住址\employeezz;int某,y;for(intf=1;ffor(intk=f+1;k{某=Integer.pareInt(em[f].age;y=Integer.pareInt(em[k].age;if(某>y{z z=em[f];em[f]=em[k];em[k]=zz;}}=+\em[j].edu+\}ta.etTe某t(;r.cloe(;tmt.cloe(;}catch(E某ceptione1{e1.printStackTrace(;}}};b2.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{try{Cla.forName(\Stringurl=\StringuerName=\Stringpaword=\Connectionconn=DriverManager.getConnection(url,uerName,pawor d;Statementtmt=conn.createStatement(;ReultSetr=tmt.e某ecuteQuery(\employee[]em=newemployee[10];inti=0;while(r.ne某t({ employeeem1=newemployee(;employeezz;int某,y;for(intf=1;ffor(intk=f+1;k{某=Integer.pareInt(em[f].la;y=Integer.pareInt(em[k].la;if(某>y{zz= em[f];em[f]=em[k];em[k]=zz;}}=+\em[j].edu+\}ta.etTe某t(;r.cloe(;tmt.cloe(;}catch(E某ceptione1{e1.printStackTrace(;}}};b3.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{ta.etTe某t(\myCard.how(f,\}};}publicvoidgo7({p7=newPanel(;p7.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;c.inet=newInet(40,0,5 0,0;Panelp7_1=newPanel(;p7_1.etLayout(newGridBagLayout(;GridBagContraint某=newGridBagContraint(;某.inet=newInet(30,60,0,80;LabelL1;Buttonb1,b2,b3,b4,b5,b6,b7;finalTe某tFieldt1;finalTe某tFieldt2;finalTe某tFieldt3;b1=newButton(\信息编号\b1.etBackground(Color.CYAN;某.grid某=0;某.gridy=0;某.gridwidth=1;某.gridheight=1;p7_1.add(b1,某;b2=newButton(\修改名称\b2.etBackground(Color.CYAN;某.grid某=0;某.gridy=5;某.gridwidth=1;某.gridheight=1;p7_1.add(b2,某;b3=newButton(\修改值\b3.etBackground(Color.CYAN;某.grid某=0;某.gridy=10;某.gridwidth=1;某.gridheight=1;p7_1.add(b3,某;b4=newButton(\修改\b4.etBackground(Color.CYAN;某.grid某=0;某.gridy=15;某.gridwidth=1;某.gridheight=1;p7_1.add(b4,某;b5=newButton(\返回\b5.etBackground(Color.CYAN;某.grid某=10;某.gridy=15;某.gridwidth=1;某.gridheight=1;p7_1.add(b5,某;b6=newButton(\查询\b6.etBackground(Color.CYAN;某.grid某=0;某.gridy=20;某.gridwidth=1;某.gridheight=1;p7_1.add(b6,某;b7=newButton(\继续\b7.etBackground(Color.CYAN;某.grid某=10;某.gridy=20;某.gridwidth=1;某.gridheight=1;p7_1.add(b7,某;t1=newTe某tField(16;某.grid某=10;某.gridy=0;某.gridwidth=1;某.gridheight=1;p7_1.add(t1,某;t2=newTe某tField(16;某.grid某=10;某.gridy=5;某.gridwidth=1;某.gridheight=1;p7_1.add(t2,某;t3=newTe某tField(16;某.grid某=10;某.gridy=10;某.gridwidth=1;某.gridheight=1;p7_1.add(t3,某;L1=newLabel(\欢迎进入职工信息修改界面某某某某某某某某某某某\ L1.etBackground(Color.CYAN;c.grid某=0;c.gridy=0;c.gridwidth=1;c.gridheight=1;p7.add(L1,c;c.grid某=0;c.gridy=10;c.gridwidth=1;c.gridheight=1;p7.add(p7_1,c;p7.etBackground(Color.green;f.add(p7,\b4.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{employeee1=newemployee(;Stringql;ql=\工号='\+t1.getTe某t(+\Sytem.out.println(ql;e1.load(ql;t1.etTe某t(\t2.etTe某t(\t3.etTe某t(\}};b5.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};b6.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};b7.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{t1.etTe某t(\t2.etTe某t(\t3.etTe某t(\}};}publicvoidgo8({p8=newPanel(;p8.etLayout(newGridBagLayout(;GridBagContraintc=newGridBagContraint(;c.inet=newInet(10,0,7 0,0;Panelp8_1=newPanel(;p8_1.etLayout(newGridBagLayout(;GridBagContraint某=newGridBagContraint(;某.inet=newInet(80,60,0,80;Buttonb1,b2,b3;LabelL1;finalTe某tFieldt1;b1=newButton(\工号\b1.etBackground(Color.CYAN;某.grid 某=0;某.gridy=0;某.gridwidth=1;某.gridheight=1;p8_1.add(b1,某;b2=newButton(\删除\b2.etBackground(Color.CYAN;某.grid某=0;某.gridy=10;某.gridwidth=1;某.gridheight=1;p8_1.add(b2,某;b3=newButton(\返回\b3.etBackground(Color.CYAN;某.grid某=10;某.gridy=10;某.gridwidth=1;某.gridheight=1;p8_1.add(b3,某;t1=newTe某tField(11;t1.etBackground(Color.CYAN;某.grid某=10;某.gridy=0;某.gridwidth=1;某.gridheight=1;p8_1.add(t1,某;L1=newLabel(\欢迎进入职工信息删除界面某某某某某某某某某某某\ L1.etBackground(Color.CYAN;c.grid某=0;c.gridy=0;c.gridwidth=1;c.gridheight=1;p8.add(L1,c;c.grid某=0;c.gridy=5;c.gridwidth=1;c.gridheight=1;p8.add(p8_1,c;p8.etBackground(Color.green;f.add(p8,\b2.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{employeee1=newemployee(;Stringql;ql=\工号=\Sytem.out.println(ql;e1.load(ql;}};b3.addMoueLitener(newMoueAdapter({publicvoidmoueClicked(Moue Evente{myCard.how(f,\}};}}。

职工信息管理系统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数据已经成功读取!");}}。

java员工管理系统代码

java员工管理系统代码

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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}}```这只是一个非常基础的例子,实际的系统可能需要包含更多的功能,例如更新员工信息,搜索员工等。

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

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

// 项目目标:建立员工管理系统第一个版本。

// 实现图形用户界面的员工信息查询、增、删、改;与数据库建立,并将修改结果时时保存到数据库。

// 模块:1。

GUI界面 2.数据库连接 3。

查询 4.增、5删 6改(操作数据库)import java.sql.*;import java.awt.*;import java.awt。

event.*;import javax。

swing。

*;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 = e.getActionCommand();if (”查询”。

equals(str)) {//if check the button of 查询,then go to method of searchEmp() searchEmp();} else if (”增加”.equals(str)) {//if check the button of 增加,then go to method of addEmp() addEmp();} else if (”修改".equals(str)){//if check the button of 修改,then go to method of alterEmp() alterEmp();}else if (”撤除".equals(str)) {//if check the button of 撤除,then go to method of deleteEmp()deleteEmp();}}//this is the constructor.EmpManageSys(){createGUI();connectToDataBase();// searchEmp();// addEmp();// deleteEmp();alterEmp();}//connect to the database by using the method getConnection from the class of JdbcUtil。

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("正在执行根据编号查找一个员工

职工信息管理系统代码(精)

职工信息管理系统代码(精)

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;基本信息表=(HashtableinTwo.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;基本信息表=(HashtableinTwo.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;基本信息表=(HashtableinTwo.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;基本信息表=(HashtableinTwo.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;基本信息表=(HashtableinTwo.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; }}}}。

职工信息管理系统源代码

职工信息管理系统源代码

#i n c l u d e<>#include<>#include<>int N=2;struct worker /*定义一个职工信息的结构体*/{int num; /*定义一个职工信息的结构体*/char name[20]; /*定义一个职工信息的结构体*/char sex[10]; 职工信息录入 || \n");printf("\t || 2. 职工信息浏览 || \n");printf("\t || 3. 职工信息添加 || \n");printf("\t || 4. 职工信息查询 || \n");printf("\t || 5. 职工信息删除 || \n");printf("\t || 6. 职工信息修改 || \n");printf("\t || 0. 退出 || \n");printf("\t ------------------------------- \n");printf("\n 输入你的选择项(0~6):\n");scanf("%d",&b);switch(b){case 1 : um); fflush(stdin);flag=1;if(worker[N].num<0)printf("请输入正整数:\n");elsefor(j=0;j<i;j++){if(worker[i].num==worker[j].num){flag=0;printf(" 工号重复,请重新输入!\n");goto loop;}}printf("姓名:");scanf("%s",worker[i].name); fflush(stdin);printf("性别:");scanf(" %s",worker[i].sex); fflush(stdin);printf("出生年月:");scanf("%d",&worker[i].birth); fflush(stdin); printf("工作年月:");scanf("%lf",&worker[i].deta); fflush(stdin); printf("请输入学历(中专=zz,大专=dz,本科=bk,研究生=yjs):\n");scanf("%s",worker[i].education);fflush(stdin);printf("工资:");scanf("%lf",worker[i].salary); fflush(stdin);printf("职务:");scanf("%s",worker[i].work); fflush(stdin);printf("住址:");scanf("%s",worker[i].addr); fflush(stdin);printf("电话:");scanf("%s",worker[i].tel); fflush(stdin);}printf("\n创建完毕!\n");}void save() um);printf("姓名:%s\n",worker[i].name);printf("性别:%s\n",worker[i].sex);printf("出生年月:%d\n",worker[i].birth);printf("工作年月:%d\n",worker[i].deta);printf("学历:%s\n",worker[i].education);printf("工资:%lf\n",worker[i].salary);printf("职务:%d\n",worker[i].work);printf("住址:%s\n",worker[i].addr);printf("电话:%s\n",worker[i].tel);}}void add() um=={printf(" 工号重复,请重新输入!\n");scanf("%d",&;}}printf("请输入姓名:\n");scanf("%s",;printf("请输入性别:\n");scanf("%s",;printf("请输入出生年月:\n");scanf("%d",&;printf("请输入工作年月:\n");scanf("%d",&;printf("请输入学历(中专=zz,大专=dz,本科=bk,研究生=yjs:):\n");scanf("%s",;printf("请输入工资:\n");scanf("%lf",&t);=t;printf("请输入职务:\n");scanf("%s",;printf("请输入住址:\n");scanf("%s",;printf("请输入电话:\n");scanf("%s",;printf("\n添加完毕!\n");if((fp=fopen("","ab"))==NULL)历2.职工号3.取消并返回");printf("Which you needed?:\n");scanf("%d",&c);if(c>3||c<1){puts("\nchoice error!please again!");getchar();ducation)==0){printf("职工号:%d\n",worker[i].num);printf("姓名:%s\n",worker[i].name);printf("性别:%s\n",worker[i].sex);printf("出生年月:%d\n",worker[i].birth);printf("工作年月:%d\n",worker[i].deta);printf("学历(中专=zz,大专=dz,本科=bk,研究生=yjs):%s\n",worker[i].education);printf("工资:%lf\n",worker[i].salary);printf("职务:%lf\n",worker[i].work);printf("住址:%s\n",worker[i].addr);printf("电话:%s\n",worker[i].tel);flag++;}}if(flag==0)printf("\n对不起没有找到!\n");getchar();}void search_num() um){printf("职工号:%d\n",worker[i].num);printf("姓名:%s\n",worker[i].name);printf("性别:%s\n",worker[i].sex);printf("出生年月:%d\n",worker[i].birth);printf("工作年月:%d\n",worker[i].deta);printf("学历(中专=zz,大专=dz,本科=bk,研究生=yjs):%s\n",worker[i].education);printf("工资:%lf\n",worker[i].salary);printf("职务:%lf\n",worker[i].work);printf("住址:%s\n",worker[i].addr);printf("电话:%s\n",worker[i].tel);flag++;}}if(flag==0)printf("\n对不起没有找到! please");getchar();}void del() ame)==0)um){printf("找到该职工的信息(任意键继续)!");printf("\n请输入职工的信息!\n");printf("请输入姓名:\n");scanf("%s",;printf("请输入性别:\n");scanf("%s",;printf("请输入出身年月:\n");scanf("%d",&;printf("请输入工作年月:\n");scanf("%lf",&;printf("请输入学历(中专=zz,大专=dz,本科=bk,研究生=yjs):\n");scanf("%s",;printf("请输入工资:\n");scanf("%lf",&t);=t;printf("请输入职务:\n");scanf("%s",;printf("请输入住址:\n");scanf("%s",;printf("请输入电话:\n");scanf("%s",;=n;if((fp=fopen("","r+"))==NULL)//以读写的方式将修改的信息写入磁盘文件{printf("\ncannot open file\n");exit(0);}fseek(fp,i*sizeof(struct worker),0);//将位置指针移到i*sizeof(struct worker)个字节处fwrite(&p,sizeof(struct worker),1,fp);fclose(fp);printf("修改成功!\n");break;}}if(i>=N)printf("\n未找到该职工!\n");}。

java实现人员信息管理系统

java实现人员信息管理系统

java实现⼈员信息管理系统本⽂实例为⼤家分享了java实现⼈员信息管理系统的具体代码,供⼤家参考,具体内容如下实现增删改查.java⼊门的练⼿⼩程序1.Person类package p1;public class Person {// Person属性private int num;private String name;private String sex;private int salary;public Person(int num, String name, String sex, int salary) {super();this.num = num; = name;this.sex = sex;this.salary = salary;}// 对Perosn操作的⽅法public int getNum() {return num;}public void setNum(int num) {this.num = num;}public String getName() {return name;}public void setName(String name) { = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public int getSalary() {return salary;}public void setSalary(int salary) {this.salary = salary;}}2.SysMenu类package p1;public class SysMenu {public static final String[] MENU = { "1.员⼯信息管理", "2.退出" };public static final String[] OPERATION_MENU = { "1.新增", "2.查看", "3.修改", "4.删除", "5.返回" };public static void showMenu(String[] Menu) {for (int i = 0; i < Menu.length; i++)System.out.print(Menu[i] + "\t\t");System.out.println();System.out.println("---------------------------------------");}}3.SysInfo类package p1;import java.util.ArrayList;import java.util.List;public class SysInfo {private static List informationList = new ArrayList();// 获取 informationListpublic static List getList() {return informationList;}}rmationService类package p1;import java.util.List;public class InformationService {private List informationList = SysInfo.getList();// 获取信息列表public List getList() {return informationList;}// 按编号查找信息public Person getPersonByNum(final int num) {if (num < 1) {System.out.println("编号错误");return null;}for (int i = 0; i < informationList.size(); i++) {Person p = (Person) informationList.get(i);if (p.getNum() == num) {System.out.println("查找成功");return p;}}System.out.println("查找失败");return null;}//查看单⼀Person信息public void showAPerson(Person p){System.out.println("编号\t\t姓名\t\t性别\t\t薪⽔");System.out.println(p.getNum()+ "\t\t" + p.getName() + "\t\t" + p.getSex() + "\t\t" + p.getSalary());}//show all Personpublic void showPerson() {System.out.println("编号\t\t姓名\t\t性别\t\t薪⽔");List ps = getList();for (int i = 0; i < ps.size(); i++) {Person p = (Person) ps.get(i);System.out.println(p.getNum() + "\t\t" + p.getName() + "\t\t" + p.getSex() + "\t\t" + p.getSalary()); }}// 按名字查找信息public Person getPersonByName(final String name) {if (name == null)return null;for (int i = 0; i < informationList.size(); i++) {Person p = (Person) informationList.get(i);if (p.getName().equals(name)) {return p;}}return null;}//检查对象是否存在public boolean CheckExitByNum(int num){for(int i=0;i<informationList.size();i++){Person p = (Person)informationList.get(i);if(p.getNum()==num)return true;}return false;}//save Personpublic void savePerson(Person p){p.setNum(getPersonMaxInt()+1);informationList.add(p);}// 查找最⼤编号public int getPersonMaxInt(){int max = 0;for(int i =0;i<informationList.size();i++){Person p =(Person)informationList.get(i);if(max < p.getNum())max = p.getNum();}return max;}}5.SysRun类package p1;import java.util.InputMismatchException;import java.util.List;import java.util.Scanner;public class SysRun {private List informationList = SysInfo.getList();private Scanner s = new Scanner(System.in);private InformationService is = new InformationService(); // 系统运⾏类public static void main(String[] args) {SysRun sys = new SysRun();sys.sysRun();}public void sysRun() {System.out.println("启动系统管理系统");boolean isExit = false;do {System.out.println("----------操作选项-------------");SysMenu.showMenu(SysMenu.MENU);// 获取⽤户输⼊int operNum = getCorrONum(SysMenu.MENU);// 管理操作isExit = doManageNum(operNum);} while (!isExit);System.out.println("系统退出.");}private boolean doManageNum(int operNum) {boolean isExit = false;switch (operNum) {case 1:is.showPerson();System.out.println("----------操作选项-------------");SysMenu.showMenu(SysMenu.OPERATION_MENU); // addPerson();//testSystem.out.println("输⼊功能选择:");int num = getVaildInt();doOperationNum(num);break;case 2:isExit = true;return isExit;}return isExit;}// doOperationNumprivate void doOperationNum(int OperationNum) {// 增,查,修,删,返回switch (OperationNum) {case 1:// addaddPerson();is.showPerson();break;case 2:// 查看viewPerson();break;case 3:updatePerson();break;case 4:deletePerson();is.showPerson();break;case 5:break;}}// 删除Personprivate void deletePerson() {int num;// Person p;boolean isOk = false;System.out.println("请输⼊要删除信息的编号:");do {num = getVaildInt();isOk = is.CheckExitByNum(num);if (isOk == true) {System.out.println("编号信息查找成功。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
(jl3);
(jtf3);
(jp3);
JPanel jp4 = new JPanel();
JLabel jl4 = new JLabel("EngName*");
(jl4);
(jtf4);
(jp4);
JPanel jp5 = new JPanel();
JLabel jl5 = new JLabel("UNIT ");
+ () + () + () + ")";
int i = ();
if (() != null) && () != null)
&& () != null) && () != null)) {
(sql);
("添加记录成功" + i + "条");
} else {
("带*号项为添加记录时不能为空");
}
} catch (SQLException e1) {
+ ().toLowerCase().trim() + "and TEAM="
+ ().toLowerCase().trim() + "and Phone="
+ ().toLowerCase().trim() + "and region="
+ ().toLowerCase().trim() + "and busStation="
StringBuffer sb = new StringBuffer();
JTextField jtf2 = new JTextField("张飞",10);
JTextField jtf3 = new JTextField(10);
JTextField jtf4 = new JTextField(10);
SQL工具类JdbcUtil:用于实现数据库连接和数据库关闭。上面程序用到了这个类
//close resultSet,statement and connection
public static void close(ResultSet rs,Statement stmt,Connection con){
(" " + (i) + " =");
(i));
}
("\n");
());
}
} catch (SQLException e11) {
();
}
}
public void addEmp() {
try {
stmt = ();
sql = "update Mstar values(" + () + ()
+ () + () + ()
searchEmp();
sql = "update Mstar set chineseName="
+ ().toLowerCase().trim() + "and id="
+ ().toLowerCase().trim() + "and engName="
+ ().toLowerCase().trim() + "and UNIT="
+ ().toLowerCase().trim() + "or busStation="
+ ().toLowerCase().trim();
(sql);
int i = ();
("撤除操作成功" + i + "条");
} catch (SQLException e) {
();
}
}
public void alterEmp() {
简单的JAVA员工信息管理系统源码
据库连接3.查询4.增、5删6改(操作数据库)
import .*;
public class EmpManageSys implements ActionListener {
Connection con;
Statement stmt;
String sql;
ResultSet rs;
(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、增加:在各个文本框中输入相应内容后,点击增加。\n3、修改:先查询到你要的记录,在更改相应内容,点击修改。\n4、撤除:类似于修改操作");
(jta10);
(jp01);
(700, 500);
;
(true);
}
public static void main(String[] args) {
new EmpManageSys();
}
}
//---------------------------------------------------------------------
try{
if(rs!=null) ();
}catch(Exception ex){
();
}
try{
if(stmt!=null) ();
}catch(Exception ex){
();
}
try{
if(con!=null) ();
}catch(Exception ex){
();
}
}
}
(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("撤除");
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);
+ ().toLowerCase().trim();
int i = 0;
try {
(sql);
i = ();
} catch (SQLException e) {
();
}
("修改操作成功" + i + "条");
}
public v = new JFrame("员工信息管理系统");
(this);
(jb111);
(jb112);
(jp11);
JPanel jp2 = new JPanel();
JLabel jl2 = new JLabel("中文名* ");
(jl2);
(jtf2);
(jp2);
JPanel jp3 = new JPanel();
JLabel jl3 = new JLabel("工号");
();
}
}
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="
相关文档
最新文档