EctomereAction.java
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:8k
源码类别:
Jsp/Servlet
开发平台:
Java
- //Created by MyEclipse Struts
- // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
- package com.oa.module.pub.ectomere;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.lang.reflect.InvocationTargetException;
- import java.util.Date;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- import org.apache.commons.beanutils.BeanUtils;
- 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.oa.module.office.user.Tuser;
- /**
- * MyEclipse Struts
- * Creation date: 01-17-2008
- *
- * // 欢迎${sessionScope.adminuserbean.loginname}登录!
- //String uno = (String)((Tuser) request.getSession().getAttribute("?????")).getUno();
- *
- * XDoclet definition:
- * @struts.action path="/ectomere" name="ectomereForm" input="/Jsp_file/ectomere/exteriorlist.jsp" parameter="task" scope="request" validate="true"
- */
- public class EctomereAction extends DispatchAction {
- // --------------------------------------------------------- Instance Variables
- private EctomereDAO ectomeredao;
- // --------------------------------------------------------- Methods
- /**
- * Method execute
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- * @throws InvocationTargetException
- */
- //查询
- public ActionForward query(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- EctomereForm ectomereForm = (EctomereForm) form;
- System.out.println(ectomeredao);
- int currentPage=1;
- try {
- currentPage=Integer.parseInt(request.getParameter("currentPage"));
- } catch (Exception e) {
- currentPage=1;
- }
- int count=5;
- Ectomere ect=new Ectomere();
- //拷贝查询参数
- try {
- BeanUtils.copyProperties(ect,ectomereForm);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- List paramlist = null;
- List userlist=null;
- userlist=ectomeredao.getUser();
- paramlist = ectomeredao.getParam();
- XPage ectpage = ectomeredao.getEctomerelist(currentPage,count,ect);
- request.setAttribute("userlist",userlist);
- request.setAttribute("paramlist",paramlist);
- request.setAttribute("ectpage",ectpage);
- return mapping.findForward("list");
- }
- //添加
- public ActionForward add(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- EctomereForm ectomereForm = (EctomereForm) form;
- //从Session作用域获得本用户ID
- HttpSession session = request.getSession();
- Tuser user = (Tuser) session.getAttribute("user");
- String userid=user.getUno();
- System.out.println(userid);
- request.setAttribute("uno",userid);
- //获取系统时间
- Date date=new Date();
- System.out.println(date);
- Calendar cd=Calendar.getInstance();
- DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm");
- String eaddtime=df.format(cd.getTime());
- System.out.println(eaddtime);
- request.setAttribute("eaddtime",eaddtime);
- List paramlist = null;
- paramlist = ectomeredao.getParam();
- request.setAttribute("paramlist",paramlist);
- ectomereForm.setTask("save");
- return mapping.getInputForward();
- }
- //添加保存------------------------------
- public ActionForward save(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- EctomereForm ectomereForm = (EctomereForm) form;
- //从Session作用域获得本用户ID
- HttpSession session = request.getSession();
- Tuser user = (Tuser) session.getAttribute("user");
- String userid=user.getUno();
- System.out.println(userid);
- Texterior info=new Texterior();
- try {
- BeanUtils.copyProperties(info, ectomereForm);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- boolean flag = ectomeredao.create(info);
- if (flag) {
- request.setAttribute("msg", "添加外联信息成功");
- return mapping.findForward("query");
- }else {
- request.setAttribute("msg", "添加外联信息失败");
- return mapping.getInputForward();
- }
- }
- //编辑
- public ActionForward init(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- EctomereForm ectomereForm = (EctomereForm) form;
- //从Session作用域获得本用户ID
- HttpSession session = request.getSession();
- Tuser user = (Tuser) session.getAttribute("user");
- String userid=user.getUno();
- System.out.println(userid);
- //判断录入人是否是本人或超级管理员
- String uno=request.getParameter("uno");
- System.out.println(uno);
- //管理员
- if(userid.equals("1")||userid.equals(uno)){
- //获取系统时间
- Date date=new Date();
- System.out.println(date);
- Calendar cd=Calendar.getInstance();
- DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm");
- String eaddtime=df.format(cd.getTime());
- System.out.println(eaddtime);
- request.setAttribute("eaddtime",eaddtime);
- request.setAttribute("uno",userid);
- Texterior info=ectomeredao.getTexteriorById(new Long(ectomereForm.getEid()));
- try {
- BeanUtils.copyProperties(ectomereForm,info);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- List paramlist = null;
- paramlist = ectomeredao.getParam();
- request.setAttribute("paramlist",paramlist);
- ectomereForm.setTask("edit");
- return mapping.getInputForward();
- }else{
- request.setAttribute("msg","无权限修改");
- return mapping.findForward("query");
- }
- }
- //编辑保存
- public ActionForward edit(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- EctomereForm ectomereForm = (EctomereForm) form;
- Texterior info=new Texterior();
- try {
- BeanUtils.copyProperties(info, ectomereForm);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- boolean flag=ectomeredao.update(info);
- if(flag){
- request.setAttribute("msg","修改成功");
- return mapping.findForward("query");
- }else{
- request.setAttribute("msg","修改失败");
- return mapping.getInputForward();
- }
- }
- //删除
- public ActionForward del(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- EctomereForm ectomereForm = (EctomereForm) form;
- //从Session作用域获得本用户ID
- HttpSession session = request.getSession();
- Tuser user = (Tuser) session.getAttribute("user");
- String userid=user.getUno();
- System.out.println(userid);
- String uno=request.getParameter("uno");
- System.out.println(uno);
- //判断录入人是否是本人或超级管理员
- System.out.println(ectomereForm.getUno());
- if(userid.equals("1")||userid.equals(uno)){
- long eid = ectomereForm.getEid();
- System.out.println(eid);
- boolean flag =ectomeredao.del(eid);
- if (flag) {
- request.setAttribute("msg", "删除外联信息成功");
- return mapping.findForward("query");
- } else {
- request.setAttribute("msg", "删除外联信息失败");
- return mapping.findForward("query");
- }
- }else{
- request.setAttribute("msg","无权限删除");
- return mapping.findForward("query");
- }
- }
- public EctomereDAO getEctomeredao() {
- return ectomeredao;
- }
- public void setEctomeredao(EctomereDAO ectomeredao) {
- this.ectomeredao = ectomeredao;
- }
- }