diff --git a/.DS_Store b/.DS_Store index bb0e384..c64e69a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Assignment.java b/Assignment.java deleted file mode 100644 index 6de5fa5..0000000 --- a/Assignment.java +++ /dev/null @@ -1,25 +0,0 @@ - - -public class Assignment { - - private String name; - private Float weight; - private Float grade; - - - - public String getName() { - return name; - } - - public Float getWeight() { - return weight; - - } - - public Float getGrade() { - return grade; - } - - -} diff --git a/GradingSystemWMX/bin/Abandon/AddStudentFrame$TextChanged.class b/GradingSystemWMX/bin/Abandon/AddStudentFrame$TextChanged.class new file mode 100644 index 0000000..f09f97a Binary files /dev/null and b/GradingSystemWMX/bin/Abandon/AddStudentFrame$TextChanged.class differ diff --git a/GradingSystemWMX/bin/Abandon/AddStudentFrame.class b/GradingSystemWMX/bin/Abandon/AddStudentFrame.class new file mode 100644 index 0000000..9204e35 Binary files /dev/null and b/GradingSystemWMX/bin/Abandon/AddStudentFrame.class differ diff --git a/GradingSystemWMX/bin/daos/CourseDao.class b/GradingSystemWMX/bin/daos/CourseDao.class index 4c64189..555ce35 100644 Binary files a/GradingSystemWMX/bin/daos/CourseDao.class and b/GradingSystemWMX/bin/daos/CourseDao.class differ diff --git a/GradingSystemWMX/bin/daos/GradesDao.class b/GradingSystemWMX/bin/daos/GradesDao.class index 1f607fa..f2e9121 100644 Binary files a/GradingSystemWMX/bin/daos/GradesDao.class and b/GradingSystemWMX/bin/daos/GradesDao.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$1.class b/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$1.class deleted file mode 100644 index 9b3aeec..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$1.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$2.class b/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$2.class deleted file mode 100644 index 1e0017b..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$2.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$TextChanged.class b/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$TextChanged.class deleted file mode 100644 index bd40b56..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame$TextChanged.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame.class b/GradingSystemWMX/bin/uis/Frame/AddStudentFrame.class deleted file mode 100644 index de63b00..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/AddStudentFrame.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/DelFrame$1.class b/GradingSystemWMX/bin/uis/Frame/DelFrame$1.class index b05ce19..011173b 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/DelFrame$1.class and b/GradingSystemWMX/bin/uis/Frame/DelFrame$1.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/DelFrame$2.class b/GradingSystemWMX/bin/uis/Frame/DelFrame$2.class index 4eefc92..9a8fdf5 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/DelFrame$2.class and b/GradingSystemWMX/bin/uis/Frame/DelFrame$2.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/DelFrame$3.class b/GradingSystemWMX/bin/uis/Frame/DelFrame$3.class index 5a387de..61e4e63 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/DelFrame$3.class and b/GradingSystemWMX/bin/uis/Frame/DelFrame$3.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/DelFrame.class b/GradingSystemWMX/bin/uis/Frame/DelFrame.class index 7dd7cc8..3501e9b 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/DelFrame.class and b/GradingSystemWMX/bin/uis/Frame/DelFrame.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$1.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$1.class index 4689536..c1217a6 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame$1.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$1.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$2.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$2.class index e20d013..29f45e1 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame$2.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$2.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$3.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$3.class index 06aa449..1c317af 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame$3.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$3.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$4.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$4.class index cae1a4c..46f40f3 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame$4.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$4.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$5.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$5.class index 7cd29b5..ee1c4c1 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame$5.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$5.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$6.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$6.class index a001dc3..ff25c56 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame$6.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$6.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$7.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$7.class index 9148c7b..7a50dfc 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame$7.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$7.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame$8.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame$8.class new file mode 100644 index 0000000..23a6b66 Binary files /dev/null and b/GradingSystemWMX/bin/uis/Frame/InfoFrame$8.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/InfoFrame.class b/GradingSystemWMX/bin/uis/Frame/InfoFrame.class index af565ff..6ae589b 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/InfoFrame.class and b/GradingSystemWMX/bin/uis/Frame/InfoFrame.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/Login$1.class b/GradingSystemWMX/bin/uis/Frame/Login$1.class index 8387a7a..951e25e 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/Login$1.class and b/GradingSystemWMX/bin/uis/Frame/Login$1.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/Login$2.class b/GradingSystemWMX/bin/uis/Frame/Login$2.class index 73485fe..b9acd30 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/Login$2.class and b/GradingSystemWMX/bin/uis/Frame/Login$2.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/Login$3.class b/GradingSystemWMX/bin/uis/Frame/Login$3.class index 97de0d6..9ee56f6 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/Login$3.class and b/GradingSystemWMX/bin/uis/Frame/Login$3.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/Login.class b/GradingSystemWMX/bin/uis/Frame/Login.class index 3928518..3767e29 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/Login.class and b/GradingSystemWMX/bin/uis/Frame/Login.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$1.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$1.class index 553bf82..403bbaa 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$1.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$1.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$10.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$10.class index 7e65d92..e8a73cb 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$10.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$10.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$2.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$2.class index 5fa8b44..8b9b954 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$2.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$2.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$3.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$3.class index 683364d..8451f99 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$3.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$3.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$4.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$4.class index 5d760f6..db6a775 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$4.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$4.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$5.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$5.class index a9b9cdb..f20b5ac 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$5.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$5.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$6.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$6.class index 7bc292a..08c95cb 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$6.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$6.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$7.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$7.class index ef7f297..8e6ed5c 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$7.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$7.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$8.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$8.class index 0e7eccd..a6e2f9d 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$8.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$8.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame$9.class b/GradingSystemWMX/bin/uis/Frame/MainFrame$9.class index b3998c7..6a11093 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame$9.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame$9.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/MainFrame.class b/GradingSystemWMX/bin/uis/Frame/MainFrame.class index 3264f82..89650a4 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/MainFrame.class and b/GradingSystemWMX/bin/uis/Frame/MainFrame.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/PerformFrame.class b/GradingSystemWMX/bin/uis/Frame/PerformFrame.class index d77377a..7eb69ae 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/PerformFrame.class and b/GradingSystemWMX/bin/uis/Frame/PerformFrame.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/StartFrame$1.class b/GradingSystemWMX/bin/uis/Frame/StartFrame$1.class index fa6cc5c..ac9c51f 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/StartFrame$1.class and b/GradingSystemWMX/bin/uis/Frame/StartFrame$1.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/StartFrame$2.class b/GradingSystemWMX/bin/uis/Frame/StartFrame$2.class index 722e4fe..955e41d 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/StartFrame$2.class and b/GradingSystemWMX/bin/uis/Frame/StartFrame$2.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/StartFrame$3.class b/GradingSystemWMX/bin/uis/Frame/StartFrame$3.class index 48d25d8..5351010 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/StartFrame$3.class and b/GradingSystemWMX/bin/uis/Frame/StartFrame$3.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/StartFrame.class b/GradingSystemWMX/bin/uis/Frame/StartFrame.class index 6a31202..eadcb10 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/StartFrame.class and b/GradingSystemWMX/bin/uis/Frame/StartFrame.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame$1.class b/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame$1.class new file mode 100644 index 0000000..8c79325 Binary files /dev/null and b/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame$1.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame$2.class b/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame$2.class new file mode 100644 index 0000000..75984f2 Binary files /dev/null and b/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame$2.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame.class b/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame.class new file mode 100644 index 0000000..cfacd27 Binary files /dev/null and b/GradingSystemWMX/bin/uis/Frame/ViewInfoFrame.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/addGradeFrame$1.class b/GradingSystemWMX/bin/uis/Frame/addGradeFrame$1.class index aa2c0b8..f2c9903 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/addGradeFrame$1.class and b/GradingSystemWMX/bin/uis/Frame/addGradeFrame$1.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/addGradeFrame$2.class b/GradingSystemWMX/bin/uis/Frame/addGradeFrame$2.class index b8b8c53..6c5d72d 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/addGradeFrame$2.class and b/GradingSystemWMX/bin/uis/Frame/addGradeFrame$2.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/addGradeFrame$TextChanged.class b/GradingSystemWMX/bin/uis/Frame/addGradeFrame$TextChanged.class index 7fbaafc..3e715c1 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/addGradeFrame$TextChanged.class and b/GradingSystemWMX/bin/uis/Frame/addGradeFrame$TextChanged.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/addGradeFrame.class b/GradingSystemWMX/bin/uis/Frame/addGradeFrame.class index 2116bd9..5889c23 100644 Binary files a/GradingSystemWMX/bin/uis/Frame/addGradeFrame.class and b/GradingSystemWMX/bin/uis/Frame/addGradeFrame.class differ diff --git a/GradingSystemWMX/bin/uis/Frame/test$1.class b/GradingSystemWMX/bin/uis/Frame/test$1.class deleted file mode 100644 index 1190a70..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/test$1.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/test$2.class b/GradingSystemWMX/bin/uis/Frame/test$2.class deleted file mode 100644 index 6bb99bf..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/test$2.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/test$3.class b/GradingSystemWMX/bin/uis/Frame/test$3.class deleted file mode 100644 index 05f5df9..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/test$3.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/test$4.class b/GradingSystemWMX/bin/uis/Frame/test$4.class deleted file mode 100644 index defe922..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/test$4.class and /dev/null differ diff --git a/GradingSystemWMX/bin/uis/Frame/test.class b/GradingSystemWMX/bin/uis/Frame/test.class deleted file mode 100644 index 2c2f77f..0000000 Binary files a/GradingSystemWMX/bin/uis/Frame/test.class and /dev/null differ diff --git a/GradingSystemWMX/db.sql b/GradingSystemWMX/db.sql deleted file mode 100644 index 1046d81..0000000 --- a/GradingSystemWMX/db.sql +++ /dev/null @@ -1,101 +0,0 @@ -/** -* admins -*/ -drop table if exists admins; -create table admins ( -id int(11) not null primary key auto_increment, -username varchar(40) not null unique, -password varchar(40) not null -) ; - - -/** -* students -*/ -drop table if exists students; -create table students ( -BUID varchar(20) not null unique, -firstname VARCHAR(255), -lastname VARCHAR(255), -major VARCHAR(11), -status tinyint(1) not null, -total DOUBLE, -letterGrade CHAR(11), -id int(11) not null primary key auto_increment -) ; - - -/** -* course -*/ -drop table if exists course; -create table course( -classid varchar(40) not null, -classname varchar(255) not null, -classyear varchar(40) not null, -classterm varchar(40) not null, -classcredit FLOAT not null, -uniqueid int(11) not null primary key auto_increment -); - - -/** -* assignment -*/ -DROP TABLE if EXISTS assignment; -CREATE TABLE assignment ( -assignname VARCHAR(255) NOT NULL, -weightg DOUBLE NOT NULL, -weightu DOUBLE NOT NULL, -category VARCHAR(255) NOT NULL, -comments VARCHAR(255), -assignid INT(11) NOT NULL PRIMARY KEY auto_increment, -classid INT(11) NOT NULL, -UNIQUE(assignname, classid), -FOREIGN KEY(classid) REFERENCES course(uniqueid) ON DELETE CASCADE -); - - - -/** -* enrollments -*/ -DROP TABLE if EXISTS enrollments; -CREATE TABLE enrollments( -id INT(11) NOT NULL PRIMARY KEY auto_increment, -studentID INT(11) NOT NULL , -classID INT (11) NOT NULL , -foreign key (studentID) references students(id) on delete cascade on update cascade, -foreign key (classID) references course(uniqueID) on delete cascade on update cascade -) - - -/** -* grades -*/ -DROP TABLE if EXISTS grades; -CREATE TABLE grades ( -id INT(11) NOT NULL PRIMARY KEY auto_increment, -studentID INT(11) NOT NULL, -classid INT(11) NOT NULL, -assignid INT(11) NOT NULL, -comments VARCHAR(255), -grade DOUBLE NOT NULL, - -FOREIGN KEY(studentID) REFERENCES students(id) ON DELETE CASCADE, -FOREIGN KEY(classid) REFERENCES course(uniqueid) ON DELETE CASCADE, -FOREIGN KEY(assignid) REFERENCES assignment(assignid) ON DELETE CASCADE, -UNIQUE(studentID, classid) -); - - - - - - - - - - - - diff --git a/GradingSystemWMX/src/uis/Frame/AddStudentFrame.java b/GradingSystemWMX/src/Abandon/AddStudentFrame.java similarity index 99% rename from GradingSystemWMX/src/uis/Frame/AddStudentFrame.java rename to GradingSystemWMX/src/Abandon/AddStudentFrame.java index 4dd8030..e54d916 100644 --- a/GradingSystemWMX/src/uis/Frame/AddStudentFrame.java +++ b/GradingSystemWMX/src/Abandon/AddStudentFrame.java @@ -1,4 +1,4 @@ -package uis.Frame; +package Abandon; import java.util.Vector; diff --git a/GradingSystemWMX/src/daos/CourseDao.java b/GradingSystemWMX/src/daos/CourseDao.java index a6f4e46..f1db470 100644 --- a/GradingSystemWMX/src/daos/CourseDao.java +++ b/GradingSystemWMX/src/daos/CourseDao.java @@ -94,5 +94,32 @@ protected void finalize() throws Throwable { System.out.println(this.getClass().toString() + "destroyed."); } + public Boolean addClass(String newID, Float newCredit, String newName, String newTerm, String newYear) { + sql = "insert into course (classid, classname, classyear, classterm, classcredit) values (?,?,?,?,?)"; + params = new ArrayList<>(); + params.add(newID); + params.add(newName); + params.add(newYear); + params.add(newTerm); + params.add(newCredit); + + try { + return dBconnection.updateByPreparedStatement(sql, params); + }catch(Exception e) { + e.printStackTrace(); + } + return false; + } + +// public List getClassList() { +// sql = "select * from course"; +// List cl = new ArrayList<>(); +// try { +// cl = dBconnection.findSimpleRefResult(sql, params, cls) +// } +// // TODO Auto-generated method stub +// return null; +// } + } diff --git a/GradingSystemWMX/src/daos/GradesDao.java b/GradingSystemWMX/src/daos/GradesDao.java index 6c33622..e4c3d71 100644 --- a/GradingSystemWMX/src/daos/GradesDao.java +++ b/GradingSystemWMX/src/daos/GradesDao.java @@ -84,7 +84,7 @@ public boolean updateTable(int studentID, int classUniqueID, int assignID) { } - public boolean updateGrade(Float grade, int studentID, int classID, int assignID) { + public boolean updateGrade(Double grade, int studentID, int classID, int assignID) { sql = "update grades set grade=? where studentID=? and classID=? and assignID=?"; params = new ArrayList<>(); diff --git a/GradingSystemWMX/src/uis/Frame/DelFrame.java b/GradingSystemWMX/src/uis/Frame/DelFrame.java index e003f3a..87ef493 100644 --- a/GradingSystemWMX/src/uis/Frame/DelFrame.java +++ b/GradingSystemWMX/src/uis/Frame/DelFrame.java @@ -22,7 +22,8 @@ public class DelFrame extends JFrame{ private Assignment assignDel = new Assignment(); private int uniqueID; private String[] names; - ArrayList del = new ArrayList<>(); + private String del; + //ArrayList del = new ArrayList<>(); public DelFrame(int uniqueID, String[] names) { setSize(300, 300); getContentPane().setLayout(new BorderLayout(0, 0)); @@ -48,7 +49,8 @@ public void valueChanged(ListSelectionEvent e) { ListModel listModel = list.getModel(); // setDelItems(listModel); for (int index : indices) { - del.add(listModel.getElementAt(index)); + del = listModel.getElementAt(index); + setDel(del); } } }); @@ -62,9 +64,9 @@ public void valueChanged(ListSelectionEvent e) { delbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean flag = false; - for(String name : del) { - flag = assignDao.delAssign(uniqueID, name); - } + + flag = assignDao.delAssign(uniqueID, del); + if(!flag) { JOptionPane.showMessageDialog(null, "Update failed!", "Error", JOptionPane.ERROR_MESSAGE); }else { @@ -85,4 +87,8 @@ public void actionPerformed(ActionEvent e) { buttonGroup.add(cancelbtn); } + protected void setDel(String del2) { + // TODO Auto-generated method stub + this.del = del2; + } } diff --git a/GradingSystemWMX/src/uis/Frame/InfoFrame.java b/GradingSystemWMX/src/uis/Frame/InfoFrame.java index 12ef2ab..6c5a35d 100644 --- a/GradingSystemWMX/src/uis/Frame/InfoFrame.java +++ b/GradingSystemWMX/src/uis/Frame/InfoFrame.java @@ -6,6 +6,7 @@ import beans.Assignment; import beans.Course; +import beans.Student; import daos.AssignmentDao; import daos.CourseDao; @@ -27,7 +28,6 @@ public class InfoFrame extends JFrame{ private static JTextField name; private static JTextField id; - private static JTextField term; private static JTextField instructor; private static JTextField year; private static JTextField credit; @@ -37,12 +37,14 @@ public class InfoFrame extends JFrame{ private CourseDao courseDao = new CourseDao(); private Course course; - private String className = null; - private String classID = null; - private String classTerm = null; - private String classYear = null; - private Float classCredit = null; + private String className = ""; + private String classID = ""; + private String classTerm = ""; + private String classYear = ""; + private Float classCredit = (float) 0.0; private int uniqueID; + + String title = ""; private final static String prof = "Christine Papadakis-Kanaris"; @@ -59,44 +61,51 @@ public class InfoFrame extends JFrame{ "Attendence", "Quiz" }; - private static Vector columnNames = new Vector() {{ - getContentPane().add("Assignment Name"); - getContentPane().add("Weight(Graduate)"); - getContentPane().add("Weight(Undergraduate)"); - getContentPane().add("Category"); - getContentPane().add("Comment"); + private static String[] terms = {"SPRING", "FALL", "SUMMER", "WINTER"}; + private Vector columnNames = new Vector() {{ + add("Assignment Name"); + add("Weight(Graduate)"); + add("Weight(Undergraduate)"); + add("Category"); + add("Comment"); }}; + private JTextField nametv; + private JTextField wgtv; + private JTextField wutv; public InfoFrame(String classid, String classyear, String classterm) { setSize(800, 501); - - classID = classid; - classYear = classyear; - classTerm = classterm; - uniqueID = courseDao.getuniqueID(classID, classTerm, classYear); - course = courseDao.getCourse(uniqueID); - className = course.getClassName(); - classCredit = course.getClassCredit(); - - assignList = assignDao.assignList(uniqueID); - for(int i = 0; i < assignList.size(); i++) { - Vector row = new Vector<>(); - row.add(assignList.get(i).getAssignName()); - row.add("" + assignList.get(i).getWeightG()); - row.add("" +assignList.get(i).getWeightU()); - row.add(assignList.get(i).getAssignCat()); - row.add(assignList.get(i).getComment()); + if(classid.equals("") || classyear.equals("") || classterm.equals("")) { + title = "Empty template"; + } else { + classID = classid; + classYear = classyear; + classTerm = classterm; + title = classID + "_" + classYear + classTerm; + uniqueID = courseDao.getuniqueID(classID, classTerm, classYear); + course = courseDao.getCourse(uniqueID); + className = course.getClassName(); + classCredit = course.getClassCredit(); - formData.add(row); + assignList = assignDao.assignList(uniqueID); + for(int i = 0; i < assignList.size(); i++) { + Vector row = new Vector<>(); + row.add(assignList.get(i).getAssignName()); + row.add("" + assignList.get(i).getWeightG()); + row.add("" +assignList.get(i).getWeightU()); + row.add(assignList.get(i).getAssignCat()); + row.add(assignList.get(i).getComment()); + + formData.add(row); + } } - System.out.println(formData.get(formData.size() - 1)); - String title = null; - if(!classID.equals(null) && !classYear.equals(null) && !classTerm.equals(null)) { - title = classID + "_" + classYear + classTerm; - } + + + //System.out.println(formData.get(formData.size() - 1)); setTitle(title); + getContentPane().setLayout(new BorderLayout(0, 0)); JPanel courseInfo = new JPanel(); @@ -126,10 +135,9 @@ public InfoFrame(String classid, String classyear, String classterm) { label_2.setForeground(new Color(255, 248, 220)); courseInfo.add(label_2); - term = new JTextField(); - courseInfo.add(term); - term.setColumns(10); - term.setText(classTerm); + JComboBox comboBox = new JComboBox(terms); + comboBox.setSelectedItem(classterm.toUpperCase().toString()); + courseInfo.add(comboBox); JLabel label_3 = new JLabel("Instructor"); label_3.setForeground(new Color(255, 248, 220)); @@ -158,8 +166,9 @@ public InfoFrame(String classid, String classyear, String classterm) { credit.setColumns(10); credit.setText("" + classCredit); - - table = new JTable(formData, columnNames); + DefaultTableModel tableModel = new DefaultTableModel(formData, columnNames); + table = new JTable(tableModel); +// table = new JTable(formData, columnNames); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); table.setFillsViewportHeight(true); @@ -215,53 +224,247 @@ public void valueChanged(ListSelectionEvent e) { JScrollPane jsp = new JScrollPane(table); jsp.setViewportView(table); getContentPane().add(jsp, BorderLayout.CENTER); - - JPanel panel = new JPanel(); -// assignInfo.add(panel, BorderLayout.SOUTH); - getContentPane().add(panel, BorderLayout.SOUTH); - panel.setLayout(new GridLayout(1, 0, 0, 0)); + + JPanel panel_1 = new JPanel(); + FlowLayout flowLayout = (FlowLayout) panel_1.getLayout(); + flowLayout.setAlignment(FlowLayout.TRAILING); + getContentPane().add(panel_1, BorderLayout.SOUTH); JButton refreshbtn = new JButton("Refresh"); + panel_1.add(refreshbtn); refreshbtn.setIcon(new ImageIcon(InfoFrame.class.getResource("/javax/swing/plaf/metal/icons/ocean/upFolder.gif"))); + + JButton save = new JButton("Save as template"); + panel_1.add(save); + + JButton startbtn = new JButton("Start/Continue"); + panel_1.add(startbtn); + startbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { +// dispose(); + List list = assignDao.assignList(uniqueID); + Double totalWeightG = 0.0; + Double totalWeightU = 0.0; + for(Assignment ass : list) { + totalWeightG += ass.getWeightG(); + totalWeightU += ass.getWeightU(); + } + if(totalWeightG == 1.0 && totalWeightU == 1.0) { + if(!title.equals("Empty template")) { + MainFrame mf = new MainFrame(uniqueID); + mf.setVisible(true); + int x = getLocation().x; + int y = getLocation().y; + mf.setLocation(x, y); + }else { + JOptionPane.showMessageDialog(null, "Please save this new class first", "Warning", JOptionPane.WARNING_MESSAGE); + } + } else { + JOptionPane.showMessageDialog(null, "The total weight is not 1.0, please modify assignments!", "Warning", JOptionPane.WARNING_MESSAGE); + } + + + } + }); + startbtn.setBackground(new Color(204, 255, 204)); + startbtn.setIcon(new ImageIcon(InfoFrame.class.getResource("/com/sun/java/swing/plaf/windows/icons/DetailsView.gif"))); + startbtn.setForeground(new Color(0, 102, 51)); + + JButton cancelbtn = new JButton("Cancel"); + panel_1.add(cancelbtn); + cancelbtn.setIcon(new ImageIcon(InfoFrame.class.getResource("/javax/swing/plaf/metal/icons/ocean/paletteClose.gif"))); + cancelbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + save.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { +// dispose(); + Course newCourse = new Course(); + Float newCredit = Float.parseFloat(credit.getText().toString()); + String newID = id.getText().toString(); + String newName = name.getText().toString(); + String newTerm = comboBox.getSelectedItem().toString(); + String newYear = year.getText().toString(); + + if(newCredit != null && !newName.equals(null) && !newTerm.equals(null) && !newYear.equals(null)) { + newCourse.setClassCredit(newCredit); + newCourse.setClassID(newID); + newCourse.setClassName(newName); + newCourse.setClassTerm(newTerm); + newCourse.setClassYear(newYear); + + //update db + if(title.equals("_") || title.equals("Empty template")) { + Boolean flag = courseDao.addClass(newID, newCredit, newName, newTerm, newYear); + uniqueID = courseDao.getuniqueID(newID, newTerm, newYear); + setUniqueID(uniqueID); +// Boolean flag1 = assignDao.addAssign(uniqueID); + if(flag) { + JOptionPane.showMessageDialog(null, "Success!", "Info", JOptionPane.INFORMATION_MESSAGE); + title = newID + "_" + newYear + newTerm; + setT(title); + setTitle(title); + }else { + JOptionPane.showMessageDialog(null, "Fail!", "Warning", JOptionPane.WARNING_MESSAGE); + } + //update assign + + } + + }else { + JOptionPane.showMessageDialog(null, "Please fill all the fields above!", "Missing fields", JOptionPane.ERROR_MESSAGE); + } + + + } + }); refreshbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // String note = "Update fail!"; - assignList = assignDao.assignList(uniqueID); - formData.clear(); - for(int i = 0; i < assignList.size(); i++) { - Vector row = new Vector<>(); - row.add(assignList.get(i).getAssignName()); - row.add("" + assignList.get(i).getWeightG()); - row.add("" +assignList.get(i).getWeightU()); - row.add(assignList.get(i).getAssignCat()); - row.add(assignList.get(i).getComment()); - - formData.add(row); + if(!title.equals("Empty template")) { + assignList = assignDao.assignList(uniqueID); + formData.clear(); + for(int i = 0; i < assignList.size(); i++) { + Vector row = new Vector<>(); + row.add(assignList.get(i).getAssignName()); + row.add("" + assignList.get(i).getWeightG()); + row.add("" +assignList.get(i).getWeightU()); + row.add(assignList.get(i).getAssignCat()); + row.add(assignList.get(i).getComment()); + + formData.add(row); + } + jsp.validate(); + jsp.repaint(); + JOptionPane.showMessageDialog(null, "Successfully upadated!", "Info", JOptionPane.INFORMATION_MESSAGE); + }else { + JOptionPane.showMessageDialog(null, "Please save this new class first", "Warning", JOptionPane.WARNING_MESSAGE); } - jsp.validate(); - jsp.repaint(); - JOptionPane.showMessageDialog(null, "Successfully upadated!", "Info", JOptionPane.INFORMATION_MESSAGE); + } }); - panel.add(refreshbtn); + + JPanel panel = new JPanel(); +// assignInfo.add(panel, BorderLayout.SOUTH); + getContentPane().add(panel, BorderLayout.WEST); + panel.setLayout(new GridLayout(12, 5, 0, 0)); + + JLabel lblNewLabel = new JLabel("Assignment Name"); + panel.add(lblNewLabel); + + nametv = new JTextField(); + panel.add(nametv); + nametv.setColumns(10); + + JLabel lblNewLabel_1 = new JLabel("Weight(Graduate)"); + panel.add(lblNewLabel_1); + + wgtv = new JTextField(); + panel.add(wgtv); + wgtv.setColumns(10); + + JLabel lblNewLabel_2 = new JLabel("Weight(Undergraduate)"); + panel.add(lblNewLabel_2); + + wutv = new JTextField(); + panel.add(wutv); + wutv.setColumns(10); + + JLabel lblNewLabel_3 = new JLabel("Category"); + panel.add(lblNewLabel_3); + + JComboBox catselect = new JComboBox(categories); + panel.add(catselect); + JLabel lblNewLabel_4 = new JLabel("Comment"); + panel.add(lblNewLabel_4); + + JTextArea commenttv = new JTextArea(); + panel.add(commenttv); + JButton addbtn = new JButton("Add"); addbtn.setIcon(new ImageIcon(InfoFrame.class.getResource("/javax/swing/plaf/metal/icons/ocean/expanded.gif"))); - addbtn.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - DialogFrame df = new DialogFrame(uniqueID); - df.setVisible(true); - int x = getLocation().x; - int y = getLocation().y; - df.setLocation(x, y); - df.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - } - }); + addbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String s = (String)catselect.getSelectedItem(); + Object []rowValues = {nametv.getText(),wgtv.getText(),wutv.getText(), + s, commenttv.getText()}; + Assignment newAssign = new Assignment(); + newAssign.setAssignName(nametv.getText()); + newAssign.setWeightG(Double.parseDouble(wgtv.getText())); + newAssign.setWeightU(Double.parseDouble(wutv.getText())); + newAssign.setAssignCat(s); + newAssign.setComment(commenttv.getText()); + newAssign.setClassID(uniqueID); + + boolean flag = assignDao.insertAssign(newAssign); + int id = assignDao.getIDbyName(uniqueID, newAssign.getAssignName()); + newAssign.setAssignID(id); +// boolean flag1= enrollDao.updateEnroll(classUniqueID, studentID); + + if(!title.equals("Empty template")) { + assignList = assignDao.assignList(uniqueID); + formData.clear(); + for(int i = 0; i < assignList.size(); i++) { + Vector row = new Vector<>(); + row.add(assignList.get(i).getAssignName()); + row.add("" + assignList.get(i).getWeightG()); + row.add("" +assignList.get(i).getWeightU()); + row.add(assignList.get(i).getAssignCat()); + row.add(assignList.get(i).getComment()); + + formData.add(row); + } + jsp.validate(); + jsp.repaint(); + JOptionPane.showMessageDialog(null, "Successfully upadated!", "Info", JOptionPane.INFORMATION_MESSAGE); + }else { + JOptionPane.showMessageDialog(null, "Please save this new class first", "Warning", JOptionPane.WARNING_MESSAGE); + } + + if(!flag) { + JOptionPane.showMessageDialog(null, "Add failed!", "Error", JOptionPane.ERROR_MESSAGE); + }else { + JOptionPane.showMessageDialog(null, "Add Success! Please click 'Refresh'.", "Info", JOptionPane.INFORMATION_MESSAGE); + } + nametv.setText(""); + wgtv.setText(""); + wutv.setText(""); + commenttv.setText(""); + catselect.setSelectedIndex(0); + + } + }); + panel.add(addbtn); + + JButton delbtn = new JButton("Delete"); delbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + if(!title.equals("Empty template")) { +// int selectedRow = table.getSelectedRow(); +// if(selectedRow != -1) +// { +// String aname = (String) tableModel.getValueAt(selectedRow, 0); +// tableModel.removeRow(selectedRow); +// int aid = assignDao.getIDbyName(uniqueID, aname); +// boolean flag = assignDao.delAssign(uniqueID, aname); +//// boolean flag1 = studentDao.removeStudent(buid); +//// boolean flag2 = enrollDao.removeEnroll(sid, classUniqueID); +//// boolean flag3 = gradesDao.removeGrade(sid, classUniqueID); +// +// if(!flag) { +// JOptionPane.showMessageDialog(null, "Delete failed!", "Error", JOptionPane.ERROR_MESSAGE); +// }else { +//// update(); +// JOptionPane.showMessageDialog(null, "Delete Success! Please click 'Refresh'.", "Info", JOptionPane.INFORMATION_MESSAGE); +// } +// +// } if(formData.isEmpty()) { //TODO: Create a pop-up window to let user add assignments // JOptionPane.showMessageDialog(null, "Empty form!", "Error", JOptionPane.ERROR_MESSAGE); @@ -280,9 +483,10 @@ public void actionPerformed(ActionEvent e) { dispose(); } } else { - String[] names = new String[table.getRowCount()]; - for(int i=0;i= 5 && selectedColumn < assignList.size() + 5) { - // grade - int studentID = s.getUniqueId(); int assignID = assignDao.getIDbyName(classUniqueID, (String)column.get(selectedColumn)); String assignName = (String)column.get(selectedColumn); - //int gradeID = gradesDao.getGradeID(studentID, classUniqueID, assignID); if(isAdjusting) { - addGradeFrame a = new addGradeFrame(assignName, studentID, classUniqueID, assignID); + addGradeFrame a = new addGradeFrame(assignName, id, classUniqueID, assignID); a.setVisible(true); int x = getLocation().x; int y = getLocation().y; @@ -237,7 +228,7 @@ public void valueChanged(ListSelectionEvent e) { } }else if(selectedColumn == column.indexOf("Total") || selectedColumn == column.indexOf("LetterGrade")) { - //calculate the total score and generate the letter grade + if(isAdjusting) { Double total = calculate(s, assignList); @@ -272,20 +263,20 @@ public void actionPerformed(ActionEvent e) { viewbtn.setBackground(new Color(210, 105, 30)); panel.add(performbtn); panel.add(cancelbtn); - lblNewLabel.setForeground(new Color(211, 211, 211)); + lblNewLabel.setForeground(new Color(255, 248, 220)); panel.add(lblNewLabel); panel.add(viewID); - lblNewLabel_1.setForeground(new Color(211, 211, 211)); + lblNewLabel_1.setForeground(new Color(255, 248, 220)); panel.add(lblNewLabel_1); panel.add(viewFn); - lblNewLabel_2.setForeground(new Color(211, 211, 211)); + lblNewLabel_2.setForeground(new Color(255, 248, 220)); panel.add(lblNewLabel_2); panel.add(viewLn); - lblNewLabel_3.setForeground(new Color(211, 211, 211)); + lblNewLabel_3.setForeground(new Color(255, 248, 220)); panel.add(lblNewLabel_3); panel.add(viewMajor); - lblNewLabel_4.setForeground(new Color(211, 211, 211)); + lblNewLabel_4.setForeground(new Color(255, 248, 220)); panel.add(lblNewLabel_4); panel.add(statusSelect); @@ -319,48 +310,48 @@ public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) { //return to the preview page to select the template or start a new one //pop-up window to make sure she would like to cancel the pj without save - + dispose(); + StartFrame sf = new StartFrame(); + sf.setVisible(true); + int x = getLocation().x; + int y = getLocation().y; + sf.setLocation(x, y); + sf.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } }); performbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - + PerformFrame pf = new PerformFrame(studentList); + pf.setVisible(true); + int x = getLocation().x; + int y = getLocation().y; + pf.setLocation(x, y); + pf.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } }); viewbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // dispose(); - + ViewInfoFrame vi = new ViewInfoFrame(course); + vi.setVisible(true); + int x = getLocation().x; + int y = getLocation().y; + vi.setLocation(x, y); + vi.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } }); panel_3.setBackground(new Color(139, 0, 0)); getContentPane().add(panel_3, BorderLayout.NORTH); - panel_3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + panel_3.setLayout(new FlowLayout(FlowLayout.TRAILING, 5, 5)); // newbtn.setBackground(new Color(128, 0, 0)); panel_3.add(newbtn); // logoutbtn.setBackground(new Color(210, 105, 30)); panel_3.add(logoutbtn); -// getContentPane().add(panel_1, BorderLayout.SOUTH); -// panel_1.setLayout(new GridLayout(2, 5, 0, 0)); -// -// panel_1.add(lblNewLabel_1); -// panel_1.add(lblNewLabel_2); -// panel_1.add(lblNewLabel_3); -// panel_1.add(lblNewLabel_4); -// -// panel_1.add(viewFn); -// panel_1.add(viewLn); -// panel_1.add(viewMajor); -// panel_1.add(statusSelect); -// panel_1.add(addbtn); -// panel_1.add(delbtn); //add student addbtn.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { String s = (String)statusSelect.getSelectedItem(); Boolean st = true; @@ -390,20 +381,12 @@ public void actionPerformed(ActionEvent e) { }else { JOptionPane.showMessageDialog(null, "Add Success! Please click 'Refresh'.", "Info", JOptionPane.INFORMATION_MESSAGE); } -// tableModel.addRow(rowValues); -// int rowCount = studentform.getRowCount() +1; viewID.setText(""); viewFn.setText(""); viewLn.setText(""); viewMajor.setText(""); statusSelect.setSelectedIndex(0); - -// AddStudentFrame ad = new AddStudentFrame(classUniqueID); -// ad.setVisible(true); -// int x = getLocation().x; -// int y = getLocation().y; -// ad.setLocation(x, y); -// ad.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + } }); @@ -424,12 +407,12 @@ public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) { //turn to the interface: create the pj (select the template or create a new one) dispose(); - InfoFrame info = new InfoFrame(null, null, null); - info.setVisible(true); + StartFrame sf = new StartFrame(); + sf.setVisible(true); int x = getLocation().x; int y = getLocation().y; - info.setLocation(x, y); - info.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + sf.setLocation(x, y); + sf.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } }); studentform.getTableHeader().setFont(new Font(null, Font.BOLD, 14)); diff --git a/GradingSystemWMX/src/uis/Frame/PerformFrame.java b/GradingSystemWMX/src/uis/Frame/PerformFrame.java index 30ba954..debf756 100644 --- a/GradingSystemWMX/src/uis/Frame/PerformFrame.java +++ b/GradingSystemWMX/src/uis/Frame/PerformFrame.java @@ -1,7 +1,122 @@ package uis.Frame; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.DateTickUnit; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.StandardXYItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; import javax.swing.*; +import beans.Student; +import java.awt.BorderLayout; +import java.awt.GridLayout; + public class PerformFrame extends JFrame{ + private static HashMap letter; + private static List totalList = new ArrayList<>(); + + public PerformFrame(List studentList) { + setSize(800,800); + letter = new HashMap<>(); + letter.put("A", 0); + letter.put("B", 0); + letter.put("C", 0); + letter.put("D", 0); + + for(Student student : studentList) { + String l = student.getLetterGrade(); + if(letter.containsKey(l)) { + letter.put(l, letter.get(l) + 1); + }else { + letter.put(l, 1); + } + + + totalList.add(student.getTotal()); + } + + JPanel panel_1 = new JPanel(); + getContentPane().add(panel_1, BorderLayout.SOUTH); + panel_1.setLayout(new GridLayout(4, 8, 100, 10)); + + JLabel lblNewLabel = new JLabel("Highest Score"); + panel_1.add(lblNewLabel); + + Collections.sort(totalList); + Double highest = totalList.get(totalList.size() - 1); + JLabel lblNewLabel_1 = new JLabel(highest.toString()); + panel_1.add(lblNewLabel_1); + + + + JLabel lblNewLabel_3 = new JLabel("Lowest Score"); + panel_1.add(lblNewLabel_3); + + Double lowest = totalList.get(0); + JLabel lblNewLabel_2 = new JLabel(lowest.toString()); + panel_1.add(lblNewLabel_2); + + JLabel lblNewLabel_4 = new JLabel("Average"); + panel_1.add(lblNewLabel_4); + + Double all = 0.0; + for(Double d : totalList) { + all += d; + } + Double average = all / totalList.size(); + JLabel lblNewLabel_5 = new JLabel(average.toString()); + panel_1.add(lblNewLabel_5); + + JLabel lblNewLabel_6 = new JLabel("Median"); + panel_1.add(lblNewLabel_6); + + Double median = totalList.get(totalList.size() / 2); + JLabel lblNewLabel_7 = new JLabel(median.toString()); + panel_1.add(lblNewLabel_7); + + CategoryDataset dataset = getDataSet(); + JFreeChart chart = ChartFactory.createBarChart3D( + "Student Performance", + "Letter Grade", + "Amount", + dataset, + PlotOrientation.VERTICAL, + true, + false, + false); + CategoryPlot plot=chart.getCategoryPlot(); + CategoryAxis domainAxis=plot.getDomainAxis(); + JPanel panel = new ChartPanel(chart,true); + getContentPane().add(panel, BorderLayout.CENTER); + panel.setLayout(new GridLayout(1, 0, 0, 0)); + } + + private static CategoryDataset getDataSet() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(letter.get("A"), "Grade" ,"A"); + dataset.addValue(letter.get("B"), "Grade" ,"B"); + dataset.addValue(letter.get("C"), "Grade" ,"C"); + dataset.addValue(letter.get("D"), "Grade" ,"D"); + + return dataset; +} + } diff --git a/GradingSystemWMX/src/uis/Frame/StartFrame.java b/GradingSystemWMX/src/uis/Frame/StartFrame.java index e492d12..5cb1c77 100644 --- a/GradingSystemWMX/src/uis/Frame/StartFrame.java +++ b/GradingSystemWMX/src/uis/Frame/StartFrame.java @@ -18,6 +18,7 @@ import java.util.List; public class StartFrame extends JFrame{ + private String selectedClass = "Empty template"; private Course course; private String[] showList; private CourseDao courseDao = new CourseDao(); @@ -28,11 +29,20 @@ public class StartFrame extends JFrame{ private String year; private String term; + + public StartFrame(Course newCourse) { + + + } public StartFrame() { + getContentPane().setBackground(new Color(128, 0, 0)); getContentPane().setLayout(new BorderLayout(0, 0)); setSize(450,300); JLabel lblNewLabel = new JLabel("Select the template to start..."); + lblNewLabel.setForeground(new Color(255, 248, 220)); + lblNewLabel.setFont(new Font("Toppan Bunkyu Gothic", Font.PLAIN, 18)); + lblNewLabel.setBackground(new Color(128, 0, 0)); getContentPane().add(lblNewLabel, BorderLayout.NORTH); @@ -47,15 +57,21 @@ public void valueChanged(ListSelectionEvent e) { int[] indices = list.getSelectedIndices(); ListModel listModel = list.getModel(); for (int index : indices) { + selectedClass = listModel.getElementAt(index); + setSelectedClass(selectedClass); System.out.println("Selected: " + index + " = " + listModel.getElementAt(index)); } System.out.println(); } + + }); + list.setSelectedIndex(0); JPanel panel = new JPanel(); + panel.setBackground(new Color(128, 0, 0)); getContentPane().add(panel, BorderLayout.SOUTH); JButton confirmbtn = new JButton("Confirm"); @@ -63,18 +79,20 @@ public void valueChanged(ListSelectionEvent e) { public void actionPerformed(ActionEvent e) { dispose(); - String[] selected = getSelectedClass().split("_"); String selectID = ""; String selecteTerm = ""; String selecteYear = ""; - if(!getSelectedClass().equals("Empty template")) { + selectedClass = (String)list.getSelectedValue(); + System.out.println(selectedClass); + if(!selectedClass.equals("Empty template")) { + + String[] selected = selectedClass.split("_"); selectID = selected[0]; String rest = selected[1]; selecteYear = rest.substring(0, 4); selecteTerm = rest.substring(4); - } - + } InfoFrame info = new InfoFrame(selectID, selecteYear, selecteTerm); info.setVisible(true); int x = getLocation().x; @@ -83,11 +101,6 @@ public void actionPerformed(ActionEvent e) { } - private String getSelectedClass() { - // TODO Auto-generated method stub - return (String) list.getSelectedValue(); - } - }); panel.add(confirmbtn); @@ -107,11 +120,16 @@ public void actionPerformed(ActionEvent e) { } + protected void setSelectedClass(String selectedClass2) { + // TODO Auto-generated method stub + this.selectedClass = selectedClass2; + + } private void initData() { // TODO Auto-generated method stub courseList = courseDao.courseImport(); showList = new String[courseList.size() + 1]; - showList[0] = " Empty template"; + showList[0] = "Empty template"; for(int i = 1; i < showList.length; i++) { String id = courseList.get(i - 1).getClassID(); String term = courseList.get(i - 1).getClassTerm(); diff --git a/GradingSystemWMX/src/uis/Frame/ViewInfoFrame.java b/GradingSystemWMX/src/uis/Frame/ViewInfoFrame.java new file mode 100644 index 0000000..802dfd4 --- /dev/null +++ b/GradingSystemWMX/src/uis/Frame/ViewInfoFrame.java @@ -0,0 +1,170 @@ +package uis.Frame; + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; + +import beans.Assignment; +import beans.Course; +import daos.AssignmentDao; +import daos.CourseDao; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.GridLayout; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; +import javax.swing.JButton; +import javax.swing.SwingConstants; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class ViewInfoFrame extends JFrame{ + private CourseDao courseDao = new CourseDao(); + private Course course; + private String className = ""; + private String classID = ""; + private String classTerm = ""; + private String classYear = ""; + private Float classCredit = (float) 0.0; + private int uniqueID; + private AssignmentDao assignDao = new AssignmentDao(); + private static List assignList = new ArrayList<>(); + String title = ""; + private static Vector> formData = new Vector<>(); + + private static Vector columnNames = new Vector() {{ + add("Assignment Name"); + add("Weight(Graduate)"); + add("Weight(Undergraduate)"); + add("Category"); + add("Comment"); + }}; + + private final static String prof = "Christine Papadakis-Kanaris"; + public ViewInfoFrame(Course course) { + + setSize(800, 501); + this.course = course; + this.className = course.getClassName(); + this.classID = course.getClassID(); + this.classTerm = course.getClassTerm(); + this.classYear = course.getClassYear(); + this.classCredit = course.getClassCredit(); + this.uniqueID = course.getUniqueID(); + + assignList = assignDao.assignList(uniqueID); + for(int i = 0; i < assignList.size(); i++) { + Vector row = new Vector<>(); + row.add(assignList.get(i).getAssignName()); + row.add("" + assignList.get(i).getWeightG()); + row.add("" +assignList.get(i).getWeightU()); + row.add(assignList.get(i).getAssignCat()); + row.add(assignList.get(i).getComment()); + + formData.add(row); + } + + setTitle(title); + + getContentPane().setLayout(new BorderLayout(0, 0)); + + JPanel courseInfo = new JPanel(); + courseInfo.setBackground(new Color(128, 0, 0)); + getContentPane().add(courseInfo, BorderLayout.NORTH); + courseInfo.setLayout(new GridLayout(3, 4, 5, 2)); + + JLabel label = new JLabel("Course Name"); + label.setForeground(new Color(255, 248, 220)); + courseInfo.add(label); + + JLabel name = new JLabel(className); + name.setForeground(new Color(255, 248, 220)); + courseInfo.add(name); + + JLabel label_1 = new JLabel("CourseID"); + label_1.setForeground(new Color(255, 248, 220)); + courseInfo.add(label_1); + + JLabel id = new JLabel(classID); + id.setForeground(new Color(255, 248, 220)); + courseInfo.add(id); + + JLabel label_2 = new JLabel("Term"); + label_2.setForeground(new Color(255, 248, 220)); + courseInfo.add(label_2); + + JLabel term = new JLabel(classTerm); + term.setForeground(new Color(255, 248, 220)); + courseInfo.add(term); + + JLabel label_3 = new JLabel("Instructor"); + label_3.setForeground(new Color(255, 248, 220)); + courseInfo.add(label_3); + + JLabel instructor = new JLabel(prof); + instructor.setForeground(new Color(255, 248, 220)); + courseInfo.add(instructor); + + JLabel label_4 = new JLabel("Year"); + label_4.setForeground(new Color(255, 248, 220)); + courseInfo.add(label_4); + + JLabel year = new JLabel(classYear); + year.setForeground(new Color(255, 248, 220)); + courseInfo.add(year); + + JLabel label_5 = new JLabel("Credit"); + label_5.setForeground(new Color(255, 248, 220)); + courseInfo.add(label_5); + + JLabel credit = new JLabel("" + classCredit); + label_5.setForeground(new Color(255, 248, 220)); + courseInfo.add(credit); + + JTable table = new JTable(formData, columnNames); + table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + table.setFillsViewportHeight(true); + + //set properties of table + table.setCellSelectionEnabled(false); + table.setPreferredSize(getPreferredSize()); + table.setForeground(Color.BLACK); + table.setFont(new Font(null, Font.PLAIN, 14)); + table.setSelectionForeground(Color.DARK_GRAY); + table.setSelectionBackground(Color.LIGHT_GRAY); + table.setGridColor(Color.GRAY); + + table.getTableHeader().setFont(new Font(null, Font.BOLD, 14)); + table.getTableHeader().setForeground(Color.DARK_GRAY); + table.getTableHeader().setResizingAllowed(true); + table.getTableHeader().setReorderingAllowed(false); + + table.setRowHeight(30); + JScrollPane jsp = new JScrollPane(table); + jsp.setViewportView(table); + getContentPane().add(jsp, BorderLayout.CENTER); + + JPanel panel = new JPanel(); + panel.setBackground(new Color(128, 0, 0)); + getContentPane().add(panel, BorderLayout.SOUTH); + + JButton btnNewButton = new JButton("Back"); + btnNewButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + btnNewButton.setHorizontalAlignment(SwingConstants.TRAILING); + panel.add(btnNewButton); + } + + + +} diff --git a/GradingSystemWMX/src/uis/Frame/addGradeFrame.java b/GradingSystemWMX/src/uis/Frame/addGradeFrame.java index 6b4b9b8..14d525f 100644 --- a/GradingSystemWMX/src/uis/Frame/addGradeFrame.java +++ b/GradingSystemWMX/src/uis/Frame/addGradeFrame.java @@ -26,7 +26,7 @@ public class addGradeFrame extends JFrame{ private int assignID; private int gradeID; - private static Float grade; + private static Double grade; public String update; public EnrollDao enrollDao; @@ -38,7 +38,7 @@ public addGradeFrame(String assignName, int studentID, int classUniqueID, int as this.assignID = assignID; //public int getGradeID(int studentID, int classID, int assignID) { - gradeID = gradeDao.getGradeID(studentID, classUniqueID, assignID); + this.gradeID = gradeDao.getGradeID(studentID, classUniqueID, assignID); // this.gradeID = gradeID; String title = "Add grade for assignment: " + assignName; @@ -70,8 +70,7 @@ public void actionPerformed(ActionEvent e) { //int studentID, int classID, int assignID boolean flag = gradeDao.updateGrade(grade, studentID, classID, assignID); - - dispose(); + if(!flag) { JOptionPane.showMessageDialog(null, "Grade failed!", "Error", JOptionPane.ERROR_MESSAGE); }else { @@ -93,7 +92,7 @@ public void actionPerformed(ActionEvent e) { getContentPane().add(cancelbtn); } - public static Float getUpdatedData() { + public static Double getUpdatedData() { // TODO Auto-generated method stub return grade; } @@ -104,7 +103,7 @@ class TextChanged implements DocumentListener{ @Override public void insertUpdate(DocumentEvent e) { // TODO Auto-generated method stub - grade = Float.parseFloat(content.getText().toString()); + grade = Double.parseDouble(content.getText().toString()); } @Override diff --git a/README.md b/README.md index 915d010..5454693 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,2 @@ # 591-Team-Nine Grading System Project - -1.These 2 jar file need to be added in project. right click project---Properties---JAVA build path---add JAR - -2.db file is the database file made by SQLite, I put it on the desktop. if you want to change place, remember to change the code in sqlConnection.java - -3.sqlConnection.java is used to connect database. download it and put it with other java file. - -# 12/06 -1. run the project start from ui.frames/startframe -2. I reconstruction the code by classes and this caused several bugs that needed to be fixed -3. re-upload the fixed code later diff --git a/StudentInfo.java b/StudentInfo.java deleted file mode 100644 index 8a38765..0000000 --- a/StudentInfo.java +++ /dev/null @@ -1,34 +0,0 @@ - - -public class StudentInfo{ - private long uniqueID; - private String name; - private String ID; - private String major; - private String status; - - public StudentInfo(long uniqueID, String name, String ID, String major, String status) { - this.name = name; - this.ID = ID; - this.major = major; - this.status = status; - this.uniqueID = uniqueID; //database unique identifier to identify column -} - - public String getName() { - return name; - } - public String getID() { - return ID; - } - public String getMajor() { - return major; - } - - public String getStatus() { - return status; - } - public long getUniqueID() { - return uniqueID; - } -} diff --git a/StudentProfileCopy.java b/StudentProfileCopy.java deleted file mode 100644 index 03040ac..0000000 --- a/StudentProfileCopy.java +++ /dev/null @@ -1,158 +0,0 @@ - - -import java.awt.EventQueue; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextPane; -import javax.swing.border.EmptyBorder; - -public class StudentProfileCopy extends JFrame { - - private JPanel contentPane; - private JLabel lblStudentProfileName; - private JLabel lblStudentProfileId; - private JLabel lblMajor; - private JLabel lblStatus; - private JLabel lblStudentProfile; - private JLabel lblUxxxxxxx; - private JLabel lblComputerScience; - private JLabel lblUndergraduate; - private JLabel lblComments; - private String name; - private String ID; - private String major; - private String status; - private JTable table; - private String[] columnNames; - private Object[][] data; - /** - * - * Launch the application. - */ - public static void main(String[] args) { - EventQueue.invokeLater(new Runnable() { - public void run() { - try { - StudentInfo s = new StudentInfo(-1, "Miranda Rivera", "U79852612", "Computer Science", "undergraduate"); - StudentProfileCopy frame = new StudentProfileCopy(s); - frame.setVisible(true); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - - - - //this must be searched on database and turned into a StudentInfo object before calling this class - //Receive Student object and extract information - public void GetStudent(StudentInfo s) { - name = s.getName(); - ID = s.getID(); - major = s.getMajor(); - status = s.getStatus(); - //missing the assignment array etc. - LoadTableData(s); - - } - - - /**database manager class - * function that takes in id of column and takes student info and turns into StudentInfo class - * function that takes in a student info and updates by overriding info for that student in database - */ - - - //student must have assignment array - public void LoadTableData(StudentInfo s) { - // TODO : Load the assignments from student - columnNames = new String[]{"Assignment", - "Weight", - "Grade"}; - - data = new Object[][] { - {"Homework1", new Float(0.5), new Float(90.0)}, - {"Homework2", new Float(0.5), new Float(90.0)}, - {"Homework3", new Float(0.5), new Float(90.0)}, - {"Homework4", new Float(0.5), new Float(90.0)}, - {"Homework5", new Float(0.5), new Float(90.0)}, - }; - - } - - - /** - * Create the frame. - */ - public StudentProfileCopy(StudentInfo s) { - GetStudent(s); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setBounds(100, 100, 450, 300); - contentPane = new JPanel(); - contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); - setContentPane(contentPane); - contentPane.setLayout(null); - - lblStudentProfileName = new JLabel("Student Name: "); - lblStudentProfileName.setBounds(6, 5, 96, 16); - contentPane.add(lblStudentProfileName); - - lblStudentProfile = new JLabel(name); // change to student.Name - lblStudentProfile.setBounds(133, 5, 200, 16); - contentPane.add(lblStudentProfile); - - lblStudentProfileId = new JLabel("Student ID: "); - lblStudentProfileId.setBounds(6, 26, 96, 16); - contentPane.add(lblStudentProfileId); - - lblUxxxxxxx = new JLabel(ID); // change to student.Id - lblUxxxxxxx.setBounds(133, 26, 200, 16); - contentPane.add(lblUxxxxxxx); - - lblMajor = new JLabel("Major: "); - lblMajor.setBounds(6, 47, 96, 16); - contentPane.add(lblMajor); - - lblComputerScience = new JLabel(major); // change to student.Major - lblComputerScience.setBounds(133, 47, 200, 16); - contentPane.add(lblComputerScience); - - lblStatus = new JLabel("Status: "); - lblStatus.setBounds(6, 68, 96, 16); - contentPane.add(lblStatus); - - lblUndergraduate = new JLabel(status); // change to student.Status - lblUndergraduate.setBounds(133, 68, 200, 16); - contentPane.add(lblUndergraduate); - - lblComments = new JLabel("Comments"); - lblComments.setBounds(293, 5, 74, 16); - contentPane.add(lblComments); - - JTextPane txtpnComment = new JTextPane(); - txtpnComment.setBounds(293, 26, 133, 101); - contentPane.add(txtpnComment); - - JButton btnSave = new JButton("Save"); - btnSave.setBounds(176, 246, 96, 26); - contentPane.add(btnSave); - - table = new JTable(data, columnNames); - table.setBounds(18, 135, 408, 101); - //contentPane.add(table); - - JScrollPane scrollPane = new JScrollPane(table); - scrollPane.setBounds(18, 135, 408, 101); - table.setFillsViewportHeight(true); - contentPane.add(scrollPane); - - - } -} - - diff --git a/course.java b/course.java deleted file mode 100644 index d97ff47..0000000 --- a/course.java +++ /dev/null @@ -1,229 +0,0 @@ -import java.awt.EventQueue; - -import javax.swing.JFrame; -import javax.swing.JTable; -import javax.swing.table.DefaultTableModel; - -import org.sqlite.SQLiteConnection; - -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; -import javax.swing.JScrollBar; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import javax.swing.JScrollPane; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import javax.swing.JTextArea; -import javax.swing.JList; -import javax.swing.JComboBox; -import javax.swing.DefaultComboBoxModel; - -import net.proteanit.sql.DbUtils;//i add a new import for Dbutils - -public class course { - - private JFrame frame; - private JTable table; - private JTextField coursename; - private JTextField courseid; - private JTextField term; - private JTextField instructor; - private JTextField year; - private JTextField credit; - private JTextField catename; - private JTextField weight1; - private JTextField weight2; - - /** - * Launch the application. - */ - public static void main(String[] args) { - EventQueue.invokeLater(new Runnable() { - public void run() { - try { - course window = new course(); - window.frame.setVisible(true); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - Connection connection = null; - /** - * Create the application. - */ - public course() { - initialize(); - connection=sqlConnection.dbConnection();// connect to database - - } - - /** - * Initialize the contents of the frame. - */ - private void initialize() { - frame = new JFrame(); - frame.setBounds(100, 100, 549, 517); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.getContentPane().setLayout(null); - - JScrollPane scrollPane = new JScrollPane(); - scrollPane.setBounds(35, 137, 477, 96); - frame.getContentPane().add(scrollPane); - - table = new JTable(); - scrollPane.setViewportView(table); - table.setModel(new DefaultTableModel( - new Object[][] { - }, - new String[] { - "Name", "Weight(M)", "Weight(U)", "Categary" - } - ) { - Class[] columnTypes = new Class[] { - String.class, Float.class, Float.class, Float.class - }; - public Class getColumnClass(int columnIndex) { - return columnTypes[columnIndex]; - } - }); - - JLabel lable1 = new JLabel("Couse Name"); - lable1.setBounds(35, 38, 79, 14); - frame.getContentPane().add(lable1); - - JLabel lable2 = new JLabel("CourseID"); - lable2.setBounds(35, 63, 64, 14); - frame.getContentPane().add(lable2); - - JLabel lable3 = new JLabel("Term"); - lable3.setBounds(35, 88, 64, 14); - frame.getContentPane().add(lable3); - - JLabel lblInstructor = new JLabel("Instructor"); - lblInstructor.setBounds(302, 35, 64, 14); - frame.getContentPane().add(lblInstructor); - - JLabel lblYear = new JLabel("Year"); - lblYear.setBounds(302, 60, 64, 14); - frame.getContentPane().add(lblYear); - - JLabel lblCredit = new JLabel("Credit"); - lblCredit.setBounds(302, 85, 64, 14); - frame.getContentPane().add(lblCredit); - - coursename = new JTextField(); - coursename.setBounds(109, 35, 128, 20); - frame.getContentPane().add(coursename); - coursename.setColumns(10); - - courseid = new JTextField(); - courseid.setColumns(10); - courseid.setBounds(109, 60, 128, 20); - frame.getContentPane().add(courseid); - - term = new JTextField(); - term.setColumns(10); - term.setBounds(109, 85, 128, 20); - frame.getContentPane().add(term); - - instructor = new JTextField(); - instructor.setColumns(10); - instructor.setBounds(376, 32, 128, 20); - frame.getContentPane().add(instructor); - - year = new JTextField(); - year.setColumns(10); - year.setBounds(376, 57, 128, 20); - frame.getContentPane().add(year); - - credit = new JTextField(); - credit.setColumns(10); - credit.setBounds(376, 82, 128, 20); - frame.getContentPane().add(credit); - - JButton btnAdd = new JButton("Add"); - btnAdd.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - } - }); - btnAdd.setBounds(35, 360, 89, 23); - frame.getContentPane().add(btnAdd); - - JButton btnDelete = new JButton("Delete"); - btnDelete.setBounds(396, 360, 89, 23); - frame.getContentPane().add(btnDelete); - - JButton btnUpgrade = new JButton("Upgrade"); - btnUpgrade.setBounds(223, 360, 89, 23); - frame.getContentPane().add(btnUpgrade); - - JLabel lblName = new JLabel("Name"); - lblName.setBounds(35, 262, 46, 14); - frame.getContentPane().add(lblName); - - JLabel lblWeight = new JLabel("Weight(master)"); - lblWeight.setBounds(35, 287, 99, 14); - frame.getContentPane().add(lblWeight); - - JLabel lblWeightundergraduate = new JLabel("Weight(under)"); - lblWeightundergraduate.setBounds(302, 287, 89, 14); - frame.getContentPane().add(lblWeightundergraduate); - - catename = new JTextField(); - catename.setBounds(109, 259, 128, 20); - frame.getContentPane().add(catename); - catename.setColumns(10); - - weight1 = new JTextField(); - weight1.setColumns(10); - weight1.setBounds(109, 284, 128, 20); - frame.getContentPane().add(weight1); - - weight2 = new JTextField(); - weight2.setColumns(10); - weight2.setBounds(384, 284, 128, 20); - frame.getContentPane().add(weight2); - - JSpinner spinner = new JSpinner(); - spinner.setModel(new SpinnerNumberModel(0, 0, 100, 1)); - spinner.setBounds(237, 284, 36, 20); - frame.getContentPane().add(spinner); - - JButton btnShowData = new JButton("Load Table"); //load button can read data from database table - btnShowData.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - try { - String query="select * from coursecategory"; - PreparedStatement pst=connection.prepareStatement(query); - ResultSet rs=pst.executeQuery(); - table.setmodel(DbUtils.resultSetToTableModel(rs)); - - } - catch(Exception e1){ - e1.printStackTrace(); - } - } - }); - btnShowData.setBounds(35, 395, 117, 29); - frame.getContentPane().add(btnShowData); - - JComboBox comboBox = new JComboBox(); - comboBox.setModel(new DefaultComboBoxModel(new String[] {"Assignment", "Task", "Quiz", "Midterm", "Finalterm"})); - comboBox.setBounds(384, 256, 128, 23); - frame.getContentPane().add(comboBox); - - JLabel lblCategory = new JLabel("Category"); - lblCategory.setBounds(310, 258, 61, 16); - frame.getContentPane().add(lblCategory); - } -} diff --git a/couse.db b/couse.db deleted file mode 100644 index e7dd54e..0000000 Binary files a/couse.db and /dev/null differ diff --git a/sqlConnection.java b/sqlConnection.java deleted file mode 100644 index 0484676..0000000 --- a/sqlConnection.java +++ /dev/null @@ -1,21 +0,0 @@ -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -public class sqlConnection { - - public static Connection dbConnection() { - Connection conn = null; - try { - // db parameters - String url = "jdbc:sqlite:/Users/lifengjun/Desktop/couse.db ";//root for db file - // create a connection to the database - conn = DriverManager.getConnection(url); - - System.out.println("Connection to SQLite has been established."); - return conn; - } catch (SQLException e) { - System.out.println(e.getMessage()); - return null; - } - }