📄 course.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="codeConvert.*"errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>提交毕业设计选题</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
background-image: url(image/bg_002.gif);
}
-->
</style></head>
<script language="JavaScript" type="text/JavaScript">
function checkSmall()
{
if (document.form2.coId.value=="")
{
alert("毕业设计课题号不能为空!");
document.form2.cId.focus();
return false;
}
else if (document.form2.coName.value=="")
{
alert("毕业设计课题名不能为空!");
document.form2.coName.focus();
return false;
}
else if (document.form2.credit.value=="")
{
alert("学分不能为空!");
document.form2.credit.focus();
return false;
}
else if (document.form2.period.value=="")
{
alert("学时不能为空!");
document.form2.period.focus();
return false;
}
else if (document.form2.cNumAll.value=="")
{
alert("可选人数不能为空!");
document.form2.cNumAll.focus();
return false;
}
}
</script>
<body>
<%
String loginNum=(String)session.getAttribute("lnum");
String name=(String)session.getAttribute("name");
session.setAttribute("lnum",loginNum);
session.setAttribute("name",name);
String tId=null;
if(loginNum.equals("2"))
{
%>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><br>
<form name="form2" method="post" action="course.jsp" onsubmit="return checkSmall()">
<table width="350" border="0" align="center" cellpadding="0" cellspacing="2" class="border">
<tr bgcolor="#999999" class="title">
<td height="25" colspan="2" align="center"><strong>提交毕业设计课题</strong></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>所属院系:</strong></div></td>
<td width="218" bgcolor="#E3E3E3">
<div align="left">
<select name="depName">
<%
try{
Connection connd=null;
Statement stmtd=null;
ResultSet rsd=null;
String dName=null;
String dId=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connd=DriverManager.getConnection("jdbc:odbc:xk","sa","");
String sqld="select * from department";
stmtd=connd.createStatement();
rsd=stmtd.executeQuery(sqld);
CodeConvert cc = new CodeConvert();
while(rsd.next())
{
dId=rsd.getString("dId");
dName=rsd.getString("dName");
out.print("<option value='"+dId+"'>"+dName+"</option>");
}
rsd.close();connd.close();stmtd.close();}
catch(Exception e){out.print(e);}
%>
</select>
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>课题号:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<input name="coId" type="text" id="coId" size="20" maxlength="30">
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>课题名:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<input name="coName" type="text" id="coName" size="20" maxlength="30">
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>教师:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<select name="tId" id="tId">
<%
try{
Connection connd=null;
Statement stmtd=null;
ResultSet rsd=null;
String tName=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connd=DriverManager.getConnection("jdbc:odbc:xk","sa","");
String sqlt="select tId,tName from teacher where tId='"+name+"'";
stmtd=connd.createStatement();
rsd=stmtd.executeQuery(sqlt);
while(rsd.next())
{
tId=rsd.getString("tId");
tName=rsd.getString("tName");
out.print("<option value='"+tId+"'>"+tName+"</option>");
}
rsd.close();connd.close();stmtd.close();}
catch(Exception e){out.print(e);}
%>
</select>
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>学分:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<input name="credit" type="text" id="credit" size="20" maxlength="30">
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>学时:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<input name="period" type="text" id="period" size="20" maxlength="30">
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>具体时间:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<input name="cTime" type="text" id="cTime" size="20" maxlength="30">
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>指导地点:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<input name="cPlace" type="text" id="cPlace" size="20" maxlength="30">
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>可选人数:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<input name="cNumAll" type="text" id="cNumAll" size="20" maxlength="30">
</div></td>
</tr>
<tr class="tdbg">
<td width="126" height="22" bgcolor="#C0C0C0"><div align="left"><strong>课题简介:</strong></div></td>
<td bgcolor="#E3E3E3">
<div align="left">
<TEXTAREA class=textarea id=intro name=intro rows=5
cols=30></TEXTAREA>
</div></td>
</tr>
<tr class="tdbg">
<td height="22" align="center" bgcolor="#C0C0C0"> </td>
<td height="22" align="center" bgcolor="#E3E3E3">
<div align="left">
<input name="Add" type="submit" value=" 添 加 ">
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
<%
if(request.getParameter("coId")!=null)
{
String coId=(String)request.getParameter("coId");
String d=(String)request.getParameter("depName");
byte[] tempname;
tempname=request.getParameter("coName").getBytes("ISO-8859-1");
String coName= new String(tempname);
tId=(String)request.getParameter("tId");
float credit=0;
if(request.getParameter("credit")!=null&&request.getParameter("credit")!="")
{
credit=Float.parseFloat(request.getParameter("credit"));
}
float period=0;
if(request.getParameter("period")!=null&&request.getParameter("period")!="")
period=Float.parseFloat(request.getParameter("period"));
byte[] temptime;
temptime=request.getParameter("cTime").getBytes("ISO-8859-1");
String cTime= new String(temptime);
String cPlace=(String)request.getParameter("cPlace");
int cNumAll=0;
if(request.getParameter("cNumAll")!=null&&request.getParameter("cNumAll")!="")
cNumAll=Integer.parseInt(request.getParameter("cNumAll"));
CodeConvert cc = new CodeConvert();
String intro=cc.native2unicode(request.getParameter("intro"));
Connection conn=null;
Statement stmt=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:xk","sa","");
String sql="insert into course(coId,coName,tId,credit,period,cTime,cPlace,cNumAll,dId,cIntro) values('"+coId+"','"+coName+"','"+tId+"','"+credit+"','"+period+"','"+cTime+"','"+cPlace+"','"+cNumAll+"','"+d+"','"+intro+"')";
stmt=conn.createStatement();
stmt.executeUpdate(sql);
response.sendRedirect("course.jsp");
}
catch(Exception e){out.print(e);out.println("输入有误");out.print("<a href=course.jsp>课程提交页面</a>");
}
}}
else
{out.println("请先登陆.....");
out.print("<a href=../index.jsp>登陆页面</a>");
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -