update,
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class AdminBean implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String fname;
|
||||
private String lname;
|
||||
private String gender;
|
||||
private String email;
|
||||
private String birthday;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFname() {
|
||||
return fname;
|
||||
}
|
||||
|
||||
public void setFname(String fname) {
|
||||
this.fname = fname;
|
||||
}
|
||||
|
||||
public String getLname() {
|
||||
return lname;
|
||||
}
|
||||
|
||||
public void setLname(String lname) {
|
||||
this.lname = lname;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return fname + " " + lname;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class AttendBean implements Serializable {
|
||||
private String id;
|
||||
private boolean attend;
|
||||
private String date;
|
||||
private StudentBean stBean;
|
||||
|
||||
public AttendBean() {
|
||||
stBean = new StudentBean();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isAttend() {
|
||||
return attend;
|
||||
}
|
||||
|
||||
public void setAttend(boolean attend) {
|
||||
this.attend = attend;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public StudentBean getStBean() {
|
||||
return stBean;
|
||||
}
|
||||
|
||||
public void setStBean(StudentBean stBean) {
|
||||
this.stBean = stBean;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class ClassBean implements Serializable{
|
||||
|
||||
private String id;
|
||||
private String className;
|
||||
private String year;
|
||||
private double attendanceTargetId;
|
||||
private TeacherBean teacherBean;
|
||||
|
||||
public ClassBean() {
|
||||
teacherBean = new TeacherBean();
|
||||
}
|
||||
|
||||
public TeacherBean getTeacherBean() {
|
||||
return teacherBean;
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(String year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public double getAttendanceTargetId() {
|
||||
return attendanceTargetId;
|
||||
}
|
||||
|
||||
public void setAttendanceTargetId(double attendanceTargetId) {
|
||||
this.attendanceTargetId = attendanceTargetId;
|
||||
}
|
||||
|
||||
|
||||
public void setTeacherBean(TeacherBean teacherBean) {
|
||||
this.teacherBean = teacherBean;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class ClassYearBean implements Serializable{
|
||||
private String id;
|
||||
private String year;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(String year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class LectureBean implements Serializable{
|
||||
|
||||
private String id;
|
||||
private String lecture;
|
||||
private String description;
|
||||
private String className;
|
||||
private LectureTimeBean time;
|
||||
private LectureDayBean day;
|
||||
private String room;
|
||||
private String teacherId;
|
||||
|
||||
public LectureBean() {
|
||||
time = new LectureTimeBean();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLecture() {
|
||||
return lecture;
|
||||
}
|
||||
|
||||
public void setLecture(String lecture) {
|
||||
this.lecture = lecture;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public LectureTimeBean getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(LectureTimeBean time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public LectureDayBean getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public void setDay(LectureDayBean day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(String room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public String getTeacherId() {
|
||||
return teacherId;
|
||||
}
|
||||
|
||||
public void setTeacherId(String teacherId) {
|
||||
this.teacherId = teacherId;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class LectureDayBean implements Serializable{
|
||||
private String id;
|
||||
private String day;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public void setDay(String day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class LectureTimeBean implements Serializable{
|
||||
private String id;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private boolean fullweek;
|
||||
|
||||
public boolean isFullweek() {
|
||||
return fullweek;
|
||||
}
|
||||
|
||||
public void setFullweek(boolean fullweek) {
|
||||
this.fullweek = fullweek;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jerrykwok
|
||||
*/
|
||||
public class LoginBean implements Serializable{
|
||||
|
||||
private String fname;
|
||||
private String lname;
|
||||
private String username;
|
||||
private String password;
|
||||
private String role;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getFname() {
|
||||
return fname;
|
||||
}
|
||||
|
||||
public void setFname(String fname) {
|
||||
this.fname = fname;
|
||||
}
|
||||
|
||||
public String getLname() {
|
||||
return lname;
|
||||
}
|
||||
|
||||
public void setLname(String lname) {
|
||||
this.lname = lname;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return fname + " " + lname;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class SchedulerBean implements Serializable{
|
||||
|
||||
private String id;
|
||||
private String title;
|
||||
private String description;
|
||||
private String start_date;
|
||||
private String end_date;
|
||||
private boolean holiday;
|
||||
private boolean schoolDay;
|
||||
private int start_day_week;
|
||||
private int end_date_week;
|
||||
private int countDate;
|
||||
private int countBusineseDay;
|
||||
|
||||
public int getCountBusineseDay() {
|
||||
return countBusineseDay;
|
||||
}
|
||||
|
||||
public void setCountBusineseDay(int countBusineseDay) {
|
||||
this.countBusineseDay = countBusineseDay;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getStart_date() {
|
||||
return start_date;
|
||||
}
|
||||
|
||||
public void setStart_date(String start_date) {
|
||||
this.start_date = start_date;
|
||||
}
|
||||
|
||||
public String getEnd_date() {
|
||||
return end_date;
|
||||
}
|
||||
|
||||
public void setEnd_date(String end_date) {
|
||||
this.end_date = end_date;
|
||||
}
|
||||
|
||||
public int getStart_date_Day() {
|
||||
return Integer.parseInt(start_date.substring(8));
|
||||
}
|
||||
|
||||
public int getEnd_date_Day() {
|
||||
return Integer.parseInt(end_date.substring(8));
|
||||
}
|
||||
|
||||
public boolean isHoliday() {
|
||||
return holiday;
|
||||
}
|
||||
|
||||
public void setHoliday(boolean holiday) {
|
||||
this.holiday = holiday;
|
||||
}
|
||||
|
||||
public boolean isSchoolDay() {
|
||||
return schoolDay;
|
||||
}
|
||||
|
||||
public void setSchoolDay(boolean schoolDay) {
|
||||
this.schoolDay = schoolDay;
|
||||
}
|
||||
|
||||
public int getStart_day_week() {
|
||||
return start_day_week;
|
||||
}
|
||||
|
||||
public void setStart_day_week(int start_day_week) {
|
||||
this.start_day_week = start_day_week;
|
||||
}
|
||||
|
||||
public int getEnd_date_week() {
|
||||
return end_date_week;
|
||||
}
|
||||
|
||||
public void setEnd_date_week(int end_date_week) {
|
||||
this.end_date_week = end_date_week;
|
||||
}
|
||||
|
||||
public int getCountDate() {
|
||||
return countDate;
|
||||
}
|
||||
|
||||
public void setCountDate(int countDate) {
|
||||
this.countDate = countDate;
|
||||
}
|
||||
|
||||
public String getStart_day_Date() {
|
||||
String[] start_dateArray = start_date.split("-");
|
||||
return start_dateArray[2];
|
||||
}
|
||||
|
||||
public String getStart_day_Month() {
|
||||
String[] start_dateArray = start_date.split("-");
|
||||
return start_dateArray[1];
|
||||
}
|
||||
|
||||
public String getStart_day_Year() {
|
||||
String[] start_dateArray = start_date.split("-");
|
||||
return start_dateArray[0];
|
||||
}
|
||||
|
||||
public String getEnd_day_Date() {
|
||||
String[] end_dateArray = end_date.split("-");
|
||||
return end_dateArray[2];
|
||||
}
|
||||
|
||||
public String getEnd_day_Month() {
|
||||
String[] end_dateArray = end_date.split("-");
|
||||
return end_dateArray[1];
|
||||
}
|
||||
|
||||
public String getEnd_day_Year() {
|
||||
String[] end_dateArray = end_date.split("-");
|
||||
return end_dateArray[0];
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class SearchBean implements Serializable{
|
||||
private String id;
|
||||
private String keyword;
|
||||
private int searchPage;
|
||||
private String staffId;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public int getSearchPage() {
|
||||
return searchPage;
|
||||
}
|
||||
|
||||
public void setSearchPage(int searchPage) {
|
||||
this.searchPage = searchPage;
|
||||
}
|
||||
|
||||
public String getStaffId() {
|
||||
return staffId;
|
||||
}
|
||||
|
||||
public void setStaffId(String staffId) {
|
||||
this.staffId = staffId;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class SemesterBean implements Serializable{
|
||||
private String year;
|
||||
private int term;
|
||||
private String start_date;
|
||||
private String end_date;
|
||||
private int countBusineseDate;
|
||||
|
||||
public int getCountBusineseDate() {
|
||||
return countBusineseDate;
|
||||
}
|
||||
|
||||
public void setCountBusineseDate(int countBusineseDate) {
|
||||
this.countBusineseDate = countBusineseDate;
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(String year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public int getTerm() {
|
||||
return term;
|
||||
}
|
||||
|
||||
public void setTerm(int term) {
|
||||
this.term = term;
|
||||
}
|
||||
|
||||
public String getStart_date() {
|
||||
return start_date;
|
||||
}
|
||||
|
||||
public void setStart_date(String start_date) {
|
||||
this.start_date = start_date;
|
||||
}
|
||||
|
||||
public String getEnd_date() {
|
||||
return end_date;
|
||||
}
|
||||
|
||||
public void setEnd_date(String end_date) {
|
||||
this.end_date = end_date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class StudentBean implements Serializable{
|
||||
private String id;
|
||||
private String fname;
|
||||
private String lname;
|
||||
private String gender;
|
||||
private String email;
|
||||
private String birthday;
|
||||
private int attendDay;
|
||||
private double attendRate;
|
||||
private String studentClassid;
|
||||
private ClassBean className;
|
||||
private ArrayList<AttendBean> attendList;
|
||||
|
||||
|
||||
public int getAttendDay() {
|
||||
return attendDay;
|
||||
}
|
||||
|
||||
public ClassBean getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public String getStudentClassid() {
|
||||
return studentClassid;
|
||||
}
|
||||
|
||||
public void setStudentClassid(String studentClassid) {
|
||||
this.studentClassid = studentClassid;
|
||||
}
|
||||
|
||||
|
||||
public void setClassName(ClassBean className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public void setAttendDay(int attendDay) {
|
||||
this.attendDay = attendDay;
|
||||
}
|
||||
|
||||
public double getAttendRate() {
|
||||
return attendRate;
|
||||
}
|
||||
|
||||
public void setAttendRate(double attendRate) {
|
||||
this.attendRate = attendRate;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFname() {
|
||||
return fname;
|
||||
}
|
||||
|
||||
public void setFname(String fname) {
|
||||
this.fname = fname;
|
||||
}
|
||||
|
||||
public String getLname() {
|
||||
return lname;
|
||||
}
|
||||
|
||||
public void setLname(String lname) {
|
||||
this.lname = lname;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return fname + " " + lname;
|
||||
}
|
||||
|
||||
public ArrayList<AttendBean> getAttendList() {
|
||||
return attendList;
|
||||
}
|
||||
|
||||
public void setAttendList(ArrayList<AttendBean> attendList) {
|
||||
this.attendList = attendList;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class TeacherBean implements Serializable{
|
||||
private String id;
|
||||
private String fname;
|
||||
private String lname;
|
||||
private String gender;
|
||||
private String email;
|
||||
private String birthday;
|
||||
private String title;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFname() {
|
||||
return fname;
|
||||
}
|
||||
|
||||
public void setFname(String fname) {
|
||||
this.fname = fname;
|
||||
}
|
||||
|
||||
public String getLname() {
|
||||
return lname;
|
||||
}
|
||||
|
||||
public void setLname(String lname) {
|
||||
this.lname = lname;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public String getTeacherFormalName() {
|
||||
if (gender.equals("M")) {
|
||||
return "Mr " + getName();
|
||||
} else {
|
||||
return "Miss " + getName();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return fname + " " + lname;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.db;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import system.bean.LoginBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jerrykwok
|
||||
*/
|
||||
public class LoginValid {
|
||||
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public LoginValid(String url, String username, String password) {
|
||||
this.url = url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Connection getConnection() throws SQLException, IOException {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return DriverManager.getConnection(url, username, password);
|
||||
}
|
||||
|
||||
public boolean validateStaffLogin(LoginBean loginBean, int title) {
|
||||
boolean isSuccess = false;
|
||||
Connection cnnct = null;
|
||||
PreparedStatement pStmnt = null;
|
||||
try {
|
||||
cnnct = getConnection();
|
||||
String preQueryStatement = "SELECT * FROM Teacher WHERE id=? and password=? AND title=?";
|
||||
pStmnt = cnnct.prepareStatement(preQueryStatement);
|
||||
pStmnt.setString(1, loginBean.getUsername());
|
||||
pStmnt.setString(2, loginBean.getPassword());
|
||||
pStmnt.setInt(3, title);
|
||||
ResultSet rs = pStmnt.executeQuery();
|
||||
if (rs.next()) {
|
||||
isSuccess = true;
|
||||
}
|
||||
pStmnt.close();
|
||||
cnnct.close();
|
||||
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
public boolean validateStudentLogin(LoginBean loginBean) {
|
||||
boolean isSuccess = false;
|
||||
Connection cnnct = null;
|
||||
PreparedStatement pStmnt = null;
|
||||
try {
|
||||
cnnct = getConnection();
|
||||
String preQueryStatement = "SELECT * FROM Student WHERE id=? and password=?";
|
||||
pStmnt = cnnct.prepareStatement(preQueryStatement);
|
||||
pStmnt.setString(1, loginBean.getUsername());
|
||||
pStmnt.setString(2, loginBean.getPassword());
|
||||
ResultSet rs = pStmnt.executeQuery();
|
||||
if (rs.next()) {
|
||||
isSuccess = true;
|
||||
}
|
||||
pStmnt.close();
|
||||
cnnct.close();
|
||||
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
}
|
@@ -0,0 +1,628 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.db;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import system.bean.AttendBean;
|
||||
import system.bean.ClassBean;
|
||||
import system.bean.LectureBean;
|
||||
import system.bean.LectureDayBean;
|
||||
import system.bean.LectureTimeBean;
|
||||
import system.bean.SchedulerBean;
|
||||
import system.bean.SemesterBean;
|
||||
import system.bean.StudentBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jerrykwok
|
||||
*/
|
||||
public class StudentDB {
|
||||
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
private String studentId;
|
||||
|
||||
public StudentDB(String url, String username, String password) {
|
||||
this.url = url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setStudentId(String teacherId) {
|
||||
this.studentId = studentId;
|
||||
}
|
||||
|
||||
public Connection getConnection() throws SQLException, IOException {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return DriverManager.getConnection(url, username, password);
|
||||
}
|
||||
|
||||
public int getCountClass() {
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT COUNT(*) FROM lecture WHERE studentId = ?";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, studentId);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
return result.getInt(1);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getCountStudent() {
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT COUNT(DISTINCT studentId) FROM studentClass, class, lecture WHERE studentclass.classId = class.id AND class.id = lecture.classId AND lecture.teacherId = ?";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, studentId);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
return result.getInt(1);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ArrayList<ClassBean> getAllClass() {
|
||||
ArrayList<ClassBean> classList = new ArrayList<ClassBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT class.*, teacher.fname, teacher.lname, teacher.email, teacher.gender FROM class, teacher WHERE class.teacherId = teacher.id";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
while (result.next()) {
|
||||
ClassBean bean = new ClassBean();
|
||||
bean.getTeacherBean().setId(result.getString("id"));
|
||||
bean.setClassName(result.getString("class"));
|
||||
bean.getTeacherBean().setEmail(result.getString("email"));
|
||||
bean.getTeacherBean().setFname(result.getString("fname"));
|
||||
bean.getTeacherBean().setLname(result.getString("lname"));
|
||||
bean.getTeacherBean().setGender(result.getString("gender"));
|
||||
classList.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return classList;
|
||||
}
|
||||
|
||||
public ArrayList<AttendBean> getAttendClass(String className, String date) {
|
||||
ArrayList<AttendBean> AttendList = new ArrayList<AttendBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preSearchQuery = "SELECT DISTINCT student.* FROM studentclass, class, student WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ?";
|
||||
PreparedStatement ptment = connt.prepareStatement(preSearchQuery);
|
||||
ptment.setString(1, className);
|
||||
ResultSet result = ptment.executeQuery();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
String preAttendQuery = "SELECT * FROM studentattend WHERE attendDate=? AND studentId=?";
|
||||
PreparedStatement ptmentAttend = connt.prepareStatement(preAttendQuery);
|
||||
ptmentAttend.setString(1, date);
|
||||
ptmentAttend.setString(2, studentBean.getId());
|
||||
ResultSet resultAttend = ptmentAttend.executeQuery();
|
||||
AttendBean attendBean = new AttendBean();
|
||||
if (resultAttend.next()) {
|
||||
attendBean.setId(resultAttend.getString("studentAttendanceId"));
|
||||
attendBean.setDate(date);
|
||||
attendBean.setAttend(resultAttend.getBoolean("attend"));
|
||||
} else {
|
||||
attendBean.setDate(date);
|
||||
attendBean.setAttend(false);
|
||||
}
|
||||
attendBean.setStBean(studentBean);
|
||||
AttendList.add(attendBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return AttendList;
|
||||
}
|
||||
|
||||
public ArrayList<StudentBean> getAllStudentClass(String className) {
|
||||
ArrayList<StudentBean> list = new ArrayList<StudentBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT * FROM studentattend, studentclass, student, class WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ? AND studentattend.studentId = student.id AND attendDate = ?";
|
||||
//String preQuery = "SELECT student.* FROM studentclass, class, student WHERE studentclass.classid = class.id AND studentclass.studentid = student.id AND class.class = ? ORDER BY student.fname ASC";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, className);
|
||||
// pStmnt.setString(2, date);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
list.add(studentBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void insertStudentAttendance(String studentId, String date, boolean attend) {
|
||||
try {
|
||||
int count = 0;
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT studentAttend.studentId FROM studentattend, studentclass, student, class WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND studentattend.studentId = ? AND studentattend.studentId = student.id AND attendDate = ? ";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, studentId);
|
||||
pStmnt.setString(2, date);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
count = result.getInt(1);
|
||||
}
|
||||
if (count >= 1) {
|
||||
String preUpdateQuery = "UPDATE studentattend SET Attend = ? WHERE attendDate = ? AND studentId = ? ";
|
||||
PreparedStatement pUpdateStmnt = connt.prepareStatement(preUpdateQuery);
|
||||
pUpdateStmnt.setBoolean(1, attend);
|
||||
pUpdateStmnt.setString(2, date);
|
||||
pUpdateStmnt.setString(3, studentId);
|
||||
pUpdateStmnt.executeUpdate();
|
||||
} else {
|
||||
String preUpdateQuery = "INSERT INTO studentattend(studentId, attendDate, attend) VALUES (?, ?, ?)";
|
||||
PreparedStatement pUpdateStmnt = connt.prepareStatement(preUpdateQuery);
|
||||
pUpdateStmnt.setString(1, studentId);
|
||||
pUpdateStmnt.setString(2, date);
|
||||
pUpdateStmnt.setBoolean(3, attend);
|
||||
pUpdateStmnt.executeUpdate();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<SemesterBean> getLatestReportYear() {
|
||||
ArrayList<SemesterBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT DISTINCT year FROM semester ORDER BY year DESC LIMIT 3";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<SemesterBean>();
|
||||
while (result.next()) {
|
||||
SemesterBean bean = new SemesterBean();
|
||||
bean.setYear(result.getString("year"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<SemesterBean> getSemsterTerm(String year) {
|
||||
ArrayList<SemesterBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT term FROM semester WHERE year = ? AND start_date<=CURRENT_DATE";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, year);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
list = new ArrayList<SemesterBean>();
|
||||
while (result.next()) {
|
||||
SemesterBean bean = new SemesterBean();
|
||||
bean.setTerm(result.getInt("term"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public SemesterBean getSemsterDate(String year, int term) {
|
||||
SemesterBean semBean = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String perQuery = "SELECT start_date, end_date, 5 * ((DATEDIFF(end_date, start_date) ) DIV 7) + MID('0123455501234445012333450122234501101234000123450', 7 * WEEKDAY(start_date) + WEEKDAY(end_date) + 1, 1) AS countBusinDay FROM semester WHERE semester.start_date AND semester.year = ? AND semester.term = ?";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(perQuery);
|
||||
pStmnt.setString(1, year);
|
||||
pStmnt.setInt(2, term);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
if (result.next()) {
|
||||
semBean = new SemesterBean();
|
||||
semBean.setStart_date(result.getString("start_date"));
|
||||
semBean.setEnd_date(result.getString("end_date"));
|
||||
semBean.setTerm(term);
|
||||
semBean.setYear(year);
|
||||
semBean.setCountBusineseDate(result.getInt("countBusinDay"));
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return semBean;
|
||||
}
|
||||
|
||||
public ArrayList<SchedulerBean> getSchCalenderholiday() {
|
||||
ArrayList<SchedulerBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT *, WEEKDAY(start_date) AS start_day_week, WEEKDAY(end_date) AS end_day_week, end_date - start_date AS countDate, 5 * ((DATEDIFF(end_date, start_date) ) DIV 7) + MID('0123455501234445012333450122234501101234000123450', 7 * WEEKDAY(start_date) + WEEKDAY(end_date) + 1, 1) AS countBusinDay FROM scheduler WHERE holiday = true";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<SchedulerBean>();
|
||||
while (result.next()) {
|
||||
SchedulerBean scheBean = new SchedulerBean();
|
||||
scheBean.setId(result.getString("id"));
|
||||
scheBean.setTitle(result.getString("title"));
|
||||
scheBean.setDescription(result.getString("description"));
|
||||
scheBean.setStart_date(result.getString("start_date"));
|
||||
scheBean.setEnd_date(result.getString("end_date"));
|
||||
scheBean.setHoliday(result.getBoolean("holiday"));
|
||||
scheBean.setSchoolDay(result.getBoolean("schoolDay"));
|
||||
scheBean.setStart_day_week(result.getInt("start_day_week"));
|
||||
scheBean.setEnd_date_week(result.getInt("end_day_week"));
|
||||
scheBean.setCountDate(result.getInt("countDate"));
|
||||
scheBean.setCountBusineseDay(result.getInt("countBusinDay"));
|
||||
list.add(scheBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<StudentBean> getStudentAttend(String startDate, String endDate, String className) {
|
||||
ArrayList<StudentBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String perQuery = "SELECT COUNT(*) AS attendDay, student.* FROM studentattend, studentclass, student, class WHERE studentattend.attend=true AND studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ? AND studentattend.studentId = student.id AND attendDate >= ? AND attendDate <= ? GROUP BY studentattend.studentId ORDER BY student.fname ASC";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(perQuery);
|
||||
pStmnt.setString(1, className);
|
||||
pStmnt.setString(2, startDate);
|
||||
pStmnt.setString(3, endDate);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
list = new ArrayList<StudentBean>();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setBirthday(result.getString("birthday"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
studentBean.setAttendDay(result.getInt("attendDay"));
|
||||
list.add(studentBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public double getAttendanceRateTarget(String className) {
|
||||
double target = 0;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT attendanceTarget FROM class, attendanceTarget WHERE class.attendanceTargetId = attendanceTarget.id AND class.class = ?";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, className);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
if (result.next()) {
|
||||
target = result.getDouble("attendanceTarget");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
public ArrayList<AttendBean> getStudentAttendDetail(String studentId, String year, int term) {
|
||||
ArrayList<AttendBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT studentattend.* FROM studentattend, class, semester, studentclass WHERE studentattend.studentId = ? AND studentattend.attendDate >= semester.start_date AND studentattend.attendDate <= semester.end_date AND semester.year = ? AND semester.term = ? AND studentclass.studentId = studentattend.studentId AND studentclass.classId = class.id";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, studentId);
|
||||
preStmnt.setString(2, year);
|
||||
preStmnt.setInt(3, term);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
list = new ArrayList<AttendBean>();
|
||||
while (result.next()) {
|
||||
AttendBean bean = new AttendBean();
|
||||
bean.setId(result.getString("studentAttendanceId"));
|
||||
bean.setDate(result.getString("attendDate"));
|
||||
bean.setAttend(result.getBoolean("attend"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<StudentBean> getAllStudentAttendZero(String className) {
|
||||
ArrayList<StudentBean> list = new ArrayList<StudentBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT * FROM studentattend, studentclass, student, class WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ? AND studentattend.studentId = student.id AND attendDate = ?";
|
||||
//String preQuery = "SELECT student.* FROM studentclass, class, student WHERE studentclass.classid = class.id AND studentclass.studentid = student.id AND class.class = ? ORDER BY student.fname ASC";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, className);
|
||||
// pStmnt.setString(2, date);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
studentBean.setAttendRate(0);
|
||||
list.add(studentBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<LectureTimeBean> getAllTimeLecture() {
|
||||
ArrayList<LectureTimeBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT * FROM timeTable ORDER BY timeTable.starttime ASC";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<LectureTimeBean>();
|
||||
while (result.next()) {
|
||||
LectureTimeBean bean = new LectureTimeBean();
|
||||
bean.setId(result.getString("timeId"));
|
||||
bean.setStartTime(result.getString("starttime"));
|
||||
bean.setEndTime(result.getString("endtime"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<LectureBean> getLecture(String studentId) {
|
||||
ArrayList<LectureBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT * FROM lecture, timetable, daytable, class, studentclass WHERE class.id = studentclass.classId AND studentclass.studentId = ? AND lecture.classId = class.id AND lecture.timeId = timetable.timeId AND lecture.dayId = daytable.id";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, studentId);
|
||||
System.out.println(studentId);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
list = new ArrayList<LectureBean>();
|
||||
while (result.next()) {
|
||||
LectureBean lectureBean = new LectureBean();
|
||||
LectureTimeBean timeBean = new LectureTimeBean();
|
||||
LectureDayBean dayBean = new LectureDayBean();
|
||||
lectureBean.setLecture(result.getString("lecture"));
|
||||
lectureBean.setDescription(result.getString("description"));
|
||||
lectureBean.setClassName(result.getString("class"));
|
||||
timeBean.setStartTime(result.getString("starttime"));
|
||||
timeBean.setEndTime(result.getString("endtime"));
|
||||
timeBean.setFullweek(result.getBoolean("fullday"));
|
||||
lectureBean.setTime(timeBean);
|
||||
dayBean.setDay(result.getString("day"));
|
||||
lectureBean.setDay(dayBean);
|
||||
lectureBean.setRoom(result.getString("room"));
|
||||
list.add(lectureBean);
|
||||
}
|
||||
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<LectureBean> getAllLecture(String teacherId) {
|
||||
ArrayList<LectureBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT * FROM lecture, class, timetable, daytable WHERE lecture.classId = class.id AND lecture.timeId = timetable.timeId AND lecture.teacherId = ? and lecture.dayId = daytable.id";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, teacherId);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
list = new ArrayList<LectureBean>();
|
||||
while (result.next()) {
|
||||
LectureBean lectureBean = new LectureBean();
|
||||
LectureTimeBean timeBean = new LectureTimeBean();
|
||||
LectureDayBean dayBean = new LectureDayBean();
|
||||
lectureBean.setLecture(result.getString("lecture"));
|
||||
lectureBean.setDescription(result.getString("description"));
|
||||
lectureBean.setClassName(result.getString("class"));
|
||||
timeBean.setStartTime(result.getString("starttime"));
|
||||
timeBean.setEndTime(result.getString("endtime"));
|
||||
timeBean.setFullweek(result.getBoolean("fullday"));
|
||||
lectureBean.setTime(timeBean);
|
||||
dayBean.setDay(result.getString("day"));
|
||||
lectureBean.setDay(dayBean);
|
||||
lectureBean.setRoom(result.getString("room"));
|
||||
list.add(lectureBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<LectureDayBean> getAllDayLecture() {
|
||||
ArrayList<LectureDayBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT * FROM daytable ORDER BY day ASC";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<LectureDayBean>();
|
||||
while (result.next()) {
|
||||
LectureDayBean bean = new LectureDayBean();
|
||||
bean.setId(result.getString("id"));
|
||||
bean.setDay(result.getString("day"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getStudentClass(String studentId) {
|
||||
String className = "";
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT class.class FROM studentclass, class WHERE studentclass.classid = class.id AND studentclass.studentId = ?";
|
||||
PreparedStatement stmnt = connt.prepareStatement(sql);
|
||||
stmnt.setString(1, studentId);
|
||||
ResultSet result = stmnt.executeQuery();
|
||||
if (result.next()) {
|
||||
className = result.getString("class");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return className;
|
||||
}
|
||||
|
||||
public String getMaxTerm() {
|
||||
String term = "";
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT term FROM semester WHERE start_date<=CURRENT_DATE AND end_date>=CURRENT_DATE";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
if (result.next()) {
|
||||
term = result.getString("term");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return term;
|
||||
}
|
||||
}
|
@@ -0,0 +1,549 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.db;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import system.bean.AttendBean;
|
||||
import system.bean.ClassBean;
|
||||
import system.bean.LectureBean;
|
||||
import system.bean.LectureDayBean;
|
||||
import system.bean.LectureTimeBean;
|
||||
import system.bean.SchedulerBean;
|
||||
import system.bean.SemesterBean;
|
||||
import system.bean.StudentBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class TeacherDB {
|
||||
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
private String teacherId;
|
||||
|
||||
public TeacherDB(String url, String username, String password) {
|
||||
this.url = url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setTeacherId(String teacherId) {
|
||||
this.teacherId = teacherId;
|
||||
}
|
||||
|
||||
public Connection getConnection() throws SQLException, IOException {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return DriverManager.getConnection(url, username, password);
|
||||
}
|
||||
|
||||
public int getCountClass() {
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT COUNT(*) FROM lecture WHERE teacherId = ?";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, teacherId);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
return result.getInt(1);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getCountStudent() {
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT COUNT(DISTINCT studentId) FROM studentClass, class, lecture WHERE studentclass.classId = class.id AND class.id = lecture.classId AND lecture.teacherId = ?";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, teacherId);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
return result.getInt(1);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ArrayList<ClassBean> getAllClass() {
|
||||
ArrayList<ClassBean> classList = new ArrayList<ClassBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT class.*, teacher.fname, teacher.lname, teacher.email, teacher.gender FROM class, teacher WHERE class.teacherId = teacher.id";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
while (result.next()) {
|
||||
ClassBean bean = new ClassBean();
|
||||
bean.getTeacherBean().setId(result.getString("id"));
|
||||
bean.setClassName(result.getString("class"));
|
||||
bean.getTeacherBean().setEmail(result.getString("email"));
|
||||
bean.getTeacherBean().setFname(result.getString("fname"));
|
||||
bean.getTeacherBean().setLname(result.getString("lname"));
|
||||
bean.getTeacherBean().setGender(result.getString("gender"));
|
||||
classList.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return classList;
|
||||
}
|
||||
|
||||
public ArrayList<AttendBean> getAttendClass(String className, String date) {
|
||||
ArrayList<AttendBean> AttendList = new ArrayList<AttendBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preSearchQuery = "SELECT DISTINCT student.* FROM studentclass, class, student WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ?";
|
||||
PreparedStatement ptment = connt.prepareStatement(preSearchQuery);
|
||||
ptment.setString(1, className);
|
||||
ResultSet result = ptment.executeQuery();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
String preAttendQuery = "SELECT * FROM studentattend WHERE attendDate=? AND studentId=?";
|
||||
PreparedStatement ptmentAttend = connt.prepareStatement(preAttendQuery);
|
||||
ptmentAttend.setString(1, date);
|
||||
ptmentAttend.setString(2, studentBean.getId());
|
||||
ResultSet resultAttend = ptmentAttend.executeQuery();
|
||||
AttendBean attendBean = new AttendBean();
|
||||
if (resultAttend.next()) {
|
||||
attendBean.setId(resultAttend.getString("studentAttendanceId"));
|
||||
attendBean.setDate(date);
|
||||
attendBean.setAttend(resultAttend.getBoolean("attend"));
|
||||
} else {
|
||||
attendBean.setDate(date);
|
||||
attendBean.setAttend(false);
|
||||
}
|
||||
attendBean.setStBean(studentBean);
|
||||
AttendList.add(attendBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return AttendList;
|
||||
}
|
||||
|
||||
public ArrayList<StudentBean> getAllStudentClass(String className) {
|
||||
ArrayList<StudentBean> list = new ArrayList<StudentBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
//String preQuery = "SELECT * FROM studentattend, studentclass, student, class WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ? AND studentattend.studentId = student.id AND attendDate = ?";
|
||||
String preQuery = "SELECT student.* FROM studentclass, class, student WHERE studentclass.classid = class.id AND studentclass.studentid = student.id AND class.class = ? ORDER BY student.fname ASC";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, className);
|
||||
// pStmnt.setString(2, date);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
list.add(studentBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void insertStudentAttendance(String studentId, String date, boolean attend) {
|
||||
try {
|
||||
int count = 0;
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT studentAttend.studentId FROM studentattend, studentclass, student, class WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND studentattend.studentId = ? AND studentattend.studentId = student.id AND attendDate = ? ";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, studentId);
|
||||
pStmnt.setString(2, date);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
count = result.getInt(1);
|
||||
}
|
||||
if (count >= 1) {
|
||||
String preUpdateQuery = "UPDATE studentattend SET Attend = ? WHERE attendDate = ? AND studentId = ? ";
|
||||
PreparedStatement pUpdateStmnt = connt.prepareStatement(preUpdateQuery);
|
||||
pUpdateStmnt.setBoolean(1, attend);
|
||||
pUpdateStmnt.setString(2, date);
|
||||
pUpdateStmnt.setString(3, studentId);
|
||||
pUpdateStmnt.executeUpdate();
|
||||
} else {
|
||||
String preUpdateQuery = "INSERT INTO studentattend(studentId, attendDate, attend) VALUES (?, ?, ?)";
|
||||
PreparedStatement pUpdateStmnt = connt.prepareStatement(preUpdateQuery);
|
||||
pUpdateStmnt.setString(1, studentId);
|
||||
pUpdateStmnt.setString(2, date);
|
||||
pUpdateStmnt.setBoolean(3, attend);
|
||||
pUpdateStmnt.executeUpdate();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<SemesterBean> getLatestReportYear() {
|
||||
ArrayList<SemesterBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT DISTINCT year FROM semester ORDER BY year DESC LIMIT 3";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<SemesterBean>();
|
||||
while (result.next()) {
|
||||
SemesterBean bean = new SemesterBean();
|
||||
bean.setYear(result.getString("year"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<SemesterBean> getSemsterTerm(String year) {
|
||||
ArrayList<SemesterBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT term FROM semester WHERE year = ? AND start_date<=CURRENT_DATE";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, year);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
list = new ArrayList<SemesterBean>();
|
||||
while (result.next()) {
|
||||
SemesterBean bean = new SemesterBean();
|
||||
bean.setTerm(result.getInt("term"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public SemesterBean getSemsterDate(String year, int term) {
|
||||
SemesterBean semBean = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String perQuery = "SELECT start_date, end_date, 5 * ((DATEDIFF(end_date, start_date) ) DIV 7) + MID('0123455501234445012333450122234501101234000123450', 7 * WEEKDAY(start_date) + WEEKDAY(end_date) + 1, 1) AS countBusinDay FROM semester WHERE semester.start_date AND semester.year = ? AND semester.term = ?";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(perQuery);
|
||||
pStmnt.setString(1, year);
|
||||
pStmnt.setInt(2, term);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
if (result.next()) {
|
||||
semBean = new SemesterBean();
|
||||
semBean.setStart_date(result.getString("start_date"));
|
||||
semBean.setEnd_date(result.getString("end_date"));
|
||||
semBean.setTerm(term);
|
||||
semBean.setYear(year);
|
||||
semBean.setCountBusineseDate(result.getInt("countBusinDay"));
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return semBean;
|
||||
}
|
||||
|
||||
public ArrayList<SchedulerBean> getSchCalenderholiday() {
|
||||
ArrayList<SchedulerBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT *, WEEKDAY(start_date) AS start_day_week, WEEKDAY(end_date) AS end_day_week, end_date - start_date AS countDate, 5 * ((DATEDIFF(end_date, start_date) ) DIV 7) + MID('0123455501234445012333450122234501101234000123450', 7 * WEEKDAY(start_date) + WEEKDAY(end_date) + 1, 1) AS countBusinDay FROM scheduler WHERE holiday = true";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<SchedulerBean>();
|
||||
while (result.next()) {
|
||||
SchedulerBean scheBean = new SchedulerBean();
|
||||
scheBean.setId(result.getString("id"));
|
||||
scheBean.setTitle(result.getString("title"));
|
||||
scheBean.setStart_date(result.getString("start_date"));
|
||||
scheBean.setEnd_date(result.getString("end_date"));
|
||||
scheBean.setHoliday(result.getBoolean("holiday"));
|
||||
scheBean.setSchoolDay(result.getBoolean("schoolDay"));
|
||||
scheBean.setStart_day_week(result.getInt("start_day_week"));
|
||||
scheBean.setEnd_date_week(result.getInt("end_day_week"));
|
||||
scheBean.setCountDate(result.getInt("countDate"));
|
||||
scheBean.setCountBusineseDay(result.getInt("countBusinDay"));
|
||||
list.add(scheBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<StudentBean> getStudentAttend(String startDate, String endDate, String className) {
|
||||
ArrayList<StudentBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String perQuery = "SELECT COUNT(*) AS attendDay, student.* FROM studentattend, studentclass, student, class WHERE studentattend.attend=true AND studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ? AND studentattend.studentId = student.id AND attendDate >= ? AND attendDate <= ? GROUP BY studentattend.studentId ORDER BY student.fname ASC";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(perQuery);
|
||||
pStmnt.setString(1, className);
|
||||
pStmnt.setString(2, startDate);
|
||||
pStmnt.setString(3, endDate);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
list = new ArrayList<StudentBean>();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setBirthday(result.getString("birthday"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
studentBean.setAttendDay(result.getInt("attendDay"));
|
||||
list.add(studentBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public double getAttendanceRateTarget(String className) {
|
||||
double target = 0;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT attendanceTarget FROM class, attendanceTarget WHERE class.attendanceTargetId = attendanceTarget.id AND class.class = ?";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, className);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
if (result.next()) {
|
||||
target = result.getDouble("attendanceTarget");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
public ArrayList<AttendBean> getStudentAttendDetail(String studentId, String year, int term) {
|
||||
ArrayList<AttendBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT studentattend.* FROM studentattend, class, semester, studentclass WHERE studentattend.studentId = ? AND studentattend.attendDate >= semester.start_date AND studentattend.attendDate <= semester.end_date AND semester.year = ? AND semester.term = ? AND studentclass.studentId = studentattend.studentId AND studentclass.classId = class.id";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, studentId);
|
||||
preStmnt.setString(2, year);
|
||||
preStmnt.setInt(3, term);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
list = new ArrayList<AttendBean>();
|
||||
while (result.next()) {
|
||||
AttendBean bean = new AttendBean();
|
||||
bean.setId(result.getString("studentAttendanceId"));
|
||||
bean.setDate(result.getString("attendDate"));
|
||||
bean.setAttend(result.getBoolean("attend"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<StudentBean> getAllStudentAttendZero(String className) {
|
||||
ArrayList<StudentBean> list = new ArrayList<StudentBean>();
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
//String preQuery = "SELECT * FROM studentattend, studentclass, student, class WHERE studentclass.classId = class.id AND studentclass.studentId = student.id AND class.class = ? AND studentattend.studentId = student.id AND attendDate = ?";
|
||||
String preQuery = "SELECT student.* FROM studentclass, class, student WHERE studentclass.classid = class.id AND studentclass.studentid = student.id AND class.class = ? ORDER BY student.fname ASC";
|
||||
PreparedStatement pStmnt = connt.prepareStatement(preQuery);
|
||||
pStmnt.setString(1, className);
|
||||
// pStmnt.setString(2, date);
|
||||
ResultSet result = pStmnt.executeQuery();
|
||||
while (result.next()) {
|
||||
StudentBean studentBean = new StudentBean();
|
||||
studentBean.setFname(result.getString("fname"));
|
||||
studentBean.setLname(result.getString("lname"));
|
||||
studentBean.setGender(result.getString("gender"));
|
||||
studentBean.setEmail(result.getString("email"));
|
||||
studentBean.setId(result.getString("id"));
|
||||
studentBean.setAttendRate(0);
|
||||
list.add(studentBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<LectureTimeBean> getAllTimeLecture() {
|
||||
ArrayList<LectureTimeBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT * FROM timeTable ORDER BY timeTable.starttime ASC";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<LectureTimeBean>();
|
||||
while (result.next()) {
|
||||
LectureTimeBean bean = new LectureTimeBean();
|
||||
bean.setId(result.getString("timeId"));
|
||||
bean.setStartTime(result.getString("starttime"));
|
||||
bean.setEndTime(result.getString("endtime"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<LectureBean> getAllLecture(String teacherId) {
|
||||
ArrayList<LectureBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String preQuery = "SELECT * FROM lecture, class, timetable, daytable WHERE lecture.classId = class.id AND lecture.timeId = timetable.timeId AND lecture.teacherId = ? and lecture.dayId = daytable.id";
|
||||
PreparedStatement preStmnt = connt.prepareStatement(preQuery);
|
||||
preStmnt.setString(1, teacherId);
|
||||
ResultSet result = preStmnt.executeQuery();
|
||||
list = new ArrayList<LectureBean>();
|
||||
while (result.next()) {
|
||||
LectureBean lectureBean = new LectureBean();
|
||||
LectureTimeBean timeBean = new LectureTimeBean();
|
||||
LectureDayBean dayBean = new LectureDayBean();
|
||||
lectureBean.setLecture(result.getString("lecture"));
|
||||
lectureBean.setDescription(result.getString("description"));
|
||||
lectureBean.setClassName(result.getString("class"));
|
||||
timeBean.setStartTime(result.getString("starttime"));
|
||||
timeBean.setEndTime(result.getString("endtime"));
|
||||
timeBean.setFullweek(result.getBoolean("fullday"));
|
||||
lectureBean.setTime(timeBean);
|
||||
dayBean.setDay(result.getString("day"));
|
||||
lectureBean.setDay(dayBean);
|
||||
lectureBean.setRoom(result.getString("room"));
|
||||
list.add(lectureBean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<LectureDayBean> getAllDayLecture() {
|
||||
ArrayList<LectureDayBean> list = null;
|
||||
try {
|
||||
Connection connt = getConnection();
|
||||
String sql = "SELECT * FROM daytable ORDER BY day ASC";
|
||||
Statement stmnt = connt.createStatement();
|
||||
ResultSet result = stmnt.executeQuery(sql);
|
||||
list = new ArrayList<LectureDayBean>();
|
||||
while (result.next()) {
|
||||
LectureDayBean bean = new LectureDayBean();
|
||||
bean.setId(result.getString("id"));
|
||||
bean.setDay(result.getString("day"));
|
||||
list.add(bean);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
while (ex != null) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//SELECT *, WEEKDAY(start_date) as start_day_week, WEEKDAY(end_date) as end_day_week FROM scheduler
|
||||
//SELECT *, WEEKDAY(start_date) as start_day_week, WEEKDAY(end_date) as end_day_week, end_date - start_date as countDate FROM scheduler WHERE holiday = true
|
||||
|
||||
// get count date select datediff(semester.end_date, semester.start_date) FROM semester, class WHERE class.termId = semester.id AND class.class = "1A"
|
||||
}
|
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.bean.StudentBean;
|
||||
import system.db.AdminDB;
|
||||
import system.db.TeacherDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminAttendController", urlPatterns = {"/admin/attendance"})
|
||||
public class AdminAttendController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
TeacherDB tdb;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
tdb = new TeacherDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
HttpSession session = request.getSession(false);
|
||||
try {
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String teacherId = (String) session.getAttribute("username");
|
||||
String className = request.getParameter("class");
|
||||
String attendDate = request.getParameter("date");
|
||||
String action = request.getParameter("action");
|
||||
RequestDispatcher rd = null;
|
||||
if (className == null) {
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/attendance.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action != null && action.equals("save")) {
|
||||
if (className != null && attendDate != null) {
|
||||
ArrayList<StudentBean> studentList = tdb.getAllStudentClass(className);
|
||||
String[] attendStudents = request.getParameterValues("attend");
|
||||
if (attendStudents != null) {
|
||||
for (String studentId : attendStudents) {
|
||||
tdb.insertStudentAttendance(studentId, attendDate, true);
|
||||
for (StudentBean student : studentList) {
|
||||
if (student.getId().equals(studentId)) {
|
||||
studentList.remove(student);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (StudentBean student : studentList) {
|
||||
tdb.insertStudentAttendance(student.getId(), attendDate, false);
|
||||
}
|
||||
}
|
||||
request.setAttribute("message", true);
|
||||
}
|
||||
if (attendDate == null) {
|
||||
attendDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
}
|
||||
request.setAttribute("date", attendDate);
|
||||
request.setAttribute("studentAttendList", tdb.getAttendClass(className, attendDate));
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/attendanceStudent.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.AdminDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminClassController", urlPatterns = {"/admin/class"})
|
||||
public class AdminClassController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String username = (String) session.getAttribute("username");
|
||||
String action = request.getParameter("action");
|
||||
String classId = request.getParameter("id");
|
||||
|
||||
RequestDispatcher rd = null;
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
request.setAttribute("searchList", db.getSearchHistory("6", username));
|
||||
if (action != null && action.equals("addPage")) {
|
||||
request.setAttribute("teacherList", db.getNotClassTeacher());
|
||||
request.setAttribute("classYearList", db.getClassYear());
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/classAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
} else if (action != null && action.equals("add")) {
|
||||
String className = request.getParameter("class");
|
||||
String teacherId = request.getParameter("teacherId");
|
||||
String yearId = request.getParameter("yearId");
|
||||
if (db.checkClassNameDupli(className)) {
|
||||
System.out.println("TESTPOTIN_TRUE");
|
||||
request.setAttribute("className", className);
|
||||
request.setAttribute("teacherId", teacherId);
|
||||
request.setAttribute("yearId", yearId);
|
||||
request.setAttribute("dupMes", true);
|
||||
request.setAttribute("teacherList", db.getNotClassTeacher());
|
||||
request.setAttribute("classYearList", db.getClassYear());
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/classAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
}else{
|
||||
System.out.println("TESTPOTIN_false");
|
||||
db.insertClass(className, teacherId, yearId, 1);
|
||||
request.setAttribute("addMes", true);
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/class.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
}
|
||||
} else if (action != null && action.equals("save")) {
|
||||
String className = request.getParameter("class");
|
||||
String teacherId = request.getParameter("teacherId");
|
||||
String yearId = request.getParameter("yearId");
|
||||
if (db.checkClassNameDupli(className, classId)) {
|
||||
request.setAttribute("className", className);
|
||||
request.setAttribute("teacherId", teacherId);
|
||||
request.setAttribute("yearId", yearId);
|
||||
request.setAttribute("dupMes", true);
|
||||
request.setAttribute("classBean", db.getClassDetails(classId));
|
||||
request.setAttribute("teacherList", db.getNotClassTeacher());
|
||||
request.setAttribute("classYearList", db.getClassYear());
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/classEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
db.updateClass(className, teacherId, yearId, 1, classId);
|
||||
System.out.println(className + "asd");
|
||||
System.out.println(teacherId + "asd");
|
||||
System.out.println(yearId + "asd");
|
||||
System.out.println(classId + "asd");
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
request.setAttribute("saveMes", classId);
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/class.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
} else if (action != null && action.equals("search")) {
|
||||
String searchVal = request.getParameter("searchVal");
|
||||
db.insertSearchHistory(searchVal, "6", username);
|
||||
request.setAttribute("classList", db.searchClass(searchVal));
|
||||
request.setAttribute("searchList", db.getSearchHistory("6", username));
|
||||
request.setAttribute("search", true);
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/class.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("delete")) {
|
||||
db.deleteClass(classId);
|
||||
request.setAttribute("deleteMes", classId);
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
} else if (classId != null) {
|
||||
request.setAttribute("classBean", db.getClassDetails(classId));
|
||||
request.setAttribute("teacherList", db.getNotClassTeacher());
|
||||
request.setAttribute("classYearList", db.getClassYear());
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/classEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/class.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.AdminDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminClassRegController", urlPatterns = {"/admin/classReg"})
|
||||
public class AdminClassRegController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String username = (String) session.getAttribute("username");
|
||||
String action = request.getParameter("action");
|
||||
String studentClassID = request.getParameter("id"); // edit function
|
||||
if (action != null && action.equals("delete")) {
|
||||
String studentId = db.deleteStudentClass(studentClassID);
|
||||
request.setAttribute("deletenMes", studentId);
|
||||
request.setAttribute("studentClassList", db.getAllStudentClass());
|
||||
request.setAttribute("searchList", db.getSearchHistory("2", username));
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/classReg.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("save")) {
|
||||
String className = request.getParameter("className");
|
||||
db.updateStudentClass(studentClassID, className);
|
||||
request.setAttribute("saveMes", studentClassID);
|
||||
request.setAttribute("studentClassList", db.getAllStudentClass());
|
||||
request.setAttribute("searchList", db.getSearchHistory("2", username));
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/classReg.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("search")) {
|
||||
String searchVal = request.getParameter("searchVal");
|
||||
request.setAttribute("studentClassList", db.searchStudentClass(searchVal));
|
||||
db.insertSearchHistory(searchVal, "2", username);
|
||||
request.setAttribute("searchHis", true);
|
||||
request.setAttribute("searchList", db.getSearchHistory("2", username));
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/classReg.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("addPage")) {
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
request.setAttribute("studnetIdList", db.getUnRegAllStudent());
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/classRegAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("add")) {
|
||||
String className = request.getParameter("className");
|
||||
db.insertStudentClass(studentClassID, className);
|
||||
request.setAttribute("studentClassList", db.getAllStudentClass());
|
||||
request.setAttribute("searchList", db.getSearchHistory("2", username));
|
||||
request.setAttribute("addMes", className);
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/classReg.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
if (studentClassID != null) {
|
||||
request.setAttribute("studenBean", db.getStudentClassDeital(studentClassID));
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
request.setAttribute("studentClassID", studentClassID);
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/classRegStudent.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
request.setAttribute("studentClassList", db.getAllStudentClass());
|
||||
request.setAttribute("searchList", db.getSearchHistory("2", username));
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/classReg.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (NullPointerException e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.AdminDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminDashboard", urlPatterns = {"/admin/dashboard"})
|
||||
public class AdminDashboardController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
request.setAttribute("courseCount", db.getCountClass());
|
||||
request.setAttribute("studentCount", db.getCountStudent());
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/dashboard.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.AdminDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminLectureController", urlPatterns = {"/admin/lecture"})
|
||||
public class AdminLectureController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String username = (String) session.getAttribute("username");
|
||||
String action = request.getParameter("action");
|
||||
String lectureId = request.getParameter("id");
|
||||
request.setAttribute("lectureList", db.getLecture());
|
||||
request.setAttribute("searchList", db.getSearchHistory("1", username));
|
||||
RequestDispatcher rd = null;
|
||||
if (action != null && action.equals("delete")) {
|
||||
db.deleteLecture(lectureId);
|
||||
request.setAttribute("deleteMes", lectureId);
|
||||
request.setAttribute("lectureList", db.getLecture());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lecture.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("addPage")) {
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
request.setAttribute("dayList", db.getDayList());
|
||||
request.setAttribute("timeList", db.getTimeList());
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lectureAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("search")) {
|
||||
String searchVal = request.getParameter("searchVal");
|
||||
request.setAttribute("lectureList", db.searchLecture(searchVal));
|
||||
db.insertSearchHistory(searchVal, "1", username);
|
||||
request.setAttribute("searchList", db.getSearchHistory("1", username));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lecture.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("save")) {
|
||||
String lecture = request.getParameter("lecture");
|
||||
String description = request.getParameter("description");
|
||||
String className = request.getParameter("className");
|
||||
String time = request.getParameter("time");
|
||||
String day = request.getParameter("day");
|
||||
String teacher = request.getParameter("teacher");
|
||||
if (db.checkTeacherDupSchedule(time, teacher, lectureId)) {
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
request.setAttribute("dayList", db.getDayList());
|
||||
request.setAttribute("timeList", db.getTimeList());
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
request.setAttribute("lectureBean", db.getLectureDetials(lectureId));
|
||||
request.setAttribute("lectureId", lectureId);
|
||||
request.setAttribute("lecture", lecture);
|
||||
request.setAttribute("description", description);
|
||||
request.setAttribute("className", className);
|
||||
request.setAttribute("time", time);
|
||||
request.setAttribute("day", day);
|
||||
request.setAttribute("teacher", teacher);
|
||||
request.setAttribute("dupMes", true);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lectureEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
db.updateLecture(lectureId, lecture, description, className, time, day, teacher);
|
||||
request.setAttribute("saveMes", lectureId);
|
||||
request.setAttribute("lectureList", db.getLecture());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lecture.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("add")) {
|
||||
String lecture = request.getParameter("lecture");
|
||||
String description = request.getParameter("description");
|
||||
String className = request.getParameter("className");
|
||||
String time = request.getParameter("time");
|
||||
String day = request.getParameter("day");
|
||||
String teacher = request.getParameter("teacher");
|
||||
if (db.checkTeacherDupSchedule(time, teacher)) {
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
request.setAttribute("dayList", db.getDayList());
|
||||
request.setAttribute("timeList", db.getTimeList());
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
request.setAttribute("lectureId", lectureId);
|
||||
request.setAttribute("lecture", lecture);
|
||||
request.setAttribute("description", description);
|
||||
request.setAttribute("className", className);
|
||||
request.setAttribute("time", time);
|
||||
request.setAttribute("day", day);
|
||||
request.setAttribute("teacher", teacher);
|
||||
request.setAttribute("dupMes", true);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lectureAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
db.insertLecture(lecture, description, className, time, day, teacher);
|
||||
request.setAttribute("lectureList", db.getLecture());
|
||||
request.setAttribute("addMes", true);
|
||||
}
|
||||
if (lectureId != null) {
|
||||
request.setAttribute("lectureId", lectureId);
|
||||
request.setAttribute("classList", db.getClassList());
|
||||
request.setAttribute("dayList", db.getDayList());
|
||||
request.setAttribute("timeList", db.getTimeList());
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
request.setAttribute("lectureBean", db.getLectureDetials(lectureId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lectureEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/lecture.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.bean.AttendBean;
|
||||
import system.bean.SchedulerBean;
|
||||
import system.bean.SemesterBean;
|
||||
import system.bean.StudentBean;
|
||||
import system.db.AdminDB;
|
||||
import system.db.TeacherDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminReportController", urlPatterns = {"/admin/report"})
|
||||
public class AdminReportController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
TeacherDB tdb;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
tdb = new TeacherDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index.jsp");
|
||||
return;
|
||||
}
|
||||
RequestDispatcher rd;
|
||||
String className = request.getParameter("class");
|
||||
String strTerm = request.getParameter("term");
|
||||
String studentId = request.getParameter("studentId");
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
String reportType = request.getParameter("report");
|
||||
if (className != null) {
|
||||
String year = request.getParameter("year");
|
||||
ArrayList<String> errList = new ArrayList<String>();
|
||||
if (strTerm == null) {
|
||||
strTerm = "1";
|
||||
};
|
||||
if (year == null) {
|
||||
year = Calendar.getInstance().get(Calendar.YEAR) + "";
|
||||
}
|
||||
|
||||
try {
|
||||
int term = Integer.parseInt(strTerm);
|
||||
SemesterBean semBean = tdb.getSemsterDate(year, term);
|
||||
int totalSchoolDay = semBean.getCountBusineseDate();
|
||||
int countHoliday = 0;
|
||||
for (SchedulerBean scheduler : tdb.getSchCalenderholiday()) {
|
||||
if (scheduler.isHoliday() && scheduler.getCountDate() == 0) {
|
||||
switch (scheduler.getStart_day_week()) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
countHoliday++;
|
||||
}
|
||||
} else if (scheduler.isHoliday() && scheduler.getCountDate() > 0) {
|
||||
countHoliday += scheduler.getCountBusineseDay() + 1;
|
||||
//countHoliday += scheduler.getCountDate();
|
||||
}
|
||||
}
|
||||
totalSchoolDay = totalSchoolDay - countHoliday;
|
||||
System.out.println(totalSchoolDay);
|
||||
ArrayList<StudentBean> studentList = tdb.getStudentAttend(semBean.getStart_date(), semBean.getEnd_date(), className);
|
||||
int allStudentCountDay = 0;
|
||||
int numberOfStudent = 0;
|
||||
int numberOfStudentNotMeetTar = 0;
|
||||
int numberOfStudentMeetTar = 0;
|
||||
int numberOfStudentWarning = 0;
|
||||
int numberOfStudentDanger = 0;
|
||||
int numberOfStudentLowAtt = 0;
|
||||
double avgStudentAttendDay = 0;
|
||||
StudentBean studentBean = null;
|
||||
|
||||
for (StudentBean student : studentList) {
|
||||
int countDay = student.getAttendDay();
|
||||
allStudentCountDay += countDay;
|
||||
double attendRate = Math.round((countDay / (float) totalSchoolDay) * 100);
|
||||
student.setAttendRate(attendRate);
|
||||
numberOfStudent++;
|
||||
if (attendRate >= tdb.getAttendanceRateTarget(className)) {
|
||||
numberOfStudentMeetTar++;
|
||||
} else {
|
||||
numberOfStudentNotMeetTar++;
|
||||
}
|
||||
System.out.println(student.getId());
|
||||
if (studentId != null && student.getId().equals(studentId)) {
|
||||
studentBean = student;
|
||||
}
|
||||
}
|
||||
ArrayList<StudentBean> lowAttendList = null;
|
||||
if (reportType != null && reportType.equals("low")) {
|
||||
lowAttendList = new ArrayList<StudentBean>();
|
||||
double avgLowAttend = 0;
|
||||
for (StudentBean student : studentList) {
|
||||
if (student.getAttendRate() <= tdb.getAttendanceRateTarget(className)) {
|
||||
lowAttendList.add(student);
|
||||
}
|
||||
if (student.getAttendRate() >= 50.0 && student.getAttendRate() < 60.0) {
|
||||
numberOfStudentWarning++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
} else if (student.getAttendRate() <= 49.0 && student.getAttendRate() >= 40.0) {
|
||||
numberOfStudentDanger++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
} else if (student.getAttendRate() >= tdb.getAttendanceRateTarget(className)) {
|
||||
|
||||
} else {
|
||||
numberOfStudentLowAtt++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
}
|
||||
}
|
||||
avgLowAttend = avgLowAttend / (numberOfStudentWarning + numberOfStudentDanger + numberOfStudentLowAtt);
|
||||
request.setAttribute("attendAVG", avgLowAttend);
|
||||
}
|
||||
|
||||
if (studentList.size() == 0 || reportType != null && reportType.equals("low") && lowAttendList.size() == 0) {
|
||||
request.setAttribute("studentAttendList", tdb.getAllStudentAttendZero(className));
|
||||
} else {
|
||||
if (reportType != null && reportType.equals("low")) {
|
||||
request.setAttribute("studentAttendList", lowAttendList);
|
||||
} else {
|
||||
request.setAttribute("studentAttendList", studentList);
|
||||
}
|
||||
}
|
||||
if (studentId != null) {
|
||||
studentBean.setAttendList(tdb.getStudentAttendDetail(studentId, year, term));
|
||||
request.setAttribute("studentDetials", studentBean);
|
||||
int totalAttendDay = 0;
|
||||
int presentDay = 0;
|
||||
int absDay = 0;
|
||||
for (AttendBean attend : studentBean.getAttendList()) {
|
||||
if (attend.isAttend()) {
|
||||
presentDay++;
|
||||
} else {
|
||||
absDay++;
|
||||
}
|
||||
totalAttendDay++;
|
||||
}
|
||||
request.setAttribute("presentDay", presentDay);
|
||||
request.setAttribute("absDay", absDay);
|
||||
request.setAttribute("totalAttendDay", totalAttendDay);
|
||||
}
|
||||
try {
|
||||
avgStudentAttendDay = (allStudentCountDay / numberOfStudent);
|
||||
} catch (ArithmeticException e) {
|
||||
avgStudentAttendDay = 0;
|
||||
}
|
||||
int attendAVG = 0;
|
||||
if(avgStudentAttendDay>0){
|
||||
attendAVG = (int) Math.round((1-(totalSchoolDay - avgStudentAttendDay) / totalSchoolDay) * 100);
|
||||
}
|
||||
|
||||
|
||||
if (reportType != null && reportType.equals("low")) {
|
||||
request.setAttribute("numberOfStudentWarning", numberOfStudentWarning);
|
||||
request.setAttribute("numberOfStudentDanger", numberOfStudentDanger);
|
||||
request.setAttribute("numberOfStudentLowAtt", numberOfStudentLowAtt);
|
||||
} else {
|
||||
request.setAttribute("numberOfStudentMeetTar", numberOfStudentMeetTar);
|
||||
request.setAttribute("numberOfStudentNotMeetTar", numberOfStudentNotMeetTar);
|
||||
request.setAttribute("attendAVG", attendAVG);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
errList.add("The term must be Integer");
|
||||
}
|
||||
|
||||
request.setAttribute("errMessage", errList);
|
||||
request.setAttribute("yearList", tdb.getLatestReportYear());
|
||||
request.setAttribute("termList", tdb.getSemsterTerm(year));
|
||||
if (studentId != null) {
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/reportStudent.jsp");
|
||||
rd.forward(request, response);
|
||||
} else {
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/reportClass.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
rd = this.getServletContext().getRequestDispatcher("/admin/report.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.AdminDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminScheduleController", urlPatterns = {"/admin/schedule"})
|
||||
public class AdminScheduleController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
RequestDispatcher rd = null;
|
||||
String className = request.getParameter("class");
|
||||
String action = request.getParameter("action");
|
||||
String scheduleId = request.getParameter("id");
|
||||
request.setAttribute("scheduleList", db.getScheduler());
|
||||
request.setAttribute("scheduleAllList", db.getSchedulerAll());
|
||||
if (className != null && className.equalsIgnoreCase("schoolDay")) {
|
||||
if (action != null && action.equals("addPage")) {
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDayAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("search")) {
|
||||
String searchVal = request.getParameter("searchVal");
|
||||
request.setAttribute("scheduleAllList", db.searchScheduler(searchVal));
|
||||
request.setAttribute("scheduleList", db.searchScheduler(searchVal));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDay.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
} else if (action != null && action.equals("save")) {
|
||||
String title = request.getParameter("title");
|
||||
String startDate = request.getParameter("startDate");
|
||||
String endDate = request.getParameter("endDate");
|
||||
String isHoliday = request.getParameter("holiday");
|
||||
String isSchoolDay = request.getParameter("schoolDay");
|
||||
if (isHoliday != null && isHoliday.equalsIgnoreCase("isHoliday") && isSchoolDay != null && isSchoolDay.equalsIgnoreCase("isSchoolDay")) {
|
||||
request.setAttribute("title", title);
|
||||
request.setAttribute("startDate", startDate);
|
||||
request.setAttribute("endDate", endDate);
|
||||
request.setAttribute("errMes", true);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDayEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
System.out.println("TESTADDD");
|
||||
if (isHoliday == null && isSchoolDay == null) {
|
||||
request.setAttribute("title", title);
|
||||
request.setAttribute("startDate", startDate);
|
||||
request.setAttribute("endDate", endDate);
|
||||
request.setAttribute("notselectMes", true);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDayEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
db.updateSchedule(title, startDate, endDate, isHoliday, isSchoolDay, scheduleId);
|
||||
request.setAttribute("saveMes", scheduleId);
|
||||
request.setAttribute("scheduleList", db.getScheduler());
|
||||
request.setAttribute("scheduleAllList", db.getSchedulerAll());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDay.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
} else if (action != null && action.equals("add")) {
|
||||
System.out.println("TESTADDD");
|
||||
String title = request.getParameter("title");
|
||||
String startDate = request.getParameter("startDate");
|
||||
String endDate = request.getParameter("endDate");
|
||||
String isHoliday = request.getParameter("holiday");
|
||||
String isSchoolDay = request.getParameter("schoolDay");
|
||||
System.out.println("isC" + isSchoolDay);
|
||||
if (isHoliday != null && isHoliday.equalsIgnoreCase("isHoliday") && isSchoolDay != null && isSchoolDay.equalsIgnoreCase("isSchoolDay")) {
|
||||
request.setAttribute("title", title);
|
||||
request.setAttribute("startDate", startDate);
|
||||
request.setAttribute("endDate", endDate);
|
||||
request.setAttribute("errMes", true);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDayAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
System.out.println("TESTADDD");
|
||||
if (isHoliday == null && isSchoolDay == null) {
|
||||
request.setAttribute("title", title);
|
||||
request.setAttribute("startDate", startDate);
|
||||
request.setAttribute("endDate", endDate);
|
||||
request.setAttribute("notselectMes", true);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDayAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
System.out.println("test");
|
||||
db.insertSchedule(title, startDate, endDate, isHoliday, isSchoolDay);
|
||||
request.setAttribute("addMes", true);
|
||||
request.setAttribute("scheduleAllList", db.getSchedulerAll());
|
||||
request.setAttribute("scheduleList", db.getScheduler());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDay.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
} else if (action != null && action.equals("delete") && scheduleId != null) {
|
||||
db.deleteSchedule(scheduleId);
|
||||
request.setAttribute("deleteMes", scheduleId);
|
||||
request.setAttribute("scheduleAllList", db.getSchedulerAll());
|
||||
request.setAttribute("scheduleList", db.getScheduler());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDay.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (scheduleId != null) {
|
||||
request.setAttribute("scheduleBean", db.getSchedulerDetials(scheduleId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDayEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleSchoolDay.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
if (className != null) {
|
||||
request.setAttribute("lectureList", db.getLecture(className));
|
||||
request.setAttribute("timeList", db.getTimeList());
|
||||
request.setAttribute("dayList", db.getDayList());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/scheduleClass.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (className != null && className.equals("schoolDay")) {
|
||||
|
||||
}
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/schedule.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,394 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.AdminDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "AdminUserController", urlPatterns = {"/admin/user"})
|
||||
public class AdminUserController extends HttpServlet {
|
||||
|
||||
AdminDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new AdminDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String username = (String) session.getAttribute("username");
|
||||
RequestDispatcher rd = null;
|
||||
String role = request.getParameter("role");
|
||||
|
||||
if (role.equals("Student")) {
|
||||
request.setAttribute("studentList", db.getStudent());
|
||||
String studentId = request.getParameter("id");
|
||||
String action = request.getParameter("action");
|
||||
System.out.println("TEST Point1");
|
||||
request.setAttribute("searchList", db.getSearchHistory("3", username));
|
||||
if (studentId != null && action != null && action.equals("delete")) {
|
||||
System.out.println("TEST Point2");
|
||||
db.deleteStudent(studentId);
|
||||
request.setAttribute("deleteMes", studentId);
|
||||
request.setAttribute("studentList", db.getStudent());
|
||||
} else if (action != null && action.equals("addPage")) {
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
} else if (action != null && action.equals("add")) {
|
||||
System.out.println("TEST Point3");
|
||||
String fname = request.getParameter("fname");
|
||||
String lname = request.getParameter("lname");
|
||||
String gender = request.getParameter("gender");
|
||||
String birthday = request.getParameter("birthday");
|
||||
String password = request.getParameter("password");
|
||||
String pwd = request.getParameter("pwd");
|
||||
if (!password.equals(pwd)) {
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("pwdMes", true);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
String insertId = db.insertStudent(fname, lname, gender, birthday, password);
|
||||
request.setAttribute("addMes", insertId);
|
||||
request.setAttribute("studentList", db.getStudent());
|
||||
} else if (action != null && action.equals("search")) {
|
||||
System.out.println("TEST Point4");
|
||||
String searchVal = request.getParameter("searchVal");
|
||||
request.setAttribute("studentList", db.searchStudent(searchVal));
|
||||
db.insertSearchHistory(searchVal, "3", username);
|
||||
request.setAttribute("searchList", db.getSearchHistory("3", username));
|
||||
} else if (action != null && action.equals("save")) {
|
||||
System.out.println("TEST Point5");
|
||||
String id = request.getParameter("id");
|
||||
String fname = request.getParameter("fname");
|
||||
String lname = request.getParameter("lname");
|
||||
String gender = request.getParameter("gender");
|
||||
String birthday = request.getParameter("birthday");
|
||||
System.out.println("Birthday" + birthday);
|
||||
String email = request.getParameter("email");
|
||||
String password = request.getParameter("password");
|
||||
String pwd = request.getParameter("pwd");
|
||||
request.setAttribute("id", id);
|
||||
if (!password.equals(pwd)) {
|
||||
request.setAttribute("id", id);
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("email", email);
|
||||
request.setAttribute("pwdMes", true);
|
||||
request.setAttribute("student", db.getStudentDetials(studentId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
if (password != "") {
|
||||
db.updateStudent(id, fname, lname, gender, birthday, pwd);
|
||||
} else {
|
||||
db.updateStudent(id, fname, lname, gender, birthday);
|
||||
}
|
||||
request.setAttribute("saveMes", id);
|
||||
request.setAttribute("studentList", db.getStudent());
|
||||
} else if (studentId != null) {
|
||||
System.out.println("TEST Point6");
|
||||
request.setAttribute("student", db.getStudentDetials(studentId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
} else if (role.equals("Teacher")) {
|
||||
String action = request.getParameter("action");
|
||||
String teacherId = request.getParameter("id");
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
request.setAttribute("searchList", db.getSearchHistory("4", username));
|
||||
if (teacherId != null && action != null && action.equals("delete")) {
|
||||
db.deleteTeacher(teacherId);
|
||||
request.setAttribute("deleteMes", teacherId);
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
request.setAttribute("searchList", db.getSearchHistory("4", username));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/user.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("admin")) {
|
||||
db.updateTeacherToAdmin(teacherId);
|
||||
request.setAttribute("updateMes", teacherId);
|
||||
request.setAttribute("searchList", db.getSearchHistory("4", username));
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/user.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("addPage")) {
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("add")) {
|
||||
String fname = request.getParameter("fname");
|
||||
String lname = request.getParameter("lname");
|
||||
String gender = request.getParameter("gender");
|
||||
String birthday = request.getParameter("birthday");
|
||||
String password = request.getParameter("password");
|
||||
String pwd = request.getParameter("pwd");
|
||||
if (db.checkTeacherDupliId(teacherId)) {
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("idMes", true);
|
||||
request.setAttribute("id", teacherId);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
if (!password.equals(pwd)) {
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("pwdMes", true);
|
||||
request.setAttribute("id", teacherId);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
db.insertTeacher(teacherId, fname, lname, gender, birthday, password);
|
||||
request.setAttribute("addMes", teacherId);
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/user.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("search")) {
|
||||
String searchVal = request.getParameter("searchVal");
|
||||
request.setAttribute("teacherList", db.searchTeacher(searchVal));
|
||||
db.insertSearchHistory(searchVal, "4", username);
|
||||
request.setAttribute("searchList", db.getSearchHistory("4", username));
|
||||
} else if (action != null && action.equals("save")) {
|
||||
String fname = request.getParameter("fname");
|
||||
String lname = request.getParameter("lname");
|
||||
String gender = request.getParameter("gender");
|
||||
String birthday = request.getParameter("birthday");
|
||||
String password = request.getParameter("password");
|
||||
String pwd = request.getParameter("pwd");
|
||||
|
||||
if (!password.equals(pwd)) {
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("pwdMes", true);
|
||||
request.setAttribute("id", teacherId);
|
||||
request.setAttribute("teacher", db.getTeacherDetials(teacherId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
if (password != "") {
|
||||
db.updateTeacher(teacherId, password, fname, lname, gender, birthday);
|
||||
} else {
|
||||
db.updateTeacher(teacherId, fname, lname, gender, birthday);
|
||||
}
|
||||
request.setAttribute("saveMes", teacherId);
|
||||
request.setAttribute("teacherList", db.getTeacher());
|
||||
} else if (teacherId != null) {
|
||||
System.out.println("TEST Point6");
|
||||
request.setAttribute("teacher", db.getTeacherDetials(teacherId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
} else if (role.equals("Admin")) {
|
||||
|
||||
String action = request.getParameter("action");
|
||||
String adminId = request.getParameter("id");
|
||||
request.setAttribute("adminList", db.getAdmin());
|
||||
request.setAttribute("searchList", db.getSearchHistory("5", username));
|
||||
if (adminId != null && action != null && action.equals("delete")) {
|
||||
db.deleteAdmin(adminId);
|
||||
request.setAttribute("deleteMes", adminId);
|
||||
request.setAttribute("adminList", db.getAdmin());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/user.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("addPage")) {
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if (action != null && action.equals("teacher")) {
|
||||
db.updateAdminToTeacher(adminId);
|
||||
request.setAttribute("updateMes", adminId);
|
||||
request.setAttribute("searchList", db.getSearchHistory("5", username));
|
||||
request.setAttribute("adminList", db.getAdmin());
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/user.jsp");
|
||||
} else if (action != null && action.equals("add")) {
|
||||
String fname = request.getParameter("fname");
|
||||
String lname = request.getParameter("lname");
|
||||
String gender = request.getParameter("gender");
|
||||
String birthday = request.getParameter("birthday");
|
||||
String password = request.getParameter("password");
|
||||
String pwd = request.getParameter("pwd");
|
||||
if (db.checkAdminDupliId(adminId)) {
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("idMes", true);
|
||||
request.setAttribute("id", adminId);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
if (!password.equals(pwd)) {
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("pwdMes", true);
|
||||
request.setAttribute("id", adminId);
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userAdd.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
db.insertAdmin(adminId, fname, lname, gender, birthday, password);
|
||||
request.setAttribute("addMes", adminId);
|
||||
request.setAttribute("adminList", db.getAdmin());
|
||||
|
||||
} else if (action != null && action.equals("search")) {
|
||||
String searchVal = request.getParameter("searchVal");
|
||||
request.setAttribute("adminList", db.searchAdmin(searchVal));
|
||||
db.insertSearchHistory(searchVal, "5", username);
|
||||
request.setAttribute("searchList", db.getSearchHistory("5", username));
|
||||
} else if (action != null && action.equals("save")) {
|
||||
String fname = request.getParameter("fname");
|
||||
String lname = request.getParameter("lname");
|
||||
String gender = request.getParameter("gender");
|
||||
String birthday = request.getParameter("birthday");
|
||||
String password = request.getParameter("password");
|
||||
String pwd = request.getParameter("pwd");
|
||||
|
||||
if (!password.equals(pwd)) {
|
||||
request.setAttribute("fname", fname);
|
||||
request.setAttribute("lname", lname);
|
||||
request.setAttribute("gender", gender);
|
||||
request.setAttribute("birthday", birthday);
|
||||
request.setAttribute("pwdMes", true);
|
||||
request.setAttribute("id", adminId);
|
||||
request.setAttribute("admin", db.getAdminDetials(adminId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
if (password != "") {
|
||||
db.updateAdmin(adminId, password, fname, lname, gender, birthday);
|
||||
} else {
|
||||
db.updateAdmin(adminId, fname, lname, gender, birthday);
|
||||
}
|
||||
request.setAttribute("saveMes", adminId);
|
||||
request.setAttribute("adminList", db.getAdmin());
|
||||
|
||||
} else if (adminId != null) {
|
||||
System.out.println("TEST Point6");
|
||||
request.setAttribute("admin", db.getAdminDetials(adminId));
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/userEdit.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
}
|
||||
System.out.println("TEST Point10");
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/admin/user.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "ErrorController", urlPatterns = {"/error"})
|
||||
public class ErrorController extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/404error.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "ErrorHandler", urlPatterns = {"/ErrorHandler"})
|
||||
public class ErrorHandler extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. You may use following sample code. */
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Servlet ErrorHandler</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Servlet ErrorHandler at " + request.getContextPath() + "</h1>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
private void processError(HttpServletRequest request,
|
||||
HttpServletResponse response) throws IOException {
|
||||
// Analyze the servlet exception
|
||||
Throwable throwable = (Throwable) request
|
||||
.getAttribute("javax.servlet.error.exception");
|
||||
Integer statusCode = (Integer) request
|
||||
.getAttribute("javax.servlet.error.status_code");
|
||||
String servletName = (String) request
|
||||
.getAttribute("javax.servlet.error.servlet_name");
|
||||
if (servletName == null) {
|
||||
servletName = "Unknown";
|
||||
}
|
||||
String requestUri = (String) request
|
||||
.getAttribute("javax.servlet.error.request_uri");
|
||||
if (requestUri == null) {
|
||||
requestUri = "Unknown";
|
||||
}
|
||||
|
||||
// Set response content type
|
||||
response.setContentType("text/html");
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write("<html><head><title>Exception/Error Details</title></head><body>");
|
||||
if(statusCode != 500){
|
||||
out.write("<h3>Error Details</h3>");
|
||||
out.write("<strong>Status Code</strong>:"+statusCode+"<br>");
|
||||
out.write("<strong>Requested URI</strong>:"+requestUri);
|
||||
}else{
|
||||
out.write("<h3>Exception Details</h3>");
|
||||
out.write("<ul><li>Servlet Name:"+servletName+"</li>");
|
||||
out.write("<li>Exception Name:"+throwable.getClass().getName()+"</li>");
|
||||
out.write("<li>Requested URI:"+requestUri+"</li>");
|
||||
out.write("<li>Exception Message:"+throwable.getMessage()+"</li>");
|
||||
out.write("</ul>");
|
||||
}
|
||||
|
||||
out.write("<br><br>");
|
||||
out.write(" <button onclick=\"history.back()\" class=\"btn btn-primary btn-lg\">\n" +
|
||||
" <span class=\"glyphicon glyphicon-home\"></span>\n" +
|
||||
" Back to Home\n" +
|
||||
" </button>");
|
||||
out.write("</body></html>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "IndexController", urlPatterns = {"/index, /"})
|
||||
public class IndexController extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
RequestDispatcher rd = null;
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null || session.getAttribute("userrole") == null) {
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/index.jsp");
|
||||
rd.forward(request, response);
|
||||
} else {
|
||||
if (session.getAttribute("userrole").equals("Admin")) {
|
||||
response.sendRedirect("admin/dashboard");
|
||||
} else if (session.getAttribute("userrole").equals("Teacher")) {
|
||||
response.sendRedirect("teacher/dashboard");
|
||||
} else {
|
||||
response.sendRedirect("dashboard");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
rd = this.getServletContext()
|
||||
.getRequestDispatcher("/index.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.bean.LoginBean;
|
||||
import system.db.LoginValid;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jerrykwok
|
||||
*/
|
||||
@WebServlet(name = "LoginController", urlPatterns = {"/login"})
|
||||
public class LoginController extends HttpServlet {
|
||||
|
||||
private LoginValid db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new LoginValid(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
String action = request.getParameter("action");
|
||||
if (action == null) {
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/login.jsp");
|
||||
rd.forward(request, response);
|
||||
} else if ("authenticate".equals(action)) {
|
||||
try {
|
||||
doAuthenticate(request, response);
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
} else if ("logout".equals(action)) {
|
||||
doLogout(request, response);
|
||||
} else {
|
||||
response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
||||
|
||||
private void doAuthenticate(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException {
|
||||
String action = request.getParameter("action");
|
||||
String username = request.getParameter("username");
|
||||
String pwd = request.getParameter("pwd");
|
||||
String role = request.getParameter("role");
|
||||
RequestDispatcher rd = null;
|
||||
// System.out.println(action + username + pwd + role);
|
||||
if (!role.equalsIgnoreCase("Teacher") && !role.equalsIgnoreCase("Student") && !role.equalsIgnoreCase("Admin")) {
|
||||
request.setAttribute("roleMes", true);
|
||||
rd = this.getServletContext().getRequestDispatcher("/index.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
LoginBean loginBean = new LoginBean();
|
||||
loginBean.setUsername(username);
|
||||
loginBean.setPassword(pwd);
|
||||
loginBean.setRole(role);
|
||||
boolean loginSucecss = false;
|
||||
if (role.equalsIgnoreCase("Teacher")) {
|
||||
loginSucecss = db.validateStaffLogin(loginBean, 1);
|
||||
} else if (role.equalsIgnoreCase("Admin")) {
|
||||
loginSucecss = db.validateStaffLogin(loginBean, 2);
|
||||
} else if (role.equalsIgnoreCase("Student")) {
|
||||
loginSucecss = db.validateStudentLogin(loginBean);
|
||||
}
|
||||
if (!loginSucecss) {
|
||||
request.setAttribute("loginMes", username);
|
||||
request.setAttribute("role", role);
|
||||
rd = this.getServletContext().getRequestDispatcher("/login.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
String targetURL = null;
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("username", username);
|
||||
session.setAttribute("userrole", loginBean.getRole());
|
||||
switch (role) {
|
||||
case "Student":
|
||||
targetURL = "student/dashboard";//
|
||||
break;
|
||||
case "Teacher":
|
||||
targetURL = "teacher/dashboard";
|
||||
break;
|
||||
case "Admin":
|
||||
targetURL = "admin/dashboard";
|
||||
break;
|
||||
}
|
||||
response.sendRedirect(targetURL);
|
||||
}
|
||||
|
||||
private boolean isAuthenticated(HttpServletRequest request) {
|
||||
boolean result = false;
|
||||
HttpSession session = request.getSession();
|
||||
if (session.getAttribute("username") != null) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void doLogout(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session != null) {
|
||||
session.removeAttribute("username");
|
||||
session.invalidate();
|
||||
}
|
||||
response.sendRedirect("index");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
}
|
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.bean.AttendBean;
|
||||
import system.bean.SchedulerBean;
|
||||
import system.bean.SemesterBean;
|
||||
import system.bean.StudentBean;
|
||||
import system.db.StudentDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "StudentAttendController", urlPatterns = {"/student/attendance"})
|
||||
public class StudentAttendController extends HttpServlet {
|
||||
|
||||
private StudentDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new StudentDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
HttpSession session = request.getSession(false);
|
||||
try {
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
|
||||
RequestDispatcher rd;
|
||||
String studentId = (String) session.getAttribute("username");
|
||||
|
||||
String className = db.getStudentClass(studentId);
|
||||
String strTerm = db.getMaxTerm();
|
||||
|
||||
// String reportType = request.getParameter("report");
|
||||
if (className != null) {
|
||||
String year = request.getParameter("year");
|
||||
ArrayList<String> errList = new ArrayList<String>();
|
||||
if (strTerm == null) {
|
||||
strTerm = "1";
|
||||
};
|
||||
if (year == null) {
|
||||
year = Calendar.getInstance().get(Calendar.YEAR) + "";
|
||||
}
|
||||
|
||||
try {
|
||||
int term = Integer.parseInt(strTerm);
|
||||
SemesterBean semBean = db.getSemsterDate(year, term);
|
||||
int totalSchoolDay = semBean.getCountBusineseDate();
|
||||
int countHoliday = 0;
|
||||
for (SchedulerBean scheduler : db.getSchCalenderholiday()) {
|
||||
if (scheduler.isHoliday() && scheduler.getCountDate() == 0) {
|
||||
switch (scheduler.getStart_day_week()) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
countHoliday++;
|
||||
}
|
||||
} else if (scheduler.isHoliday() && scheduler.getCountDate() > 0) {
|
||||
countHoliday += scheduler.getCountBusineseDay() + 1;
|
||||
//countHoliday += scheduler.getCountDate();
|
||||
}
|
||||
}
|
||||
totalSchoolDay = totalSchoolDay - countHoliday;
|
||||
System.out.println(totalSchoolDay);
|
||||
ArrayList<StudentBean> studentList = db.getStudentAttend(semBean.getStart_date(), semBean.getEnd_date(), className);
|
||||
int allStudentCountDay = 0;
|
||||
int numberOfStudent = 0;
|
||||
int numberOfStudentNotMeetTar = 0;
|
||||
int numberOfStudentMeetTar = 0;
|
||||
int numberOfStudentWarning = 0;
|
||||
int numberOfStudentDanger = 0;
|
||||
int numberOfStudentLowAtt = 0;
|
||||
double avgStudentAttendDay = 0;
|
||||
StudentBean studentBean = null;
|
||||
for (StudentBean student : studentList) {
|
||||
int countDay = student.getAttendDay();
|
||||
allStudentCountDay += countDay;
|
||||
double attendRate = Math.round((countDay / (float) totalSchoolDay) * 100);
|
||||
student.setAttendRate(attendRate);
|
||||
numberOfStudent++;
|
||||
if (attendRate >= db.getAttendanceRateTarget(className)) {
|
||||
numberOfStudentMeetTar++;
|
||||
} else {
|
||||
numberOfStudentNotMeetTar++;
|
||||
}
|
||||
System.out.println(student.getId());
|
||||
if (studentId != null && student.getId().equals(studentId)) {
|
||||
studentBean = student;
|
||||
}
|
||||
}
|
||||
// ArrayList<StudentBean> lowAttendList = null;
|
||||
/* if (reportType != null && reportType.equals("low")) {
|
||||
lowAttendList = new ArrayList<StudentBean>();
|
||||
double avgLowAttend = 0;
|
||||
for (StudentBean student : studentList) {
|
||||
if (student.getAttendRate() <= db.getAttendanceRateTarget(className)) {
|
||||
lowAttendList.add(student);
|
||||
}
|
||||
if (student.getAttendRate() >= 50.0 && student.getAttendRate() < 60.0) {
|
||||
numberOfStudentWarning++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
} else if (student.getAttendRate() <= 49.0 && student.getAttendRate() >= 40.0) {
|
||||
numberOfStudentDanger++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
} else if (student.getAttendRate() >= db.getAttendanceRateTarget(className)) {
|
||||
|
||||
} else {
|
||||
numberOfStudentLowAtt++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
}
|
||||
}
|
||||
avgLowAttend = avgLowAttend / (numberOfStudentWarning + numberOfStudentDanger + numberOfStudentLowAtt);
|
||||
request.setAttribute("attendAVG", avgLowAttend);
|
||||
}*/
|
||||
|
||||
/* if (studentList.size() == 0 || reportType != null && reportType.equals("low") && lowAttendList.size() == 0) {
|
||||
request.setAttribute("studentAttendList", db.getAllStudentAttendZero(className));
|
||||
} else {
|
||||
if (reportType != null && reportType.equals("low")) {
|
||||
request.setAttribute("studentAttendList", lowAttendList);
|
||||
} else {
|
||||
request.setAttribute("studentAttendList", studentList);
|
||||
}
|
||||
}*/
|
||||
if (studentId != null) {
|
||||
studentBean.setAttendList(db.getStudentAttendDetail(studentId, year, term));
|
||||
request.setAttribute("studentDetials", studentBean);
|
||||
int totalAttendDay = 0;
|
||||
int presentDay = 0;
|
||||
int absDay = 0;
|
||||
for (AttendBean attend : studentBean.getAttendList()) {
|
||||
if (attend.isAttend()) {
|
||||
presentDay++;
|
||||
} else {
|
||||
absDay++;
|
||||
}
|
||||
totalAttendDay++;
|
||||
}
|
||||
request.setAttribute("presentDay", presentDay);
|
||||
request.setAttribute("absDay", absDay);
|
||||
request.setAttribute("totalAttendDay", totalAttendDay);
|
||||
}
|
||||
try {
|
||||
avgStudentAttendDay = (allStudentCountDay / numberOfStudent);
|
||||
} catch (ArithmeticException e) {
|
||||
avgStudentAttendDay = 0;
|
||||
}
|
||||
int attendAVG = 0;
|
||||
if(avgStudentAttendDay>0){
|
||||
attendAVG = (int) Math.round((1-(totalSchoolDay - avgStudentAttendDay) / totalSchoolDay) * 100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
request.setAttribute("numberOfStudentMeetTar", numberOfStudentMeetTar);
|
||||
request.setAttribute("numberOfStudentNotMeetTar", numberOfStudentNotMeetTar);
|
||||
request.setAttribute("attendAVG", attendAVG);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
errList.add("The term must be Integer");
|
||||
}
|
||||
|
||||
request.setAttribute("errMessage", errList);
|
||||
request.setAttribute("yearList", db.getLatestReportYear());
|
||||
request.setAttribute("termList", db.getSemsterTerm(year));
|
||||
}
|
||||
|
||||
rd = this.getServletContext().getRequestDispatcher("/student/attendanceStudent.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*String StudentId = (String) session.getAttribute("username");
|
||||
String className = request.getParameter("class");
|
||||
String attendDate = request.getParameter("date");
|
||||
String action = request.getParameter("action");
|
||||
RequestDispatcher rd = null;
|
||||
db.setStudentId(StudentId);
|
||||
if (className == null) {
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
rd = this.getServletContext().getRequestDispatcher("/student/attendance.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
if (action != null && action.equals("save")) {
|
||||
|
||||
if (className != null && attendDate != null) {
|
||||
ArrayList<StudentBean> studentList = db.getAllStudentClass(className);
|
||||
String[] attendStudents = request.getParameterValues("attend");
|
||||
if (attendStudents != null) {
|
||||
for (String studentId : attendStudents) {
|
||||
db.insertStudentAttendance(studentId, attendDate, true);
|
||||
for (StudentBean student : studentList) {
|
||||
if (student.getId().equals(studentId)) {
|
||||
studentList.remove(student);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (StudentBean student : studentList) {
|
||||
db.insertStudentAttendance(student.getId(), attendDate, false);
|
||||
}
|
||||
}
|
||||
request.setAttribute("message", true);
|
||||
}*/
|
||||
/* if (attendDate == null) {
|
||||
attendDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
}
|
||||
request.setAttribute("date", attendDate);
|
||||
request.setAttribute("studentAttendList", db.getAttendClass(className, attendDate));
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
rd = this.getServletContext().getRequestDispatcher("/student/attendanceStudent.jsp");
|
||||
rd.forward(request, response);*/
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.StudentDB;
|
||||
|
||||
|
||||
@WebServlet(name = "StudentDashboardController", urlPatterns = {"/student/dashboard"})
|
||||
public class StudentDashboardController extends HttpServlet {
|
||||
|
||||
private StudentDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new StudentDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String studentId = (String) session.getAttribute("username");
|
||||
db.setStudentId(studentId);
|
||||
request.setAttribute("courseCount", db.getCountClass());
|
||||
request.setAttribute("studentCount", db.getCountStudent());
|
||||
request.setAttribute("lectureList", db.getLecture(studentId));
|
||||
request.setAttribute("timeList", db.getAllTimeLecture());
|
||||
request.setAttribute("dayList", db.getAllDayLecture());
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/student/dashboard.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (NullPointerException e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.bean.StudentBean;
|
||||
import system.db.TeacherDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "TeacherAttendController", urlPatterns = {"/teacher/attendance"})
|
||||
public class TeacherAttendController extends HttpServlet {
|
||||
|
||||
private TeacherDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new TeacherDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
HttpSession session = request.getSession(false);
|
||||
try {
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String teacherId = (String) session.getAttribute("username");
|
||||
String className = request.getParameter("class");
|
||||
String attendDate = request.getParameter("date");
|
||||
String action = request.getParameter("action");
|
||||
RequestDispatcher rd = null;
|
||||
db.setTeacherId(teacherId);
|
||||
if (className == null) {
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
rd = this.getServletContext().getRequestDispatcher("/teacher/attendance.jsp");
|
||||
rd.forward(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action != null && action.equals("save")) {
|
||||
|
||||
if (className != null && attendDate != null) {
|
||||
ArrayList<StudentBean> studentList = db.getAllStudentClass(className);
|
||||
String[] attendStudents = request.getParameterValues("attend");
|
||||
if (attendStudents != null) {
|
||||
for (String studentId : attendStudents) {
|
||||
db.insertStudentAttendance(studentId, attendDate, true);
|
||||
for (StudentBean student : studentList) {
|
||||
if (student.getId().equals(studentId)) {
|
||||
studentList.remove(student);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (StudentBean student : studentList) {
|
||||
db.insertStudentAttendance(student.getId(), attendDate, false);
|
||||
}
|
||||
}
|
||||
request.setAttribute("message", true);
|
||||
}
|
||||
if (attendDate == null) {
|
||||
attendDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
}
|
||||
request.setAttribute("date", attendDate);
|
||||
request.setAttribute("studentAttendList", db.getAttendClass(className, attendDate));
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
rd = this.getServletContext().getRequestDispatcher("/teacher/attendanceStudent.jsp");
|
||||
rd.forward(request, response);
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.db.TeacherDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "TeacherDashbaordController", urlPatterns = {"/teacher/dashboard"})
|
||||
public class TeacherDashbaordController extends HttpServlet {
|
||||
|
||||
private TeacherDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new TeacherDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
String teacherId = (String) session.getAttribute("username");
|
||||
db.setTeacherId(teacherId);
|
||||
request.setAttribute("courseCount", db.getCountClass());
|
||||
request.setAttribute("studentCount", db.getCountStudent());
|
||||
request.setAttribute("lectureList", db.getAllLecture(teacherId));
|
||||
request.setAttribute("timeList", db.getAllTimeLecture());
|
||||
request.setAttribute("dayList", db.getAllDayLecture());
|
||||
RequestDispatcher rd = this.getServletContext()
|
||||
.getRequestDispatcher("/teacher/dashboard.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (NullPointerException e) {
|
||||
response.sendRedirect("../index");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.sql.Date;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import system.bean.AttendBean;
|
||||
import system.bean.SchedulerBean;
|
||||
import system.bean.SemesterBean;
|
||||
import system.bean.StudentBean;
|
||||
import system.db.TeacherDB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
@WebServlet(name = "TeacherReportController", urlPatterns = {"/teacher/report"})
|
||||
public class TeacherReportController extends HttpServlet {
|
||||
|
||||
private TeacherDB db;
|
||||
|
||||
public void init() {
|
||||
String dbUser = this.getServletContext().getInitParameter("dbUser");
|
||||
String dbPassword = this.getServletContext().getInitParameter("dbPassword");
|
||||
String dbUrl = this.getServletContext().getInitParameter("dbUrl");
|
||||
db = new TeacherDB(dbUrl, dbUser, dbPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session.getAttribute("username") == null) {
|
||||
response.sendRedirect("../index.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
RequestDispatcher rd;
|
||||
String className = request.getParameter("class");
|
||||
String strTerm = request.getParameter("term");
|
||||
String studentId = request.getParameter("studentId");
|
||||
request.setAttribute("classList", db.getAllClass());
|
||||
String reportType = request.getParameter("report");
|
||||
if (className != null) {
|
||||
String year = request.getParameter("year");
|
||||
ArrayList<String> errList = new ArrayList<String>();
|
||||
if (strTerm == null) {
|
||||
strTerm = "1";
|
||||
};
|
||||
if (year == null) {
|
||||
year = Calendar.getInstance().get(Calendar.YEAR) + "";
|
||||
}
|
||||
|
||||
try {
|
||||
int term = Integer.parseInt(strTerm);
|
||||
SemesterBean semBean = db.getSemsterDate(year, term);
|
||||
int totalSchoolDay = semBean.getCountBusineseDate();
|
||||
int countHoliday = 0;
|
||||
for (SchedulerBean scheduler : db.getSchCalenderholiday()) {
|
||||
if (scheduler.isHoliday() && scheduler.getCountDate() == 0) {
|
||||
switch (scheduler.getStart_day_week()) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
countHoliday++;
|
||||
}
|
||||
} else if (scheduler.isHoliday() && scheduler.getCountDate() > 0) {
|
||||
countHoliday += scheduler.getCountBusineseDay() + 1;
|
||||
//countHoliday += scheduler.getCountDate();
|
||||
}
|
||||
}
|
||||
totalSchoolDay = totalSchoolDay - countHoliday;
|
||||
System.out.println(totalSchoolDay);
|
||||
ArrayList<StudentBean> studentList = db.getStudentAttend(semBean.getStart_date(), semBean.getEnd_date(), className);
|
||||
int allStudentCountDay = 0;
|
||||
int numberOfStudent = 0;
|
||||
int numberOfStudentNotMeetTar = 0;
|
||||
int numberOfStudentMeetTar = 0;
|
||||
int numberOfStudentWarning = 0;
|
||||
int numberOfStudentDanger = 0;
|
||||
int numberOfStudentLowAtt = 0;
|
||||
double avgStudentAttendDay = 0;
|
||||
StudentBean studentBean = null;
|
||||
|
||||
for (StudentBean student : studentList) {
|
||||
int countDay = student.getAttendDay();
|
||||
allStudentCountDay += countDay;
|
||||
double attendRate = Math.round((countDay / (float) totalSchoolDay) * 100);
|
||||
student.setAttendRate(attendRate);
|
||||
numberOfStudent++;
|
||||
if (attendRate >= db.getAttendanceRateTarget(className)) {
|
||||
numberOfStudentMeetTar++;
|
||||
} else {
|
||||
numberOfStudentNotMeetTar++;
|
||||
}
|
||||
System.out.println(student.getId());
|
||||
if (studentId != null && student.getId().equals(studentId)) {
|
||||
studentBean = student;
|
||||
}
|
||||
}
|
||||
ArrayList<StudentBean> lowAttendList = null;
|
||||
if (reportType != null && reportType.equals("low")) {
|
||||
lowAttendList = new ArrayList<StudentBean>();
|
||||
double avgLowAttend = 0;
|
||||
for (StudentBean student : studentList) {
|
||||
if (student.getAttendRate() <= db.getAttendanceRateTarget(className)) {
|
||||
lowAttendList.add(student);
|
||||
}
|
||||
if (student.getAttendRate() >= 50.0 && student.getAttendRate() < 60.0) {
|
||||
numberOfStudentWarning++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
} else if (student.getAttendRate() <= 49.0 && student.getAttendRate() >= 40.0) {
|
||||
numberOfStudentDanger++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
} else if (student.getAttendRate() >= db.getAttendanceRateTarget(className)) {
|
||||
|
||||
} else {
|
||||
numberOfStudentLowAtt++;
|
||||
avgLowAttend += student.getAttendRate();
|
||||
}
|
||||
}
|
||||
avgLowAttend = avgLowAttend / (numberOfStudentWarning + numberOfStudentDanger + numberOfStudentLowAtt);
|
||||
request.setAttribute("attendAVG", avgLowAttend);
|
||||
}
|
||||
|
||||
if (studentList.size() == 0 || reportType != null && reportType.equals("low") && lowAttendList.size() == 0) {
|
||||
request.setAttribute("studentAttendList", db.getAllStudentAttendZero(className));
|
||||
} else {
|
||||
if (reportType != null && reportType.equals("low")) {
|
||||
request.setAttribute("studentAttendList", lowAttendList);
|
||||
} else {
|
||||
request.setAttribute("studentAttendList", studentList);
|
||||
}
|
||||
}
|
||||
if (studentId != null) {
|
||||
studentBean.setAttendList(db.getStudentAttendDetail(studentId, year, term));
|
||||
request.setAttribute("studentDetials", studentBean);
|
||||
int totalAttendDay = 0;
|
||||
int presentDay = 0;
|
||||
int absDay = 0;
|
||||
for (AttendBean attend : studentBean.getAttendList()) {
|
||||
if (attend.isAttend()) {
|
||||
presentDay++;
|
||||
} else {
|
||||
absDay++;
|
||||
}
|
||||
totalAttendDay++;
|
||||
}
|
||||
request.setAttribute("presentDay", presentDay);
|
||||
request.setAttribute("absDay", absDay);
|
||||
request.setAttribute("totalAttendDay", totalAttendDay);
|
||||
}
|
||||
try {
|
||||
avgStudentAttendDay = (allStudentCountDay / numberOfStudent);
|
||||
} catch (ArithmeticException e) {
|
||||
avgStudentAttendDay = 0;
|
||||
}
|
||||
int attendAVG = 0;
|
||||
if (avgStudentAttendDay > 0) {
|
||||
attendAVG = (int) Math.round((1 - (totalSchoolDay - avgStudentAttendDay) / totalSchoolDay) * 100);
|
||||
}
|
||||
|
||||
if (reportType != null && reportType.equals("low")) {
|
||||
request.setAttribute("numberOfStudentWarning", numberOfStudentWarning);
|
||||
request.setAttribute("numberOfStudentDanger", numberOfStudentDanger);
|
||||
request.setAttribute("numberOfStudentLowAtt", numberOfStudentLowAtt);
|
||||
} else {
|
||||
request.setAttribute("numberOfStudentMeetTar", numberOfStudentMeetTar);
|
||||
request.setAttribute("numberOfStudentNotMeetTar", numberOfStudentNotMeetTar);
|
||||
request.setAttribute("attendAVG", attendAVG);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
errList.add("The term must be Integer");
|
||||
}
|
||||
|
||||
request.setAttribute("errMessage", errList);
|
||||
request.setAttribute("yearList", db.getLatestReportYear());
|
||||
request.setAttribute("termList", db.getSemsterTerm(year));
|
||||
if (studentId != null) {
|
||||
rd = this.getServletContext().getRequestDispatcher("/teacher/reportStudent.jsp");
|
||||
rd.forward(request, response);
|
||||
} else {
|
||||
rd = this.getServletContext().getRequestDispatcher("/teacher/reportClass.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
rd = this.getServletContext().getRequestDispatcher("/teacher/report.jsp");
|
||||
rd.forward(request, response);
|
||||
} catch (Exception e) {
|
||||
response.sendRedirect("../index");
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package system.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.jsp.*;
|
||||
import javax.servlet.jsp.tagext.SimpleTagSupport;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JerryKwok
|
||||
*/
|
||||
public class NavTag extends SimpleTagSupport {
|
||||
|
||||
private String role;
|
||||
private String active;
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public void setActive(String active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public void doTag() {
|
||||
try {
|
||||
JspWriter out = getJspContext().getOut();
|
||||
out.print("<div class=\"list-group\">");
|
||||
if (role.equalsIgnoreCase("Student")) {
|
||||
|
||||
out.print("<a href=\"dashboard\" class=\"list-group-item main-color-bg-nav>");
|
||||
if (active.equalsIgnoreCase("dashboard")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">dashboard</i> ");
|
||||
out.print("<span>Dashboard</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"attendance\" class=\"list-group-item >");
|
||||
if (active.equalsIgnoreCase("attendance")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">check_box</i>");
|
||||
out.print("<span> Attendance</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"../login?action=logout\" class=\"list-group-item text-right\">");
|
||||
out.print("<span> Logout</span> ");
|
||||
out.print("</a>");
|
||||
|
||||
} else if (role.equalsIgnoreCase("Admin")) {
|
||||
|
||||
out.print("<a href=\"dashboard\" class=\"list-group-item main-color-bg-nav");
|
||||
if (active.equalsIgnoreCase("dashboard")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">dashboard</i> ");
|
||||
out.print("<span>Dashboard</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"lecture\" class=\"list-group-item main-color-bg-nav");
|
||||
if (active.equalsIgnoreCase("Lecture")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">view_module</i> ");
|
||||
out.print("<span>Lecture</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"class\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Class")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">class</i><span>Class</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"classReg\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("ClassReg")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">account_tree</i><span> Class Register</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"user?role=Student\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Student")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">library_books</i><span> Student</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"user?role=Teacher\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Teacher")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">supervisor_account</i><span> Teacher</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"user?role=Admin\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Admin")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">vpn_key</i> <span> Admin</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"schedule\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Schdeule")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">schedule</i><span> Schedule</span>");
|
||||
out.print("</a>");
|
||||
out.print(" <a href=\"attendance\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Attendance")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">check_box</i><span> Attendance</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"report\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Report")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">insert_drive_file</i><span> Reports</span>");
|
||||
out.print("</a>");
|
||||
out.print("<a href=\"../login?action=logout\" class=\"list-group-item text-right\">");
|
||||
out.print("<span> Logout</span> ");
|
||||
out.print("</a>");
|
||||
|
||||
} else if (role.equalsIgnoreCase("Teacher")) {
|
||||
out.print(" <a href=\"dashboard\" class=\"list-group-item main-color-bg-nav");
|
||||
if (active.equalsIgnoreCase("dashboard")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">dashboard</i><span>Dashboard</span></a>");
|
||||
out.print(" <a href=\"attendance\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Attendance")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">check_box</i><span> Attendace</span></a>");
|
||||
out.print("<a href=\"report\" class=\"list-group-item");
|
||||
if (active.equalsIgnoreCase("Report")) {
|
||||
out.print(" active\">");
|
||||
} else {
|
||||
out.print("\">");
|
||||
}
|
||||
out.print("<i class=\"material-icons\">insert_drive_file</i><span> Reports</span></a>");
|
||||
out.print("<a href=\"../login?action=logout\" class=\"list-group-item text-right\"><span> Logout</span></a>");
|
||||
}
|
||||
out.print("</div>");
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user