package sms.bean;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import javax.servlet.jsp.tagext.TryCatchFinally;
import sms.db.DBAccess;
public class CourseBean implements Serializable {
public ArrayList queryByCourseId(String courseType, String term,
String courseId) {
String sql = "select a.course_id,a.course_name,a.type,b.name teachername,b.id "
+ "teacher_id,a.term,a.week,a.period,a.begintime,a.endtime,a.classroom,"
+ "a.description from course_info a,teach_info b where a.teach_id=b.id";
if (courseId != null) {
sql += " and a.course_id='" + courseId + "'";
}
if (courseType != null) {
sql += " and a.type='" + courseType + "'";
}
if (term != null) {
sql += " and a.term=" + term;
}
sql += " order by a.course_id";
DBAccess dba = new DBAccess();
try {
dba.getConnection();
ArrayList arrayList = new ArrayList();
ResultSet rs = null;
rs = dba.query(sql);
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
arrayList.add(courseBean);
}
return arrayList;
}
} catch (SQLException ex) {
return null;
} finally {
dba.closeConnection();
}
return null;
}
public Hashtable queryCourseScheme(String classId, String studentId,
String term) {
String sql = "select a.course_id,a.course_name,a.type,b.name teachername,"
+ "b.id teacher_id,a.term,a.week,a.period,a.begintime,a.endtime,a.classroom,"
+ "a.description from course_info a,teach_info b,selective_course_scheme c"
+ " where a.type!='A' and a.teach_id=b.id and a.course_id=c.course_id and a.term="
+ term + " and c.stu_id=" + studentId;
// 此SQL语句从course_info得到非必修课的信息
String sql2 = "select a.course_id,a.course_name,a.type,b.name teachername,"
+ "a.teach_id teacher_id,a.term,a.week,a.period,a.begintime,a.endtime, "
+ "a.classroom, a.description from course_info a,teach_info b,"
+ "required_course_scheme c where a.type='A' and a.teach_id=b.id and "
+ "a.course_id=c.course_id "
+ "and a.term="
+ term
+ " and c.class_id=" + classId;
// 此SQL语句从course_info得到必修课的信息
DBAccess dba = new DBAccess();
try {
dba.getConnection();
Hashtable courseHTable = new Hashtable();
ResultSet rs = null;
rs = dba.query(sql);
String key = null;
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
key = rs.getString("week").trim() + "-"
+ rs.getString("period").trim();
courseHTable.put(key, courseBean);
}
}
rs = null;
rs = dba.query(sql2);
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
key = rs.getString("week").trim() + "-"
+ rs.getString("period").trim();
courseHTable.put(key, courseBean);
}
return courseHTable;
}
} catch (SQLException ex) {
return null;
} finally {
dba.closeConnection();
}
return null;
}
@SuppressWarnings("unchecked")
public List queryCanChooseCourse(String term, String week, String period) {
List result = new ArrayList();
String sql = String.format("select * from course_info where term = %d and week = %d and period = %d", Integer.valueOf(term),
Integer.valueOf(week), Integer.valueOf(period));
DBAccess dba = new DBAccess();
try {
dba.getConnection();
ResultSet rs = dba.query(sql);
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
result.add(courseBean);
}
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
dba.closeConnection();
}
return result;
}
public Integer getBeginTime() {
return beginTime;
}
public void setBeginTime(Integer beginTime) {
this.beginTime = beginTime;
}
public Integer getEndTime() {
return endTime;
}
public void setEndTime(Integer endTime) {
this.endTime = endTime;
}
public Integer getPeriod() {
return period;
}
public void setPeriod(Integer period) {
this.period = period;
}
public Integer getTerm() {
return term;
}
public void setTerm(Integer term) {
this.term = term;
}
public Integer getWeek() {
return week;
}
public void setWeek(Integer week) {
this.week = week;
}
public String getClassRoom() {
return classRoom;
}
public void setClassRoom(String classRoom) {
this.classRoom = classRoom;
}
public String getCourseId() {
return courseId;
}
public void setCourseId(String courseId) {
this.courseId = courseId;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public String getCourseType() {
return courseType;
}
public void setCourseType(String courseType) {
this.courseType = courseType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getTeacherName() {
return teacherName;
}
public void setTeacherName(String teacherName) {
this.teacherName = teacher
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Java学习宝典.rar (93个子文件)
source
ch20
TestFilterServlet.java 2KB
TestListener.java 714B
TestFilter.java 2KB
ch21
sql
ch21
CREATE-student_info.sql 963B
CREATE-college_info.sql 258B
CREATE-selective_course_scheme.sql 556B
CREATE-teach_info.sql 442B
CREATE-course_info.sql 700B
CREATE-required_course_scheme.sql 421B
src
sms
db
DBAccess.java 6KB
bean
TeacherBean.java 2KB
CourseBean.java 8KB
StudentBean.java 6KB
CourseSchemeBean.java 3KB
WebRoot
WEB-INF
viewCourse.jsp 4KB
viewTeacherInfo.jsp 2KB
chooseCourse.jsp 3KB
login.jsp 2KB
ch24
Pre_Radium2.rar 14.03MB
pre_radium.sql 8KB
ch18
date.jsp 234B
requestMethodTest.jsp 2KB
form.jsp 509B
include.jsp 372B
ch18_2_4_01.jsp 600B
responseRedirect.jsp 924B
jspStruct.jsp 575B
outTest.jsp 498B
main.jsp 432B
applicationTest.jsp 852B
ch18_2_5_01.jsp 204B
sessionTest.jsp 204B
sessionCounter.jsp 353B
cookieTest.jsp 988B
pageContextTest.jsp 1KB
responseTest.jsp 585B
jspStruct_jsp.java 3KB
ch22
src
database
DBsource.java 348B
BaseDAO.java 3KB
access
PowerAccess.java 2KB
servlet
AddItemToCartServlet.java 2KB
CheckServlet.java 2KB
bean
Order.java 4KB
Item.java 2KB
CarItem.java 424B
Proitem.java 650B
Account.java 2KB
SignOn.java 501B
LineItem.java 877B
Category.java 651B
Supplier.java 1KB
Cart.java 2KB
OrderStatus.java 552B
Inventory.java 334B
WebRoot
categoryList.jsp 837B
WEB-INF
web.xml 2KB
item.jsp 2KB
index.jsp 998B
cart.jsp 3KB
product.jsp 1KB
category.jsp 325B
ch25
boronold.sql 83KB
BoronOld2.rar 16.81MB
ch17
WEB-INF
web.xml 3KB
fail.html 405B
src
servlet
HelloUserServlet.java 2KB
FontServlet.java 1KB
LoginServlet.java 924B
RequestInfoServlet.java 3KB
HelloServlet.java 1KB
CounterSessionServlet.java 2KB
CookieCounterServlet.java 2KB
ContextServlet.java 1KB
login.html 869B
success.html 389B
ch19
buyBook1.jsp 2KB
deleteGoods.jsp 605B
GuessGame.java 1KB
minusGoods.jsp 611B
buyBook2.jsp 4KB
Counter.java 375B
Alden1.java 464B
guessGame.jsp 945B
BuyCar.java 1KB
Alden2.java 661B
buyBook3.jsp 4KB
CounterBean.java 219B
online.jsp 481B
Cart.java 1KB
Alden3.java 2KB
ch16
helloworld.jsp 854B
ch23
MyBBS.rar 939KB
bbs.sql 3KB
共 93 条
- 1
资源评论
- yunlvrensheng2015-05-20真心有用的代码,感谢分享者!
- sinat_150799092014-06-19第21,22章代码不全
- qq_284296532015-05-23第二十一章代码还是不全,真坑。。。。。
xiaoyuwl_2011
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功