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

📄 departmentaddaction.java

📁 eclipse java/jsp 航空管理系统
💻 JAVA
字号:
/**
 *<p>application name:        DepartmentAddAction.java</p>
 *<p>application describing:  this class controls the requesst
 *                            of the client that will operate 
 *                            the addaction
 *<p>copyright :              Copyright  东软 国际合作事业部版权所有</p>
 *<p>company:                 neusoft</p>
 *<p>time:                    2005.04.19</p>
 * @author:                   尹超
*/

package yinchao.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.util.MessageResources;
import yinchao.model.DepartmentAddModel;
import yinchao.form.DepartmentAddForm;
import zhangchunliang.model.AppMode;

/**
 * @see yinchao.action.DepartmentAction
 * @author yinchao
 * @version 2005-4-19
*/

public class DepartmentAddAction extends Action{
  
    public ActionForward execute(ActionMapping mapping, 
                ActionForm form, HttpServletRequest request,
                HttpServletResponse response) throws Exception
	{
    	
		if(!AppMode.getAppMode()){
			System.out.println("Application is terminated...");
			return mapping.findForward("appInfo");
		}
        
    	DepartmentAddForm  departmentaddform=(DepartmentAddForm)form;
    	DepartmentAddModel departmentaddModel=new DepartmentAddModel();
      
       /** 判断输入是否有错 */
        MessageResources resource = super.getResources(request);
		ActionErrors errors = new ActionErrors();
	
       /**判断部门号或名是否为空为空报错没有填写部门号*/
		 if ("".equals(departmentaddform.getDepno()))
		 {
			System.out.println("11111");
		 	errors.add("E0001", new ActionError("E0001"));
			saveErrors(request, errors);
			return mapping.getInputForward();
		 }
	   /** 部门名不能为空为空报错没有填写部门名 */
		if ("".equals(departmentaddform.getDepname()))
		{
			errors.add("E0002", new ActionError("E0002"));
			saveErrors(request, errors);
			return mapping.getInputForward();
		}
		/**操作的表不能为空为空报错没有选中表 */
		
		if (departmentaddform.getGroupNo()==null)
		{
			errors.add("E0004", new ActionError("E0004"));
			saveErrors(request, errors);
			return mapping.getInputForward();
		}
		 System.out.println(departmentaddform.getGroupNo());
	  /**部门号,部门电话,部门人数,部门工资为整形
	   * 如果不为整形则报错类型不对
	  */
	
		try 
		{
			Integer.parseInt(departmentaddform.getDepno());
			Integer.parseInt(departmentaddform.getDeptel());
			Integer.parseInt(departmentaddform.getDepsalary());
		}catch(Exception e)
		{
			errors.add("E0003", new ActionError("E0003"));
			saveErrors(request, errors);
			return mapping.getInputForward();
		}
		try{
			/**部门名为字符形不能为数字为数字报类型错误*/
			Integer.parseInt(departmentaddform.getDepname());	
			errors.add("E0003", new ActionError("E0003"));
			saveErrors(request, errors);
			return mapping.getInputForward();
		}catch(Exception e  )
		{
			try
			{
				/**部门负责人为字符形不是报类型错误*/
				Integer.parseInt(departmentaddform.getDepleader());	
				errors.add("E0003", new ActionError("E0003"));
				saveErrors(request, errors);
				return mapping.getInputForward();
			}catch(Exception e1)
			{
	       /**
           * 根据返回值返回不同的ActionForward
           * 为1位成功则跳转到成功界面,
           * 2为出错界面,
           * 3为部门号或部门名义存在出错界面
           */
				
		   /** 取得返回值 */
		   int forward;
	       forward = departmentaddModel.addRecordModel(departmentaddform);		
          if(forward == 1)
           {
            return mapping.findForward("changesuccess");
           }
          if(forward==3) 
           {
            return mapping.findForward("depnoexit");
           }else
           {
           	return mapping.findForward("error");
         } 
         }
		}
	}
}



        
    
    


⌨️ 快捷键说明

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