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

📄 teachmngaction.java

📁 培训考试系统代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package com.huawei.icd30.agt.teachmng;

import javax.servlet.http.*;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import com.huawei.icd30.agt.util.*;
import com.huawei.icd30.common.db.*;

/**
 * <p> 本类的功能描述信息</p>
 * <p> (这家伙很懒,什么都没有写)</p>
 * <p> </p>
 * <p> </p>
 * @author unascribed
 * @version 1.0
 */

public class TeachmngAction extends Action
{
      public ActionForward perform(ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
    {
        // 检查session是否超时
  //       ActionForward checkForword = Tools.checkSession(req,res);
 //        得到操作标识operatorflag
        String operatorflag = ((TeachmngForm) form).getOperatorflag();
        /* 根据查询条件查询培训教师列表 */
        if (operatorflag.equalsIgnoreCase("TEACHMNG_QUERYLIST"))
        {
             return queryTeacherList(mapping, form, req, res);
        }
       //查询教师档案详细信息
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_QUERYDETAIL"))
        {
             return queryTeacherArchive(mapping,form,req,res);
        }
        //新增培训教师档案
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_ADD"))
        {
             return newTeacherArchive(mapping, form, req, res);
        }
        //修改培训教师档案
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_MOD"))
        {
             return modTeacherArchive(mapping, form, req, res);
        }
       //根据教师ID删除教师档案
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_DEL"))
        {
             return delTeacherArchive(mapping, form, req, res);
        }

        //新增教师课酬;
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_REWARDADD"))
        {
             return newTeachReward(mapping, form, req, res);
        }

        //查询教师课酬列表;
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_QUERY_REWARDLIST")||
                  operatorflag.equalsIgnoreCase("TEACHMNG_QUERY_MYREWARD"))
        {
             return  queryRewardList(mapping, form, req, res);
        }
        //查询登录用户是否有教师档案;
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_QUERY_CHECKMYREWARD"))
        {
             return  checkMyReward(mapping, form, req, res);
        }
         //查询教师课酬详细信息;
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_QUERY_LOCATEAREWARD"))
        {
             return  locateAReward(mapping, form, req, res);
        }
         //修改教师课酬详细信息;
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_MOD_REWARD"))
        {
             return  modTeachReward(mapping, form, req, res);
        }
         //删除教师课酬详细信息;
        else if (operatorflag.equalsIgnoreCase("TEACHMNG_DEL_REWARD"))
        {
             return  delAReward(mapping, form, req, res);
        }
        else
          {
             req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
            return(mapping.findForward("error"));
          }

    }
        /****************************************************
         * 根据查询条件查询培训教师人员列表
         ****************************************************/
       private ActionForward queryTeacherList (ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
    {
       //得到教师ID、教师姓名、业务代表ID、授课方向
       String teacherid = ((TeachmngForm) form).getTeacherid();
       String teachername = ((TeachmngForm) form).getTeachername();
       String staffno = ((TeachmngForm) form).getStaffno();
       String major = ((TeachmngForm) form).getMajor();
       SysDbConn aplcoms = null ;
       try
       {
           //连接数据源
           aplcoms = SysConnPool.getInstance().getAplComs();
           aplcoms.preparedSP();

           //获得输入参数teacherid、teachername、staffno、teachermajor
           aplcoms.setString(1,teacherid);
           aplcoms.setString(2,teachername);
           aplcoms.setString(3,staffno);
           aplcoms.setString(4,major);

           //调用P_Agt_TeacherSearch查询,得到数据集rs1
           SysResultSet rs1 = aplcoms.csCommonSP("P_Agt_TeacherSearch").getResultSet();
           rs1.next();
           aplcoms.preparedQuery(rs1.getString(1));
           SysResultSet rs2 = aplcoms.csCommonQuery("SELFSQL","1","-1").getResultSet();
           //if (rs 不为空)
           if (rs2 != null)
           {
            //按业务代表ID排序
            rs2.sort(0,true);
            //将结果集放到session中 TEACHMNG-LIST
            req.getSession().setAttribute("TEACHMNG-LIST",new ResUtil(rs2));

           //将输入的查询条件传递给页面
            req.setAttribute("teacherid",teacherid);
            req.setAttribute("teachername",teachername);
            req.setAttribute("staffno",staffno);
            req.setAttribute("major",major);
            //定向到列表页面teacherlist
            return (mapping.findForward("teacherlist"));
           }
           else
           {
             req.setAttribute("errorId",ErrorCode.TEACHMNG_SEARCHLIST);
            return(mapping.findForward("error"));
           }
        }
      catch (SysDbException aple)
      {
        //捕获CommonService系统异常,定向到出错页面,错误码为ErrorCode.COMMONSERVICE_ERROR
          aple.printStackTrace();
          req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(java.sql.SQLException sqle)
      {
        //捕获调用aplcoms异常,定向到出错页面,错误码为ErrorCode.DATABASE_ERROR
          sqle.printStackTrace();
          req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(Exception e)
      {
        //捕获未知异常,定向到出错页面,错误码为ErrorCode.UNKNOW_ERROR
          e.printStackTrace();
          req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
          return (mapping.findForward("error"));
       }
      finally
        //关闭连接实例
        {
          if(aplcoms != null)
          {
             aplcoms.close();
          }
        }
    }
        /****************************************************
         *根据培训教师ID查询培训教师档案详细信息
         ****************************************************/
       private ActionForward queryTeacherArchive (ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
    {
      String teacherid = ((TeachmngForm) form).getTeacherid();
      SysDbConn aplcoms = null ;
       try
       {
           //连接数据源
           aplcoms = SysConnPool.getInstance().getAplComs();
           aplcoms.preparedQuery("");
           //设置查询参数
           aplcoms.setString(1,teacherid);
          //调用SQL_AGT_QueryTeacherArchive查询得到此教师的档案详细信息
           SysResultSet rs = new ResUtil(aplcoms.csCommonQuery("SQL_AGT_QueryTeacherArchive","1","-1").getResultSet());

          //if (rs 不为空)
           if (rs != null)
           {
            rs.next();
            //将查询结果传递给页面
            req.setAttribute("teacherid",rs.getString(0));
            req.setAttribute("staffno",rs.getString(1));
            req.setAttribute("teachername",rs.getString(2));
            if (rs.getString(3) != "")
            {
                req.setAttribute("birthday",
                   rs.getString(3).substring(0,4)+"-"+rs.getString(3).substring(4,6)+"-"+rs.getString(3).substring(6,8));
            }
            else
            {
                req.setAttribute("birthday", "");
             }
            req.setAttribute("sex",rs.getString(4));
            req.setAttribute("edulevelid",rs.getString(5));
            if (rs.getString(6) != "")
            {
                req.setAttribute("graduatedate",
                   rs.getString(6).substring(0,4)+"-"+rs.getString(6).substring(4,6)+"-"+rs.getString(6).substring(6,8));
            }
            else
            {
                req.setAttribute("graduatedate", "");
             }
            req.setAttribute("major",rs.getString(7));
            req.setAttribute("company",rs.getString(8));
            req.setAttribute("duty",rs.getString(9));
            req.setAttribute("note",rs.getString(10));
            //定向到列表页面teachermodify
            return (mapping.findForward("teachermodify"));
            }
           else
           {
             req.setAttribute("errorId",ErrorCode.TEACHMNG_LOCATEA);
             return(mapping.findForward("error"));
           }
        }
      catch (SysDbException aple)
      {
        //捕获CommonService系统异常,定向到出错页面,错误码为ErrorCode.COMMONSERVICE_ERROR
          aple.printStackTrace();
          req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(java.sql.SQLException sqle)
      {
        //捕获调用aplcoms异常,定向到出错页面,错误码为ErrorCode.DATABASE_ERROR
          sqle.printStackTrace();
          req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(Exception e)
      {
        //捕获未知异常,定向到出错页面,错误码为ErrorCode.UNKNOW_ERROR
          e.printStackTrace();
          req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
          return (mapping.findForward("error"));
       }
      finally
        //关闭连接实例
        {
          if(aplcoms != null)
          {
             aplcoms.close();
          }
        }
    }

        /****************************************************
         *新增培训教师档案
         ****************************************************/
      private ActionForward newTeacherArchive (ActionMapping mapping,
       ActionForm form, HttpServletRequest req,
        HttpServletResponse res)
       {
        //得到输入参数
    String operatorflag = ((TeachmngForm)form).getOperatorflag();
    String teacherid =((TeachmngForm)form).getTeacherid();
    String teachername = ((TeachmngForm)form).getTeachername();
    String staffno = ((TeachmngForm)form).getStaffno();
    String birthday = ((TeachmngForm)form).getBirthday();
    String sex = ((TeachmngForm)form).getSex();
    String edulevelid = ((TeachmngForm)form).getEdulevelid() ;
    String graduatedate = ((TeachmngForm)form).getGraduatedate();
    String major = ((TeachmngForm)form).getMajor();
    String company = ((TeachmngForm)form).getCompany();
    String duty = ((TeachmngForm)form).getDuty();
    String note = ((TeachmngForm)form).getNote();
    if (birthday != null)
    {
         birthday = birthday.replaceAll("-","");
    }
    if (graduatedate != null)
    {
         graduatedate = graduatedate.replaceAll("-","");
    }
    SysDbConn aplcoms = null;
    try
   {
      //连接数据源
      aplcoms = SysConnPool.getInstance().getAplComs();
      aplcoms.preparedSP();
      //获得参数
      aplcoms.setString(1 ,teacherid);
      aplcoms.setString(2 ,staffno);
      aplcoms.setString(3 ,teachername);
      aplcoms.setString(4 ,birthday);
      aplcoms.setString(5 ,sex);
      aplcoms.setString(6 ,edulevelid);
      aplcoms.setString(7 ,graduatedate);
      aplcoms.setString(8 ,major);
      aplcoms.setString(9 ,company);
      aplcoms.setString(10 ,duty);
      aplcoms.setString(11 ,note);
      //调用P_Agt_AddTeacherArchive新增记录
      SysDataSet ds = aplcoms.csCommonSP("P_Agt_AddTeacherArchive");
      SysRecord rc = ds.getParamSet();
      if (rc!=null && rc.getInt(0) == 0)
      {
/*
           ((TeachmngForm)form).setTeacherid(teacherid);
           ((TeachmngForm)form).setOperatorflag("TEACHMNG_QUERYDETAIL");
           return queryTeacherArchive(mapping,form,req,res);
*/
       
       return (mapping.findForward("teachsuccess"));
    }else
     {
       req.setAttribute("errorId",ErrorCode.TEACHMNG_ADD);
       return (mapping.findForward("error"));
     }
   }catch (SysDbException aple)
      {
        //捕获CommonService系统异常,定向到出错页面,错误码为ErrorCode.COMMONSERVICE_ERROR
          aple.printStackTrace();
          req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(java.sql.SQLException sqle)
      {
        //捕获调用aplcoms异常,定向到出错页面,错误码为ErrorCode.DATABASE_ERROR
          sqle.printStackTrace();
          req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(Exception e)
      {
        //捕获未知异常,定向到出错页面,错误码为ErrorCode.UNKNOW_ERROR
          e.printStackTrace();
          req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
          return (mapping.findForward("error"));
       }
      finally
        //关闭连接实例
        {
          if(aplcoms != null)

⌨️ 快捷键说明

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