/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.wlin.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.wlin.operatedb.Generate2;
import com.wlin.operatedb.OperateDb;
import com.wlin.pojo.EmployeeInfo;
import com.wlin.pojo.Login;
import com.wlin.struts.form.EmployeeForm;
import com.wlin.struts.form.LoginForm;
/**
* MyEclipse Struts
* Creation date: 10-12-2008
*
* XDoclet definition:
* @struts.action path="/employee" name="employeeForm" input="/employee.jsp" parameter="methods" scope="request" validate="true"
*/
public class EmployeeAction extends DispatchAction {
/*
* Generated Methods
*/
OperateDb db = new OperateDb();
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward query(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm employeeForm = (EmployeeForm) form;// TODO Auto-generated method stub
EmployeeInfo ei = new EmployeeInfo();
String hql = "from EmployeeInfo";
List list = db.query(hql);
System.out.println(list.size());
if(list!=null||!list.equals("")){
request.setAttribute("palist",list);
}
return new ActionForward("/employeelist.jsp");
}
/**
* 增加数据
*/
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm employeeForm = (EmployeeForm) form;// TODO Auto-generated method stub
Generate2 tt= new Generate2();
String id = tt.generateId();
EmployeeInfo lg= new EmployeeInfo();
lg.setId(id);
lg.setName(request.getParameter("name"));//姓名
lg.setFileid(request.getParameter("fildid"));//档案号
lg.setGraduateschool(request.getParameter("graduateschool"));//毕业学院
if(request.getParameter("sex").trim().equals("0")){
lg.setState("男");//状态 0正常 1锁定
}else if(request.getParameter("sex").trim().equals("1")){
lg.setState("女");//状态 0正常 1锁定
}
lg.setCardid(request.getParameter("cardid"));//身份证
lg.setGraduatedate(request.getParameter("graduatedate"));//毕业时间
lg.setAge(request.getParameter("age"));//年龄
lg.setBirthdate(request.getParameter("birthdate"));//出生日期
lg.setRelationphone(request.getParameter("relationphone"));//联系电话
lg.setMarriagestatus(request.getParameter("marriagestatus"));//婚姻状况
lg.setMobile(request.getParameter("mobile"));//手机
lg.setWorkingdate(request.getParameter("workingdate"));//工作时间
lg.setWorkage(request.getParameter("workage"));//工龄
lg.setNation(request.getParameter("nation"));//民族
lg.setPostcode(request.getParameter("postcode"));//邮编
lg.setSpeciality(request.getParameter("speciality"));//专业
lg.setEmail(request.getParameter("email"));//电子邮箱
lg.setWorkdate(request.getParameter("workdate"));//入职日期
lg.setDepartid(request.getParameter("departid"));//
if(request.getParameter("state").trim().equals("0")){
lg.setState("正常");//状态 0正常 1锁定
}else if(request.getParameter("state").trim().equals("1")){
lg.setState("锁定");//状态 0正常 1锁定
}else if(request.getParameter("state").trim().equals("2")){
lg.setState("离职");//状态 0正常 1锁定
}
lg.setPolity(request.getParameter("polity"));//政治面貌
lg.setHometown(request.getParameter("hometown"));//籍贯
lg.setBankcardname(request.getParameter("bankcardname"));//发卡银行
lg.setMemo1(request.getParameter("memo1"));//备注
lg.setHomeplace(request.getParameter("homeplace"));//籍贯住址
lg.setFamilyplace(request.getParameter("familyplace"));//家庭住址
lg.setDepartment(request.getParameter("department"));//部门
boolean hql = db.insert(lg);
if(hql){
request.setAttribute("infor", "保存成功");
}
return new ActionForward("/addemployee.jsp");
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
//获取传递过来的ID值
String id = request.getParameter("id");
//实例话数据库操作类
String sql="delete EmployeeInfo as us where us.id ='"+id+"'";
boolean hql=db.delete(sql);
if(hql){
request.setAttribute("infor", "删除成功");
return new ActionForward("/employee.do?methods=query");
}else{
request.setAttribute("infor", "删除失败");
return new ActionForward("/employeelist.jsp");
}
}
/*
* 修改数据方法
*/
public ActionForward edit1(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
String id=request.getParameter("id");
String hql="from EmployeeInfo as us where us.id='"+id+"'";
List list=db.query(hql);
if(list!=null||!list.equals(""))
{
request.setAttribute("palist",list);
return new ActionForward("/editemployee.jsp");
}
else
{
return new ActionForward("/employeelist.jsp");
}
}
public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm employeeForm = (EmployeeForm) form;// TODO Auto-generated method stub
EmployeeInfo u1= new EmployeeInfo();
u1.setId(request.getParameter("id"));
u1.setName(request.getParameter("name"));//姓名
u1.setFileid(request.getParameter("fildid"));//档案号
u1.setGraduateschool(request.getParameter("graduateschool"));//毕业学院
u1.setGraduateschool(request.getParameter("sex"));
u1.setCardid(request.getParameter("cardid"));//身份证
u1.setGraduatedate(request.getParameter("graduatedate"));//毕业时间
u1.setAge(request.getParameter("age"));//年龄
u1.setBirthdate(request.getParameter("birthdate"));//出生日期
u1.setRelationphone(request.getParameter("relationphone"));//联系电话
u1.setMarriagestatus(request.getParameter("marriagestatus"));//婚姻状况
u1.setMobile(request.getParameter("mobile"));//手机
u1.setWorkingdate(request.getParameter("workingdate"));//工作时间
u1.setWorkage(request.getParameter("workage"));//工龄
u1.setNation(request.getParameter("nation"));//民族
u1.setPostcode(request.getParameter("postcode"));//邮编
u1.setSpeciality(request.getParameter("speciality"));//专业
u1.setEmail(request.getParameter("email"));//电子邮箱
u1.setWorkdate(request.getParameter("workdate"));//入职日期
u1.setDepartid(request.getParameter("departid"));//
if(request.getParameter("state").trim().equals("0")){
u1.setState("正常");//状态 0正常 1锁定
}else if(request.getParameter("state").trim().equals("1")){
u1.setState("锁定");//状态 0正常 1锁定
}else if(request.getParameter("state").trim().equals("2")){
u1.setState("离职");//状态 0正常 1锁定
}
u1.setPolity(request.getParameter("polity"));//政治面貌
u1.setHometown(request.getParameter("hometown"));//籍贯
u1.setBankcardname(request.getParameter("bankcardname"));//发卡银行
u1.setMemo1(request.getParameter("memo1"));//备注
u1.setHomeplace(request.getParameter("homeplace"));//籍贯住址
u1.setFamilyplace(request.getParameter("familyplace"));//家庭住址
u1.setDepartment(request.getParameter("department"));//部门
boolean obj = db.update(u1);
request.getSession().setAttribute("infor", "修改成功");
return new ActionForward("/employee.do?methods=query");
}
public ActionForward query1(ActionMapping mapping, ActionForm for
评论0