Course.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:5k
- package StudyCourse;
- import java.util.*;
- import java.sql.ResultSet;
- public class Course{
-
- protected int id;
- protected String classNo ;
- protected String courseName;
- protected String place;
- protected String time;
- protected String detail ;
- protected String condition;
- protected int price;
- protected int courseTypeId ;
-
- public Course(){ }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public int getId(){
- return id;
- }
-
- public void setClassNo(String classNo) {
- this.classNo = classNo;
- }
-
- public String getClassNo(){
- return classNo;
- }
-
- public void setCourseName(String courseName) {
- this.courseName = courseName;
- }
-
- public String getCourseName(){
- return courseName;
- }
-
- public void setPlace(String place) {
- this.place = place;
- }
-
- public String getPlace(){
- return place;
- }
-
- public void setTime(String time) {
- this.time = time;
- }
-
- public String getTime(){
- return time;
- }
-
- public void setDetail(String detail) {
- this.detail = detail;
- }
-
- public String getDetail(){
- return detail;
- }
-
- public void setCondition(String condition) {
- this.condition = condition;
- }
-
- public String getCondition(){
- return condition;
- }
-
- public void setPrice(int price) {
- this.price = price;
- }
-
- public int getPrice(){
- return price;
- }
-
- public void setCourseTypeId(int courseTypeId) {
- this.courseTypeId = courseTypeId;
- }
-
- public int getCourseTypeId(){
- return courseTypeId;
- }
-
- /* public boolean Insert(DB db) throws Exception{
- String strSql;
- ResultSet rs;
- int iMaxId;
- strSql = "Select max(id) From news";
- rs = db.OpenSql(strSql);
- if ( rs.next()) {
- iMaxId=rs.getInt(1)+1;
- }
- else{
- iMaxId=1;
- }
-
- strSql = "insert into news values("
- + iMaxId +",'"
- + title +"','"
- + content +"','"
- + author +"',sysdate,'"
- + keyword +"')";
- if ( db.ExecSql(strSql)==0) {
- return false;
- }
- else{
- return true;
- }
-
- }
-
- public boolean Edit(DB db) throws Exception{
- String strSql;
- strSql = "update news set title='"+title+"',"
- + " content='"+ content +"',"
- + " author='"+ author +"',"
- + " keyword='"+ keyword +"'"
- + " where id="+id;
- if ( db.ExecSql(strSql)==0) {
- return false;
- }
- else{
- return true;
- }
- }
- */
- public static Vector SearchCourse(DB db,int courseType,String field,String keyword) throws Exception{
- Vector courseList = new Vector();
- ResultSet rs,rsNest;
- String strSql=null;
- String sField=null;
-
- if (courseType==0 ) {
- strSql = "select * from course where 1=1 ";
- }
- else{
- strSql = "select * from course where coursetypeid=" + courseType;
- }
-
- if (keyword==null||keyword==""){
- strSql = strSql + " order by classno";
- }
- else{
- if (field.equals("1")) sField="classno";
- else if(field.equals("2")) sField="coursename";
- else if(field.equals("3")) sField="place";
-
- strSql = strSql + " and " + sField +" like '%" + keyword +"%' order by classno";
- }
-
- rs = db.OpenSql(strSql);
-
- while (rs.next()){
- Course course = new Course();
-
- course.setId(rs.getInt("id")) ;
- course.setClassNo(rs.getString("classno")) ;
- course.setCourseName(rs.getString("coursename")) ;
- course.setPrice(rs.getInt("price")) ;
- course.setPlace(rs.getString("place")) ;
- course.setTime(rs.getString("time")) ;
-
- courseList.add(course);
- }
- System.out.println("courseList: "+courseList.size());
-
- return courseList;
- }
-
- /* public static Vector SearchRelativeNews(DB db,int newsId,String keyword) throws Exception{
- Vector newsList = new Vector();
- ResultSet rs,rsNest;
- String strSql=null;
-
- strSql = "select * from news where id<>" + newsId +" and title like '%"
- + keyword + "%' order by time desc";
- rs = db.OpenSql(strSql);
-
- while (rs.next()){
- News news = new News();
-
- news.setId(rs.getInt("id")) ;
- news.setTitle(rs.getString("title")) ;
- news.setTime(rs.getString("time")) ;
-
- newsList.add(news);
- }
- System.out.println("newsList: "+newsList.size());
-
- return newsList;
- }
- */
- public static Course GetDetail(DB db,int courseId) throws Exception{
- ResultSet rs,rsNest;
- String strSql=null;
- String rplContent=null;
-
- strSql = "select * from course where id=" + courseId;
- rs = db.OpenSql(strSql);
- Course course = new Course();
- if (rs.next()){
-
- course.setId(rs.getInt("id")) ;
- course.setClassNo(rs.getString("classno")) ;
- course.setCourseName(rs.getString("coursename")) ;
- course.setPrice(rs.getInt("price")) ;
- course.setPlace(rs.getString("place")) ;
-
- rplContent = rs.getString("detail");
- rplContent = rplContent.replaceAll("n","<br>");
-
- course.setDetail(rplContent) ;
- course.setTime(rs.getString("time")) ;
- course.setCondition(rs.getString("condition")) ;
- }
- return course;
- }
-
- /* public static boolean Delete(DB db,int newsId) throws Exception{
- String strSql;
- strSql = "delete from news where id='"+newsId+"'";
- if ( db.ExecSql(strSql)==0) {
- return false;
- }
- else{
- return true;
- }
- }
- */
- }