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

📄 viewcourse.jsp

📁 学生信息管理系统 jsp + sql + javabean 实现
💻 JSP
字号:
<%@page contentType="text/html; charset=gb2312" errorPage=""%>
<%@page import="java.sql.*,sms.db.*,sms.bean.*,java.util.*"%>
<%!
  private String isSelected(String value1, String value2) {
    if (value1 != null && value2 != null && value1.equals(value2))
      return "selected";
    else
      return "";
  }
  private String isChecked(String value1, String value2) {
    if (value1 != null && value2 != null && value1.equals(value2))
      return "checked";
    else
      return "";
  }
%>
<%
  request.setCharacterEncoding("gb2312");
  CourseBean courseBean =  new CourseBean();
  //以下是得到页面的参数
  String commitFlag = (String) request.getParameter("queryButton");//得到按钮事件
  String term = request.getParameter("term");
  String courseType = request.getParameter("courseType");
  String courseInfo = request.getParameter("courseInfo");
  String queryType = request.getParameter("RadioGCourseInfo");
  ArrayList courseList = null;
  if (term != null && term.equals("all")) {
    term = null;
  }
  if (courseType != null && courseType.equals("all")) {
    courseType = null;
  }
  if(queryType == null || queryType.equals("")){
    queryType = "1";
  }
  if (courseInfo != null && courseInfo.length() > 0) {
    //以下是根据选择了不同的单选按钮来调用不同的方法来查询课程信息
    if (queryType != null && queryType.equals("1")) {//按照课程编号来查询
      courseList = courseBean.queryByCourseId(courseType, term, courseInfo);
    }
    else if (queryType != null && queryType.equals("2")) {//按照课程名来查询
      courseList = courseBean.queryByName(courseType, term, courseInfo);
    }
    else if (queryType != null && queryType.equals("3")) {//按照课程名模糊查询
      courseList = courseBean.queryByNameImprecise(courseType, term, courseInfo);
    }
  }
  else {
    courseList = courseBean.queryByCourseId(courseType, term, null);
  }
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查看课程信息</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
  <!--
    body {
	background-color: #CCCCCC;
	margin-top: 0px;
	margin-bottom: 0px;
    }
  -->
</style>
</head>
<body>
<table width="99%" border="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="20" bgcolor="#999999">
      <form name="form1" method="post" action="viewCourse.jsp">
      <table width="100%" border="0">
        <tr>
          <td width="17%" height="58"> 
            学期
              <select name="term">
              <option id="0" value="all">所有学期</option>
              <option id="1" value="1">第1学期</option>
              <option id="2" value="2">第2学期</option>
              <option id="3" value="3">第3学期</option>
              <option id="4" value="4">第4学期</option>
              <option id="5" value="5">第5学期</option>
              <option id="6" value="6">第6学期</option>
              <option id="7" value="7">第7学期</option>
              <option id="8" value="8">第8学期</option>
            </select>
          </td>
          <td width="21%">课程类型
            <select name="courseType">
              <option id="0" value="all">所有课程</option>
              <option id="1" value="A">A类课程</option>
              <option id="2" value="B">B类课程</option>
              <option id="3" value="C">C类课程</option>
            </select>
          </td>
          <td width="25%">            课程信息:
            <input name="courseInfo" type="text" class="text1" value="<%=courseInfo==null?"":courseInfo%>">
          </td>
          <td width="27%">
            <table width="100%" border="0">
              <tr>
                <td width="12%">
                  <input type="radio" name="RadioGCourseInfo" value="1">
                </td>
                <td width="88%">课程号</td>
              </tr>
              <tr>
                <td>
                  <input type="radio" name="RadioGCourseInfo" value="2">
                </td>
                <td>课程名精确查询</td>
              </tr>
              <tr>
                <td>
                  <input type="radio" name="RadioGCourseInfo" value="3">
                </td>
                <td>课程名模糊查询</td>
              </tr>
            </table>
          </td>
          <td width="10%">
            <input name="queryButton" type="submit" class="button1" value="查询">
          </td>
        </tr>
      </table>
      </form>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="380" valign="top">
    <%
      if (courseList != null && courseList.size() > 0) {
        CourseBean courseBean2 = null;
        Iterator it = courseList.iterator();
        String temp = "";
        String temp2 = "";
        while (it.hasNext()) {
          courseBean2 = (CourseBean) it.next();
          temp = String.valueOf(courseBean2.getBeginTime()) + "-" + String.valueOf(courseBean2.getEndTime()) + "周";
          temp2 = "周" + courseBean2.getWeek() + "," + String.valueOf((courseBean2.getPeriod() * 2) - 1) + "-" + String.valueOf(courseBean2.getPeriod() * 2) + "节";
    %>
      <table width="100%" border="1" bordercolorlight=#C1A4F4 borderColorDark=#ffffff cellPadding=0 cellSpacing=0>
        <tr>
          <th width="9%" scope="col">课程号</th>
          <th width="22%" scope="col">课程名</th>
          <th width="13%" scope="col">主讲教师</th>
          <th width="8%" scope="col">类型</th>
          <th width="15%" scope="col">上课时间</th>
          <th width="14%" scope="col">时间(周)</th>
          <th width="11%" scope="col">上课地点</th>
          <th width="8%" scope="col">学期</th>
        </tr>
        <tr>
          <th scope="row"><%=courseBean2.getCourseId()%>          </th>
          <td align="center"><%=courseBean2.getCourseName()%>          </td>
          <td align="center"><a href="viewTeacherInfo.jsp?teacherId=<%=courseBean2.getTeacherId()%>"><%=courseBean2.getTeacherName()%>          </td>
          <td align="center"><%=courseBean2.getCourseType()%>          </td>
          <td align="center"><%=temp2%>          </td>
          <td align="center"><%=temp%>          </td>
          <td align="center"><%=courseBean2.getClassRoom()%>          </td>
          <td align="center"><%=courseBean2.getTerm()%>          </td>
        </tr>
        <tr>
          <th height="27" scope="row">课程描述</th>
          <td colspan="7">&nbsp;&nbsp;<%=courseBean2.getDescription()%></td>
        </tr>
      </table>
	  &nbsp;
<%
      }
          }else{
%>
<script language="javascript" type="">
    alert('没有该课程信息!');
    </script>
<%
          }
%>
    </td>
  </tr>
  <tr>
    <td height="27">&nbsp;</td>
  </tr>
</table>
</body>
</html>

⌨️ 快捷键说明

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