@Override public int updateSubject(Subject subject, String start, String end) { subject.setCapacity(Integer.parseInt(subject.getCapacity_String().replace(",", ""))); subject.setLecture_totalday( Integer.parseInt(subject.getLecture_totalday_String().replace(",", ""))); subject.setTuition_fee(Integer.parseInt(subject.getTuition_fee_String().replace(",", ""))); Time start1 = null; Time end1 = null; if (start.length() < 7) { start1 = Time.valueOf(start + ":00"); } else { start1 = Time.valueOf(start); } if (end.length() < 7) { end1 = Time.valueOf(end + ":00"); } else { end1 = Time.valueOf(end); } long a = (end1.getTime() - start1.getTime()) / 1000; int b = (int) (subject.getLecture_totalday() * a); Subject subject2 = new Subject( subject.getSubject_id(), subject.getSubject_name(), subject.getCapacity(), subject.getSubject_explanation(), subject.getInstructional_objectives(), subject.getSubject_point(), subject.getLecture_target(), subject.getLecture_totalday(), subject.getTuition_fee(), subject.getLecture_content(), start1, end1, b / 3600); return sqlSession.getMapper(SubjectDAO.class).updateSubject(subject2); }
@Override public int insertSubject(Subject subject, String start, String end) { subject.setCapacity(Integer.parseInt(subject.getCapacity_String().replace(",", ""))); subject.setLecture_totalday( Integer.parseInt(subject.getLecture_totalday_String().replace(",", ""))); subject.setTuition_fee(Integer.parseInt(subject.getTuition_fee_String().replace(",", ""))); Time start1 = Time.valueOf(start + ":00"); Time end1 = Time.valueOf(end + ":00"); long a = (end1.getTime() - start1.getTime()) / 1000; int time3 = (int) (subject.getLecture_totalday() * a); Subject subject2 = new Subject( subject.getSubject_id(), subject.getSubject_name(), subject.getCapacity(), subject.getSubject_explanation(), subject.getInstructional_objectives(), subject.getSubject_point(), subject.getLecture_target(), subject.getLecture_totalday(), subject.getTuition_fee(), subject.getLecture_content(), subject.getCenter_id(), start1, end1, time3 / 3600); return sqlSession.getMapper(SubjectDAO.class).insertSubject(subject2); }