您的当前位置:首页正文

Web课程设计

2024-07-24 来源:爱站旅游
导读Web课程设计
课题名称:企业职工工资在线管理信息系统的设计与实现

《Web开发技术课程设计》

学生姓名: ***

专业班级: 软件工程13201207 专业课程: 《web开发技术》

指导老师: ***

2016年 3月 13日

Web开发技术课程设计

目 录

第1章 系统设计目的 ............................................................................................................... 1

1.1题目与要求 .................................................................................................................. 1 1.2课程设计任务 .............................................................................................................. 1 第2章 系统功能模块设计 ....................................................................... 错误!未定义书签。

2.1 职工模块 ..................................................................................... 错误!未定义书签。 2.2人事管理员模块 .......................................................................................................... 2 第3章 数据库设计 ................................................................................................................... 3

3.1职工基本信息表worker................................................................................................................................3 3.2岗位信息表单Job.............................................................................................................................................3 3.3所有员工工资记录表Allwage....................................................................................................................4 第4章 各功能模块的程序设计及运行测试结果 ................................................................... 4

4.1职工功能模块......................................................................................................................................................4

4.1.1职工的注册与登陆..............................................................................................................................4 4.1.2职工岗位工资信息查询...................................................................................................................8 4.1.3职工留言板..............................................................................................................................................9 4.2人事管理员功能模块....................................................................................................................................11

4.2.1职工工资信息添加、查询和更新............................................................................................11 4.2.2职工个人工资信息的更新............................................................................................................15 4.2.3留言板管理............................................................................................................................................17 第5章 课程设计体会 ............................................................................................................. 20 5.1问题调试....................................................................................................................................................20 5.2体会与感想................................................................................................................................................21

主要Servlet代码附录.................................................................................................................................................21 主要JavaBeans代码附录..........................................................................................................................................30 参考文献 ................................................................................................................................... 46

Web开发技术课程设计

第1章 系统设计目的

1.1题目与要求

Dreamweaver+JSP+SQL SERVER 1.2课程设计任务

1.主要功能

设计一个企业职工工资管理信息系统,该系统的用户分别是:职工和人事管理员。不同的用户拥有不同的权限,各自完成各自的管理功能,不同的用户看到不同的系统功能。用Sql server2000创建后台数据库,然后利用JSP技术编写程序实现对数据库的操作,按照要求完成所有的功能和模块。

职工的主要功能模块包括: (1)职工注册与登录

(2)职工岗位工资信息查询 (3)职工留言板

人事管理员的主要功能模板包括:

(1)工资信息的查询、添加、更新 (2)职工个人工资信息的更新和维护 (3)留言板管理 2.主要数据库表单

(1)职工基本信息表单

主要字段有:职工号、姓名、性别、出生日期、岗位编号、工作年限 (2)岗位信息表单

主要字段有:岗位编号、岗位名称、岗位基本工资、岗位津贴、特殊津贴、月工资(岗位工资+岗位工资+岗位津贴+特殊津贴)、养老保险(月工资*8%)、医疗保险(月工资*6%)、失业保险(月工资*1%)

1

Web开发技术课程设计

第2章 系统功能模块设计

2.1 职工模块

2.2人事管理员模块

管理员登录 职工个人工资记录添加 留言板管理 全体职工工资信息查询和更新 职工个人工资信息查询和更新 注册 职工工资岗位信息查询 登录 职工注册 职工留言板

2

Web开发技术课程设计

第3章 数据库设计

3.1职工基本信息表worker

3.2岗位信息表单Job

3.3所有员工工资记录表Allwage

3

Web开发技术课程设计

第4章 各功能模块的程序设计及运行测试结果

4.1职工功能模块

4.1.1职工的注册与登陆 程序设计代码: //登录

企业职工工资在线管理信息系统


登录


4

Web开发技术课程设计

职工

管理员

}

myForm.submit();

@WebServlet(\"/Servlet2\")

public class Servlet2 extends HttpServlet {

private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public Servlet2() { super();

// TODO Auto-generated constructor stub }

/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub

request.setCharacterEncoding(\"UTF-8\");

response.setContentType(\"text/html;charset=utf-8\"); InsertInformation data=new InsertInformation(); SelectInformation num=new SelectInformation(); String user=request.getParameter(\"user\");

String password=request.getParameter(\"password\");

String passwordAgain=request.getParameter(\"passwordAgain\"); String name=request.getParameter(\"name\"); String tel=request.getParameter(\"tel\");

if(data.InsertData(num.Length(),user,password,passwordAgain,name,tel)==true){

request.getRequestDispatcher(\"/login.jsp\").forward(request, response); } else

request.getRequestDispatcher(\"RegisterFail.jsp\").forward(request, response); }

8

Web开发技术课程设计

/**

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }

4.1.2职工岗位工资信息查询

职工岗位工资信息查询

9

Web开发技术课程设计

<% String str[][]=new String [100][100]; str=(String[][])request.getAttribute(\"str\"); for(int i=1;i<=10;i++){ out.print(\"

\"); if(str[i][1]==null) break; for(int j=1;j<=8;j++){%> <% }

out.print(\"

\"); } %>
岗位编号 岗位名称 岗位基本工资 岗位津贴 月工资 养老保险医疗保险 失业保险
<%=str[i][j]%>

10

Web开发技术课程设计

4.1.3职工留言板

留言板

您的留言回复:

<%if(request.getAttribute(\"massage\")==null){%>

<%} else %>

您提交的留言还没有得到回复<%=request.getAttribute(\"massage\")%>

4.2人事管理员功能模块

4.2.1职工工资信息添加、查询和更新

//添加

添加员工工资信息表



职工姓名


月份

岗位名称

特殊津贴

//职工工资信息的查询

13

Web开发技术课程设计

<%

String str[][]=new String [100][100];

str=(String[][])request.getAttribute(\"massage\"); for(int i=1;i<=20;i++){ if(str[i][1]==null) break;%>

<% out.print(\"\"); } %>

职工姓名 岗位名称 基本工资 特殊津贴 月工资 是否更新
\"

onclick=\"onclick1('<%=str[i][1]%>')\" style=\"background-color:transparent\"/>

\"

value=\"<%=str[i][2]%>\"style=\"background-color:transparent\"/>

<%=str[i][3]%> value=\"<%=str[i][4]%>\"style=\"background-color:transparent\"/> <%=str[i][5]%> onclick=\"onClicka('<%=str[i][1].trim()%>','<%=str[i][2].trim()%>','<%=str[i][4]%>',<%=1%>)\"style=\"background-color:transparent\"/>

//工资信息的更新

14

Web开发技术课程设计

<%

String str[][]=new String [100][100];

str=(String[][])request.getAttribute(\"massage\"); for(int i=1;i<=20;i++){ if(str[i][1]==null) break;%>

15

Web开发技术课程设计

<% out.print(\"

\"); } %>

职工姓名 岗位名称 基本工资 特殊津贴 月工资 是否更新
\"

onclick=\"onclick1('<%=str[i][1]%>')\" style=\"background-color:transparent\"/>

\"

value=\"<%=str[i][2]%>\"style=\"background-color:transparent\"/>

<%=str[i][3]%> value=\"<%=str[i][4]%>\"style=\"background-color:transparent\"/> <%=str[i][5]%> onclick=\"onClicka('<%=str[i][1].trim()%>','<%=str[i][2].trim()%>','<%=str[i][4]%>',<%=1%>)\"style=\"background-color:transparent\"/>

19

Web开发技术课程设计

第5章 课程设计体会

5.1调试问题记录

2016.3.6

问题1.去空格问题

在这个问题中有个棘手的问题就是,Eclipse不会爆出任何错,并且在jsp,Servlet,Javabean当中都没有任何错误爆出; 解决方法:在String+.trim(). 问题2.数据入库乱码问题

描述:在Servlet提交数据到数据库时,中文出现乱码,因为在Servlet中没有设置发送文件的类型为utf-8。

解决方法:在Servlet中加入:request.setCharacterEncoding(\"UTF-8\"); 问题3.单选框传值问题

描述:单选按钮向Servlet中传值。 解决方案:

选项1

20

Web开发技术课程设计

选项2在servlet中String str = request.getParameter(\"myitem\");如果str为null则什么都没选,如果str为value1则选了选项1如果str为value2则选了选项2 2016.3.8

问题4:JS使用URL传值到Servlet当中,出现乱码。

问题描述:通常js传值会自动使用ISO-95581解码,使得出现。 解决方法:td= new String(td.getBytes(\"ISO-8859-1\"),\"UTF-8\");

5.2体会与感想

这次Web课程设计,我又重新学习了一遍JSP、Javascript、Servlet、Html、JavaBean、Css。这次课程设计我做的企业职工在线管理信息系统,在老师和同学的帮助之下,虽然题目要求的功能基本都实现了,但是还有有很多没有完善的地方,例如:代码不够精简,MVC使用不够熟练。对我印象最深的就是CSS和JS,主要使用Css对页面样式布局。使用Js控制页面输入。也比以前更加懂得使用JSP和Servlet。不过也通过这次知道了自己在学习Java和Web的过程中存在不足。以后应该更加好好学习。

主要Servlet源代码附录:

//servlet1

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append(\"Served at: \").append(request.getContextPath()); response.setContentType(\"text/html;charset=utf-8\"); request.setCharacterEncoding(\"UTF-8\"); boolean s=false; //boolean s2=false; String user=request.getParameter(\"user\"); String password=request.getParameter(\"password\"); String radio=request.getParameter(\"radio\"); SelectInformation database=new SelectInformation(); if(radio.equals(\"radio1\")){ for(int i=1;i<=database.Length();i++){ if(user.equals((database.FdUser(i)).trim())&&password.equals((database.FdPassword(i)).trim())) { request.getSession().setAttribute(\"WorkName\",database.FdWorkName(user)); s=true; }

21

Web开发技术课程设计

} if(s) request.getRequestDispatcher(\"/WorkMenu.jsp\").forward(request, response); else{ request.setAttribute(\"str\",\"123\"); request.getRequestDispatcher(\"/login.jsp\").forward(request, response); } } if(radio.equals(\"radio2\")){ for(int i=1;i<=2;i++){ if(user.equals((database.AdminId(i)).trim())&&password.equals((database.AdminPassword(i)).trim())) { request.getSession().setAttribute(\"AdminId\",database.AdminId(i)); s=true; } } if(s) request.getRequestDispatcher(\"/AdminMenu.jsp\").forward(request, response); else { request.setAttribute(\"str\",\"456\"); request.getRequestDispatcher(\"/login.jsp\").forward(request, response); } } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }

22

Web开发技术课程设计

//Servlet2

@WebServlet(\"/Servlet2\")

public class Servlet2 extends HttpServlet { private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public Servlet2() { super();

// TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding(\"UTF-8\"); response.setContentType(\"text/html;charset=utf-8\"); InsertInformation data=new InsertInformation(); SelectInformation num=new SelectInformation(); String user=request.getParameter(\"user\"); String password=request.getParameter(\"password\"); String passwordAgain=request.getParameter(\"passwordAgain\"); String name=request.getParameter(\"name\"); String tel=request.getParameter(\"tel\"); if(data.InsertData(num.Length(),user,password,passwordAgain,name,tel)==true){ request.getRequestDispatcher(\"/login.jsp\").forward(request, response); } else request.getRequestDispatcher(\"RegisterFail.jsp\").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response);

23

Web开发技术课程设计

} }

//updateMassage

@WebServlet(\"/updateMassage\")

public class updateMassage extends HttpServlet { private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public updateMassage() { super();

// TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding(\"UTF-8\"); response.setContentType(\"text/html;charset=utf-8\"); int massageNum=Integer.parseInt(request.getParameter(\"id\")); String resContent=request.getParameter(\"resContents\"); resContent=new String(resContent.getBytes(\"iso-8859-1\"),\"utf-8\"); System.out.print(resContent); Manage data=new Manage(); if(data.updateMassage(massageNum,resContent)==true){ request.setAttribute(\"massage\",data.massageMassage()); request.getRequestDispatcher(\"/MassageManage.jsp\").forward(request, response); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response);

24

Web开发技术课程设计

} }

//updateSomebodyWageServlet

@WebServlet(\"/updateSomebodyWageServlet\")

public class updateSomebodyWageServlet extends HttpServlet { private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public updateSomebodyWageServlet() { super();

// TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding(\"UTF-8\"); response.setContentType(\"text/html;charset=utf-8\"); float tushuWage=Float.parseFloat(request.getParameter(\"TeshuWage\")); String yMonth=request.getParameter(\"yMonth\"); String workname=(String)request.getSession().getAttribute(\"somebody\"); System.out.print(workname); UpdateInformation data1=new UpdateInformation(); SelectData data=new SelectData(); if(data1.updateSomebodyWage(workname,yMonth,tushuWage)){ request.setAttribute(\"str\", data.selectSomebody(workname)); request.getRequestDispatcher(\"/update.jsp\").forward(request, response); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response);

25

Web开发技术课程设计

} }

//InsertWageServlet

@WebServlet(\"/InsertWageServlet\")

public class InsertWageServlet extends HttpServlet { private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public InsertWageServlet() { super();

// TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding(\"UTF-8\"); response.setContentType(\"text/html;charset=utf-8\"); InsertInformation data=new InsertInformation(); SelectInformation num=new SelectInformation(); String name=request.getParameter(\"name\"); String month=request.getParameter(\"month\"); String jobNum=request.getParameter(\"jobNum\"); float teshuwage=Float.parseFloat(request.getParameter(\"teshu\")); if(data.InsertWageInformation(name,month,jobNum,teshuwage)==true){ request.setAttribute(\"massage\",num.selectWorkWage()); request.getRequestDispatcher(\"/workerMoneyTable.jsp\").forward(request, response); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub

26

Web开发技术课程设计

doGet(request, response); } }

//manageServlet

@WebServlet(\"/manageServlet\")

public class manageServlet extends HttpServlet { private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public manageServlet() { super();

// TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding(\"UTF-8\"); response.setContentType(\"text/html;charset=utf-8\"); Manage data=new Manage(); Date nowtime=new Date(); String name=(String)request.getSession().getAttribute(\"WorkName\"); String contents=request.getParameter(\"textarea\"); String time=nowtime.toString(); String password=request.getParameter(\"password\"); String tel=request.getParameter(\"tel\"); if(data.InsertMassage(data.ManageLength(),name,contents,time,\"\")==true){ request.getRequestDispatcher(\"/workerManage.jsp\").forward(request, response); } else request.getRequestDispatcher(\"/workerManage.jsp\").forward(request, response); } /**

27

Web开发技术课程设计

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }

//updateWorkWageServlet

@WebServlet(\"/updateWorkWageServlet\")

public class updateWorkWageServlet extends HttpServlet { private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public updateWorkWageServlet() { super();

// TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding(\"UTF-8\"); response.setContentType(\"text/html;charset=utf-8\"); String workname=request.getParameter(\"workname\"); workname=new String(workname.getBytes(\"iso-8859-1\"),\"utf-8\"); String name=request.getParameter(\"name\"); name=new String(name.getBytes(\"iso-8859-1\"),\"utf-8\"); String jintie=request.getParameter(\"jintie\"); UpdateInformation data1=new UpdateInformation(); SelectInformation data=new SelectInformation(); if(data1.updateworkerWage(workname,name,jintie)){ request.setAttribute(\"massage\",data.selectWorkWage()); request.getRequestDispatcher(\"/workerMoneyTable.jsp\").forward(request, response); } }

28

Web开发技术课程设计

/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }

//onclickSelectServlet

@WebServlet(\"/onclickSelectServlet\")

public class onclickSelectServlet extends HttpServlet { private static final long serialVersionUID = 1L; /**

* @see HttpServlet#HttpServlet() */

public onclickSelectServlet() { super();

// TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding(\"UTF-8\"); response.setContentType(\"text/html;charset=utf-8\"); String workname=request.getParameter(\"workname\"); workname= new String(workname.getBytes(\"ISO-8859-1\"),\"UTF-8\"); request.getSession().setAttribute(\"somebody\",workname); SelectData data=new SelectData(); request.setAttribute(\"str\", data.selectSomebody(workname)); request.getRequestDispatcher(\"/update.jsp\").forward(request, response); } /**

29

Web开发技术课程设计

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }

主要JavaBean源代码附录: //UpdateInformation

package javaBeans;

import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet;

public class UpdateInformation { public boolean updateworkerWage(String workname,String jobname,String jintie) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String jobnum=\"\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql1=\"select JobNum from Job where JobName=?\"; PreparedStatement pstmt1 = dbConn.prepareStatement(sql1); pstmt1.setString(1,jobname); ResultSet rs = pstmt1.executeQuery();

30

Web开发技术课程设计

if(rs.next()){ jobnum=rs.getString(1); } System.out.print(jobnum); String sql =\"update Worker set JobNum=? where WorkName=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setString(1,jobnum); pstmt.setString(2,workname); pstmt.executeUpdate(); return true; }catch(Exception e) { e.printStackTrace(); return false; } } public boolean updateSomebodyWage(String workname,String month,float jintie) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; int worknum=1; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql1=\"select WorkNum from Worker where WorkName=?\"; PreparedStatement pstmt1 = dbConn.prepareStatement(sql1); pstmt1.setString(1,workname); ResultSet rs = pstmt1.executeQuery(); if(rs.next()){ worknum=rs.getInt(1); } System.out.print(worknum); String sql =\"update AllWage set TeshuWage=? where WorkNum=? and YMonth=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setFloat(1,jintie);

31

Web开发技术课程设计

}

pstmt.setInt(2,worknum); pstmt.setString(3,month); pstmt.executeUpdate(); return true; }catch(Exception e) { e.printStackTrace(); return false; } }

//SelectInformation

package javaBeans; import java.sql.*;

import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;

public class SelectInformation {

public String FdUser(int num){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String user=\"aaa\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select Users from Register where Num=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setInt(1, num); ResultSet rs = pstmt.executeQuery(); if (rs.next()){ user = rs.getString(1);

32

Web开发技术课程设计

} }catch(Exception e) { e.printStackTrace(); } return user; } public String FdPassword(int num) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String

dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String password=\"aaa\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection

dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select PassWord from Register where Num=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setInt(1, num); ResultSet rs = pstmt.executeQuery(); if (rs.next()){ password= rs.getString(1); } }catch(Exception e) { e.printStackTrace(); } return password; } public String FdWorkName(String user) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String name=\"aaa\"; try

33

Web开发技术课程设计

{ Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select Name from Register where Users=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setString(1,user); ResultSet rs = pstmt.executeQuery(); if (rs.next()){ name= rs.getString(\"Name\"); } }catch(Exception e) { e.printStackTrace(); } return name; }

public String AdminId(int num){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String AdminId=\"aaa\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select Id from Admin where Num=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setInt(1, num); ResultSet rs = pstmt.executeQuery(); if (rs.next()){ AdminId = rs.getString(1); } }catch(Exception e) { e.printStackTrace();

34

Web开发技术课程设计

} return AdminId; }

public String AdminPassword(int num) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String AdminPassword=\"aaa\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select APassword from Admin where Num=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setInt(1, num); ResultSet rs = pstmt.executeQuery(); if (rs.next()){ AdminPassword= rs.getString(1); } }catch(Exception e) { e.printStackTrace(); } return AdminPassword; }

public String[][] selectSomebody(String name){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String[][] somebody=new String[100][100]; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd);

35

Web开发技术课程设计

String sql = \"select

YMonth,JobName,JobWage,JobSubsidy,JobAge,MonthWage,PensionInsurance,MedicalInsurance,UnemploymentInsurance from Job,AllWage,Worker where

AllWage.JobNum=Job.JobNum and AllWage.WorkNum=Worker.WorkNum and WorkName=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setString(1,name); ResultSet rs = pstmt.executeQuery(); int i=1; int j=1; while(rs.next()){ somebody[i][j]=rs.getString(1); j++; somebody[i][j]=rs.getString(2); j++; somebody[i][j]=rs.getString(3); j++; somebody[i][j]=rs.getString(4); j++; somebody[i][j]=rs.getString(5); j++; somebody[i][j]=rs.getString(6); j++; somebody[i][j]=rs.getString(7); j++; somebody[i][j]=rs.getString(8); j++; somebody[i][j]=rs.getString(9); i++;j=j-8; } }catch(Exception e) { e.printStackTrace(); } return somebody; } public String[][] selectWorkWage(){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String[][] everybody=new String[100][100]; try {

36

Web开发技术课程设计

Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql2=\"select WorkName,JobName,JobWage,Jobsubsidy,MonthWage from Worker,Job where Worker.JobNum=Job.JobNum\"; PreparedStatement pstmt1 = dbConn.prepareStatement(sql2); ResultSet rs = pstmt1.executeQuery(); int i=1; int j=1; while(rs.next()){ everybody[i][j]=rs.getString(1); j++; everybody[i][j]=rs.getString(2); j++; everybody[i][j]=rs.getString(3); j++; everybody[i][j]=rs.getString(4); j++; everybody[i][j]=rs.getString(5); i++;j=j-4; } }catch(Exception e) { e.printStackTrace(); } return everybody; } public String[][] selectjob(){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String[][] jobInformal=new String[100][100]; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd);

37

Web开发技术课程设计

String sql2=\"select * from Job\"; PreparedStatement pstmt1 = dbConn.prepareStatement(sql2); ResultSet rs = pstmt1.executeQuery(); int i=1; int j=1; while(rs.next()){ jobInformal[i][j]=rs.getString(1); j++; jobInformal[i][j]=rs.getString(2); j++; jobInformal[i][j]=rs.getString(3); j++; jobInformal[i][j]=rs.getString(4); j++; jobInformal[i][j]=rs.getString(5); j++; jobInformal[i][j]=rs.getString(6); j++; jobInformal[i][j]=rs.getString(7); j++; jobInformal[i][j]=rs.getString(8); i++;j=j-7; } }catch(Exception e) { e.printStackTrace(); } return jobInformal; }

public int Length (){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; int count=1; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select Num from Register\";

38

Web开发技术课程设计

PreparedStatement pstmt = dbConn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while(rs.next()){ count++; } }catch(Exception e) { e.printStackTrace(); }

return count ; }

public int workerTableLength (){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; int count=1; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select WorkNum from Worker\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while(rs.next()){ count++; } }catch(Exception e) { e.printStackTrace(); }

return count ; } }

// InsertMassage

package javaBeans;

import java.sql.Connection; import java.sql.DriverManager;

39

Web开发技术课程设计

import java.sql.PreparedStatement; import java.sql.ResultSet;

public class Manage { public boolean InsertMassage(int manageNum,String workname,String contents,String time,String resContens) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); PreparedStatement pstmt=dbConn.prepareStatement(\"insert into Manage values(?,?,?,?,?)\"); pstmt.setInt(1,manageNum ); pstmt.setString(2,workname); pstmt.setString(3,contents); pstmt.setString(4,time); pstmt.setString(5,resContens); pstmt.execute(); return true; }catch(Exception e) { e.printStackTrace(); return false; } }

public int ManageLength(){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; int count=1; try { Class.forName(driverName);

40

Web开发技术课程设计

}catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select * from Manage\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while(rs.next()){ count++; } }catch(Exception e) { e.printStackTrace(); }

return count ; }

public String[][] massageMassage(){ String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String[][] somebody=new String[100][100]; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select * from Manage \"; PreparedStatement pstmt = dbConn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); int i=1; while(rs.next()){ somebody[i][1]=rs.getString(1); somebody[i][2]=rs.getString(2); somebody[i][3]=rs.getString(3); somebody[i][4]=rs.getString(4); somebody[i][5]=rs.getString(5); i++; } }catch(Exception e)

41

Web开发技术课程设计

{ e.printStackTrace(); }

return somebody; }

public boolean updateMassage(int massageNum,String resContent) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql =\"update Manage set ResContents=? where ManangeNum=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setString(1,resContent); pstmt.setInt(2,massageNum); pstmt.executeUpdate(); return true; }catch(Exception e) { e.printStackTrace(); return false; } }

public String resMassage(String workname) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; String resContent=\"\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace();

42

Web开发技术课程设计

} try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select ResContents from Manage where WorkName=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setString(1,workname); ResultSet rs = pstmt.executeQuery(); while(rs.next()){ resContent=rs.getString(1); }

}catch(Exception e) { e.printStackTrace(); }

return resContent ; } }

//InsertInformation package javaBeans;

import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet;

public class InsertInformation {

public boolean InsertData(int num,String user,String password,String againPassword,String name,String tel) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{

43

Web开发技术课程设计

Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); PreparedStatement pstmt=dbConn.prepareStatement(\"insert into Register values(?,?,?,?,?,?)\"); pstmt.setInt(1,num ); pstmt.setString(2, user); pstmt.setString(3, password); pstmt.setString(4, againPassword); pstmt.setString(5, name); pstmt.setString(6, tel); pstmt.execute(); return true; }catch(Exception e) { e.printStackTrace(); return false; } }

public boolean InsertWorker(int workNum,String workerName,String sex,String Born,String jobNum,int jobAge) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); PreparedStatement pstmt=dbConn.prepareStatement(\"insert into Worker values(?,?,?,?,?,?)\"); pstmt.setInt(1,workNum); pstmt.setString(2, workerName); pstmt.setString(3,sex); pstmt.setString(4,Born); pstmt.setString(5,jobNum); pstmt.setInt(6,jobAge); pstmt.execute(); return true;

44

Web开发技术课程设计

}catch(Exception e) { e.printStackTrace(); return false; } }

public boolean InsertWageInformation(String workerName,String month,String jobnum,float teshuWage) { String driverName=\"com.microsoft.sqlserver.jdbc.SQLServerDriver\"; String dbURL=\"jdbc:sqlserver://localhost:1433;DatabaseName=WorkerMoney\"; String userName=\"sa\"; String userPwd=\"111\"; int workNum=1; try { Class.forName(driverName); }catch(Exception e){ e.printStackTrace(); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = \"select WorkNum from Worker where WorkName=?\"; PreparedStatement pstmt = dbConn.prepareStatement(sql); pstmt.setString(1,workerName); ResultSet rs = pstmt.executeQuery(); if (rs.next()){ workNum= rs.getInt(1); } PreparedStatement pstmt1=dbConn.prepareStatement(\"insert into AllWage values(?,?,?,?)\"); pstmt1.setInt(1,workNum); pstmt1.setString(2,month); pstmt1.setString(3,jobnum); pstmt1.setFloat(4,teshuWage); pstmt1.execute(); return true; }catch(Exception e) { e.printStackTrace(); return false; }

45

Web开发技术课程设计

} }

参考文献

[1]耿祥义.JSP基础教程. 北京:清华大学出版社.2004 [2]冯燕奎.JSP实用案例教程.北京:清华大学出版社.2004 [3]刘志成.JSP程序设计案例教程.北京:清华大学出版社.2007 [4] 网上资料

46

因篇幅问题不能全部显示,请点此查看更多更全内容