java课程设计报告职工工资管理系统.pdf
《java课程设计报告职工工资管理系统.pdf》由会员分享,可在线阅读,更多相关《java课程设计报告职工工资管理系统.pdf(18页珍藏版)》请在三一文库上搜索。
1、. . 目 录 一、设计目的2 二、功能介绍2 三、程序流程2 四、设计步骤3 五、设计总结7 六、程序清单8 七、参考文献17 . . 一、设计目的 通过课程设计,使学生提高理论联系实际解决实际问题的能力;也使学生对 基于面向对象的理论进行系统设计过程中的诸多具体问题有感性的认识和深入的理 解;进而提高学生的学习兴趣为其将来顺利进入毕业环节作必要的准备。 二、功能介绍 (1)具有新用户注册功能。 (2)具有注册用户登录功能。 (3)具有职工工资的录入功能,要求只录入工资各项,自动计算每个职工工 资总额。 (4)具有数据查询功能,可以实现查询全部信息和按条件执行查询。 (5)具有按条件删除数据
2、功能。 三、程序流程 开始 新用户登录 ? 输入用户名和密码 进入系统选择操作 录入功能查找功能删除功能 注册新用户 向数据库添加记 录 可按职工号查询 或查询所有数据 按选中行的行号 删除数据 结束 Y N . . 四、设计步骤 4.1、登陆界面 进入系统首先进入登陆界面如图4.1 ,输入账号和密码,点击登录就会进入职 工工资管理系统,点击注册进入新用户注册界面,定义了局部变量String类型的 user,password 和 pass 分别记录界面输入的账号,密码和数据库查找的密码,定义 了成员变量 boolean 型的 bool 记录输入账号和密码是否匹配。 图 4.1 登陆界面 4.2
3、 、职工工资管理系统 登陆成功后进入的界面如图4.2 ,界面有增删改查的功能。widgetSelected() 方法创建 button 的点击事件,创建DBHelper 类的对象 db连接数据库,进行查找, 删除修改功能,增删改用update()方法,查询用query ()方法。 . . 图 4.2 职工工资管理界面 4.3 、全部查找功能 点击右边的查询按钮可以查找出所有员工的工资信息如图4.3 ,通过自己封 装的连接数据库的类DBHelper类的对象 db,传递 sql 语句查找数据库的所有信息, 用 getString ()方法导出从数据库中查找到的数据,所得工资=基本工资 +职位提成
4、-50* 迟到天数 -100* 旷工天数,通过查找的数据和自己定义的公式得到所得工资。 图 4.3 全部查找界面 . . 4.4 、按条件查找功能 在文本框中输入职工号,点击查找能找到对应职工的工资情况,如图4.4 。用 getText ()方法获得 text文本框中的的输入信息,定义局部变量boolean 型的数据 bool ,记录数据库中是否有对应的职工号,如果查到则为true ,并且在表格中先用 removeAll()方法清空表的信息, 然后用 sql 语句找出 text 中的职工号对应的数据。 图 4.4 按条件查找界面 4.5 、录入功能 点击录入键进入录入界面如图4.5 , 输入职
5、工信息,点击录入修改数据库的信息, 并且能更新查找的结果。用getText ()方法获得text文本框的信息,定义局部变 量 String类型的 s1,s2,s3,s4,s5,s6记录六个文本框的信息, 通过 DBHelper 的对象 db 调用 update 方法把信息传入数据库。 . . 图 4.5 录入功能界面 4.6 、删除功能 点击选中行, 然后点击删除按钮就会将选种的行删除掉,例如删除图 4.3 中第 三行数据如图 4.6 。定义局部变量 TableItem数组用 table.getSelection()方法查 找并存储选中行的信息,定义int型数组用 table.getSelec
6、tionIndices()方法查 找并存储选中行的行号,用这两个信息分别删除数据库和界面的选中信息。 图 4.6 删除功能界面 . . 4.7 、注册功能 点击注册键后进入如图4.7 所示的界面, 输入新用户账号和密码, 如果两次密 码输入相同就注册成功。定义局部变量String类型的 user ,password 和 pass 分别 记录三个文本框输入的内容,用equals 方法判断 pass 和 password 是否相同,如果 相同,则注册成功,并用dispose ()方法关闭此窗口。 图 4.7 注册功能界面 五、设计总结 这次课程设计, 我们知道了成员变量和局部变量的不同,有些变量如
7、果不设成成 员变量就无法把数据传递出去,我们学会了封装,将连接数据库的方法封装到 DBHelper 类中,封装的便利让我们写程序更快捷,但是界面的功能还不够人性化。 . . 六、程序清单 import java.sql.ResultSet; import java.sql.SQLException; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widg
8、ets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import com.swtdesigner.SWTResourceManager; publicclass denglu extends Shell booleanbool ; private Text text_1 ; private Text text ; pub
9、licstaticvoid main(String args) try Display display = Display.getDefault(); denglu shell = new denglu(display, SWT.SHELL_TRIM); shell.open(); shell.layout(); while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep(); catch (Exception e) e.printStackTrace(); public denglu(Display disp
10、lay, int style) super (display, style); createContents(); protectedvoid createContents() setText(“ 登陆界面 “); setSize(622, 439); final Label label = new Label(this , SWT.BORDER); label.setFont(SWTResourceManager.getFont( “ , 12, SWT.BOLD); label.setText(“ 账号: “ ); label.setBounds(90, 112, 60, 27); fin
11、al Label label_1 = new Label(this , SWT.BORDER); label_1.setFont(SWTResourceManager.getFont( “ , 12, SWT.BOLD); label_1.setText(“密码: “); label_1.setBounds(90, 185, 60, 27); text = new Text(this , SWT.BORDER); text .setBounds(208, 112, 125, 27); text_1 = new Text(this , SWT.BORDER | SWT.PASSWORD); .
12、. text_1 .setBounds(208, 185, 125, 27); final Button button = new Button(this , SWT.NONE); button.addSelectionListener(new SelectionAdapter() publicvoid widgetSelected(final SelectionEvent e) String user=text .getText(); String password=text_1 .getText(); DBHelper db= new DBHelper(); String sql=“sel
13、ect 密码 from user_Table where 账号 =“ +user+ “; ResultSet rs=db.query(sql); try while (rs.next() String pass=rs.getString(“ 密码 “ ); if (password.equals(pass) bool =true ; else bool =false ; if (bool =true ) try Display display = Display.getDefault(); zhigonggongzi shell = new zhigonggongzi(display, SWT
14、.SHELL_TRIM); shell.open(); shell.layout(); while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep(); catch (Exception e2) e2.printStackTrace(); catch (SQLException e1) / TODO Auto-generated catch block e1.printStackTrace(); ); button.setFont(SWTResourceManager.getFont( “ , 12, SWT.
15、BOLD); button.setText(“ 登陆 “); button.setBounds(388, 255, 48, 22); final Button button_1 = new Button(this , SWT.NONE); button_1.setFont(SWTResourceManager.getFont( “ , 12, SWT.BOLD); button_1.setText(“注册 “ ); button_1.setBounds(388, 306, 48, 22); final Label label_2 = new Label(this , SWT.BORDER);
16、label_2.setFont(SWTResourceManager.getFont( “ , 15, SWT.BOLD); label_2.setText(“欢迎使用员工工资管理系统“ ); label_2.setBounds(90, 37, 271, 27); / . . Override protectedvoid checkSubclass() / Disable the check that prevents subclassing of SWT components import java.sql.ResultSet; import java.sql.SQLException; i
17、mport org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.w
18、idgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; import com.swtdesigner.SWTResourceManager; publicclass zhigonggongzi extends Shell private Text text ; private Table table ; publicstaticvoid main(String args) try
19、 Display display = Display.getDefault(); zhigonggongzi shell = new zhigonggongzi(display, SWT.SHELL_TRIM); shell.open(); shell.layout(); while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep(); catch (Exception e) e.printStackTrace(); public zhigonggongzi(Display display, int style
20、) super (display, style); createContents(); protectedvoid createContents() setText(“ 职工工资管理系统界面“ ); setSize(697, 458); table = new Table(this , SWT.FULL_SELECTION | SWT.BORDER); table .setLinesVisible(true ); table .setHeaderVisible(true ); table .setBounds(10, 67, 573, 214); final TableColumn newCo
21、lumnTableColumn = new TableColumn( table , SWT.NONE); newColumnTableColumn.setWidth(73); . . newColumnTableColumn.setText(“ 职工号 “ ); final TableColumn newColumnTableColumn_1 = new TableColumn( table , SWT.NONE); newColumnTableColumn_1.setWidth(76); newColumnTableColumn_1.setText(“ 职工姓名 “ ); final Ta
22、bleColumn newColumnTableColumn_2 = new TableColumn( table , SWT.NONE); newColumnTableColumn_2.setWidth(76); newColumnTableColumn_2.setText(“ 基本工资 “ ); final TableColumn newColumnTableColumn_3 = new TableColumn( table , SWT.NONE); newColumnTableColumn_3.setWidth(80); newColumnTableColumn_3.setText(“
23、职位提成 “ ); final TableColumn newColumnTableColumn_4 = new TableColumn( table , SWT.NONE); newColumnTableColumn_4.setWidth(79); newColumnTableColumn_4.setText(“ 迟到天数 “ ); final TableColumn newColumnTableColumn_5 = new TableColumn( table , SWT.NONE); newColumnTableColumn_5.setWidth(83); newColumnTableC
24、olumn_5.setText(“ 旷工天数 “ ); final TableColumn newColumnTableColumn_6 = new TableColumn( table , SWT.NONE); newColumnTableColumn_6.setWidth(100); newColumnTableColumn_6.setText(“ 所得工资 “ ); final Button button = new Button(this , SWT.NONE); button.addSelectionListener(new SelectionAdapter() publicvoid
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 课程设计 报告 职工 工资管理 系统
链接地址:https://www.31doc.com/p-5595651.html