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
	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.º 3
0
	public MySession getMySession() {
		if (mySession == null)
			mySession = (MySession) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("MySession");
		if (mySession == null)
			FunctionLib.redirect(FunctionLib.getWebAppName());
		return mySession;
	}
Ejemplo n.º 4
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.º 5
0
	public Lang getLang() {
		if (lang == null)
			lang = (Lang) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("Lang");
		if (lang == null)
			FunctionLib.redirect(FunctionLib.getWebAppName());
		return lang;
	}
Ejemplo n.º 6
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.º 7
0
	public void addChildren(String parentKey, int orgId, int parentId, String oName, String pName) {
		try {
			level++;
			Query query = getSession().getNamedQuery("core.department.getchildren");
			query.setParameter("orgId", orgId);
			query.setParameter("parentId", parentId);
			Iterator<?> it = query.list().iterator();
			int id;
			String name;
			int i = 1;
			while (it.hasNext()) {
				Object obj[] = (Object[]) it.next();
				id = 0;
				name = "";
				if (obj[0] != null)
					id = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[1] != null)
					name = String.valueOf(obj[1]);
				bf.append(parentKey + "." + i + "=depa," + id + "," + FunctionLib.gb23122Unicode(name) + "\r\n");

				if (hasChild(orgId, id))
					addChildren(parentKey + "." + i, orgId, id, oName, name);
				i++;
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
Ejemplo n.º 8
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.º 9
0
	public void buildTreeFile() {
		try {
			bf = new StringBuffer();
			rootNode = new TreeNodeImpl<Department>();

			Query query = getSession().getNamedQuery("core.org.records");
			Iterator<?> it = query.list().iterator();
			int id;
			String name;
			level = 1;
			int i = 1;
			while (it.hasNext()) {
				Object obj[] = (Object[]) it.next();
				id = 0;
				name = "";
				if (obj[0] != null)
					id = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[6] != null)
					name = String.valueOf(obj[6]);
				bf.append(i + "=org," + id + "," + FunctionLib.gb23122Unicode(name) + "\r\n");
				addChildren(String.valueOf(i), id, 0, name, name);
				i++;
			}
			it = null;

			String filename = FunctionLib.getBaseDir() + "department.properties";
			File f = new File(filename);
			if (f.exists())
				f.delete();
			FileWriter fstream = new FileWriter(filename);
			BufferedWriter out = new BufferedWriter(fstream);
			out.write(bf.toString());
			out.close();
			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.º 10
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.º 11
0
	public void ballot() {
		try {

			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String hId = (String) params.get("headerId");
			Query query = getSession().getNamedQuery("core.ballot.items.records.count");
			query.setParameter("headerId", hId);
			int rowcount = Integer.valueOf(query.list().get(0).toString());
			//
			query = getSession().getNamedQuery("core.ballot.items.check");
			query.setParameter("headerId", hId);
			query.setParameter("mId", getMySession().getUserId());
			ID_ = FunctionLib.getInt(query.list().get(0));
			if(ID_ ==0){
				String msg = getLang().getProp().get(getMySession().getL()).get("ballotwaring");
				getMySession().setMsg(msg, 2);
				return;
			}
			boolean bool = true;
			while (bool) {
				Random random = new Random();
				int order = random.nextInt(rowcount) + 1;
				query = getSession().getNamedQuery("core.ballot.items.getordernum");
				query.setParameter("id", ID_);
				query.setParameter("orderNum", order);
				query.setParameter("headerId", hId);
				if ("0".equals(String.valueOf(query.list().get(0)))) {
					query = getSession().getNamedQuery("core.ballot.items.updaterecordbyid");
					query.setParameter("mId", getMySession().getUserId());
					query.setParameter("orderNum", order);
					query.setParameter("id", ID_);
					query.executeUpdate();
					break;
				}
			}
			query = getSession().getNamedQuery("core.ballot.items.completed");
			query.setParameter("headerId", hId);
			query.executeUpdate();
		} catch (Exception ex) {
			String msg = getLang().getProp().get(getMySession().getL()).get("faield");
			getMySession().setMsg(msg, 2);
			ex.printStackTrace();
		}
	}
Ejemplo n.º 12
0
	/**
	 * 读取一条记录
	 */
	public void selectRecordById() {
		try {
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			String id = (String) params.get("id");
			Query query = getSession().getNamedQuery("core.ballot.items.getrecordbyid");
			query.setParameter("id", id);
			Iterator<?> it = query.list().iterator();
			while (it.hasNext()) {
				this.reset();
				Object obj[] = (Object[]) it.next();
				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]);
				headerId = FunctionLib.getInt(obj[6]);
				title = FunctionLib.getString(obj[7]);
				orderNum = FunctionLib.getInt(obj[8]);
			}
			it = null;
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
Ejemplo n.º 13
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();
		}
	}