/** 增加通知 */ public boolean addNotic(Notic notic) throws ManagerException { boolean r = false; DBUtil db = new DBUtil(); String sql = "intsert into TD_SD_NOTIC (notic_planner_id,EXECUTOR_ID,topic,place,begintime,endtime,content,status,source) " + "values (" + notic.getNoticPlannerID() + "," + notic.getExecutorID() + ",'" + notic.getTopic() + "'," + notic.getBeginTime() + "," + notic.getEndTime() + ",'" + notic.getContent() + "'," + notic.getStatus() + ",'" + notic.getSource() + "')"; try { db.executeInsert(sql); r = true; } catch (SQLException e) { e.printStackTrace(); } return r; }
/** 修改通知 */ public boolean modifyNotic(Notic notic) throws ManagerException { boolean r = false; DBUtil db = new DBUtil(); String sql = "update TD_SD_NOTIC set" + " topic='" + notic.getTopic() + "', content='" + notic.getContent() + "', begintime=" + SQLManager.getInstance().getDBAdapter().getDateString(notic.getBeginTime()) + ", endtime=" + SQLManager.getInstance().getDBAdapter().getDateString(notic.getEndTime()) + ", place='" + notic.getPlace() + "', SOURCE=" + notic.getSource() + " where schedular_id=" + notic.getNoticID() + ""; try { db.executeUpdate(sql); r = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return r; }
/** 更具通知ID得到通知属性 */ public Notic getNotic(int j) throws ManagerException { Notic notic = new Notic(); DBUtil db = new DBUtil(); String sql = "select a.*,b.user_name from TD_SD_NOTIC a,td_sm_user b " + "where a.notic_planner_id = b.user_id and NOTIC_ID=" + j + ""; try { db.executeSelect(sql); for (int i = 0; i < db.size(); i++) { notic.setBeginTime(db.getDate(i, "begintime")); notic.setEndTime(db.getDate(i, "endtime")); notic.setContent(db.getString(i, "content")); notic.setExecutorID(db.getInt(i, "executor_id")); notic.setPlace(db.getString(i, "place")); notic.setNoticPlannerName(db.getString(i, "user_nasme")); notic.setStatus(db.getInt(i, "status")); notic.setTopic(db.getString(i, "topic")); notic.setSource(db.getString(i, "source")); notic.setNoticPlannerID(db.getInt(i, "notic_planner_id")); return notic; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return notic; }
/** 得到通知列表 */ public ListInfo getNoticList(String sql, int offset, int maxItem) throws ManagerException { DBUtil dbUtil = new DBUtil(); try { dbUtil.executeSelect(sql, offset, maxItem); ListInfo listInfo = new ListInfo(); List list = new ArrayList(); for (int i = 0; i < dbUtil.size(); i++) { Notic notic = new Notic(); notic.setNoticID(dbUtil.getInt(i, "NOTIC_ID")); notic.setBeginTime(dbUtil.getDate(i, "begintime")); notic.setEndTime(dbUtil.getDate(i, "endtime")); notic.setContent(dbUtil.getString(i, "content")); notic.setPlace(dbUtil.getString(i, "place")); notic.setExecutorID(dbUtil.getInt(i, "executor_id")); notic.setNoticPlannerName(dbUtil.getString(i, "user_name")); notic.setNoticPlannerRealName(dbUtil.getString(i, "user_realname")); notic.setSource(dbUtil.getString(i, "source")); notic.setStatus(dbUtil.getInt(i, "status")); notic.setTopic(dbUtil.getString(i, "topic")); list.add(notic); } listInfo.setDatas(list); listInfo.setTotalSize(dbUtil.getTotalSize()); return listInfo; } catch (SQLException e) { e.printStackTrace(); throw new ManagerException(e.getMessage()); } }