bollotaction.java

来自「spring+struts+hibernate做的银行系统」· Java 代码 · 共 219 行

JAVA
219
字号
package cn.com.tym.admin;
/*
 * Created on 2006-3-26
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author jack_booth
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

import java.util.ArrayList;

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 cn.com.tym.newclass.BollotBean;
import cn.com.tym.pub.ConnPool;
import cn.com.tym.pub.Constants;

import javax.sql.DataSource;
import cn.com.tym.pub.DB;
 
public class BollotAction extends DispatchAction{
  
	//ǰ̨,ͶƱ
	public ActionForward setBollot(ActionMapping mapping, 
			 ActionForm form,
			 HttpServletRequest request, 
			 HttpServletResponse response){
		
	    String PageForward="gobollot"; 
 
	   	 BollotActionForm frm=(BollotActionForm)form;
	   	BollotBean bollot=new BollotBean();
	   DB db=null;
	   try{
		 	ConnPool pool=new ConnPool();
	        DataSource dataSource=pool.Tomcat_JDBC_DataSource();
	        db = new DB(dataSource);
	      
	       if(bollot.goBollot(frm.getBollotId(),db)){
	          	 
	          	//���ͶƱ�ɹ�
	        } 
   } 
	    catch(Exception e){
	    	e.printStackTrace();
	    	//����ͳһ���ش���ҳ��
	    	PageForward="fail";
   }
   finally{
   		db.close();
   }
   return mapping.findForward(PageForward);
}
	
	//ǰ̨ҳ��鿴����
	public ActionForward lookBollot(ActionMapping mapping, 
			 ActionForm form,
			 HttpServletRequest request, 
			 HttpServletResponse response){

	    String PageForward="voteff"; 
	   	ArrayList arraylist=new ArrayList();	
	   	BollotBean bollot=new BollotBean();
	   DB db=null;
	   try{
		 	ConnPool pool=new ConnPool();
	        DataSource dataSource=pool.Tomcat_JDBC_DataSource();
	        db = new DB(dataSource);
	         
	        arraylist=bollot.bollotList(db);
	        request.setAttribute(Constants.BOLLOT,arraylist);
  } 
	    catch(Exception e){
	    	e.printStackTrace();
	    	//����ͳһ���ش���ҳ��
	    	PageForward="fail";
  }
  finally{
  		db.close();
  }
  return mapping.findForward(PageForward);
}
	
	
	//�鿴
	public ActionForward adminBollot(ActionMapping mapping, 
			 ActionForm form,
			 HttpServletRequest request, 
			 HttpServletResponse response){
	    
		if (AdminLogin.isLogin(request) == 0) {
			return mapping.findForward("admin");
		}
 
	    String PageForward="bollot"; 
	   	ArrayList arraylist=new ArrayList();	
	   	BollotBean bollot=new BollotBean();
	   DB db=null;
	   try{
		 	ConnPool pool=new ConnPool();
	        DataSource dataSource=pool.Tomcat_JDBC_DataSource();
	        db = new DB(dataSource);
	         
	        arraylist=bollot.bollotList(db);
	        request.setAttribute(Constants.BOLLOT,arraylist);
	        
   } 
	    catch(Exception e){
	    	e.printStackTrace();
	    	//����ͳһ���ش���ҳ��
	    	PageForward="fail";
   }
   finally{
   		db.close();
   }
   return mapping.findForward(PageForward);
}
	
	//ɾ��
	
 public ActionForward  BollotDele(ActionMapping mapping, 
					 ActionForm form,
					 HttpServletRequest request, 
					 HttpServletResponse response){
//				�ж��Ƿ��½
				if (AdminLogin.isLogin(request) == 0) {
					return mapping.findForward("admin");
				}

				String id=request.getParameter("bollotId");
				
			    String PageForward="bollotPage"; 
			  
			   BollotBean bollot=new BollotBean();
			 
			   DB db=null;
			   try{
				 	ConnPool pool=new ConnPool();
			        DataSource dataSource=pool.Tomcat_JDBC_DataSource();
			        db = new DB(dataSource);
			        
			        //���� 
			        if(bollot.delete(id,db)){
			        	 
			        	//���ɾ��ɹ�
			        }
			       }

			    catch(Exception e){

			    	e.printStackTrace();
			    	//����ͳһ���ش���ҳ��
			    	PageForward="fail";
		  }
		  finally{
		  		db.close();
		  		db=null;
		  }
		  return mapping.findForward(PageForward);
			
		}
	//���
 public ActionForward  BollotAdd(ActionMapping mapping, 
		 ActionForm form,
		 HttpServletRequest request, 
		 HttpServletResponse response){
//	�ж��Ƿ��½
	if (AdminLogin.isLogin(request) == 0) {
		return mapping.findForward("admin");
	}

	String name=request.getParameter("bollotName");
	
   String PageForward="bollotPage"; 
 
  BollotBean bollot=new BollotBean();

  DB db=null;
  try{
	 	ConnPool pool=new ConnPool();
       DataSource dataSource=pool.Tomcat_JDBC_DataSource();
       db = new DB(dataSource);
       
       //���� 
       if(bollot.addBollot(name,db)){
       	 
       	//���ɾ��ɹ�
       }
      }

   catch(Exception e){

   	e.printStackTrace();
   	//����ͳһ���ش���ҳ��
   	PageForward="fail";
}
finally{
		db.close();
		db=null;
}
return mapping.findForward(PageForward);

}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?