admin_mn_test_add.jsp
上传用户:nbluoke
上传日期:2013-08-09
资源大小:4851k
文件大小:2k
源码类别:

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
  2. <%@ page import="jinghua.*"%>
  3. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  4. </jsp:useBean>
  5. <%!boolean debug=false;
  6. %>
  7. <%
  8. String testname=""+request.getParameter("testname");
  9. String gradenote=""+request.getParameter("selgrade");
  10. testname=Tools.codestring(testname);
  11. testname=testname.trim();
  12. gradenote=Tools.codestring(gradenote);
  13. gradenote=gradenote.trim();
  14. String begindate=request.getParameter("dateyear")+"-"+
  15.     request.getParameter("datemonth")+"-"+request.getParameter("dateday");
  16. String enddate=request.getParameter("dateyear1")+"-"+
  17.     request.getParameter("datemonth1")+"-"+request.getParameter("dateday1");
  18. if(debug){
  19.     out.print("<br>testname="+testname);
  20.     out.print("<br>gradenode="+gradenote);
  21.     out.print("<br>begindate="+begindate);
  22.     out.print("<br>enddate="+enddate);
  23. }
  24. if(testname.equals("") ){
  25.     Tools.showalert("请您输入科目名称",out);
  26.     Tools.goback(out);
  27. }else{
  28.     try{
  29.         Connection con=DBCon.getConnection();
  30.         String sql="select * from mn_test where name='"+testname.trim()+"' and grade_note='"+gradenote+"'";
  31.         Statement stmt=con.createStatement();
  32.         ResultSet rs=stmt.executeQuery(sql);
  33.         if (rs.next()){
  34.             Tools.showalert("该年级的此次模拟考试信息在数据库中已经存在!",out);
  35.             Tools.goback(out);
  36.             rs.close();
  37.             stmt.close();
  38.         }else{
  39.             rs.close();
  40.             stmt.close();
  41.                 //status=有效
  42.             sql="insert into mn_test(name,grade_note,begin_date,end_date,test_num,sub_num,status) "+
  43.            " values('"+testname+"','"+gradenote+"','"+begindate+"','"+enddate+"',0,0,"+"2"+")";
  44.             stmt=con.createStatement();
  45.             stmt.executeUpdate(sql);
  46.             if(debug){
  47.                 out.print("<BR>insert="+sql);
  48.             }
  49.             Tools.showalert("成功添加科目信息!",out);
  50.             response.sendRedirect("admin_mn_test.jsp");
  51.            //Tools.showJS("window.open('admin_subject.jsp','_self')",out);
  52.            //Tools.showJS("history.back(1)",out);
  53.         }
  54.     }catch(SQLException se){
  55.         out.println(se.toString());
  56.     }
  57.     finally{
  58.     DBCon.dropConnection();
  59.     }
  60. }
  61. %>