admin_knowadd.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 name=""+request.getParameter("name");
  9. String gradenote=""+request.getParameter("selgrade");
  10. String subject=""+request.getParameter("selsubject");
  11. name=Tools.codestring(name);
  12. name=name.trim();
  13. gradenote=Tools.codestring(gradenote);
  14. gradenote=gradenote.trim();
  15. if(debug){
  16.     out.print("<br>subname="+name);
  17.     out.print("<br>gradenode="+gradenote);
  18. }
  19. if(name.equals("") ){
  20.     Tools.showalert("请您输入知识点名称",out);
  21.     Tools.goback(out);
  22. }else{
  23.     try{
  24.         Connection con=DBCon.getConnection();
  25.         String sql="select * from knowpoint where name='"+name+"' and gradenote='"+gradenote+
  26.                     "' and subid="+subject;
  27.         PreparedStatement pstmt=con.prepareStatement(sql);
  28.         ResultSet rs=pstmt.executeQuery();
  29.         if (rs.next()){
  30.             rs.close();
  31.             pstmt.close();
  32.             Tools.showalert("该知识点信息在数据库中已经存在!",out);
  33.             Tools.goback(out);
  34.         }else{
  35.             rs.close();
  36.             pstmt.close();
  37.             sql="insert into knowpoint(name,gradenote,subid) values('"+name+"','"+gradenote+"'"+","+subject+")";
  38.             //Tools.showalert(sql,out);
  39.             pstmt=con.prepareStatement(sql);
  40.             pstmt.executeUpdate();
  41.             if(debug){
  42.                 out.print("<BR>insert="+sql);
  43.             }
  44.             Tools.showalert("成功添加知识点信息!",out);
  45.             response.sendRedirect("admin_knowpoint.jsp");
  46.            //Tools.showJS("window.open('admin_subject.jsp','_self')",out);
  47.         }
  48.     }catch(SQLException se){
  49.         out.println(se.toString());
  50.     }catch(Exception e){
  51.         out.print(e.toString());
  52.     }finally{
  53.         DBCon.dropConnection();
  54.     }
  55. }
  56. %>