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

📄 choosecourse.jsp

📁 学生信息管理系统简单实现 可以简单得实现现阶段学生信息得增加 修改 删除 查看
💻 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");
  String chooseCourseFlag = request.getParameter("chooseButton");
  String term = request.getParameter("term");
  String week = request.getParameter("week");
  String period = request.getParameter("period");
  CourseBean courseBean = new CourseBean();
  if (term != null && term.equals("0")) {
    term = null;
  }
  if (week != null && week.equals("0")) {
    week = null;
  }
  if (period != null && period.equals("0")) {
    period = null;
  }
  ArrayList courseList = courseBean.queryCanChooseCourse(term, week, period);//查询可选课程
  if(chooseCourseFlag != null){
    String id = request.getParameter("selectedCourseId");
    if(id == null || id.equals("")){//如果没有在左侧的单选按钮处选择一门课程,给出提示
%>
 <script language="javascript" type="">
    alert('请您选择一门课程!');
 </script>
<%
    }else{
    StudentBean studentBean = (StudentBean)session.getAttribute("studentBean");//从session中得到登录信息
    if(studentBean != null && studentBean.getStudentId() != null){//如果学生已经登录,从session中取得学生编号
      CourseSchemeBean courseSchemeBean = new CourseSchemeBean();
      int flag = courseSchemeBean.chooseCourse(id,studentBean.getStudentId(),studentBean.getClassId());
      if(flag == -3){//已经选修了此课程
%>
 <script language="javascript" type="">
    alert('该时间有必修课!');
 </script>
<%
      }else if(flag == 0){//已经选修了此课程
%>
 <script language="javascript" type="">
    alert('您已经选择了该课程!');
 </script>
<%
      }else if(flag == 1){//选课成功
%>
 <script language="javascript" type="">
    alert('选课成功!');
 </script>
<%
      }else{//选课失败
%>
 <script language="javascript" type="">
    alert('选课失败!');
 </script>
<%
      }
    }else{//如果学生还未登录,转发到登录页面
      RequestDispatcher dispatcher = request.getRequestDispatcher("/login.jsp");
      dispatcher.forward(request,response);
    }
  }
  }
%>
<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;
    }
  -->
</style>
</head>
<body>
<form name="form1" method="post" action="chooseCourse.jsp">
<table width="100%" border="0">
  <tr>
    <td height="30" valign="top" bgcolor="#999999">
      <table width="100%">
        <tr>
          <td width="25%" height="31" align="center">            第
            <select name="term">
              <option id="0" value="0">全部学期</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="18%">            星期
            <select name="week">
              <option id="0" value="0">全部</option>
              <option id="1" value="1">一</option>
              <option id="2" value="2">二</option>
              <option id="3" value="3">三</option>
              <option id="4" value="4">四</option>
              <option id="5" value="5">五</option>
            </select>
          </td>
          <td width="24%">            第
            <select name="period">
              <option id="0" value="0">全部</option>
              <option id="1" value="1">1-2</option>
              <option id="2" value="2">3-4</option>
              <option id="3" value="3">5-6</option>
              <option id="4" value="4">7-8</option>
              <option id="5" value="5">9-10</option>
            </select>
          </td>
          <td width="15%">&nbsp;          </td>
          <td width="18%">
            <input type="submit" name="queryButton" value="查询">
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td valign="top">
      <table width="100%" border="1" bordercolorlight=#C1A4F4 borderColorDark=#ffffff cellPadding=0 cellSpacing=0>
        <tr>
          <th width="7%" scope="col">选择</th>
          <th width="8%" scope="col">课程号</th>
          <th width="21%" scope="col">课程名</th>
          <th width="6%" scope="col">类型</th>
          <th width="11%" scope="col">教师</th>
          <th width="19%" scope="col">上课时间</th>
          <th width="8%" scope="col">教室</th>
          <th width="20%" scope="col">课程描述</th>
        </tr>
      <%
        if (courseList != null && courseList.size() > 0) {
          CourseBean courseBean3 = null;
          Iterator it = courseList.iterator();
          String temp = "";
          String temp2 = "";
          while (it.hasNext()) {
            courseBean3 = (CourseBean) it.next();
            temp = String.valueOf(courseBean3.getBeginTime()) + "-" + String.valueOf(courseBean3.getEndTime()) + "周,周";
            temp2 = String.valueOf((courseBean3.getPeriod() * 2) - 1) + "-" + String.valueOf(courseBean3.getPeriod() * 2);
            temp += courseBean3.getWeek();
            temp += ",第";
            temp += temp2;
            temp += "节";
      %>
        <tr>
          <td align="center">
            <input type="radio" name="selectedCourseId" value="<%=courseBean3.getCourseId()%>">
          </td>
          <td align="center"><%=courseBean3.getCourseId()%>          </td>
          <td align="center"><%=courseBean3.getCourseName()%>          </td>
          <td align="center"><%=courseBean3.getCourseType()%>          </td>
          <td align="center"><%=courseBean3.getTeacherName()%>          </td>
          <td align="center"><%=temp%>          </td>
          <td align="center"><%=courseBean3.getClassRoom()%>          </td>
          <td align="center"><%=courseBean3.getDescription()%>          </td>
        </tr>
      <%
        }
            }
      %>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <input type="submit" name="chooseButton" value="选课">
    </td>

  <tr>
    <td>
      <font size="2" face="宋体" color="#ff0000"><%=((String)request.getAttribute("noSelectARowMessege"))==null?"":(String)request.getAttribute("noSelectARowMessege")%>      </font>
    </td>
  </tr>
</table>
</form>
</body>
</html>

⌨️ 快捷键说明

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