diff --git a/HRMS/.classpath b/HRMS/.classpath new file mode 100644 index 0000000..2771403 --- /dev/null +++ b/HRMS/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HRMS/.project b/HRMS/.project new file mode 100644 index 0000000..1c565a5 --- /dev/null +++ b/HRMS/.project @@ -0,0 +1,46 @@ + + + HRMS + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator + + + + + com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/HRMS/.settings/.jsdtscope b/HRMS/.settings/.jsdtscope new file mode 100644 index 0000000..2fc9dba --- /dev/null +++ b/HRMS/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/HRMS/.settings/org.eclipse.jdt.core.prefs b/HRMS/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f42de36 --- /dev/null +++ b/HRMS/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/HRMS/.settings/org.eclipse.wst.common.component b/HRMS/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..d202b21 --- /dev/null +++ b/HRMS/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/HRMS/.settings/org.eclipse.wst.common.project.facet.core.xml b/HRMS/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..ae218fe --- /dev/null +++ b/HRMS/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/HRMS/.settings/org.eclipse.wst.jsdt.ui.superType.container b/HRMS/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/HRMS/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/HRMS/.settings/org.eclipse.wst.jsdt.ui.superType.name b/HRMS/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/HRMS/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/HRMS/WebRoot/META-INF/MANIFEST.MF b/HRMS/WebRoot/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/HRMS/WebRoot/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/HRMS/WebRoot/WEB-INF/classes/action/ContractAction.class b/HRMS/WebRoot/WEB-INF/classes/action/ContractAction.class new file mode 100644 index 0000000..1a894af Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/action/ContractAction.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/action/EmployAction.class b/HRMS/WebRoot/WEB-INF/classes/action/EmployAction.class new file mode 100644 index 0000000..fd94117 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/action/EmployAction.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/action/SuperAction.class b/HRMS/WebRoot/WEB-INF/classes/action/SuperAction.class new file mode 100644 index 0000000..a1825bb Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/action/SuperAction.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/action/TrainAction.class b/HRMS/WebRoot/WEB-INF/classes/action/TrainAction.class new file mode 100644 index 0000000..27857d9 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/action/TrainAction.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/action/UserAction.class b/HRMS/WebRoot/WEB-INF/classes/action/UserAction.class new file mode 100644 index 0000000..76e206d Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/action/UserAction.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/db/MyHibernateSessionFactory.class b/HRMS/WebRoot/WEB-INF/classes/db/MyHibernateSessionFactory.class new file mode 100644 index 0000000..8c712a7 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/db/MyHibernateSessionFactory.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Contract.class b/HRMS/WebRoot/WEB-INF/classes/entity/Contract.class new file mode 100644 index 0000000..039e544 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/entity/Contract.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Contract.hbm.xml b/HRMS/WebRoot/WEB-INF/classes/entity/Contract.hbm.xml new file mode 100644 index 0000000..ae34e1a --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/classes/entity/Contract.hbm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Employ.class b/HRMS/WebRoot/WEB-INF/classes/entity/Employ.class new file mode 100644 index 0000000..183bef5 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/entity/Employ.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Employ.hbm.xml b/HRMS/WebRoot/WEB-INF/classes/entity/Employ.hbm.xml new file mode 100644 index 0000000..f6031e9 --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/classes/entity/Employ.hbm.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Staff.class b/HRMS/WebRoot/WEB-INF/classes/entity/Staff.class new file mode 100644 index 0000000..ce711ba Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/entity/Staff.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Staff.hbm.xml b/HRMS/WebRoot/WEB-INF/classes/entity/Staff.hbm.xml new file mode 100644 index 0000000..1f1a6ff --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/classes/entity/Staff.hbm.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/TestDatabase.class b/HRMS/WebRoot/WEB-INF/classes/entity/TestDatabase.class new file mode 100644 index 0000000..492af44 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/entity/TestDatabase.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Train.class b/HRMS/WebRoot/WEB-INF/classes/entity/Train.class new file mode 100644 index 0000000..d62b90f Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/entity/Train.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/Train.hbm.xml b/HRMS/WebRoot/WEB-INF/classes/entity/Train.hbm.xml new file mode 100644 index 0000000..aa09043 --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/classes/entity/Train.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/User.class b/HRMS/WebRoot/WEB-INF/classes/entity/User.class new file mode 100644 index 0000000..c740dae Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/entity/User.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/entity/User.hbm.xml b/HRMS/WebRoot/WEB-INF/classes/entity/User.hbm.xml new file mode 100644 index 0000000..77df7e9 --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/classes/entity/User.hbm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/WebRoot/WEB-INF/classes/hibernate.cfg.xml b/HRMS/WebRoot/WEB-INF/classes/hibernate.cfg.xml new file mode 100644 index 0000000..5c3f786 --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/classes/hibernate.cfg.xml @@ -0,0 +1,26 @@ + + + + + + root + root + com.mysql.jdbc.Driver + jdbc:mysql:///hrms?useUnicode=true&characterEncoding=UTF-8 + org.hibernate.dialect.MySQLDialect + true + true + update + thread + + + + + + + + \ No newline at end of file diff --git a/HRMS/WebRoot/WEB-INF/classes/service/ContractDao.class b/HRMS/WebRoot/WEB-INF/classes/service/ContractDao.class new file mode 100644 index 0000000..a3ea8b2 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/ContractDao.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/EmployDao.class b/HRMS/WebRoot/WEB-INF/classes/service/EmployDao.class new file mode 100644 index 0000000..64ee28e Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/EmployDao.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/TrainDao.class b/HRMS/WebRoot/WEB-INF/classes/service/TrainDao.class new file mode 100644 index 0000000..df9efaf Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/TrainDao.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/UserDao.class b/HRMS/WebRoot/WEB-INF/classes/service/UserDao.class new file mode 100644 index 0000000..93419cf Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/UserDao.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/ContractDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/ContractDaoImpl.class new file mode 100644 index 0000000..6b80767 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/ContractDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/EmployDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/EmployDaoImpl.class new file mode 100644 index 0000000..17eee51 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/EmployDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/TestContractDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestContractDaoImpl.class new file mode 100644 index 0000000..1643822 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestContractDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/TestEmployDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestEmployDaoImpl.class new file mode 100644 index 0000000..1d53f2c Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestEmployDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/TestTrainDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestTrainDaoImpl.class new file mode 100644 index 0000000..be8daea Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestTrainDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/TestUserDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestUserDaoImpl.class new file mode 100644 index 0000000..6aad051 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/TestUserDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/TrainDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/TrainDaoImpl.class new file mode 100644 index 0000000..5e794cd Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/TrainDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/service/impl/UserDaoImpl.class b/HRMS/WebRoot/WEB-INF/classes/service/impl/UserDaoImpl.class new file mode 100644 index 0000000..b43d83b Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/service/impl/UserDaoImpl.class differ diff --git a/HRMS/WebRoot/WEB-INF/classes/struts.xml b/HRMS/WebRoot/WEB-INF/classes/struts.xml new file mode 100644 index 0000000..5478756 --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/classes/struts.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + /user/User_login_success.jsp + /user/User_login.jsp + /user/User_login.jsp + /user/User_login.jsp + + + + + /employ/Employ_query_success.jsp + Employ_query + /employ/Employ_add_success.jsp + /employ/Employ_modify.jsp + /employ/Employ_modify_success.jsp + + + + + /train/Train_query_success.jsp + Train_query + /train/Train_add_success.jsp + /train/Train_modify.jsp + /train/Train_modify_success.jsp + + + + + /contract/Contract_query_success.jsp + Contract_query + /contract/Contract_add_success.jsp + /contract/Contract_modify.jsp + /contract/Contract_modify_success.jsp + + + diff --git a/HRMS/WebRoot/WEB-INF/classes/util/Util.class b/HRMS/WebRoot/WEB-INF/classes/util/Util.class new file mode 100644 index 0000000..4892ab9 Binary files /dev/null and b/HRMS/WebRoot/WEB-INF/classes/util/Util.class differ diff --git a/HRMS/WebRoot/WEB-INF/web.xml b/HRMS/WebRoot/WEB-INF/web.xml new file mode 100644 index 0000000..748c00f --- /dev/null +++ b/HRMS/WebRoot/WEB-INF/web.xml @@ -0,0 +1,15 @@ + + + + struts2 + org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter + + + + struts2 + /* + + + diff --git a/HRMS/WebRoot/components/dtree/dtree.css b/HRMS/WebRoot/components/dtree/dtree.css new file mode 100644 index 0000000..d91d624 --- /dev/null +++ b/HRMS/WebRoot/components/dtree/dtree.css @@ -0,0 +1,33 @@ +/*--------------------------------------------------| +| dTree 2.05 | www.destroydrop.com/javascript/tree/ | +|---------------------------------------------------| +| Copyright (c) 2002-2003 Geir Landr? | +|--------------------------------------------------*/ + +.dtree { + font-size: 12px; + color: #666; + white-space: nowrap; +} +.dtree img { + border: 0px; + vertical-align: middle; +} +.dtree a { + color: #333; + text-decoration: none; +} +.dtree a.node, .dtree a.nodeSel { + white-space: nowrap; + padding: 1px 2px 1px 2px; +} +.dtree a.node:hover, .dtree a.nodeSel:hover { + color: #333; + text-decoration: underline; +} +.dtree a.nodeSel { + background-color: #c0d2ec; +} +.dtree .clip { + overflow: hidden; +} \ No newline at end of file diff --git a/HRMS/WebRoot/components/dtree/dtree.js b/HRMS/WebRoot/components/dtree/dtree.js new file mode 100644 index 0000000..049a3f9 --- /dev/null +++ b/HRMS/WebRoot/components/dtree/dtree.js @@ -0,0 +1,347 @@ +/*--------------------------------------------------| +| dTree 2.05 | www.destroydrop.com/javascript/tree/ | +|---------------------------------------------------| +| Copyright (c) 2002-2003 Geir Landr? | +| | +| This script can be used freely as long as all | +| copyright messages are intact. | +| | +| Updated: 17.04.2003 | +|--------------------------------------------------*/ + +// Node object +function Node(id, pid, name, url, title, target, icon, iconOpen, open) { + this.id = parseInt(id); + this.pid = parseInt(pid); + this.name = name; + this.url = url; + this.title = title; + this.target = target; + this.icon = icon; + this.iconOpen = iconOpen; + this._io = open || false; + this._is = false; + this._ls = false; + this._hc = false; + this._ai = 0; + this._p; +}; + +// Tree object +function dTree(objName) { + this.config = { + target : null, + folderLinks : true, + useSelection : true, + useCookies : true, + useLines : true, + useIcons : true, + useStatusText : false, + closeSameLevel : false, + inOrder : false + } + this.icon = { + root : dtreeIconBasePath + '/img/base.gif', + folder : dtreeIconBasePath + '/img/folder.gif', + folderOpen : dtreeIconBasePath + '/img/folderopen.gif', + node : dtreeIconBasePath + '/img/page.gif', + empty : dtreeIconBasePath + '/img/empty.gif', + line : dtreeIconBasePath + '/img/line.gif', + join : dtreeIconBasePath + '/img/join.gif', + joinBottom : dtreeIconBasePath + '/img/joinbottom.gif', + plus : dtreeIconBasePath + '/img/plus.gif', + plusBottom : dtreeIconBasePath + '/img/plusbottom.gif', + minus : dtreeIconBasePath + '/img/minus.gif', + minusBottom : dtreeIconBasePath + '/img/minusbottom.gif', + nlPlus : dtreeIconBasePath + '/img/nolines_plus.gif', + nlMinus : dtreeIconBasePath + '/img/nolines_minus.gif' + }; + this.obj = objName; + this.aNodes = []; + this.aIndent = []; + this.root = new Node(-1); + this.selectedNode = null; + this.selectedFound = false; + this.completed = false; +}; + +// Adds a new node to the node array +dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { + this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open); +}; + +// Open/close all nodes +dTree.prototype.openAll = function() { + this.oAll(true); +}; +dTree.prototype.closeAll = function() { + this.oAll(false); +}; + +// Outputs the tree to the page +dTree.prototype.toString = function() { + var str = '
\n'; + if (document.getElementById) { + if (this.config.useCookies) this.selectedNode = this.getSelected(); + str += this.addNode(this.root); + } else str += 'Browser not supported.'; + str += '
'; + if (!this.selectedFound) this.selectedNode = null; + this.completed = true; + return str; +}; + +// Creates the tree structure +dTree.prototype.addNode = function(pNode) { + var str = ''; + var n=0; + if (this.config.inOrder) n = pNode._ai; + for (n; n'; + } + if (node.url) { + str += ''; + str += node.name; + if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; + str += ''; + if (node._hc) { + str += '
'; + str += this.addNode(node); + str += '
'; + } + this.aIndent.pop(); + return str; +}; + +// Adds the empty and line icons +dTree.prototype.indent = function(node, nodeId) { + var str = ''; + if (this.root.id != node.pid) { + for (var n=0; n'; + (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); + if (node._hc) { + str += ''; + } else str += ''; + } + return str; +}; + +// Checks if a node has any children and if it is the last sibling +dTree.prototype.setCS = function(node) { + var lastId; + for (var n=0; n +<%@ taglib prefix="s" uri="/struts-tags"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + + + +
+
+
+ +签署合同 +
+
+
+ + + + + + + + + + + + + + + + + + + + +
合同类型:
合同年限:
薪酬:
员工编号:
+
+ + +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/contract/Contract_add_success.jsp b/HRMS/WebRoot/contract/Contract_add_success.jsp new file mode 100644 index 0000000..fc56927 --- /dev/null +++ b/HRMS/WebRoot/contract/Contract_add_success.jsp @@ -0,0 +1,94 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + +
+ +
+
+ 签署合同成功,继续签署? + +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/contract/Contract_modify.jsp b/HRMS/WebRoot/contract/Contract_modify.jsp new file mode 100644 index 0000000..ff8f62d --- /dev/null +++ b/HRMS/WebRoot/contract/Contract_modify.jsp @@ -0,0 +1,125 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<%@ taglib prefix="s" uri="/struts-tags"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + + + +
+
+
+ +修改合同信息 +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
合同编号:
合同类型:
合同年限:
薪酬:
员工编号:
+
+ +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/contract/Contract_modify_success.jsp b/HRMS/WebRoot/contract/Contract_modify_success.jsp new file mode 100644 index 0000000..d3d5a57 --- /dev/null +++ b/HRMS/WebRoot/contract/Contract_modify_success.jsp @@ -0,0 +1,94 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + +
+ +
+
+ 修改合同成功,返回合同列表 + +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/contract/Contract_query_success.jsp b/HRMS/WebRoot/contract/Contract_query_success.jsp new file mode 100644 index 0000000..dfad3cf --- /dev/null +++ b/HRMS/WebRoot/contract/Contract_query_success.jsp @@ -0,0 +1,127 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<%@ taglib prefix="s" uri="/struts-tags"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
合同编号合同类型合同年限薪酬员工编号操作
">" onclick="javascript: return confirm('真的要删除吗?');">删除
+
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/css/default.css b/HRMS/WebRoot/css/default.css new file mode 100644 index 0000000..bac0be2 --- /dev/null +++ b/HRMS/WebRoot/css/default.css @@ -0,0 +1,433 @@ +/* 基本样式 */ + + +/* 去掉图片、表单边框 */ +img, form { + margin:0; + padding:0; + border:0; +} + +/* 超链接 */ +a { + text-decoration: none; +} +a:link, a:visited { + color:#063685; + text-decoration:none; +} +a:hover, a:active { + color:#FF5500; + text-decoration:underline; +} + +/* 表格 */ +table.default { + border:1px solid #0283c5; + border-collapse:collapse; + margin-top:5px; +} +table.default td, table.default tr.style1 td { + padding:2 5 2 5; + height:26px; + border:1px solid #ffffff; +} +table.default tr, table.default tr.style1{ + background-color:#f0f0f0; +} +table.default tr.style0{ + background-color:#dfdfdf; +} +table.default tr.title td, table.default tr.ltitle td { + font-weight:bold; + background:#0283c5; + color:#ffffff; + border:1px solid #ffffff; + white-space:nowrap; + height:26px; + line-height:26px; + vertical-align:middle; +} +table.default tr.ltitle td { + text-align:left; +} +table.default tr.title td { + text-align:center; + line-height:26px; + vertical-align:middle; +} +table.default tr.subtitle td ,table.default tr.lsubtitle td { + font-weight:bold; + background:#69f; + color:#ffffff; + border:1px solid #ffffff; + white-space:nowrap; + height:26px; + line-height:26px; + vertical-align:middle; +} +table.default tr.lsubtitle td { + text-align:left; +} +table.default tr.subtitle td { + text-align:center; +} + +table.default tr.strong td { + font-weight:bold; + background:#DDD; +} + +table.default tr.stronghl td { + font-weight:bold; + background:#FFCC99; + text-align:center; +} + +table.default tr.hl td { + background:#ffffcc/*#FFFF99*/; +} + +table.default td.item { + font-weight:bold; + color:#333333; + text-align:right; +} + +table.default td.text { + line-height:150%; +} + +table.default td.opt { + background:#FFFF99; + padding-right:10px; +} + +table.explain { + margin-top:5px; + margin-bottom:5px; +} +table.explain td { + font-family:宋体; + font-size:12px; + border:1px solid #333333; + background:#f0f0f0; + padding:8px; + line-height:120%; +} + +table.pages { + border:0; +} +table.pages td { + height:26px; +} + +table.reswb { + border:1px solid #0283c5; + border-collapse:collapse; + margin-top:10px; +} + +table.reswb tr.title td { + padding:2 5 2 5; + font-weight:bold; + background:#0283c5; + color:#ffffff; + border:1px solid #ffffff; + white-space:nowrap; + height:26px; + line-height:26px; + vertical-align:middle; +} + +table.default tr.list{ + text-align: center; + line-height:26px; + vertical-align:middle; +} + +/* 普通信息 */ +div.info { + padding:5px 5px 5px 2px; + margin-top:10px; +} + +/* 前台导航用 */ +.tdnormal { + border-bottom:1px solid white; +} + +.tdselected { + border:1px solid white; + border-bottom:0; + font-weight:bold; +} +.navtab td { + height:30px; + color:white; + font-size:9pt; + text-align:center; +} +a.navbar, a.navbar:visited, a.navbar:active {text-decoration: none;color:#FFF;} +a.navbar:hover {text-decoration: underline;color:#FFF;} + + +/* 错误信息 */ +.errorBox { + border:1px solid #ff0000; + padding:5px; + background:#FFCCCC; +} +.errorMessage { + color:#cc0000; +} +ul { + margin-left:30px; + margin-top:0; + margin-bottom:0; +} + +/* 分页页码样式 */ +.selectedPage { + border:1px solid #999999; + background:#ffffcc; + color:#000000; + padding:0 3px 2px 3px; +} +.noSelectedPage { + padding:0 3px 0 3px; +} +a.page { + font-size:12px; + text-decoration: none; +} +a.page:link, a.page:visited { + color:#0044DD; + text-decoration:none; +} +a.page:hover, a.page:active { + color:#FF5500; + text-decoration:none; +} + +/* 表单元素样式 */ +.input_text { + width:200px; + margin-right:5px; +} +.notNull { + color:red; +} +.notice { + color:#20A8F0; +} + +/* 后台任务链接样式 */ +a.navlink { + font-family:宋体; + height:25px; + font-weight:normal; + letter-spacing:1px; + padding:4 5 0 5; + background:#e0e0e0; + border:2px outset; + FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#20A8F0); +} + +a.navlink {text-decoration: none;color:#000000;} +a.navlink:visited {text-decoration: none;color:#000000;} +a.navlink:active {text-decoration: none;color:#0044DD;} +a.navlink:hover {text-decoration: none;color:#FF5500;} + +/* 操作按钮 */ +div.oper { + margin:5px; + text-align:right; +} + +div.oper input { + margin-left:5px; + margin-right:5px; +} + +/* 背景色 */ +.fbg { + background:#065FB9; +} +.bbg { + background:#04477C; +} + +/* tooltip */ +/* +span.tip { + cursor:default; +} +#tooltip { + position: absolute; + z-index: 3000; + border: 1px solid #111; + background-color: #eee; + padding: 5px; + opacity: 0.85; +} +#tooltip h3, #tooltip div { + font-size:12px; + margin: 0; +} +*/ + +/* 特殊高亮文本 */ +span.spec { + color:#003399; +} + +/* 特殊灰色文本 */ +span.gray { + color:#666; +} + +/* 黄色背景 */ +.bg1 { + background:#FFCC99;/*#FFFF99;*/ +} + +/* 绿色背景 */ +.bg2 { + background:#99CC99; +} + +/* 文章样式 */ + +div.title { + font-size:16px; + font-weight:bold; + background:#FFFF99; + border-bottom:2px solid #000; + padding:5px; + margin-bottom:10px; +} + +div.content { + font-size:14px; + line-height:150%; +} + +div.faq-q { + padding:5px; + background:#DDD; + font-weight:bold; +} + +div.faq-a { + padding:5px; + line-height:150%; + font-size:16px; +} + +/* 问卷样式 */ +.option { + margin-right:10px; +} + +.answer { + background:#060; + color:white; + font-weight:bold; + padding:2px; +} + +table.stat { + border-collapse:collapse; +} +table.stat td { + border:0; + padding-left:20px; +} +hr.percent { + height:10px; + color:#093; + border:1px solid black; +} + +td.indent { + padding-left:10px; +} + +#page_explain { + display:none; +} + +#navDiv { + color:#333; + padding-left:10px; + line-height:30px; + background:#CCFF99; + border-bottom:1px solid #065FB9; + height:30px; + padding-top:6px; +} +/*--------分页样式-----------*/ +.pager-top { + overflow:hidden; + padding:5px 10px 0; + color:#333333; + font-family:Tahoma,Verdana,sans-serif,simsun; + font-size:12px; + margin-top:10px; + border-bottom:1px solid #D8DFEA; +} +.pager-top span { + float:left; + padding-bottom:6px; +} +.pagerpro { + float:right; + list-style-image:none; + list-style-position:outside; + list-style-type:none; + margin:0; + padding:0; +} +.pagerpro li { + display:inline; + float:left; +} +.pagerpro li a.chn { + font-size:12px; +} +.pagerpro li a { + display:block; + font-size:11px; + padding:3px 3px 2px; + color:#005EAC; + text-decoration:none; +} +.pagerpro li a.chn:hover { + border-bottom:1px solid #005EAC; +} +.pagerpro li a:hover { + background:#005EAC none repeat scroll 0 0; + border-bottom:2px solid #005EAC; + border-color:#D8DFEA #D8DFEA #005EAC; + color:#FFFFFF; + text-decoration:none; +} +.pagerpro li.current a, .pagerpro li.current a:hover { + background:transparent none repeat scroll 0 0; + border-bottom:2px solid #005EAC; + border-color:#005EAC; + color:#005EAC; + font-weight:700; + padding-left:2px; + padding-right:2px; +} +.marquee_txt{ + font-size:12px; + font-family:"微软雅黑"; + margin-top:5px; + margin-left:auto; + margin-right:auto; + width:222px; +} \ No newline at end of file diff --git a/HRMS/WebRoot/css/index.css b/HRMS/WebRoot/css/index.css new file mode 100644 index 0000000..90b64be --- /dev/null +++ b/HRMS/WebRoot/css/index.css @@ -0,0 +1,176 @@ +* { + background: none repeat scroll 0 0 transparent; + border: 0 none; + margin: 0; + padding: 0; + vertical-align: baseline; +} +body{ + min-height:600px; + min-width:1280px; + overflow-y:hidden; +} +#wrapper { + background-image: -moz-linear-gradient(top,#77D1F6, #2F368F); + background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #77D1F6),color-stop(1, #2F368F)); + font-family: "lucida Grande",Tahoma,Arial; + font-size: 12px; + overflow: hidden; + height:100%; + width:100%; + height:100%; +} +#header { + float: left; + height: 62px; + position: relative; + width: 100%; + z-index: 10; + text-align:center; +} +#logo { + //border:1px solid red; + float: left; + height: 38px; + line-height:38px; + vertical-align:middle; + margin: 15px 0 0 1%; + width: 60px; +} +#title { + //border:1px solid red; + float: left; + height: 38px; + line-height:38px; + vertical-align:middle; + margin: 15px 0 0 1%; + width: 260px; + font-family:微软雅黑; + font-size:18px; + font-weight:bold; + text-align:center; +} +#menu{ + position:absolute; + left:50%; + margin-top:15px; + margin-left:-300px; + float: float; + height: 38px; + width:615px; + line-height:38px; + vertical-align:middle; + text-align:center; + border-radius: 8px; + background-color:#000000; + opacity:0.5; +} +#menu_container{ + position:relative; + margin:2px; + height: 34px; + line-height:34px; + vertical-align:middle; + border-radius: 8px; + background-image: -moz-linear-gradient(top,#EBEBEB, #BFBFBF); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #EBEBEB),color-stop(1, #BFBFBF)); +} +#menu_items{ + list-style:none; + line-height: normal; + height: 34px; + line-height:34px; + vertical-align:middle; + font-size:14px; + border:2px solid solid; + border-right-style:groove; +} +.menu_item{ + display: list-item; + float:left; + width:100px; + border-right:2px solid #F6F6F6; + border-right-style:groove; + cursor:pointer; +} +.on{ + display: list-item; + float:left; + width:100px; + background:#77D1F6; + font-weight:bold; +} +.menu_item a{ + height: 34px; + line-height:34px; + display:block; +} +#user_info { + height: 35px; + line-height:35px; + vertical-align:middle; + position: relative; + float:right; + margin-top:15px; + margin-right:15px; + width:240px; + font-weight:bold; + font-size:14px; +} +#welcome{ + left:-20px; + position: relative; + float:left; +} +#logout{ + position: relative; + float:right; +} +#footer{ + position: absolute; + float:left; + left:0px; + width: 100%; + height: 25px; + vertical-align:middle; + line-height:25px; + text-align:center; + font-family:微软雅黑; + font-size:14px; + font-weight:bold; + font-color:#FFF; +} +#navigator{ + position:relative; + float:left; + width:200px; + margin:5px 2px 5px 2px; + left:5px; + border-color: #77D1F6; + border-width: 2px; + border-style: solid; + border-radius: 12px; + -moz-box-shadow: 6px 6px 12px #282828; + -webkit-box-shadow: 6px 6px 12px #282828; +} +#main{ + position:relative; + float:left; + width: 80%; + margin:5px; + left:5px; + border-color: #77D1F6; + border-width: 2px; + border-style: solid; + border-radius: 12px 12px; + -moz-box-shadow: 6px 6px 12px #282828; + -webkit-box-shadow: 6px 6px 12px #282828; +} +iframe{ + height:100%; + width:100%; + background:#FFF; + position:relative; + border-radius:12px; + overflow:hidden; +} \ No newline at end of file diff --git a/HRMS/WebRoot/employ/Employ_add.jsp b/HRMS/WebRoot/employ/Employ_add.jsp new file mode 100644 index 0000000..9bc731b --- /dev/null +++ b/HRMS/WebRoot/employ/Employ_add.jsp @@ -0,0 +1,129 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<%@ taglib prefix="s" uri="/struts-tags"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + + + +
+
+
+ +发布招聘信息 +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
招聘岗位:
招聘人数:
岗位说明: +
招聘起始时间: +
招聘截止时间: +
+
+ + +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/employ/Employ_add_success.jsp b/HRMS/WebRoot/employ/Employ_add_success.jsp new file mode 100644 index 0000000..242d1c4 --- /dev/null +++ b/HRMS/WebRoot/employ/Employ_add_success.jsp @@ -0,0 +1,94 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + +
+ +
+
+ 发布招聘信息成功,继续发布? + +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/employ/Employ_modify.jsp b/HRMS/WebRoot/employ/Employ_modify.jsp new file mode 100644 index 0000000..986ddfa --- /dev/null +++ b/HRMS/WebRoot/employ/Employ_modify.jsp @@ -0,0 +1,133 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<%@ taglib prefix="s" uri="/struts-tags"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + + + +
+
+
+ +修改招聘信息 +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
招聘编号:
招聘岗位:
招聘人数:
岗位说明: +
招聘起始时间:"/> +
招聘截止时间:"/> +
+
+ +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/employ/Employ_modify_success.jsp b/HRMS/WebRoot/employ/Employ_modify_success.jsp new file mode 100644 index 0000000..861910d --- /dev/null +++ b/HRMS/WebRoot/employ/Employ_modify_success.jsp @@ -0,0 +1,94 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + +
+ +
+
+ 修改成功,返回招聘列表 + +
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/employ/Employ_query_success.jsp b/HRMS/WebRoot/employ/Employ_query_success.jsp new file mode 100644 index 0000000..cb8ed01 --- /dev/null +++ b/HRMS/WebRoot/employ/Employ_query_success.jsp @@ -0,0 +1,130 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> +<%@ taglib prefix="s" uri="/struts-tags"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
招聘编号招聘岗位招聘人数岗位说明招聘起始时间招聘截止时间操作
">" onclick="javascript: return confirm('真的要删除吗?');">删除
+
+ + \ No newline at end of file diff --git a/HRMS/WebRoot/images/admin.png b/HRMS/WebRoot/images/admin.png new file mode 100644 index 0000000..b2ac7a0 Binary files /dev/null and b/HRMS/WebRoot/images/admin.png differ diff --git a/HRMS/WebRoot/images/arror.gif b/HRMS/WebRoot/images/arror.gif new file mode 100644 index 0000000..d84ce62 Binary files /dev/null and b/HRMS/WebRoot/images/arror.gif differ diff --git a/HRMS/WebRoot/images/icon_default.gif b/HRMS/WebRoot/images/icon_default.gif new file mode 100644 index 0000000..c50070c Binary files /dev/null and b/HRMS/WebRoot/images/icon_default.gif differ diff --git a/HRMS/WebRoot/images/main_bg.jpg b/HRMS/WebRoot/images/main_bg.jpg new file mode 100644 index 0000000..0aedc01 Binary files /dev/null and b/HRMS/WebRoot/images/main_bg.jpg differ diff --git a/HRMS/WebRoot/images/welcome.jpg b/HRMS/WebRoot/images/welcome.jpg new file mode 100644 index 0000000..51b19d0 Binary files /dev/null and b/HRMS/WebRoot/images/welcome.jpg differ diff --git a/HRMS/WebRoot/index.jsp b/HRMS/WebRoot/index.jsp new file mode 100644 index 0000000..07328b0 --- /dev/null +++ b/HRMS/WebRoot/index.jsp @@ -0,0 +1,6 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; + response.sendRedirect(path+"/user/User_login.jsp"); +%> diff --git a/HRMS/WebRoot/js/Calendar3.js b/HRMS/WebRoot/js/Calendar3.js new file mode 100644 index 0000000..e6e14b6 --- /dev/null +++ b/HRMS/WebRoot/js/Calendar3.js @@ -0,0 +1,374 @@ + +/////////////////////////调用实例 +//
+// 交易查询: 从 +// +// +// 至 +// +// + +//
+ +/** + * Calendar + * @param beginYear 1990 + * @param endYear 2010 + * @param language 0(zh_cn)|1(en_us)|2(en_en)|3(zh_tw) + * @param patternDelimiter "-" + * @param date2StringPattern "yyyy-MM-dd" + * @param string2DatePattern "ymd" + * @version 1.0 build 2006-04-01 + * @version 1.1 build 2006-12-17 + * @author KimSoft (jinqinghua [at] gmail.com) + * NOTE! you can use it free, but keep the copyright please + * IMPORTANT:you must include this script file inner html body elment + */ +function Calendar(beginYear, endYear, language, patternDelimiter, date2StringPattern, string2DatePattern) { + this.beginYear = beginYear || 1990; + this.endYear = endYear || 2020; + this.language = language || 0; + this.patternDelimiter = patternDelimiter || "-"; + this.date2StringPattern = date2StringPattern || Calendar.language["date2StringPattern"][this.language].replace(/\-/g, this.patternDelimiter); + this.string2DatePattern = string2DatePattern || Calendar.language["string2DatePattern"][this.language]; + + this.dateControl = null; + this.panel = this.getElementById("__calendarPanel"); + this.iframe = window.frames["__calendarIframe"]; + this.form = null; + + this.date = new Date(); + this.year = this.date.getFullYear(); + this.month = this.date.getMonth(); + + this.colors = {"bg_cur_day":"#00CC33","bg_over":"#EFEFEF","bg_out":"#FFCC00"} +}; + +Calendar.language = { + "year" : ["\u5e74", "", "", "\u5e74"], + "months" : [ + ["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"], + ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"], + ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"], + ["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"] + ], + "weeks" : [["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"], + ["Sun","Mon","Tur","Wed","Thu","Fri","Sat"], + ["Sun","Mon","Tur","Wed","Thu","Fri","Sat"], + ["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"] + ], + "clear" : ["\u6e05\u7a7a", "Clear", "Clear", "\u6e05\u7a7a"], + "today" : ["\u4eca\u5929", "Today", "Today", "\u4eca\u5929"], + "close" : ["\u5173\u95ed", "Close", "Close", "\u95dc\u9589"], + "date2StringPattern" : ["yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd"], + "string2DatePattern" : ["ymd","ymd", "ymd", "ymd"] +}; + +Calendar.prototype.draw = function() { + calendar = this; + + var _cs = []; + _cs[_cs.length] = '
'; + _cs[_cs.length] = ''; + _cs[_cs.length] = ' '; + _cs[_cs.length] = ' '; + for(var i = 0; i < 7; i++) { + _cs[_cs.length] = ''; + for(var j = 0; j < 7; j++) { + switch (j) { + case 0: _cs[_cs.length] = ''; + _cs[_cs.length] = '
<\/th>'; + _cs[_cs.length] = ' <\/select><\/th>'; + _cs[_cs.length] = ' <\/th>'; + _cs[_cs.length] = ' <\/tr>'; + _cs[_cs.length] = '
'; + _cs[_cs.length] = Calendar.language["weeks"][this.language][i]; + _cs[_cs.length] = '<\/th>'; + } + _cs[_cs.length] = '<\/tr>'; + for(var i = 0; i < 6; i++){ + _cs[_cs.length] = '
 <\/td>'; break; + case 6: _cs[_cs.length] = ' <\/td>'; break; + default:_cs[_cs.length] = ' <\/td>'; break; + } + } + _cs[_cs.length] = '<\/tr>'; + } + _cs[_cs.length] = '
<\/th>'; + _cs[_cs.length] = ' <\/th>'; + _cs[_cs.length] = ' <\/th>'; + _cs[_cs.length] = ' <\/tr>'; + _cs[_cs.length] = '<\/table>'; + _cs[_cs.length] = '<\/form>'; + + this.iframe.document.body.innerHTML = _cs.join(""); + this.form = this.iframe.document.forms["__calendarForm"]; + + this.form.clearButton.value = Calendar.language["clear"][this.language]; + this.form.selectTodayButton.value = Calendar.language["today"][this.language]; + this.form.closeButton.value = Calendar.language["close"][this.language]; + + this.form.goPrevMonthButton.onclick = function () {calendar.goPrevMonth(this);} + this.form.goNextMonthButton.onclick = function () {calendar.goNextMonth(this);} + this.form.yearSelect.onchange = function () {calendar.update(this);} + this.form.monthSelect.onchange = function () {calendar.update(this);} + + this.form.clearButton.onclick = function () {calendar.dateControl.value = "";calendar.hide();} + this.form.closeButton.onclick = function () {calendar.hide();} + this.form.selectTodayButton.onclick = function () { + var today = new Date(); + calendar.date = today; + calendar.year = today.getFullYear(); + calendar.month = today.getMonth(); + calendar.dateControl.value = today.format(calendar.date2StringPattern); + calendar.hide(); + } +}; + +Calendar.prototype.bindYear = function() { + var ys = this.form.yearSelect; + ys.length = 0; + for (var i = this.beginYear; i <= this.endYear; i++){ + ys.options[ys.length] = new Option(i + Calendar.language["year"][this.language], i); + } +}; + +Calendar.prototype.bindMonth = function() { + var ms = this.form.monthSelect; + ms.length = 0; + for (var i = 0; i < 12; i++){ + ms.options[ms.length] = new Option(Calendar.language["months"][this.language][i], i); + } +}; + +Calendar.prototype.goPrevMonth = function(e){ + if (this.year == this.beginYear && this.month == 0){return;} + this.month--; + if (this.month == -1) { + this.year--; + this.month = 11; + } + this.date = new Date(this.year, this.month, 1); + this.changeSelect(); + this.bindData(); +}; + +Calendar.prototype.goNextMonth = function(e){ + if (this.year == this.endYear && this.month == 11){return;} + this.month++; + if (this.month == 12) { + this.year++; + this.month = 0; + } + this.date = new Date(this.year, this.month, 1); + this.changeSelect(); + this.bindData(); +}; + +Calendar.prototype.changeSelect = function() { + var ys = this.form.yearSelect; + var ms = this.form.monthSelect; + for (var i= 0; i < ys.length; i++){ + if (ys.options[i].value == this.date.getFullYear()){ + ys[i].selected = true; + break; + } + } + for (var i= 0; i < ms.length; i++){ + if (ms.options[i].value == this.date.getMonth()){ + ms[i].selected = true; + break; + } + } +}; + +Calendar.prototype.update = function (e){ + this.year = e.form.yearSelect.options[e.form.yearSelect.selectedIndex].value; + this.month = e.form.monthSelect.options[e.form.monthSelect.selectedIndex].value; + this.date = new Date(this.year, this.month, 1); + this.changeSelect(); + this.bindData(); +}; + +Calendar.prototype.bindData = function () { + var calendar = this; + var dateArray = this.getMonthViewDateArray(this.date.getFullYear(), this.date.getMonth()); + var tds = this.getElementsByTagName("td", this.getElementById("__calendarTable", this.iframe.document)); + for(var i = 0; i < tds.length; i++) { + tds[i].style.backgroundColor = calendar.colors["bg_over"]; + tds[i].onclick = null; + tds[i].onmouseover = null; + tds[i].onmouseout = null; + tds[i].innerHTML = dateArray[i] || " "; + if (i > dateArray.length - 1) continue; + if (dateArray[i]){ + tds[i].onclick = function () { + if (calendar.dateControl){ + calendar.dateControl.value = new Date(calendar.date.getFullYear(), + calendar.date.getMonth(), + this.innerHTML).format(calendar.date2StringPattern); + } + calendar.hide(); + } + tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];} + tds[i].onmouseout = function () {this.style.backgroundColor = calendar.colors["bg_over"];} + var today = new Date(); + if (today.getFullYear() == calendar.date.getFullYear()) { + if (today.getMonth() == calendar.date.getMonth()) { + if (today.getDate() == dateArray[i]) { + tds[i].style.backgroundColor = calendar.colors["bg_cur_day"]; + tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];} + tds[i].onmouseout = function () {this.style.backgroundColor = calendar.colors["bg_cur_day"];} + } + } + } + }//end if + }//end for +}; + +Calendar.prototype.getMonthViewDateArray = function (y, m) { + var dateArray = new Array(42); + var dayOfFirstDate = new Date(y, m, 1).getDay(); + var dateCountOfMonth = new Date(y, m + 1, 0).getDate(); + for (var i = 0; i < dateCountOfMonth; i++) { + dateArray[i + dayOfFirstDate] = i + 1; + } + return dateArray; +}; + +Calendar.prototype.show = function (dateControl, popuControl) { + if (this.panel.style.visibility == "visible") { + this.panel.style.visibility = "hidden"; + } + if (!dateControl){ + throw new Error("arguments[0] is necessary!") + } + this.dateControl = dateControl; + popuControl = popuControl || dateControl; + + this.draw(); + this.bindYear(); + this.bindMonth(); + if (dateControl.value.length > 0){ + this.date = new Date(dateControl.value.toDate(this.patternDelimiter, this.string2DatePattern)); + this.year = this.date.getFullYear(); + this.month = this.date.getMonth(); + } + this.changeSelect(); + this.bindData(); + + var xy = this.getAbsPoint(popuControl); + this.panel.style.left = xy.x + "px"; + this.panel.style.top = (xy.y + dateControl.offsetHeight) + "px"; + this.panel.style.visibility = "visible"; +}; + +Calendar.prototype.hide = function() { + this.panel.style.visibility = "hidden"; +}; + +Calendar.prototype.getElementById = function(id, object){ + object = object || document; + return document.getElementById ? object.getElementById(id) : document.all(id); +}; + +Calendar.prototype.getElementsByTagName = function(tagName, object){ + object = object || document; + return document.getElementsByTagName ? object.getElementsByTagName(tagName) : document.all.tags(tagName); +}; + +Calendar.prototype.getAbsPoint = function (e){ + var x = e.offsetLeft; + var y = e.offsetTop; + while(e = e.offsetParent){ + x += e.offsetLeft; + y += e.offsetTop; + } + return {"x": x, "y": y}; +}; + +/** + * @param d the delimiter + * @param p the pattern of your date + * @author meizz + * @author kimsoft add w+ pattern + */ +Date.prototype.format = function(style) { + var o = { + "M+" : this.getMonth() + 1, //month + "d+" : this.getDate(), //day + "h+" : this.getHours(), //hour + "m+" : this.getMinutes(), //minute + "s+" : this.getSeconds(), //second + "w+" : "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".charAt(this.getDay()), //week + "q+" : Math.floor((this.getMonth() + 3) / 3), //quarter + "S" : this.getMilliseconds() //millisecond + } + if (/(y+)/.test(style)) { + style = style.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + } + for(var k in o){ + if (new RegExp("("+ k +")").test(style)){ + style = style.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); + } + } + return style; +}; + +/** + * @param d the delimiter + * @param p the pattern of your date + * @rebuilder kimsoft + * @version build 2006.12.15 + */ +String.prototype.toDate = function(delimiter, pattern) { + delimiter = delimiter || "-"; + pattern = pattern || "ymd"; + var a = this.split(delimiter); + var y = parseInt(a[pattern.indexOf("y")], 10); + //remember to change this next century ;) + if(y.toString().length <= 2) y += 2000; + if(isNaN(y)) y = new Date().getFullYear(); + var m = parseInt(a[pattern.indexOf("m")], 10) - 1; + var d = parseInt(a[pattern.indexOf("d")], 10); + if(isNaN(d)) d = 1; + return new Date(y, m, d); +}; + +document.writeln(' +
+ +
+ + + + + \ No newline at end of file diff --git a/HRMS/src/action/ContractAction.java b/HRMS/src/action/ContractAction.java new file mode 100644 index 0000000..d1ccb2c --- /dev/null +++ b/HRMS/src/action/ContractAction.java @@ -0,0 +1,64 @@ +package action; + +import java.util.List; + +import service.ContractDao; +import service.impl.ContractDaoImpl; +import entity.Contract; + +public class ContractAction extends SuperAction { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public String query() { + ContractDao ContractDao = new ContractDaoImpl(); + List list = ContractDao.queryAllContract(); + if (list != null && list.size() > 0) { + session.setAttribute("Contract_list", list); + } + return "Contract_query_success"; + } + + public String delete() { + ContractDao ContractDao = new ContractDaoImpl(); + String eid = request.getParameter("cid"); + ContractDao.deleteContract(eid); + return "Contract_delete_success"; + } + + public String add() throws Exception { + ContractDao ContractDao = new ContractDaoImpl(); + Contract c = new Contract(); + c.setSalary(Float.parseFloat(request.getParameter("salary"))); + c.setSid(request.getParameter("sid")); + c.setType(request.getParameter("type")); + c.setYear(Integer.parseInt(request.getParameter("year"))); + ContractDao.addContract(c); + return "Contract_add_success"; + } + + public String modify() { + String cid = request.getParameter("cid"); + ContractDao ContractDao = new ContractDaoImpl(); + Contract s = ContractDao.queryContractByCid(cid); + // ڻỰ + session.setAttribute("modify_Contract", s); + return "Contract_modify_success"; + } + + public String save() throws Exception { + ContractDao ContractDao = new ContractDaoImpl(); + Contract c = new Contract(); + c.setCid(request.getParameter("cid")); + c.setSalary(Float.parseFloat(request.getParameter("salary"))); + c.setSid(request.getParameter("sid")); + c.setType(request.getParameter("type")); + c.setYear(Integer.parseInt(request.getParameter("year"))); + ContractDao.updateContract(c); + return "Contract_save_success"; + } + +} diff --git a/HRMS/src/action/EmployAction.java b/HRMS/src/action/EmployAction.java new file mode 100644 index 0000000..dfa38ba --- /dev/null +++ b/HRMS/src/action/EmployAction.java @@ -0,0 +1,69 @@ +package action; + +import java.text.SimpleDateFormat; +import java.util.List; + +import service.EmployDao; +import service.impl.EmployDaoImpl; +import entity.Employ; + +public class EmployAction extends SuperAction { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public String query() { + EmployDao EmployDao = new EmployDaoImpl(); + List list = EmployDao.queryAllEmploy(); + if (list != null && list.size() > 0) { + session.setAttribute("Employ_list", list); + } + return "Employ_query_success"; + } + + public String delete() { + EmployDao EmployDao = new EmployDaoImpl(); + String eid = request.getParameter("eid"); + EmployDao.deleteEmploy(eid); + return "Employ_delete_success"; + } + + public String add() throws Exception { + EmployDao EmployDao = new EmployDaoImpl(); + Employ e = new Employ(); + e.setCount(Integer.parseInt(request.getParameter("count"))); + e.setIllustration(request.getParameter("illustration")); + e.setJob(request.getParameter("job")); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + e.setEndTime(sdf.parse(request.getParameter("endTime"))); + e.setStartTime(sdf.parse(request.getParameter("startTime"))); + EmployDao.addEmploy(e); + return "Employ_add_success"; + } + + public String modify() { + String eid = request.getParameter("eid"); + EmployDao EmployDao = new EmployDaoImpl(); + Employ s = EmployDao.queryEmployByEid(eid); + // ڻỰ + session.setAttribute("modify_Employ", s); + return "Employ_modify_success"; + } + + public String save() throws Exception { + EmployDao EmployDao = new EmployDaoImpl(); + Employ e = new Employ(); + e.setEid(request.getParameter("eid")); + e.setCount(Integer.parseInt(request.getParameter("count"))); + e.setIllustration(request.getParameter("illustration")); + e.setJob(request.getParameter("job")); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + e.setEndTime(sdf.parse(request.getParameter("endTime"))); + e.setStartTime(sdf.parse(request.getParameter("startTime"))); + EmployDao.updateEmploy(e); + return "Employ_save_success"; + } + +} diff --git a/HRMS/src/action/SuperAction.java b/HRMS/src/action/SuperAction.java new file mode 100644 index 0000000..5d1b4e0 --- /dev/null +++ b/HRMS/src/action/SuperAction.java @@ -0,0 +1,40 @@ +package action; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.interceptor.ServletRequestAware; +import org.apache.struts2.interceptor.ServletResponseAware; +import org.apache.struts2.util.ServletContextAware; + +import com.opensymphony.xwork2.ActionSupport; + +//Actionĸ +public class SuperAction extends ActionSupport implements ServletRequestAware, ServletResponseAware, ServletContextAware{ + /** + * + */ + private static final long serialVersionUID = 1L; + protected HttpServletRequest request; + protected HttpServletResponse response; + protected HttpSession session; + protected ServletContext application; + @Override + public void setServletContext(ServletContext application) { + this.application = application; + } + + @Override + public void setServletResponse(HttpServletResponse response) { + this.response = response; + } + + @Override + public void setServletRequest(HttpServletRequest request) { + this.request = request; + this.session = this.request.getSession(); + } + +} diff --git a/HRMS/src/action/TrainAction.java b/HRMS/src/action/TrainAction.java new file mode 100644 index 0000000..61ac7ad --- /dev/null +++ b/HRMS/src/action/TrainAction.java @@ -0,0 +1,65 @@ +package action; + +import java.text.SimpleDateFormat; +import java.util.List; + +import service.TrainDao; +import service.impl.TrainDaoImpl; +import entity.Train; + +public class TrainAction extends SuperAction { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public String query() { + TrainDao TrainDao = new TrainDaoImpl(); + List list = TrainDao.queryAllTrain(); + if (list != null && list.size() > 0) { + session.setAttribute("Train_list", list); + } + return "Train_query_success"; + } + + public String delete() { + TrainDao TrainDao = new TrainDaoImpl(); + String tid = request.getParameter("tid"); + TrainDao.deleteTrain(tid); + return "Train_delete_success"; + } + + public String add() throws Exception { + TrainDao TrainDao = new TrainDaoImpl(); + Train t = new Train(); + t.setCount(Integer.parseInt(request.getParameter("count"))); + t.setName(request.getParameter("name")); + t.setTutor(request.getParameter("tutor")); + t.setType(request.getParameter("type")); + TrainDao.addTrain(t); + return "Train_add_success"; + } + + public String modify() { + String tid = request.getParameter("tid"); + TrainDao TrainDao = new TrainDaoImpl(); + Train s = TrainDao.queryTrainByTid(tid); + // ڻỰ + session.setAttribute("modify_Train", s); + return "Train_modify_success"; + } + + public String save() throws Exception { + TrainDao TrainDao = new TrainDaoImpl(); + Train t = new Train(); + t.setTid(request.getParameter("tid")); + t.setCount(Integer.parseInt(request.getParameter("count"))); + t.setName(request.getParameter("name")); + t.setTutor(request.getParameter("tutor")); + t.setType(request.getParameter("type")); + TrainDao.updateTrain(t); + return "Train_save_success"; + } + +} diff --git a/HRMS/src/action/UserAction.java b/HRMS/src/action/UserAction.java new file mode 100644 index 0000000..ec71dc0 --- /dev/null +++ b/HRMS/src/action/UserAction.java @@ -0,0 +1,59 @@ +package action; + +import org.apache.struts2.interceptor.validation.SkipValidation; + +import service.UserDao; +import service.impl.UserDaoImpl; + +import com.opensymphony.xwork2.ModelDriven; + +import entity.User; + +public class UserAction extends SuperAction implements ModelDriven { + + /** + * + */ + private static final long serialVersionUID = 1L; + private User user = new User(); + + // û¼ + public String login() { + UserDao userdao = new UserDaoImpl(); + if (userdao.userLogin(user)) { + //¼ɹû + session.setAttribute("loginUserName", user.getUsername()); + return "login_success"; + } else { + return "login_failure"; + } + } + + @SkipValidation + //ûע + public String logout() { + if(session.getAttribute("loginUserName") != null) { + session.removeAttribute("loginUserName"); + } + return "logout_success"; + } + + + + @Override + public void validate() { + super.validate(); + if("".equals(user.getUsername().trim())) { + this.addFieldError("usernameError", "ûΪգ"); + } + if(user.getPassword().length() < 6) { + this.addFieldError("passwordError", "볤Ȳ6λ"); + } + } + + @Override + public User getModel() { + return this.user; + } + +} diff --git a/HRMS/src/db/MyHibernateSessionFactory.java b/HRMS/src/db/MyHibernateSessionFactory.java new file mode 100644 index 0000000..6e3f0ed --- /dev/null +++ b/HRMS/src/db/MyHibernateSessionFactory.java @@ -0,0 +1,25 @@ +package db; + +import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; + +public class MyHibernateSessionFactory { + // Ự + private static SessionFactory sessionFactory; + + private MyHibernateSessionFactory() { + + } + + public static SessionFactory getSessionFactory() { + if (sessionFactory == null) { + Configuration configuration = new Configuration().configure(); + StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() + .configure().build(); + sessionFactory = configuration.buildSessionFactory(serviceRegistry); + } + return sessionFactory; + } +} diff --git a/HRMS/src/entity/Contract.hbm.xml b/HRMS/src/entity/Contract.hbm.xml new file mode 100644 index 0000000..ae34e1a --- /dev/null +++ b/HRMS/src/entity/Contract.hbm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/src/entity/Contract.java b/HRMS/src/entity/Contract.java new file mode 100644 index 0000000..4f8cf37 --- /dev/null +++ b/HRMS/src/entity/Contract.java @@ -0,0 +1,73 @@ +package entity; + +//ͬϢ +public class Contract { + // ͬ + private String cid; + // ͬ + private String type; + // ͬ + private int year; + // н + private float salary; + // Ա + private String sid; + + public String getCid() { + return cid; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public float getSalary() { + return salary; + } + + public void setSalary(float salary) { + this.salary = salary; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + @Override + public String toString() { + return "Contract [cid=" + cid + ", type=" + type + ", year=" + year + + ", salary=" + salary + ", sid=" + sid + "]"; + } + + public Contract() { + } + + public Contract(String cid, String type, int year, float salary, String sid) { + this.cid = cid; + this.type = type; + this.year = year; + this.salary = salary; + this.sid = sid; + } + +} diff --git a/HRMS/src/entity/Employ.hbm.xml b/HRMS/src/entity/Employ.hbm.xml new file mode 100644 index 0000000..f6031e9 --- /dev/null +++ b/HRMS/src/entity/Employ.hbm.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/src/entity/Employ.java b/HRMS/src/entity/Employ.java new file mode 100644 index 0000000..9b34582 --- /dev/null +++ b/HRMS/src/entity/Employ.java @@ -0,0 +1,87 @@ +package entity; + +import java.util.Date; + +//ƸϢ +public class Employ { + // Ƹ + private String eid; + // Ƹλ + private String job; + // Ƹ + private int count; + // λ˵ + private String illustration; + // Ƹʼʱ + private Date startTime; + // Ƹֹʱ + private Date endTime; + + public String getEid() { + return eid; + } + + public void setEid(String eid) { + this.eid = eid; + } + + public String getJob() { + return job; + } + + public void setJob(String job) { + this.job = job; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public String getIllustration() { + return illustration; + } + + public void setIllustration(String illustration) { + this.illustration = illustration; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + @Override + public String toString() { + return "Employ [eid=" + eid + ", job=" + job + ", count=" + count + + ", illustration=" + illustration + ", startTime=" + startTime + + ", endTime=" + endTime + "]"; + } + + public Employ(String eid, String job, int count, String illustration, + Date startTime, Date endTime) { + this.eid = eid; + this.job = job; + this.count = count; + this.illustration = illustration; + this.startTime = startTime; + this.endTime = endTime; + } + + public Employ() { + } +} diff --git a/HRMS/src/entity/Staff.hbm.xml b/HRMS/src/entity/Staff.hbm.xml new file mode 100644 index 0000000..1f1a6ff --- /dev/null +++ b/HRMS/src/entity/Staff.hbm.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/src/entity/Staff.java b/HRMS/src/entity/Staff.java new file mode 100644 index 0000000..4dccbf0 --- /dev/null +++ b/HRMS/src/entity/Staff.java @@ -0,0 +1,146 @@ +package entity; + +import java.util.Date; + +//ԱϢ +public class Staff { + // Ա + private String sid; + // + private String name; + // Ա + private String sex; + // + private String nation; + // + private Date birthday; + // μӹʱ + private Date worktime; + // ְ + private String job; + // ְ + private String level; + // ֤ + private String idCard; + // ַ + private String address; + // ֻ + private String phone; + + @Override + public String toString() { + return "Staff [sid=" + sid + ", name=" + name + ", sex=" + sex + + ", nation=" + nation + ", birthday=" + birthday + + ", worktime=" + worktime + ", job=" + job + ", level=" + + level + ", idCard=" + idCard + ", address=" + address + + ", phone=" + phone + "]"; + } + + public Staff() { + } + + public Staff(String sid, String name, String sex, String nation, + Date birthday, Date worktime, String job, String level, + String idCard, String address, String phone) { + this.sid = sid; + this.name = name; + this.sex = sex; + this.nation = nation; + this.birthday = birthday; + this.worktime = worktime; + this.job = job; + this.level = level; + this.idCard = idCard; + this.address = address; + this.phone = phone; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSex() { + return sex; + } + + public void setSex(String sex) { + this.sex = sex; + } + + public String getNation() { + return nation; + } + + public void setNation(String nation) { + this.nation = nation; + } + + public Date getBirthday() { + return birthday; + } + + public void setBirthday(Date birthday) { + this.birthday = birthday; + } + + public Date getWorktime() { + return worktime; + } + + public void setWorktime(Date worktime) { + this.worktime = worktime; + } + + public String getJob() { + return job; + } + + public void setJob(String job) { + this.job = job; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + +} diff --git a/HRMS/src/entity/Train.hbm.xml b/HRMS/src/entity/Train.hbm.xml new file mode 100644 index 0000000..aa09043 --- /dev/null +++ b/HRMS/src/entity/Train.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/src/entity/Train.java b/HRMS/src/entity/Train.java new file mode 100644 index 0000000..f8d5cf0 --- /dev/null +++ b/HRMS/src/entity/Train.java @@ -0,0 +1,74 @@ +package entity; + +//ѵϢ +public class Train { + // ѵ + private String tid; + // ѵĿ + private String name; + // ѵʦ + private String tutor; + // + private int count; + // ѵ + private String type; + + public Train() { + } + + public Train(String tid, String name, String tutor, int count, String type) { + super(); + this.tid = tid; + this.name = name; + this.tutor = tutor; + this.count = count; + this.type = type; + } + + @Override + public String toString() { + return "Train [tid=" + tid + ", name=" + name + ", tutor=" + tutor + + ", count=" + count + ", type=" + type + "]"; + } + + public String getTid() { + return tid; + } + + public void setTid(String tid) { + this.tid = tid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTutor() { + return tutor; + } + + public void setTutor(String tutor) { + this.tutor = tutor; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/HRMS/src/entity/User.hbm.xml b/HRMS/src/entity/User.hbm.xml new file mode 100644 index 0000000..77df7e9 --- /dev/null +++ b/HRMS/src/entity/User.hbm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HRMS/src/entity/User.java b/HRMS/src/entity/User.java new file mode 100644 index 0000000..cb96ee7 --- /dev/null +++ b/HRMS/src/entity/User.java @@ -0,0 +1,74 @@ +package entity; + +//ûϢ +public class User { + //û + private String uid; + //û + private String username; + // + private String password; + //Ȩ 0ʾͨû1ʾԱ + private int authority; + //Ա + private String sid; + + @Override + public String toString() { + return "User [uid=" + uid + ", username=" + username + ", password=" + + password + ", authority=" + authority + ", sid=" + sid + "]"; + } + + public User() { + } + + public User(String uid, String username, String password, int authority, + String sid) { + this.uid = uid; + this.username = username; + this.password = password; + this.authority = authority; + this.sid = sid; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getAuthority() { + return authority; + } + + public void setAuthority(int authority) { + this.authority = authority; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + +} diff --git a/HRMS/src/hibernate.cfg.xml b/HRMS/src/hibernate.cfg.xml new file mode 100644 index 0000000..5c3f786 --- /dev/null +++ b/HRMS/src/hibernate.cfg.xml @@ -0,0 +1,26 @@ + + + + + + root + root + com.mysql.jdbc.Driver + jdbc:mysql:///hrms?useUnicode=true&characterEncoding=UTF-8 + org.hibernate.dialect.MySQLDialect + true + true + update + thread + + + + + + + + \ No newline at end of file diff --git a/HRMS/src/service/ContractDao.java b/HRMS/src/service/ContractDao.java new file mode 100644 index 0000000..2e12e0e --- /dev/null +++ b/HRMS/src/service/ContractDao.java @@ -0,0 +1,22 @@ +package service; + +import java.util.List; + +import entity.Contract; + +public interface ContractDao { + // ƸϢ + public boolean addContract(Contract c); + + // ɾƸϢ + public boolean deleteContract(String cid); + + // ޸ƸϢ + public boolean updateContract(Contract c); + + // ѯƸϢ + public Contract queryContractByCid(String cid); + + // ѯƸϢ + public List queryAllContract(); +} diff --git a/HRMS/src/service/EmployDao.java b/HRMS/src/service/EmployDao.java new file mode 100644 index 0000000..db28549 --- /dev/null +++ b/HRMS/src/service/EmployDao.java @@ -0,0 +1,22 @@ +package service; + +import java.util.List; + +import entity.Employ; + +public interface EmployDao { + // ƸϢ + public boolean addEmploy(Employ e); + + // ɾƸϢ + public boolean deleteEmploy(String eid); + + // ޸ƸϢ + public boolean updateEmploy(Employ e); + + // ѯƸϢ + public Employ queryEmployByEid(String eid); + + // ѯƸϢ + public List queryAllEmploy(); +} diff --git a/HRMS/src/service/TrainDao.java b/HRMS/src/service/TrainDao.java new file mode 100644 index 0000000..6221062 --- /dev/null +++ b/HRMS/src/service/TrainDao.java @@ -0,0 +1,22 @@ +package service; + +import java.util.List; + +import entity.Train; + +public interface TrainDao { + // ƸϢ + public boolean addTrain(Train t); + + // ɾƸϢ + public boolean deleteTrain(String tid); + + // ޸ƸϢ + public boolean updateTrain(Train t); + + // ѯƸϢ + public Train queryTrainByTid(String tid); + + // ѯƸϢ + public List queryAllTrain(); +} diff --git a/HRMS/src/service/UserDao.java b/HRMS/src/service/UserDao.java new file mode 100644 index 0000000..1dde5e5 --- /dev/null +++ b/HRMS/src/service/UserDao.java @@ -0,0 +1,9 @@ +package service; + +import entity.User; + +public interface UserDao { + + //û¼ + boolean userLogin(User u); +} diff --git a/HRMS/src/service/impl/ContractDaoImpl.java b/HRMS/src/service/impl/ContractDaoImpl.java new file mode 100644 index 0000000..542333f --- /dev/null +++ b/HRMS/src/service/impl/ContractDaoImpl.java @@ -0,0 +1,130 @@ +package service.impl; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import db.MyHibernateSessionFactory; +import entity.Contract; +import entity.Train; +import service.ContractDao; +import util.Util; + +public class ContractDaoImpl implements ContractDao{ + + @Override + public boolean addContract(Contract c) { + c.setCid(Util.getNewId("cid", "Contract")); + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.save(c); + ts.commit(); + return true; + } catch (Exception ep) { + ep.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public boolean deleteContract(String cid) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Contract s = session.get(Contract.class, cid); + session.delete(s); + ts.commit(); + return true; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public boolean updateContract(Contract c) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.update(c); + ts.commit(); + return true; + } catch (Exception ep) { + ep.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public Contract queryContractByCid(String cid) { + Transaction ts = null; + Contract s = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + s = session.get(Contract.class, cid); + ts.commit(); + return s; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return s; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public List queryAllContract() { + Transaction ts = null; + List list = null; + String hql = ""; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + hql = "from Contract"; + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + + list = query.list(); + ts.commit(); + return list; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return list; + } finally { + if (ts != null) { + ts = null; + } + } + } + +} diff --git a/HRMS/src/service/impl/EmployDaoImpl.java b/HRMS/src/service/impl/EmployDaoImpl.java new file mode 100644 index 0000000..e7fa0ec --- /dev/null +++ b/HRMS/src/service/impl/EmployDaoImpl.java @@ -0,0 +1,129 @@ +package service.impl; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import db.MyHibernateSessionFactory; +import entity.Employ; +import service.EmployDao; +import util.Util; + +public class EmployDaoImpl implements EmployDao { + + @Override + public boolean addEmploy(Employ e) { + e.setEid(Util.getNewId("eid", "Employ")); + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.save(e); + ts.commit(); + return true; + } catch (Exception ep) { + ep.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public boolean deleteEmploy(String eid) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Employ s = session.get(Employ.class, eid); + session.delete(s); + ts.commit(); + return true; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public boolean updateEmploy(Employ e) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.update(e); + ts.commit(); + return true; + } catch (Exception ep) { + ep.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public Employ queryEmployByEid(String eid) { + Transaction ts = null; + Employ s = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + s = session.get(Employ.class, eid); + ts.commit(); + return s; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return s; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public List queryAllEmploy() { + Transaction ts = null; + List list = null; + String hql = ""; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + hql = "from Employ"; + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + + list = query.list(); + ts.commit(); + return list; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return list; + } finally { + if (ts != null) { + ts = null; + } + } + } + +} diff --git a/HRMS/src/service/impl/TrainDaoImpl.java b/HRMS/src/service/impl/TrainDaoImpl.java new file mode 100644 index 0000000..8a0cab1 --- /dev/null +++ b/HRMS/src/service/impl/TrainDaoImpl.java @@ -0,0 +1,129 @@ +package service.impl; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import db.MyHibernateSessionFactory; +import entity.Train; +import service.TrainDao; +import util.Util; + +public class TrainDaoImpl implements TrainDao{ + + @Override + public boolean addTrain(Train t) { + t.setTid(Util.getNewId("tid", "Train")); + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.save(t); + ts.commit(); + return true; + } catch (Exception ep) { + ep.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public boolean deleteTrain(String tid) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Train s = session.get(Train.class, tid); + session.delete(s); + ts.commit(); + return true; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public boolean updateTrain(Train t) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.update(t); + ts.commit(); + return true; + } catch (Exception ep) { + ep.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public Train queryTrainByTid(String tid) { + Transaction ts = null; + Train s = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + s = session.get(Train.class, tid); + ts.commit(); + return s; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return s; + } finally { + if (ts != null) { + ts = null; + } + } + } + + @Override + public List queryAllTrain() { + Transaction ts = null; + List list = null; + String hql = ""; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + hql = "from Train"; + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + + list = query.list(); + ts.commit(); + return list; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return list; + } finally { + if (ts != null) { + ts = null; + } + } + } + +} diff --git a/HRMS/src/service/impl/UserDaoImpl.java b/HRMS/src/service/impl/UserDaoImpl.java new file mode 100644 index 0000000..50b64c8 --- /dev/null +++ b/HRMS/src/service/impl/UserDaoImpl.java @@ -0,0 +1,44 @@ +package service.impl; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import service.UserDao; +import db.MyHibernateSessionFactory; +import entity.User; + +public class UserDaoImpl implements UserDao { + + @Override + public boolean userLogin(User u) { + Transaction ts = null; + String hql = ""; + try { + hql = "from User where username=? and password=?"; + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + query.setParameter(0, u.getUsername()); + query.setParameter(1, u.getPassword()); + List list = query.list(); + ts.commit(); + if (list.size() > 0) { + return true; + } else { + return false; + } + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + +} diff --git a/HRMS/src/struts.xml b/HRMS/src/struts.xml new file mode 100644 index 0000000..5478756 --- /dev/null +++ b/HRMS/src/struts.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + /user/User_login_success.jsp + /user/User_login.jsp + /user/User_login.jsp + /user/User_login.jsp + + + + + /employ/Employ_query_success.jsp + Employ_query + /employ/Employ_add_success.jsp + /employ/Employ_modify.jsp + /employ/Employ_modify_success.jsp + + + + + /train/Train_query_success.jsp + Train_query + /train/Train_add_success.jsp + /train/Train_modify.jsp + /train/Train_modify_success.jsp + + + + + /contract/Contract_query_success.jsp + Contract_query + /contract/Contract_add_success.jsp + /contract/Contract_modify.jsp + /contract/Contract_modify_success.jsp + + + diff --git a/HRMS/src/util/Util.java b/HRMS/src/util/Util.java new file mode 100644 index 0000000..e10886c --- /dev/null +++ b/HRMS/src/util/Util.java @@ -0,0 +1,51 @@ +package util; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import db.MyHibernateSessionFactory; + +public class Util { + // ѧѧ + public static String getNewId(String primaryName, String tableName) { + Transaction ts = null; + String hql = ""; + String id = null; + String prefix = primaryName.substring(0, 1); + prefix = prefix.toUpperCase(); + System.out.println(prefix); + try { + hql = "select max(" + primaryName + ") from " + tableName; + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + id = (String) query.uniqueResult(); + if (id == null || id.equals("")) { + // Ĭϵ + id = prefix + "0000001"; + } else { + String temp = id.substring(1); // ȥλ + int i = Integer.parseInt(temp); // ת + i++; + temp = String.valueOf(i); + int len = temp.length(); + for (int k = 0; k < 7 - len; k++) { + temp = "0" + temp; + } + id = prefix + temp; + } + ts.commit(); + return id; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return id; + } finally { + if (ts != null) { + ts = null; + } + } + } +} diff --git a/HRMS/test/entity/TestDatabase.java b/HRMS/test/entity/TestDatabase.java new file mode 100644 index 0000000..b067a82 --- /dev/null +++ b/HRMS/test/entity/TestDatabase.java @@ -0,0 +1,62 @@ +package entity; + +import java.util.EnumSet; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.hibernate.tool.schema.TargetType; +import org.junit.Test; + +public class TestDatabase { +// +// // Ӳ +// @Test +// public void testAddStudent() { +// // ö +// Configuration configuration = new Configuration().configure(); +// // SessionFactory +// SessionFactory sessionFactory = configuration.buildSessionFactory(); +// // session +// Session session = sessionFactory.getCurrentSession(); +// // +// Transaction ts = session.beginTransaction(); +// +// Student s1 = new Student("S0000001", "skyward", "", new Date(), "δ֪"); +// Student s2 = new Student("S0000002", "geek", "", new Date(), "δ֪"); +// Student s3 = new Student("S0000004", "hacker", "", new Date(), "δ֪"); +// +// session.save(s1); +// session.save(s2); +// session.save(s3); +// +// ts.commit(); +// sessionFactory.close(); +// } + + @Test + public void testSchemaExport() { + // ö + Configuration configuration = new Configuration().configure(); + // ע + StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() + .configure().build(); + // SessionFactory + SessionFactory sessionFactory = configuration.buildSessionFactory(); + // session + Session session = sessionFactory.getCurrentSession(); + // SchemaExport + SchemaExport schemaExport = new SchemaExport(); + + Metadata metadata = new MetadataSources(serviceRegistry) + .buildMetadata(); + + schemaExport.create(EnumSet.of(TargetType.DATABASE), metadata); + } + +} diff --git a/HRMS/test/service/impl/TestContractDaoImpl.java b/HRMS/test/service/impl/TestContractDaoImpl.java new file mode 100644 index 0000000..8ad1666 --- /dev/null +++ b/HRMS/test/service/impl/TestContractDaoImpl.java @@ -0,0 +1,55 @@ +package service.impl; + +import java.util.List; + +import junit.framework.Assert; + +import org.junit.Test; + +import service.ContractDao; +import util.Util; +import entity.Contract; + +public class TestContractDaoImpl { + + //ԺͬѯԪ + @Test + public void TestQueryAllContract() { + List list = new ContractDaoImpl().queryAllContract(); + for (Contract c : list) { + System.out.println(c.toString()); + } + } + + //ӺͬԪ + @Test + public void TestAddContract() { + Contract c = new Contract(); + c.setSalary(1000000); + c.setSid("1"); + c.setType("δ֪"); + c.setYear(10000); + ContractDao ContractDao = new ContractDaoImpl(); + Assert.assertEquals(true, ContractDao.addContract(c)); + } + + //޸ĺͬԪ + @Test + public void TestUpdateContract() { + Contract c = new Contract(); + c.setCid("C0000004"); + c.setSalary(1000000); + c.setSid("1"); + c.setType("kk"); + c.setYear(10000); + ContractDao ContractDao = new ContractDaoImpl(); + Assert.assertEquals(true, ContractDao.updateContract(c)); + } + + //ɾͬԪ + @Test + public void TestDeleteContract() { + ContractDao ContractDao = new ContractDaoImpl(); + Assert.assertEquals(true, ContractDao.deleteContract("C0000002")); + } +} diff --git a/HRMS/test/service/impl/TestEmployDaoImpl.java b/HRMS/test/service/impl/TestEmployDaoImpl.java new file mode 100644 index 0000000..ee1468c --- /dev/null +++ b/HRMS/test/service/impl/TestEmployDaoImpl.java @@ -0,0 +1,39 @@ +package service.impl; + +import java.util.Date; +import java.util.List; + +import junit.framework.Assert; + +import org.junit.Test; + +import service.EmployDao; +import util.Util; +import entity.Employ; + +public class TestEmployDaoImpl { + @Test + public void TestQueryAllEmploy() { + List list = new EmployDaoImpl().queryAllEmploy(); + for(Employ s : list) { + System.out.println(s.toString()); + } + } + + @Test + public void TestGetNewSid() { + System.out.println(Util.getNewId("eid", "Employ")); + } + + @Test + public void TestAddEmploy() { + Employ e = new Employ(); + e.setCount(100); + e.setEndTime(new Date()); + e.setIllustration("Ƹ"); + e.setJob(""); + e.setStartTime(new Date()); + EmployDao employDao = new EmployDaoImpl(); + Assert.assertEquals(true, employDao.addEmploy(e)); + } +} diff --git a/HRMS/test/service/impl/TestTrainDaoImpl.java b/HRMS/test/service/impl/TestTrainDaoImpl.java new file mode 100644 index 0000000..32182e4 --- /dev/null +++ b/HRMS/test/service/impl/TestTrainDaoImpl.java @@ -0,0 +1,38 @@ +package service.impl; + +import java.util.Date; +import java.util.List; + +import junit.framework.Assert; + +import org.junit.Test; + +import service.TrainDao; +import util.Util; +import entity.Train; + +public class TestTrainDaoImpl { + @Test + public void TestQueryAllTrain() { + List list = new TrainDaoImpl().queryAllTrain(); + for(Train s : list) { + System.out.println(s.toString()); + } + } + + @Test + public void TestGetNewId() { + System.out.println(Util.getNewId("tid", "Train")); + } + + @Test + public void TestAddTrain() { + Train e = new Train(); + e.setCount(1000); + e.setName("ѵĿ"); + e.setTutor(""); + e.setType("Ȼ"); + TrainDao TrainDao = new TrainDaoImpl(); + Assert.assertEquals(true, TrainDao.addTrain(e)); + } +} diff --git a/HRMS/test/service/impl/TestUserDaoImpl.java b/HRMS/test/service/impl/TestUserDaoImpl.java new file mode 100644 index 0000000..914e7bb --- /dev/null +++ b/HRMS/test/service/impl/TestUserDaoImpl.java @@ -0,0 +1,17 @@ +package service.impl; + +import junit.framework.Assert; + +import org.junit.Test; + +import service.UserDao; +import entity.User; + +public class TestUserDaoImpl { + @Test + public void testUserLogin() { + User user = new User("2", "skyward", "123456", 1, "1"); + UserDao userDao = new UserDaoImpl(); + Assert.assertEquals(false, userDao.userLogin(user)); + } +} diff --git a/readme.md b/readme.md index 8ab2866..d163e5a 100644 --- a/readme.md +++ b/readme.md @@ -1,113 +1,113 @@ -#Java Web应用开发技术与案例教程例题与习题代码 -##第2章静态网页开发技术 -###1、例2-2 文本和段落标签示例——唐诗欣赏 -###2、例2-3 有序列表与无序列表标签示例——新闻通知 -###3、例2-4 超链接和图片链接标签示例——泰山风景介绍 -###4、例2-5 表格标签——期末成绩表 -###5、例2-6 表单设计案例——学校入校注册页面设计 -###6、例2-7 框架设计案例——多媒体播放系统设计 -###7、例2-8 CSS——利用CSS对注册页面实现修饰 -###8、例2-9 JavaScript——单击按钮事件示例 -###9、例2-10 JavaScript——JavaScript实现输入验证 -###10、例2-11 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现下拉菜单 -###11、例2-12 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现表格变色 +# Java Web应用开发技术与案例教程例题与习题代码 +## 第2章静态网页开发技术 +### 1、例2-2 文本和段落标签示例——唐诗欣赏 +### 2、例2-3 有序列表与无序列表标签示例——新闻通知 +### 3、例2-4 超链接和图片链接标签示例——泰山风景介绍 +### 4、例2-5 表格标签——期末成绩表 +### 5、例2-6 表单设计案例——学校入校注册页面设计 +### 6、例2-7 框架设计案例——多媒体播放系统设计 +### 7、例2-8 CSS——利用CSS对注册页面实现修饰 +### 8、例2-9 JavaScript——单击按钮事件示例 +### 9、例2-10 JavaScript——JavaScript实现输入验证 +### 10、例2-11 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现下拉菜单 +### 11、例2-12 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现表格变色 -##第3章JSP技术 -###1、例3-1 简单的JSP程序 -###2、例3-2 以直角三角形的形式显示数字并根据随机产生的数据的不同,显示不同的问候 -###3、例3-3 page指令import属性示例 -###4、例3-4 include指令示例 -###5、例3-5 利用include动作实现参数传递 -###6、例3-6 利用表单传递参数 -###7、例3-7 追加在网址后实现参数传递 -###8、例3-8 采用getParameterNames()方法获得参数并显示参数值 -###9、例3-9 计算任意两个实数的和 -###10、例3-10 使用request对象获取客户端的有关信息 -###11、例3-11 用户登录验证 -###12、例3-12 页面自动刷新时间 -###13、例3-13 利用session对象获取会话信息并显示 -###14、例3-14 统计网站访问人数 -###15、例3-15 利用out对象输出页面信息 -###16、例3-16 网上答题及其自动评测系统 -###17、例3-17 简单的购物车应用案例 -##第4章JDBC数据库访问技术 -###1、学生身体体质信息管理系统(通过JDBC驱动程序直接连接数据库) -###2、学生身体体质信息管理系统(通过连接池技术连接数据库) -###3、使用说明 -##第5章JavaBean技术 -###3、例5-1 设计一个圆的JavaBean类 -###3、例5-2 基于JavaBean+JSP求任意两数代数和 -###3、例5-3 网页计数器JavaBean的设计与使用 -###4、例5-4 数据库访问JavaBean的设计 -##第6章Servlet技术 -###1、例6-1 基于JSP+Servlet的用户登录验证 -###2、例6-2 基于JSP+Servlet+JavaBean实现复数运算 -###3、例6-3 利用Cookie实现自动登录 -##第7章Java Web常用开发模式与案例 -###1、例7-1 JSP页面开发模式案例——求1+2+3+...+100的和值 -###2、例7-2 JSP页面开发模式案例——求任意两个整数之间的累加和值 -###3、例7-3 JSP+JDBC开发模式案例——实现基于数据库的登录验证 -###4、例7-4 JSP+JavaBean开发案例——求和运算 -###5、例7-5 JSP+JavaBean+JDBC案例——基于数据库的登录验证 -###6、例7-6 JSP+Servlet开发案例——求和运算 -###7、例7-7 JSP+Servlet+JDBC开发案例——基于数据库的登录验证 -###8、例7-8 JSP+Servlet+JavaBean开发案例——求和运算 -###9、例7-9 JSP+Servlet+JavaBean案例——基于数据库的登录验证 -###10、例7-10 JSP+Servlet+JavaBean案例——学生体质信息管理系统 -###11、例7-11 JSP+Servlet+JavaBean+DAO案例——学生体质信息管理系统 -##第8章EL、JSTL和Ajax技术 -###1、例8-1 EL表达式语言运算 -###2、例8-2 EL表达式访问集合中的元素 -###3、例8-3 EL对表单数据的访问 -###4、例8-4 EL对作用域属性的访问 -###5、例8-5 EL对Web工程初始参数的访问 -###6、例8-6 EL对JavaBean的访问 -###7、例8-7 JSTL中单分支标签和多分支标签的使用 -###8、例8-8 JSTL中循环标签的使用 -###9、例8-9 使用EL和JSTL显示查询结果 -###10、例8-10 Ajax应用案例——异步表单验证 -###11、例8-11 Ajax应用案例——实现级联列表 -###12、例8-12 Ajax应用案例——输入提示和自动完成 +## 第3章JSP技术 +### 1、例3-1 简单的JSP程序 +### 2、例3-2 以直角三角形的形式显示数字并根据随机产生的数据的不同,显示不同的问候 +### 3、例3-3 page指令import属性示例 +### 4、例3-4 include指令示例 +### 5、例3-5 利用include动作实现参数传递 +### 6、例3-6 利用表单传递参数 +### 7、例3-7 追加在网址后实现参数传递 +### 8、例3-8 采用getParameterNames()方法获得参数并显示参数值 +### 9、例3-9 计算任意两个实数的和 +### 10、例3-10 使用request对象获取客户端的有关信息 +### 11、例3-11 用户登录验证 +### 12、例3-12 页面自动刷新时间 +### 13、例3-13 利用session对象获取会话信息并显示 +### 14、例3-14 统计网站访问人数 +### 15、例3-15 利用out对象输出页面信息 +### 16、例3-16 网上答题及其自动评测系统 +### 17、例3-17 简单的购物车应用案例 +## 第4章JDBC数据库访问技术 +### 1、学生身体体质信息管理系统(通过JDBC驱动程序直接连接数据库) +### 2、学生身体体质信息管理系统(通过连接池技术连接数据库) +### 3、使用说明 +## 第5章JavaBean技术 +### 1、例5-1 设计一个圆的JavaBean类 +### 2、例5-2 基于JavaBean+JSP求任意两数代数和 +### 3、例5-3 网页计数器JavaBean的设计与使用 +### 4、例5-4 数据库访问JavaBean的设计 +## 第6章Servlet技术 +### 1、例6-1 基于JSP+Servlet的用户登录验证 +### 2、例6-2 基于JSP+Servlet+JavaBean实现复数运算 +### 3、例6-3 利用Cookie实现自动登录 +## 第7章Java Web常用开发模式与案例 +### 1、例7-1 JSP页面开发模式案例——求1+2+3+...+100的和值 +### 2、例7-2 JSP页面开发模式案例——求任意两个整数之间的累加和值 +### 3、例7-3 JSP+JDBC开发模式案例——实现基于数据库的登录验证 +### 4、例7-4 JSP+JavaBean开发案例——求和运算 +### 5、例7-5 JSP+JavaBean+JDBC案例——基于数据库的登录验证 +### 6、例7-6 JSP+Servlet开发案例——求和运算 +### 7、例7-7 JSP+Servlet+JDBC开发案例——基于数据库的登录验证 +### 8、例7-8 JSP+Servlet+JavaBean开发案例——求和运算 +### 9、例7-9 JSP+Servlet+JavaBean案例——基于数据库的登录验证 +### 10、例7-10 JSP+Servlet+JavaBean案例——学生体质信息管理系统 +### 11、例7-11 JSP+Servlet+JavaBean+DAO案例——学生体质信息管理系统 +## 第8章EL、JSTL和Ajax技术 +### 1、例8-1 EL表达式语言运算 +### 2、例8-2 EL表达式访问集合中的元素 +### 3、例8-3 EL对表单数据的访问 +### 4、例8-4 EL对作用域属性的访问 +### 5、例8-5 EL对Web工程初始参数的访问 +### 6、例8-6 EL对JavaBean的访问 +### 7、例8-7 JSTL中单分支标签和多分支标签的使用 +### 8、例8-8 JSTL中循环标签的使用 +### 9、例8-9 使用EL和JSTL显示查询结果 +### 10、例8-10 Ajax应用案例——异步表单验证 +### 11、例8-11 Ajax应用案例——实现级联列表 +### 12、例8-12 Ajax应用案例——输入提示和自动完成 -##第9章过滤器和监听器技术 -###1、例9-1 基于过滤器的用户权限控制 -###2、例9-2 基于过滤器的中文乱码解决 -###3、例9-3 禁止未授权的IP访问站点过滤器 -###4、例9-4 会话计数监听器的设计 -##第10章Java Web实用开发技术 -###1、例10-1 带图形验证码的登录模块 -###2、例10-2 使用CKEditor编辑公告内容 -###3、例10-3 使用Cos组件实现作业上传 -###4、例10-4 使用JavaMail实现邮件发送 -##第11章Struts2框架技术 -###1、例11-1 Struts2——任意两数据的代数和 -###2、例11-2 Struts2——Action访问Web对象 -###3、例11-3 Struts2——多方法的Action -###4、例11-4 Struts2——非表单标签 -###5、例11-5 Struts2——实现国际化 -###6、例11-6 Struts2的国际化应用案例——适应于中英文的登录系统 -###7、例11-7 Struts2——文字过滤器的设计与应用 -###8、例11-8 Struts2——实现客户注册输入验证 -###9、例11-9 Struts2——使用配置验证文件实现客户注册输入验证 -##第12章Hibernate持久化技术 -###1、例12-1 Hibernate——实现用户信息的注册 -###2、例12-2 基于Struts2+Hibernate的学生信息管理系统 +## 第9章过滤器和监听器技术 +### 1、例9-1 基于过滤器的用户权限控制 +### 2、例9-2 基于过滤器的中文乱码解决 +### 3、例9-3 禁止未授权的IP访问站点过滤器 +### 4、例9-4 会话计数监听器的设计 +## 第10章Java Web实用开发技术 +### 1、例10-1 带图形验证码的登录模块 +### 2、例10-2 使用CKEditor编辑公告内容 +### 3、例10-3 使用Cos组件实现作业上传 +### 4、例10-4 使用JavaMail实现邮件发送 +## 第11章Struts2框架技术 +### 1、例11-1 Struts2——任意两数据的代数和 +### 2、例11-2 Struts2——Action访问Web对象 +### 3、例11-3 Struts2——多方法的Action +### 4、例11-4 Struts2——非表单标签 +### 5、例11-5 Struts2——实现国际化 +### 6、例11-6 Struts2的国际化应用案例——适应于中英文的登录系统 +### 7、例11-7 Struts2——文字过滤器的设计与应用 +### 8、例11-8 Struts2——实现客户注册输入验证 +### 9、例11-9 Struts2——使用配置验证文件实现客户注册输入验证 +## 第12章Hibernate持久化技术 +### 1、例12-1 Hibernate——实现用户信息的注册 +### 2、例12-2 基于Struts2+Hibernate的学生信息管理系统 -##实验 -###1、 -###例2-7 框架设计案例——多媒体播放系统设计 -###2、 -###例2-11 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现下拉菜单 -###例2-12 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现表格变色 -###3、 -###学生身体体质信息管理系统(通过JDBC驱动程序直接连接数据库) -###学生身体体质信息管理系统(通过连接池技术连接数据库) -###4、JSP+Servlet+JavaBean+DAO案例——学生体质信息管理系统 -###5、 +## 实验 +### 1、 +### 例2-7 框架设计案例——多媒体播放系统设计 +### 2、 +### 例2-11 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现下拉菜单 +### 例2-12 基于HTML+JavaScript+CSS的开发案例——JavaScript+CSS+DIV实现表格变色 +### 3、 +### 学生身体体质信息管理系统(通过JDBC驱动程序直接连接数据库) +### 学生身体体质信息管理系统(通过连接池技术连接数据库) +### 4、 +### JSP+Servlet+JavaBean+DAO案例——学生体质信息管理系统 -##习题 +## 习题 ### -##附录 -###1、MySql的安装与配置 -###2、相关jar包——Struts2,Hibernate,junit4,Mysql -###3、connections.ncx——数据库文件 +## 附录 +### 1、MySql的安装与配置 +### 2、相关jar包——Struts2,Hibernate,junit4,Mysql +### 3、connections.ncx——数据库文件 diff --git a/student/.classpath b/student/.classpath new file mode 100644 index 0000000..16cb2ac --- /dev/null +++ b/student/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/student/.project b/student/.project new file mode 100644 index 0000000..d8c00b5 --- /dev/null +++ b/student/.project @@ -0,0 +1,46 @@ + + + student + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator + + + + + com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/student/.settings/.jsdtscope b/student/.settings/.jsdtscope new file mode 100644 index 0000000..2fc9dba --- /dev/null +++ b/student/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/student/.settings/org.eclipse.core.resources.prefs b/student/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..ac7bf4f --- /dev/null +++ b/student/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//WebRoot/css/default.css=UTF-8 diff --git a/student/.settings/org.eclipse.jdt.core.prefs b/student/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f42de36 --- /dev/null +++ b/student/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/student/.settings/org.eclipse.wst.common.component b/student/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..c658b67 --- /dev/null +++ b/student/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/student/.settings/org.eclipse.wst.common.project.facet.core.xml b/student/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..ae218fe --- /dev/null +++ b/student/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/student/.settings/org.eclipse.wst.jsdt.ui.superType.container b/student/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/student/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/student/.settings/org.eclipse.wst.jsdt.ui.superType.name b/student/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/student/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/student/WebRoot/META-INF/MANIFEST.MF b/student/WebRoot/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/student/WebRoot/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/student/WebRoot/WEB-INF/classes/action/StudentAction.class b/student/WebRoot/WEB-INF/classes/action/StudentAction.class new file mode 100644 index 0000000..ee021a1 Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/action/StudentAction.class differ diff --git a/student/WebRoot/WEB-INF/classes/action/SuperAction.class b/student/WebRoot/WEB-INF/classes/action/SuperAction.class new file mode 100644 index 0000000..a1825bb Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/action/SuperAction.class differ diff --git a/student/WebRoot/WEB-INF/classes/action/UserAction.class b/student/WebRoot/WEB-INF/classes/action/UserAction.class new file mode 100644 index 0000000..76e206d Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/action/UserAction.class differ diff --git a/student/WebRoot/WEB-INF/classes/db/MyHibernateSessionFactory.class b/student/WebRoot/WEB-INF/classes/db/MyHibernateSessionFactory.class new file mode 100644 index 0000000..8c712a7 Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/db/MyHibernateSessionFactory.class differ diff --git a/student/WebRoot/WEB-INF/classes/entity/Student.class b/student/WebRoot/WEB-INF/classes/entity/Student.class new file mode 100644 index 0000000..a6cd8a1 Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/entity/Student.class differ diff --git a/student/WebRoot/WEB-INF/classes/entity/Student.hbm.xml b/student/WebRoot/WEB-INF/classes/entity/Student.hbm.xml new file mode 100644 index 0000000..e2fa114 --- /dev/null +++ b/student/WebRoot/WEB-INF/classes/entity/Student.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/student/WebRoot/WEB-INF/classes/entity/TestDatabase.class b/student/WebRoot/WEB-INF/classes/entity/TestDatabase.class new file mode 100644 index 0000000..2737eaa Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/entity/TestDatabase.class differ diff --git a/student/WebRoot/WEB-INF/classes/entity/User.class b/student/WebRoot/WEB-INF/classes/entity/User.class new file mode 100644 index 0000000..2b51f4b Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/entity/User.class differ diff --git a/student/WebRoot/WEB-INF/classes/entity/User.hbm.xml b/student/WebRoot/WEB-INF/classes/entity/User.hbm.xml new file mode 100644 index 0000000..365eeb1 --- /dev/null +++ b/student/WebRoot/WEB-INF/classes/entity/User.hbm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/student/WebRoot/WEB-INF/classes/hibernate.cfg.xml b/student/WebRoot/WEB-INF/classes/hibernate.cfg.xml new file mode 100644 index 0000000..ae0c01c --- /dev/null +++ b/student/WebRoot/WEB-INF/classes/hibernate.cfg.xml @@ -0,0 +1,23 @@ + + + + + + root + root + com.mysql.jdbc.Driver + jdbc:mysql:///test?useUnicode=true&characterEncoding=UTF-8 + org.hibernate.dialect.MySQLDialect + true + true + update + thread + + + + + \ No newline at end of file diff --git a/student/WebRoot/WEB-INF/classes/service/StudentDao.class b/student/WebRoot/WEB-INF/classes/service/StudentDao.class new file mode 100644 index 0000000..0f49581 Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/service/StudentDao.class differ diff --git a/student/WebRoot/WEB-INF/classes/service/UserDao.class b/student/WebRoot/WEB-INF/classes/service/UserDao.class new file mode 100644 index 0000000..93419cf Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/service/UserDao.class differ diff --git a/student/WebRoot/WEB-INF/classes/service/impl/StudentDaoImpl.class b/student/WebRoot/WEB-INF/classes/service/impl/StudentDaoImpl.class new file mode 100644 index 0000000..cb69f2c Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/service/impl/StudentDaoImpl.class differ diff --git a/student/WebRoot/WEB-INF/classes/service/impl/TestStudentDaoImpl.class b/student/WebRoot/WEB-INF/classes/service/impl/TestStudentDaoImpl.class new file mode 100644 index 0000000..6ed08e4 Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/service/impl/TestStudentDaoImpl.class differ diff --git a/student/WebRoot/WEB-INF/classes/service/impl/TestUserDaoImpl.class b/student/WebRoot/WEB-INF/classes/service/impl/TestUserDaoImpl.class new file mode 100644 index 0000000..5f512c4 Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/service/impl/TestUserDaoImpl.class differ diff --git a/student/WebRoot/WEB-INF/classes/service/impl/UserDaoImpl.class b/student/WebRoot/WEB-INF/classes/service/impl/UserDaoImpl.class new file mode 100644 index 0000000..b43d83b Binary files /dev/null and b/student/WebRoot/WEB-INF/classes/service/impl/UserDaoImpl.class differ diff --git a/student/WebRoot/WEB-INF/classes/struts.xml b/student/WebRoot/WEB-INF/classes/struts.xml new file mode 100644 index 0000000..7f32242 --- /dev/null +++ b/student/WebRoot/WEB-INF/classes/struts.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + /user/User_login_success.jsp + /user/User_login.jsp + /user/User_login.jsp + /user/User_login.jsp + + + + + + /student/Student_query_success.jsp + Student_query + /student/Student_add_success.jsp + /student/Student_modify.jsp + /student/Student_modify_success.jsp + + + + diff --git a/student/WebRoot/WEB-INF/web.xml b/student/WebRoot/WEB-INF/web.xml new file mode 100644 index 0000000..748c00f --- /dev/null +++ b/student/WebRoot/WEB-INF/web.xml @@ -0,0 +1,15 @@ + + + + struts2 + org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter + + + + struts2 + /* + + + diff --git a/student/WebRoot/components/dtree/dtree.css b/student/WebRoot/components/dtree/dtree.css new file mode 100644 index 0000000..d91d624 --- /dev/null +++ b/student/WebRoot/components/dtree/dtree.css @@ -0,0 +1,33 @@ +/*--------------------------------------------------| +| dTree 2.05 | www.destroydrop.com/javascript/tree/ | +|---------------------------------------------------| +| Copyright (c) 2002-2003 Geir Landr? | +|--------------------------------------------------*/ + +.dtree { + font-size: 12px; + color: #666; + white-space: nowrap; +} +.dtree img { + border: 0px; + vertical-align: middle; +} +.dtree a { + color: #333; + text-decoration: none; +} +.dtree a.node, .dtree a.nodeSel { + white-space: nowrap; + padding: 1px 2px 1px 2px; +} +.dtree a.node:hover, .dtree a.nodeSel:hover { + color: #333; + text-decoration: underline; +} +.dtree a.nodeSel { + background-color: #c0d2ec; +} +.dtree .clip { + overflow: hidden; +} \ No newline at end of file diff --git a/student/WebRoot/components/dtree/dtree.js b/student/WebRoot/components/dtree/dtree.js new file mode 100644 index 0000000..049a3f9 --- /dev/null +++ b/student/WebRoot/components/dtree/dtree.js @@ -0,0 +1,347 @@ +/*--------------------------------------------------| +| dTree 2.05 | www.destroydrop.com/javascript/tree/ | +|---------------------------------------------------| +| Copyright (c) 2002-2003 Geir Landr? | +| | +| This script can be used freely as long as all | +| copyright messages are intact. | +| | +| Updated: 17.04.2003 | +|--------------------------------------------------*/ + +// Node object +function Node(id, pid, name, url, title, target, icon, iconOpen, open) { + this.id = parseInt(id); + this.pid = parseInt(pid); + this.name = name; + this.url = url; + this.title = title; + this.target = target; + this.icon = icon; + this.iconOpen = iconOpen; + this._io = open || false; + this._is = false; + this._ls = false; + this._hc = false; + this._ai = 0; + this._p; +}; + +// Tree object +function dTree(objName) { + this.config = { + target : null, + folderLinks : true, + useSelection : true, + useCookies : true, + useLines : true, + useIcons : true, + useStatusText : false, + closeSameLevel : false, + inOrder : false + } + this.icon = { + root : dtreeIconBasePath + '/img/base.gif', + folder : dtreeIconBasePath + '/img/folder.gif', + folderOpen : dtreeIconBasePath + '/img/folderopen.gif', + node : dtreeIconBasePath + '/img/page.gif', + empty : dtreeIconBasePath + '/img/empty.gif', + line : dtreeIconBasePath + '/img/line.gif', + join : dtreeIconBasePath + '/img/join.gif', + joinBottom : dtreeIconBasePath + '/img/joinbottom.gif', + plus : dtreeIconBasePath + '/img/plus.gif', + plusBottom : dtreeIconBasePath + '/img/plusbottom.gif', + minus : dtreeIconBasePath + '/img/minus.gif', + minusBottom : dtreeIconBasePath + '/img/minusbottom.gif', + nlPlus : dtreeIconBasePath + '/img/nolines_plus.gif', + nlMinus : dtreeIconBasePath + '/img/nolines_minus.gif' + }; + this.obj = objName; + this.aNodes = []; + this.aIndent = []; + this.root = new Node(-1); + this.selectedNode = null; + this.selectedFound = false; + this.completed = false; +}; + +// Adds a new node to the node array +dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { + this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open); +}; + +// Open/close all nodes +dTree.prototype.openAll = function() { + this.oAll(true); +}; +dTree.prototype.closeAll = function() { + this.oAll(false); +}; + +// Outputs the tree to the page +dTree.prototype.toString = function() { + var str = '
\n'; + if (document.getElementById) { + if (this.config.useCookies) this.selectedNode = this.getSelected(); + str += this.addNode(this.root); + } else str += 'Browser not supported.'; + str += '
'; + if (!this.selectedFound) this.selectedNode = null; + this.completed = true; + return str; +}; + +// Creates the tree structure +dTree.prototype.addNode = function(pNode) { + var str = ''; + var n=0; + if (this.config.inOrder) n = pNode._ai; + for (n; n'; + } + if (node.url) { + str += ''; + str += node.name; + if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; + str += ''; + if (node._hc) { + str += '
'; + str += this.addNode(node); + str += '
'; + } + this.aIndent.pop(); + return str; +}; + +// Adds the empty and line icons +dTree.prototype.indent = function(node, nodeId) { + var str = ''; + if (this.root.id != node.pid) { + for (var n=0; n'; + (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); + if (node._hc) { + str += ''; + } else str += ''; + } + return str; +}; + +// Checks if a node has any children and if it is the last sibling +dTree.prototype.setCS = function(node) { + var lastId; + for (var n=0; n +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; + response.sendRedirect(path+"/user/User_login.jsp"); +%> diff --git a/student/WebRoot/js/Calendar3.js b/student/WebRoot/js/Calendar3.js new file mode 100644 index 0000000..e6e14b6 --- /dev/null +++ b/student/WebRoot/js/Calendar3.js @@ -0,0 +1,374 @@ + +/////////////////////////调用实例 +//
+// 交易查询: 从 +// +// +// 至 +// +// + +//
+ +/** + * Calendar + * @param beginYear 1990 + * @param endYear 2010 + * @param language 0(zh_cn)|1(en_us)|2(en_en)|3(zh_tw) + * @param patternDelimiter "-" + * @param date2StringPattern "yyyy-MM-dd" + * @param string2DatePattern "ymd" + * @version 1.0 build 2006-04-01 + * @version 1.1 build 2006-12-17 + * @author KimSoft (jinqinghua [at] gmail.com) + * NOTE! you can use it free, but keep the copyright please + * IMPORTANT:you must include this script file inner html body elment + */ +function Calendar(beginYear, endYear, language, patternDelimiter, date2StringPattern, string2DatePattern) { + this.beginYear = beginYear || 1990; + this.endYear = endYear || 2020; + this.language = language || 0; + this.patternDelimiter = patternDelimiter || "-"; + this.date2StringPattern = date2StringPattern || Calendar.language["date2StringPattern"][this.language].replace(/\-/g, this.patternDelimiter); + this.string2DatePattern = string2DatePattern || Calendar.language["string2DatePattern"][this.language]; + + this.dateControl = null; + this.panel = this.getElementById("__calendarPanel"); + this.iframe = window.frames["__calendarIframe"]; + this.form = null; + + this.date = new Date(); + this.year = this.date.getFullYear(); + this.month = this.date.getMonth(); + + this.colors = {"bg_cur_day":"#00CC33","bg_over":"#EFEFEF","bg_out":"#FFCC00"} +}; + +Calendar.language = { + "year" : ["\u5e74", "", "", "\u5e74"], + "months" : [ + ["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"], + ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"], + ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"], + ["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"] + ], + "weeks" : [["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"], + ["Sun","Mon","Tur","Wed","Thu","Fri","Sat"], + ["Sun","Mon","Tur","Wed","Thu","Fri","Sat"], + ["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"] + ], + "clear" : ["\u6e05\u7a7a", "Clear", "Clear", "\u6e05\u7a7a"], + "today" : ["\u4eca\u5929", "Today", "Today", "\u4eca\u5929"], + "close" : ["\u5173\u95ed", "Close", "Close", "\u95dc\u9589"], + "date2StringPattern" : ["yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd"], + "string2DatePattern" : ["ymd","ymd", "ymd", "ymd"] +}; + +Calendar.prototype.draw = function() { + calendar = this; + + var _cs = []; + _cs[_cs.length] = ''; + _cs[_cs.length] = ''; + _cs[_cs.length] = ' '; + _cs[_cs.length] = ' '; + for(var i = 0; i < 7; i++) { + _cs[_cs.length] = ''; + for(var j = 0; j < 7; j++) { + switch (j) { + case 0: _cs[_cs.length] = ''; + _cs[_cs.length] = '
<\/th>'; + _cs[_cs.length] = ' <\/select><\/th>'; + _cs[_cs.length] = ' <\/th>'; + _cs[_cs.length] = ' <\/tr>'; + _cs[_cs.length] = '
'; + _cs[_cs.length] = Calendar.language["weeks"][this.language][i]; + _cs[_cs.length] = '<\/th>'; + } + _cs[_cs.length] = '<\/tr>'; + for(var i = 0; i < 6; i++){ + _cs[_cs.length] = '
 <\/td>'; break; + case 6: _cs[_cs.length] = ' <\/td>'; break; + default:_cs[_cs.length] = ' <\/td>'; break; + } + } + _cs[_cs.length] = '<\/tr>'; + } + _cs[_cs.length] = '
<\/th>'; + _cs[_cs.length] = ' <\/th>'; + _cs[_cs.length] = ' <\/th>'; + _cs[_cs.length] = ' <\/tr>'; + _cs[_cs.length] = '<\/table>'; + _cs[_cs.length] = '<\/form>'; + + this.iframe.document.body.innerHTML = _cs.join(""); + this.form = this.iframe.document.forms["__calendarForm"]; + + this.form.clearButton.value = Calendar.language["clear"][this.language]; + this.form.selectTodayButton.value = Calendar.language["today"][this.language]; + this.form.closeButton.value = Calendar.language["close"][this.language]; + + this.form.goPrevMonthButton.onclick = function () {calendar.goPrevMonth(this);} + this.form.goNextMonthButton.onclick = function () {calendar.goNextMonth(this);} + this.form.yearSelect.onchange = function () {calendar.update(this);} + this.form.monthSelect.onchange = function () {calendar.update(this);} + + this.form.clearButton.onclick = function () {calendar.dateControl.value = "";calendar.hide();} + this.form.closeButton.onclick = function () {calendar.hide();} + this.form.selectTodayButton.onclick = function () { + var today = new Date(); + calendar.date = today; + calendar.year = today.getFullYear(); + calendar.month = today.getMonth(); + calendar.dateControl.value = today.format(calendar.date2StringPattern); + calendar.hide(); + } +}; + +Calendar.prototype.bindYear = function() { + var ys = this.form.yearSelect; + ys.length = 0; + for (var i = this.beginYear; i <= this.endYear; i++){ + ys.options[ys.length] = new Option(i + Calendar.language["year"][this.language], i); + } +}; + +Calendar.prototype.bindMonth = function() { + var ms = this.form.monthSelect; + ms.length = 0; + for (var i = 0; i < 12; i++){ + ms.options[ms.length] = new Option(Calendar.language["months"][this.language][i], i); + } +}; + +Calendar.prototype.goPrevMonth = function(e){ + if (this.year == this.beginYear && this.month == 0){return;} + this.month--; + if (this.month == -1) { + this.year--; + this.month = 11; + } + this.date = new Date(this.year, this.month, 1); + this.changeSelect(); + this.bindData(); +}; + +Calendar.prototype.goNextMonth = function(e){ + if (this.year == this.endYear && this.month == 11){return;} + this.month++; + if (this.month == 12) { + this.year++; + this.month = 0; + } + this.date = new Date(this.year, this.month, 1); + this.changeSelect(); + this.bindData(); +}; + +Calendar.prototype.changeSelect = function() { + var ys = this.form.yearSelect; + var ms = this.form.monthSelect; + for (var i= 0; i < ys.length; i++){ + if (ys.options[i].value == this.date.getFullYear()){ + ys[i].selected = true; + break; + } + } + for (var i= 0; i < ms.length; i++){ + if (ms.options[i].value == this.date.getMonth()){ + ms[i].selected = true; + break; + } + } +}; + +Calendar.prototype.update = function (e){ + this.year = e.form.yearSelect.options[e.form.yearSelect.selectedIndex].value; + this.month = e.form.monthSelect.options[e.form.monthSelect.selectedIndex].value; + this.date = new Date(this.year, this.month, 1); + this.changeSelect(); + this.bindData(); +}; + +Calendar.prototype.bindData = function () { + var calendar = this; + var dateArray = this.getMonthViewDateArray(this.date.getFullYear(), this.date.getMonth()); + var tds = this.getElementsByTagName("td", this.getElementById("__calendarTable", this.iframe.document)); + for(var i = 0; i < tds.length; i++) { + tds[i].style.backgroundColor = calendar.colors["bg_over"]; + tds[i].onclick = null; + tds[i].onmouseover = null; + tds[i].onmouseout = null; + tds[i].innerHTML = dateArray[i] || " "; + if (i > dateArray.length - 1) continue; + if (dateArray[i]){ + tds[i].onclick = function () { + if (calendar.dateControl){ + calendar.dateControl.value = new Date(calendar.date.getFullYear(), + calendar.date.getMonth(), + this.innerHTML).format(calendar.date2StringPattern); + } + calendar.hide(); + } + tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];} + tds[i].onmouseout = function () {this.style.backgroundColor = calendar.colors["bg_over"];} + var today = new Date(); + if (today.getFullYear() == calendar.date.getFullYear()) { + if (today.getMonth() == calendar.date.getMonth()) { + if (today.getDate() == dateArray[i]) { + tds[i].style.backgroundColor = calendar.colors["bg_cur_day"]; + tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];} + tds[i].onmouseout = function () {this.style.backgroundColor = calendar.colors["bg_cur_day"];} + } + } + } + }//end if + }//end for +}; + +Calendar.prototype.getMonthViewDateArray = function (y, m) { + var dateArray = new Array(42); + var dayOfFirstDate = new Date(y, m, 1).getDay(); + var dateCountOfMonth = new Date(y, m + 1, 0).getDate(); + for (var i = 0; i < dateCountOfMonth; i++) { + dateArray[i + dayOfFirstDate] = i + 1; + } + return dateArray; +}; + +Calendar.prototype.show = function (dateControl, popuControl) { + if (this.panel.style.visibility == "visible") { + this.panel.style.visibility = "hidden"; + } + if (!dateControl){ + throw new Error("arguments[0] is necessary!") + } + this.dateControl = dateControl; + popuControl = popuControl || dateControl; + + this.draw(); + this.bindYear(); + this.bindMonth(); + if (dateControl.value.length > 0){ + this.date = new Date(dateControl.value.toDate(this.patternDelimiter, this.string2DatePattern)); + this.year = this.date.getFullYear(); + this.month = this.date.getMonth(); + } + this.changeSelect(); + this.bindData(); + + var xy = this.getAbsPoint(popuControl); + this.panel.style.left = xy.x + "px"; + this.panel.style.top = (xy.y + dateControl.offsetHeight) + "px"; + this.panel.style.visibility = "visible"; +}; + +Calendar.prototype.hide = function() { + this.panel.style.visibility = "hidden"; +}; + +Calendar.prototype.getElementById = function(id, object){ + object = object || document; + return document.getElementById ? object.getElementById(id) : document.all(id); +}; + +Calendar.prototype.getElementsByTagName = function(tagName, object){ + object = object || document; + return document.getElementsByTagName ? object.getElementsByTagName(tagName) : document.all.tags(tagName); +}; + +Calendar.prototype.getAbsPoint = function (e){ + var x = e.offsetLeft; + var y = e.offsetTop; + while(e = e.offsetParent){ + x += e.offsetLeft; + y += e.offsetTop; + } + return {"x": x, "y": y}; +}; + +/** + * @param d the delimiter + * @param p the pattern of your date + * @author meizz + * @author kimsoft add w+ pattern + */ +Date.prototype.format = function(style) { + var o = { + "M+" : this.getMonth() + 1, //month + "d+" : this.getDate(), //day + "h+" : this.getHours(), //hour + "m+" : this.getMinutes(), //minute + "s+" : this.getSeconds(), //second + "w+" : "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".charAt(this.getDay()), //week + "q+" : Math.floor((this.getMonth() + 3) / 3), //quarter + "S" : this.getMilliseconds() //millisecond + } + if (/(y+)/.test(style)) { + style = style.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + } + for(var k in o){ + if (new RegExp("("+ k +")").test(style)){ + style = style.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); + } + } + return style; +}; + +/** + * @param d the delimiter + * @param p the pattern of your date + * @rebuilder kimsoft + * @version build 2006.12.15 + */ +String.prototype.toDate = function(delimiter, pattern) { + delimiter = delimiter || "-"; + pattern = pattern || "ymd"; + var a = this.split(delimiter); + var y = parseInt(a[pattern.indexOf("y")], 10); + //remember to change this next century ;) + if(y.toString().length <= 2) y += 2000; + if(isNaN(y)) y = new Date().getFullYear(); + var m = parseInt(a[pattern.indexOf("m")], 10) - 1; + var d = parseInt(a[pattern.indexOf("d")], 10); + if(isNaN(d)) d = 1; + return new Date(y, m, d); +}; + +document.writeln(' +
+ +
+ + + + + \ No newline at end of file diff --git a/student/src/action/StudentAction.java b/student/src/action/StudentAction.java new file mode 100644 index 0000000..b3291cc --- /dev/null +++ b/student/src/action/StudentAction.java @@ -0,0 +1,76 @@ +package action; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.List; + +import service.StudentDao; +import service.impl.StudentDaoImpl; +import entity.Student; + +//ѧAction +public class StudentAction extends SuperAction{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + + //ѯѧϵĶ + public String query() { + StudentDao studentDao = new StudentDaoImpl(); + List list = studentDao.queryAllStudent(); + if(list != null && list.size() > 0) { + session.setAttribute("student_list", list); + } + return "student_query_success"; + } + + //ɾѧϵĶ + public String delete() { + StudentDao studentDao = new StudentDaoImpl(); + String sid = request.getParameter("sid"); + studentDao.deleteStudent(sid); + return "student_delete_success"; + } + + //ѧϵĶ + public String add() throws Exception { + StudentDao studentDao = new StudentDaoImpl(); + Student s = new Student(); + s.setSname(request.getParameter("sname")); + s.setGender(request.getParameter("gender")); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + s.setBirthday(sdf.parse(request.getParameter("birthday"))); + s.setAddress(request.getParameter("address")); + studentDao.addStudent(s); + return "student_add_success"; + } + + //޸ѧϵĶ + public String modify() { + + String sid = request.getParameter("sid"); + StudentDao studentDao = new StudentDaoImpl(); + Student s = studentDao.queryStudentBySid(sid); + //ڻỰ + session.setAttribute("modify_student", s); + return "student_modify_success"; + } + + //޸ĺѧ϶ + public String save() throws Exception { + StudentDao studentDao = new StudentDaoImpl(); + Student s = new Student(); + s.setSid(request.getParameter("sid")); + s.setSname(request.getParameter("sname")); + s.setGender(request.getParameter("gender")); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + s.setBirthday(sdf.parse(request.getParameter("birthday"))); + s.setAddress(request.getParameter("address")); + studentDao.updateStudent(s); + return "student_save_success"; + } + +} diff --git a/student/src/action/SuperAction.java b/student/src/action/SuperAction.java new file mode 100644 index 0000000..5d1b4e0 --- /dev/null +++ b/student/src/action/SuperAction.java @@ -0,0 +1,40 @@ +package action; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.interceptor.ServletRequestAware; +import org.apache.struts2.interceptor.ServletResponseAware; +import org.apache.struts2.util.ServletContextAware; + +import com.opensymphony.xwork2.ActionSupport; + +//Actionĸ +public class SuperAction extends ActionSupport implements ServletRequestAware, ServletResponseAware, ServletContextAware{ + /** + * + */ + private static final long serialVersionUID = 1L; + protected HttpServletRequest request; + protected HttpServletResponse response; + protected HttpSession session; + protected ServletContext application; + @Override + public void setServletContext(ServletContext application) { + this.application = application; + } + + @Override + public void setServletResponse(HttpServletResponse response) { + this.response = response; + } + + @Override + public void setServletRequest(HttpServletRequest request) { + this.request = request; + this.session = this.request.getSession(); + } + +} diff --git a/student/src/action/UserAction.java b/student/src/action/UserAction.java new file mode 100644 index 0000000..ec71dc0 --- /dev/null +++ b/student/src/action/UserAction.java @@ -0,0 +1,59 @@ +package action; + +import org.apache.struts2.interceptor.validation.SkipValidation; + +import service.UserDao; +import service.impl.UserDaoImpl; + +import com.opensymphony.xwork2.ModelDriven; + +import entity.User; + +public class UserAction extends SuperAction implements ModelDriven { + + /** + * + */ + private static final long serialVersionUID = 1L; + private User user = new User(); + + // û¼ + public String login() { + UserDao userdao = new UserDaoImpl(); + if (userdao.userLogin(user)) { + //¼ɹû + session.setAttribute("loginUserName", user.getUsername()); + return "login_success"; + } else { + return "login_failure"; + } + } + + @SkipValidation + //ûע + public String logout() { + if(session.getAttribute("loginUserName") != null) { + session.removeAttribute("loginUserName"); + } + return "logout_success"; + } + + + + @Override + public void validate() { + super.validate(); + if("".equals(user.getUsername().trim())) { + this.addFieldError("usernameError", "ûΪգ"); + } + if(user.getPassword().length() < 6) { + this.addFieldError("passwordError", "볤Ȳ6λ"); + } + } + + @Override + public User getModel() { + return this.user; + } + +} diff --git a/student/src/db/MyHibernateSessionFactory.java b/student/src/db/MyHibernateSessionFactory.java new file mode 100644 index 0000000..6e3f0ed --- /dev/null +++ b/student/src/db/MyHibernateSessionFactory.java @@ -0,0 +1,25 @@ +package db; + +import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; + +public class MyHibernateSessionFactory { + // Ự + private static SessionFactory sessionFactory; + + private MyHibernateSessionFactory() { + + } + + public static SessionFactory getSessionFactory() { + if (sessionFactory == null) { + Configuration configuration = new Configuration().configure(); + StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() + .configure().build(); + sessionFactory = configuration.buildSessionFactory(serviceRegistry); + } + return sessionFactory; + } +} diff --git a/student/src/entity/Student.hbm.xml b/student/src/entity/Student.hbm.xml new file mode 100644 index 0000000..e2fa114 --- /dev/null +++ b/student/src/entity/Student.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/student/src/entity/Student.java b/student/src/entity/Student.java new file mode 100644 index 0000000..bb6e489 --- /dev/null +++ b/student/src/entity/Student.java @@ -0,0 +1,71 @@ +package entity; + +import java.util.Date; + +public class Student { + private String sid; + private String sname; + private String gender; + private Date birthday; + private String address; + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getSname() { + return sname; + } + + public void setSname(String sname) { + this.sname = sname; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public Date getBirthday() { + return birthday; + } + + @Override + public String toString() { + return "Student [sid=" + sid + ", sname=" + sname + ", gender=" + + gender + ", birthday=" + birthday + ", address=" + address + + "]"; + } + + public void setBirthday(Date birthday) { + this.birthday = birthday; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Student() { + } + + public Student(String sid, String sname, String gender, Date birthday, + String address) { + this.sid = sid; + this.sname = sname; + this.gender = gender; + this.birthday = birthday; + this.address = address; + } + +} diff --git a/student/src/entity/User.hbm.xml b/student/src/entity/User.hbm.xml new file mode 100644 index 0000000..365eeb1 --- /dev/null +++ b/student/src/entity/User.hbm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/student/src/entity/User.java b/student/src/entity/User.java new file mode 100644 index 0000000..e46ea5c --- /dev/null +++ b/student/src/entity/User.java @@ -0,0 +1,47 @@ +package entity; + +public class User { + private int uid; + private String username; + private String password; + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User() { + } + + public User(int uid, String username, String password) { + this.uid = uid; + this.username = username; + this.password = password; + } + + @Override + public String toString() { + return "User [uid=" + uid + ", username=" + username + ", password=" + + password + "]"; + } + +} diff --git a/student/src/hibernate.cfg.xml b/student/src/hibernate.cfg.xml new file mode 100644 index 0000000..ae0c01c --- /dev/null +++ b/student/src/hibernate.cfg.xml @@ -0,0 +1,23 @@ + + + + + + root + root + com.mysql.jdbc.Driver + jdbc:mysql:///test?useUnicode=true&characterEncoding=UTF-8 + org.hibernate.dialect.MySQLDialect + true + true + update + thread + + + + + \ No newline at end of file diff --git a/student/src/service/StudentDao.java b/student/src/service/StudentDao.java new file mode 100644 index 0000000..28456f1 --- /dev/null +++ b/student/src/service/StudentDao.java @@ -0,0 +1,24 @@ +package service; + +import java.util.List; + +import entity.Student; + +//ѧҵ߼ӿ +public interface StudentDao { + + // ѯѧ + public List queryAllStudent(); + + // ѧŲѯѧ + public Student queryStudentBySid(String sid); + + // ѧ + public boolean addStudent(Student s); + + // ޸ѧ + public boolean updateStudent(Student s); + + // ɾѧ + public boolean deleteStudent(String sid); +} diff --git a/student/src/service/UserDao.java b/student/src/service/UserDao.java new file mode 100644 index 0000000..1dde5e5 --- /dev/null +++ b/student/src/service/UserDao.java @@ -0,0 +1,9 @@ +package service; + +import entity.User; + +public interface UserDao { + + //û¼ + boolean userLogin(User u); +} diff --git a/student/src/service/impl/StudentDaoImpl.java b/student/src/service/impl/StudentDaoImpl.java new file mode 100644 index 0000000..fa4509f --- /dev/null +++ b/student/src/service/impl/StudentDaoImpl.java @@ -0,0 +1,172 @@ +package service.impl; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import db.MyHibernateSessionFactory; +import entity.Student; +import service.StudentDao; + +//ѧҵ߼ӿڵʵ +public class StudentDaoImpl implements StudentDao { + + // ѯѧ + @Override + public List queryAllStudent() { + Transaction ts = null; + List list = null; + String hql = ""; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + hql = "from Student"; + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + + list = query.list(); + ts.commit(); + return list; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return list; + } finally { + if (ts != null) { + ts = null; + } + } + } + + // ѧŲѯѧ + @Override + public Student queryStudentBySid(String sid) { + Transaction ts = null; + Student s = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + s = session.get(Student.class, sid); + ts.commit(); + return s; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return s; + } finally { + if (ts != null) { + ts = null; + } + } + } + + // ޸ѧ + @Override + public boolean updateStudent(Student s) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.update(s); + ts.commit(); + return true; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + // ɾѧ + @Override + public boolean deleteStudent(String sid) { + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Student s = session.get(Student.class, sid); + session.delete(s); + ts.commit(); + return true; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + // ѧ + @Override + public boolean addStudent(Student s) { + s.setSid(getNewSid()); + Transaction ts = null; + try { + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + session.save(s); + ts.commit(); + return true; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + + // ѧѧ + public String getNewSid() { + Transaction ts = null; + String hql = ""; + String sid = null; + try { + hql = "select max(sid) from Student"; + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + sid = (String) query.uniqueResult(); + if (sid == null || sid.equals("")) { + // Ĭϵ + sid = "S0000001"; + } else { + String temp = sid.substring(1); // ȥλ + int i = Integer.parseInt(temp); // ת + i++; + temp = String.valueOf(i); + int len = temp.length(); + for (int k = 0; k < 7 - len; k++) { + temp = "0" + temp; + } + sid = "S" + temp; + } + ts.commit(); + return sid; + } catch (Exception e) { + e.printStackTrace(); + ts.commit(); + return sid; + } finally { + if (ts != null) { + ts = null; + } + } + } +} diff --git a/student/src/service/impl/UserDaoImpl.java b/student/src/service/impl/UserDaoImpl.java new file mode 100644 index 0000000..50b64c8 --- /dev/null +++ b/student/src/service/impl/UserDaoImpl.java @@ -0,0 +1,44 @@ +package service.impl; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import service.UserDao; +import db.MyHibernateSessionFactory; +import entity.User; + +public class UserDaoImpl implements UserDao { + + @Override + public boolean userLogin(User u) { + Transaction ts = null; + String hql = ""; + try { + hql = "from User where username=? and password=?"; + Session session = MyHibernateSessionFactory.getSessionFactory() + .getCurrentSession(); + ts = session.beginTransaction(); + Query query = session.createQuery(hql); + query.setParameter(0, u.getUsername()); + query.setParameter(1, u.getPassword()); + List list = query.list(); + ts.commit(); + if (list.size() > 0) { + return true; + } else { + return false; + } + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + if (ts != null) { + ts = null; + } + } + } + +} diff --git a/student/src/struts.xml b/student/src/struts.xml new file mode 100644 index 0000000..7f32242 --- /dev/null +++ b/student/src/struts.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + /user/User_login_success.jsp + /user/User_login.jsp + /user/User_login.jsp + /user/User_login.jsp + + + + + + /student/Student_query_success.jsp + Student_query + /student/Student_add_success.jsp + /student/Student_modify.jsp + /student/Student_modify_success.jsp + + + + diff --git a/student/test/entity/TestDatabase.java b/student/test/entity/TestDatabase.java new file mode 100644 index 0000000..775f93d --- /dev/null +++ b/student/test/entity/TestDatabase.java @@ -0,0 +1,64 @@ +package entity; + +import java.util.Date; +import java.util.EnumSet; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.hibernate.tool.schema.TargetType; +import org.junit.Test; + +public class TestDatabase { + + // Ӳ + @Test + public void testAddStudent() { + // ö + Configuration configuration = new Configuration().configure(); + // SessionFactory + SessionFactory sessionFactory = configuration.buildSessionFactory(); + // session + Session session = sessionFactory.getCurrentSession(); + // + Transaction ts = session.beginTransaction(); + + Student s1 = new Student("S0000001", "skyward", "", new Date(), "δ֪"); + Student s2 = new Student("S0000002", "geek", "", new Date(), "δ֪"); + Student s3 = new Student("S0000004", "hacker", "", new Date(), "δ֪"); + + session.save(s1); + session.save(s2); + session.save(s3); + + ts.commit(); + sessionFactory.close(); + } + + @Test + public void testSchemaExport() { + // ö + Configuration configuration = new Configuration().configure(); + // ע + StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() + .configure().build(); + // SessionFactory + SessionFactory sessionFactory = configuration.buildSessionFactory(); + // session + Session session = sessionFactory.getCurrentSession(); + // SchemaExport + SchemaExport schemaExport = new SchemaExport(); + + Metadata metadata = new MetadataSources(serviceRegistry) + .buildMetadata(); + + schemaExport.create(EnumSet.of(TargetType.DATABASE), metadata); + } + +} diff --git a/student/test/service/impl/TestStudentDaoImpl.java b/student/test/service/impl/TestStudentDaoImpl.java new file mode 100644 index 0000000..91fd9ca --- /dev/null +++ b/student/test/service/impl/TestStudentDaoImpl.java @@ -0,0 +1,37 @@ +package service.impl; + +import java.util.Date; +import java.util.List; + +import junit.framework.Assert; + +import org.junit.Test; + +import service.StudentDao; +import entity.Student; + +public class TestStudentDaoImpl { + @Test + public void TestQueryAllStudent() { + List list = new StudentDaoImpl().queryAllStudent(); + for(Student s : list) { + System.out.println(s.toString()); + } + } + + @Test + public void TestGetNewSid() { + System.out.println(new StudentDaoImpl().getNewSid()); + } + + @Test + public void TestAddStudent() { + Student s = new Student(); + s.setAddress("δ֪ϵ"); + s.setBirthday(new Date()); + s.setGender(""); + s.setSname("skyward"); + StudentDao studentDao = new StudentDaoImpl(); + Assert.assertEquals(true, studentDao.addStudent(s)); + } +} diff --git a/student/test/service/impl/TestUserDaoImpl.java b/student/test/service/impl/TestUserDaoImpl.java new file mode 100644 index 0000000..8466448 --- /dev/null +++ b/student/test/service/impl/TestUserDaoImpl.java @@ -0,0 +1,17 @@ +package service.impl; + +import junit.framework.Assert; + +import org.junit.Test; + +import service.UserDao; +import entity.User; + +public class TestUserDaoImpl { + @Test + public void testUserLogin() { + User user = new User(1, "skyward", "123456"); + UserDao userDao = new UserDaoImpl(); + Assert.assertEquals(true, userDao.userLogin(user)); + } +}