admintc2.jsp
上传用户:mkymky1985
上传日期:2014-06-23
资源大小:754k
文件大小:3k
- <%@ page language = "java" contentType = "text/html;charset=gb2312"%>
- <%@ page import = "java.sql.*,wsxk.*" %>
- <jsp:useBean id="subject" scope="page" class="wsxk.ConDB"/>
- <%! String trans(String chi)
- {
- String result = null;
- byte temp [];
- try
- {
- temp=chi.getBytes("iso-8859-1");
- result = new String(temp, "gb2312");
- }
- catch(Exception e)
- {
- System.out.println (e.toString());
- }
- return result;
- }
- %>
- <%
- String strSQL1 = "select tcid from tc order by tcid asc";
- ResultSet rs2 = subject.executeQuery(strSQL1);
- String MaxID = new String();
- int id = 0;
- while(rs2.next())
- {
- id = rs2.getInt("tcid");
- }
- /*int k = 0;
- for (k = 0; k < 999999; k++)
- {
- if (id.equals(MaxID.valueOf(k)))
- break;
- }
- ++k;
- if (k >= 999999)
- k = 1;
- id = MaxID.valueOf(k);*/
- id++;
- System.out.println("id" + id);
- rs2.close();
- %>
- <%
- //String couid = new String (request.getParameter("couid"));
- String couname = new String (request.getParameter("select"));
- String teaname = new String (request.getParameter("select2"));
- //String coumark = new String (request.getParameter("coumark"));
- //String couback = new String (request.getParameter("couback"));
- //String stupsw = new String (request.getParameter("stupsw"));
- System.out.println (couname);
- couname=couname.trim();
- System.out.println (couname);
- couname=trans(couname);
- System.out.println (couname);
- teaname= teaname.trim();
- teaname= trans(teaname);
- String teaid = new String();
- String couid = new String();
- String sql = "select couid,couname from course where couname = '"+couname+"'";
- ResultSet rs = subject.executeQuery(sql);
- while(rs.next())
- {
- couid = rs.getString("couid");
- }
- rs.close();
- String sql2= "select teaid,teaname from teacher where teaname = '"+teaname+"'";
- ResultSet rs1 = subject.executeQuery(sql2);
- while(rs1.next())
- {
- teaid = rs1.getString("teaid");
- }
- rs1.close();
- System.out.println(couid);
- System.out.println(teaid);
- //String str = null;
- //String str2 = "";
- %>
- <% /*if (couid.trim().equals("")||couname.trim().equals("")||coumark.trim().equals(""))
- {response.sendRedirect("admincourseerr.htm");}*/
- String sql3 = "insert into tc(tcid, teaid, couid) values(" + id + ",'" + teaid + "','" + couid + "')";
- subject.executeUpdate(sql3);
- %>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <meta HTTP-EQUIV=REFRESH CONTENT="10; URL=admintc.jsp">
- <link href="_notes/aaa.css" rel="stylesheet" type="text/css">
- <style type="text/css">
- <!--
- @import url("_notes/ccc");
- body,td,th {
- font-size: 12px;
- color: #FFFFFF;
- font-weight: bold;
- }
- .style1 {color: #000000}
- -->
- </style>
- </HEAD>
- <BODY BGCOLOR=#0D85A6 BACKGROUND="images/bg.gif" >
- <div align="center">
- <p align="left"> <br>
- 课程分配成功,本页将于10秒内自动<a href="admintc.jsp" class="style1">返回前页</a></p>
- <p><br>
- <img src="images/qa.jpg" width="640" height="427"></p>
- </div>
- </BODY>
- </HTML>