⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checi_modifycheciaction.java

📁 java做的 公交车查询系统....毕业设计
💻 JAVA
字号:
//在checi.jsp页面中,进行修改车次的处理动作
package gongjiaochexitong.gongjiaoche.checi_pkg;

import gongjiaochexitong.gongjiaoche.*;
import gongjiaochexitong.gongjiaoche.main_pkg.*;

import java.sql.Time;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.ActionMessage;
import javax.servlet.ServletContext;
import javax.sql.DataSource;

public final class checi_modifyCheCiAction extends Action{
	
	public ActionForward execute(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,  
			HttpServletResponse response) throws Exception {
				
	  checi_modifyCheCiForm modifycheciform = (checi_modifyCheCiForm)form;
	  int checihao = modifycheciform.getChecihao();
	  String type = modifycheciform.getType().trim();
	  Time startTime = Time.valueOf(modifycheciform.getStartTime().trim());//从表单中获取得数据是字符串hh:mm:ss格式的,需将其转换为Time类型
	  Time endTime = Time.valueOf(modifycheciform.getEndTime().trim());
	  String startStation = modifycheciform.getStartStation().trim();
	  String endStation = modifycheciform.getEndStation().trim();
			
	  ServletContext context = servlet.getServletContext();
	  DataSource dataSource = (DataSource)context.getAttribute("db_gongjiaoche");
	  conn_Bus db = new conn_Bus(dataSource);
	  
	  HttpSession session = request.getSession();
	  ActionMessages actionMessages = new ActionMessages();
	  
	  String msg[]=new String[1];  //存放异常信息
	  msg[0]=null;
			
	  if(checihao!=0 && type!=null && !type.equals("") &&
			  startStation!=null && !startStation.equals("") && 
			  endStation!=null && !endStation.equals("") && 
			  startTime!=null && endTime!=null){
		if(checi_procedure.modifyCheCi(db,checihao,type,startTime,
				endTime,startStation,endStation,msg)!=0){
			
			try {              //刷新车次列表(省掉在按"更新"按钮时,才更新车次列表)				
				Vector checi_list=procedure.getCheCi_List(db);   //这里的站点是站点号,须转换
				session.setAttribute(constants.CHECI_LIST_KEY2,checi_procedure.stationNo2stationName(db,checi_list));
			} catch (Exception e) {
				//System.out.println("出现异常:"+e);
				e.printStackTrace();				
			}
			
			actionMessages.add(ActionMessages.GLOBAL_MESSAGE,
					new ActionMessage("label.checi_modifiedCheCiSuccess"));
						
			if (!actionMessages.isEmpty()) {
						saveMessages(request, actionMessages);
			}
			db.conn_Close();     //close connection
			return mapping.findForward("checi_updateSuccess");
		}
		else if(msg!=null){
			actionMessages.add(ActionMessages.GLOBAL_MESSAGE,
					new ActionMessage("label.checi_modifiedCheCiFailure"));
						
			if (!actionMessages.isEmpty()) {
						saveMessages(request, actionMessages);
			}
			db.conn_Close();     //close connection
			return mapping.findForward("checi_updateError");
		}
		else{
			actionMessages.add(ActionMessages.GLOBAL_MESSAGE,
					new ActionMessage("label.checi_modifiedCheCiFailure"));
						
			if (!actionMessages.isEmpty()) {
						saveMessages(request, actionMessages);
			}
			db.conn_Close();     //close connection
			return mapping.findForward("checi_updateError");
		}			
	  }
	  else{
		actionMessages.add(ActionMessages.GLOBAL_MESSAGE,
		  new ActionMessage("label.checi_modifiedCheCiFailure"));
						
		if (!actionMessages.isEmpty()) {
		  saveMessages(request, actionMessages);
		}
		db.conn_Close();     //close connection
		return mapping.findForward("checi_updateError");
	  }	
			
	}

}

⌨️ 快捷键说明

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