Ejemplo n.º 1
0
	/**
	 * 更新一条记录
	 */
	public void updateRecordById() {
		try {
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String orgId = (String) params.get("orgId");
			String parentId = (String) params.get("parentId");
			String id = (String) params.get("id");
			if (!FunctionLib.isNum(orgId) || !FunctionLib.isNum(parentId) || !FunctionLib.isNum(id))
				return;
			if ("".equals(depaName)) {
				String msg = getLang().getProp().get(getMySession().getL()).get("name") + getLang().getProp().get(getMySession().getL()).get("cannotbenull");
				getMySession().setMsg(msg, 2);
				return;
			}
			Query query = getSession().getNamedQuery("core.department.updaterecordbyid");
			query.setParameter("mId", 0);
			query.setParameter("depaName", depaName);
			query.setParameter("depaDesc", depaDesc);
			query.setParameter("sequence", sequence);
			query.setParameter("id", id);
			query.executeUpdate();
			query = null;

			query = getSession().getNamedQuery("core.department.of.update");
			query.setParameter("id", id);
			query.executeUpdate();

			String msg = getLang().getProp().get(getMySession().getL()).get("success");
			getMySession().setMsg(msg, 1);
		} catch (Exception ex) {
			String msg = getLang().getProp().get(getMySession().getL()).get("faield");
			getMySession().setMsg(msg, 2);
			ex.printStackTrace();
		}
	}
Ejemplo n.º 2
0
	/**
	 * 新增一条记录,注意这里没有使用到insert语句,这是hibernate的特点
	 */
	public void newRecord() {
		try {
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String orgId = (String) params.get("orgId");
			String parentId = (String) params.get("parentId");
			if (!FunctionLib.isNum(orgId) || !FunctionLib.isNum(parentId))
				return;
			if ("".equals(depaName)) {
				String msg = getLang().getProp().get(getMySession().getL()).get("name") + getLang().getProp().get(getMySession().getL()).get("cannotbenull");
				getMySession().setMsg(msg, 2);
				return;
			}
			Department bean = new Department();
			bean.setOrgId(Integer.valueOf(orgId));
			bean.setParentId(Integer.valueOf(parentId));
			bean.setDepaName(depaName);
			bean.setDepaDesc(depaDesc);
			bean.setSequence(sequence);
			bean.setCID_(0);
			bean.setCDATE_(new java.util.Date());
			getSession().save(bean);
			bean = null;

			String msg = getLang().getProp().get(getMySession().getL()).get("success");
			getMySession().setMsg(msg, 1);
		} catch (Exception ex) {
			String msg = getLang().getProp().get(getMySession().getL()).get("faield");
			getMySession().setMsg(msg, 2);
			ex.printStackTrace();
		}
	}
Ejemplo n.º 3
0
	public void moveRecordById() {
		try {
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String orgId = (String) params.get("orgId");
			String parentId = (String) params.get("parentId");
			String id = (String) params.get("id");
			if (!FunctionLib.isNum(orgId) || !FunctionLib.isNum(parentId) || !FunctionLib.isNum(id))
				return;
			getMySession().getTempStr().put("Department.move.id", id);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
Ejemplo n.º 4
0
	public void processSelection(NodeSelectedEvent event) {
		try {
			HtmlTree tree = (HtmlTree) event.getComponent();
			Department bean = (Department) tree.getRowData();
			ID_ = bean.getID_();
			selectRecordById(String.valueOf(ID_));
			orgId = bean.getOrgId();
			parentId = bean.getParentId();
			orgName = bean.getOrgName();
			parentName = bean.getParentName();
			if (FunctionLib.isNum(getMySession().getTempStr().get("Department.move.id"))) {
				Query query = getSession().getNamedQuery("core.department.moverecordbyid");
				query.setParameter("mId", 0);
				query.setParameter("orgId", orgId);
				query.setParameter("parentId", ID_);
				query.setParameter("id", getMySession().getTempStr().get("Department.move.id"));
				query.executeUpdate();
				query = null;
				getMySession().getTempStr().put("Department.move.id", "");

				query = getSession().createSQLQuery("CALL of_update_group(:id)");
				query.setParameter("id", getMySession().getTempStr().get("Department.move.id"));
				query.executeUpdate();

				FunctionLib.refresh();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
Ejemplo n.º 5
0
	/**
	 * 新增一条记录,注意这里没有使用到insert语句,这是hibernate的特点
	 */
	public void newRecord() {
		try {
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String hId = (String) params.get("headerId");
			if (FunctionLib.isNum(hId)) {
				getMySession().getTempStr().put("BallotItems.headerId", (String) params.get("headerId"));

				BallotItems bean = new BallotItems();
				bean.setHeaderId(Integer.valueOf(hId));
				bean.setTitle(title);
				bean.setOrderNum(orderNum);
				bean.setCID_(getMySession().getUserId());
				bean.setCDATE_(new java.util.Date());
				bean.setMID_(MID_);
				getSession().save(bean);
				bean = null;
				String msg = getLang().getProp().get(getMySession().getL()).get("success");
				getMySession().setMsg(msg, 1);
			}
		} catch (Exception ex) {
			String msg = getLang().getProp().get(getMySession().getL()).get("faield");
			getMySession().setMsg(msg, 2);
			ex.printStackTrace();
		}
	}
Ejemplo n.º 6
0
	/**
	 * 将全部记录加入列表
	 */
	public void buildRecordsList() {
		try {
			getMySession();
			recordsList = new ArrayList<BallotItems>();
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String hId = (String) params.get("headerId");
			if (!FunctionLib.isNum(hId))
				hId = getMySession().getTempStr().get("BallotItems.headerId");
			if (FunctionLib.isNum(hId)) {
				getMySession().getTempStr().put("BallotItems.headerId", hId);

				Query query = getSession().getNamedQuery("core.ballot.items.records");
				query.setParameter("headerId", hId);

				Iterator<?> it = query.list().iterator();
				int id, cId, mId;
				String cDate, mDate, uuid;
				String t;
				int o;
				String hasOp = "false";
				while (it.hasNext()) {
					Object obj[] = (Object[]) it.next();
					id = cId = mId = 0;
					cDate = mDate = uuid = "";
					t = "";
					o = 0;
					id = FunctionLib.getInt(obj[0]);
					cId = FunctionLib.getInt(obj[1]);
					cDate = FunctionLib.getDateTimeString(obj[2]);
					mId = FunctionLib.getInt(obj[3]);
					mDate = FunctionLib.getDateTimeString(obj[4]);
					t = FunctionLib.getString(obj[7]);
					o = FunctionLib.getInt(obj[8]);
					recordsList.add(new BallotItems(id, cId, cDate, mId, mDate, uuid, Integer.valueOf(hId), t, o, FunctionLib.getString(obj[9])));
					if (mId == getMySession().getUserId() && o == 0)
						hasOp = "true";
				}
				it = null;
				getMySession().getTempStr().put("BallotItems.hasOp", hasOp);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
Ejemplo n.º 7
0
	/**
	 * 删除一条记录
	 */
	public void deleteRecordById() {
		try {
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String id = (String) params.get("id");
			if (!FunctionLib.isNum(id))
				return;

			Query query = getSession().getNamedQuery("core.department.of.delete");
			query.setParameter("id", id);
			query.executeUpdate();

			query = getSession().getNamedQuery("core.department.deleterecordbyid");
			query.setParameter("id", id);
			query.executeUpdate();
			query = null;
			String msg = getLang().getProp().get(getMySession().getL()).get("success");
			getMySession().setMsg(msg, 1);

		} catch (Exception ex) {
			String msg = getLang().getProp().get(getMySession().getL()).get("faield");
			getMySession().setMsg(msg, 2);
			ex.printStackTrace();
		}
	}