⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rightbean.java

📁 这是一个很好用的软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
 * Version 1.0 Date:2003-11-07 Description:权限控制 Other: Variable List: 1.String
 * uid = "-1";//人员编号 String Orgid = "-1";//部门编号
 * 
 * Function List: 1.public void setUID(String uid)//设置人员编号 2.public void
 * setOrgid(String Orgid)//设置部门编号
 * 
 * //三种权限 3.public boolean isAdmin();//判断是否是系统管理员 4.public Vector
 * getRightConf()//配置权限 5.public Vector getRightMode()//模块权限 6.public Vector
 * getRightFlow()//流程权限 7.public String getConfValue(String type)//取得配置数字
 * 8.public boolean isRightMode(String mode,String
 * button)//是否有操作button对模块mode的权限 9.public boolean isRightFlow(String
 * flow)//是否有操作流程flow的权限
 * 
 * //公文权限 10.public Vector getRightConfidential()机要权限 11.public boolean
 * isRightConfidential()判断当前是否有该权限 12.public boolean isRightSecretary()文书权限
 * 13.public Vector getRightDuty()职务权限 14.public Vector getRightArchives()档案权限
 * 15.public Vector getRightPeriodical()期刊权限
 * 
 * //版面管理权限 16.public Vector getBMBHS()//当前职工所在的部门编号(包括被分配职务后得到的职务部门编号) 柳美\
 * 17.public boolean isRightOrg(String
 * lbid)//部门新闻操作权限(根据orgmenu.id判断)(uid,orgid) 18.public boolean
 * isRightPage(String dxbh,String whichtable,String sf,String cz)//版面权限
 * 
 * 19. //*取得模块权限------------lbh-----------11-29 //public String
 * getRightModelbh() 20. //是否有模块操作权限------------lbh-----------11-29 //public
 * boolean isRightModelbh(String strmkmc,String strbtnmc)
 * 
 * History:
 ******************************************************************************/
package oa.bean;

import java.util.*;
import java.sql.*;
import oa.main.*;

public class RightBean extends ParentBean {
	String uid = "-1";//人员编号

	String Orgid = "-1";//部门编号

	public void setUID(String uid)//设置人员编号
	{
		this.uid = uid.trim();
	}

	public void setOrgid(String Orgid)//设置部门编号
	{
		this.Orgid = Orgid.trim();
	}

	/** 判断是否是系统管理员 */
	public boolean isAdmin() {
		String name = toName("ZZ_ZGB", "ZGBH", "ZGBH", uid).toLowerCase();
		if (name.equals("1"))
			return true;
		else
			return false;
	}

	/** 配置权限 */
	public Vector getRightConf() {
		Vector vect = new Vector();
		String right = "";
		ResultSet rs = selectRecord("select PZCS from news.ZZ_ZGB where ZGBH='"
				+ uid + "'");
		Statement stmt = null;
		try {
			if (rs.next()) {
				right = ds.toString(rs.getString("PZCS"));
			}
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out
							.println("RightBean.getRightConf()关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out
							.println("RightBean.getRightConf()关闭声明时statement出错"
									+ e);
				}

			//if(right.equals(""))//当当前人员表为空时,查询职务表权限集合
			{
				rs = selectRecord("select PZCS from news.ZZ_ZWB where (BMBH,ZWBH) in (select BMBH,ZWBH from ZZ_ZGZWB where ZGBH='"
						+ uid + "')");
				if (rs.next()) {
					if (!right.equals(""))
						right += ",";
					right = ds.toString(rs.getString("PZCS"));
				}
				if (rs != null)
					try {
						stmt = rs.getStatement();
						rs.close();
					} catch (Exception e) {
						System.out.println("RightBean.getRightConf()关闭记录集rs时出错"
								+ e);
					}
				if (stmt != null)
					try {
						stmt.close();
					} catch (Exception e) {
						System.out
								.println("RightBean.getRightConf()关闭声明时statement出错"
										+ e);
					}
			}

			if (right.equals(""))//当职务表集合为空时
			{
				stmt = rs.getStatement();
				rs.close();
				stmt.close();
				rs = selectRecord("select PZSZ from news.CODE_XTPZ order by PZBH");
				while (rs.next()) {
					vect.add(ds.toString(rs.getString(1)));
				}
				if (rs != null)
					try {
						stmt = rs.getStatement();
						rs.close();
					} catch (Exception e) {
						System.out.println("RightBean.getRightConf()关闭记录集rs时出错"
								+ e);
					}
				if (stmt != null)
					try {
						stmt.close();
					} catch (Exception e) {
						System.out
								.println("RightBean.getRightConf()关闭声明时statement出错"
										+ e);
					}
			} else {
				String str[] = ds.splitStr(right, ',');
				for (int i = 0; i < str.length; i++) {
					vect.add(str[i]);
				}
			}
		} catch (Exception e) {
			System.out.println("运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("关闭声明时statement出错" + e);
				}
		}
		return vect;
	}

	public String getConfValue(String type)//取得配置数字
	{
		String confvalue = "";
		Vector vect = getRightConf();
		int pzbh = toID("CODE_XTPZ", "PZMC", "PZBH", type.trim());
		if (vect.size() >= pzbh && pzbh > 0)
			confvalue = (String) vect.get(pzbh - 1);
		return confvalue;
	}

	/** 模块权限 */
	public Vector getRightMode() {
		Vector vect = new Vector();
		String sql = "select BMBH,ZWBH,CZQX from news.ZZ_ZGZWB where ZGBH='"
				+ uid + "'";
		if (!uid.equals("1") && !Orgid.equals("-1")) {
			char bmsub;
			int n = 19;
			for (n = 19; n >= 0; n--) {
				bmsub = Orgid.charAt(n);
				if (bmsub != '0')
					break;
			}
			if (n == -1)
				n = 1;
			sql += " and (BMBH='" + Orgid + "' or BMBH like '%"
					+ Orgid.substring(0, n + 1) + "%')";
		}
		String right = "";

		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			while (rs.next())//取得职务表权限
			{
				String czqx = ds.toString(rs.getString("CZQX"));
				String bmbh = ds.toString(rs.getString("BMBH"));
				String zwbh = ds.toString(rs.getString("ZWBH"));
				if (czqx.equals(""))//当职务表中权限为空时,去部门职务表权限
				{
					sql = "select CZQX from news.ZZ_ZWB where BMBH='" + bmbh
							+ "' and ZWBH=" + zwbh + " and ZWZT=0";
					ResultSet rs_t = selectRecord(sql);
					try {
						rs_t.next();
						czqx = ds.toString(rs_t.getString("CZQX"));
					} catch (Exception e) {
						System.out.println("运行时出错:" + e);
					} finally {
						if (rs_t != null)
							try {
								stmt = rs_t.getStatement();
								rs_t.close();
							} catch (Exception e) {
								System.out.println("关闭记录集rs时出错" + e);
							}
						if (stmt != null)
							try {
								stmt.close();
							} catch (Exception e) {
								System.out.println("关闭声明时statement出错" + e);
							}
					}
				}
				if (!right.equals("") && !czqx.equals(""))
					right += ",";
				if (!czqx.equals(""))
					right += czqx;
			}

			//if(right.equals(""))//当职务权限集合为空时查询字典
			//{
			stmt = rs.getStatement();
			rs.close();
			stmt.close();
			rs = selectRecord("select ID from news.CODE_ANCZQXB where MRCZ=1 and SYZT=0");
			while (rs.next()) {
				vect.add(rs.getString(1));
			}
		} catch (Exception e) {
			System.out.println("运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("关闭声明时statement出错" + e);
				}
		}
		//}
		//else
		//{
		String str[] = ds.splitStr(right, ',');
		for (int i = 0; i < str.length; i++) {
			vect.add(str[i]);
		}
		//}
		return vect;
	}

	/** 流程权限 */
	public Vector getRightFlow() {
		Vector vect = new Vector();
		String sql = "select BMBH,ZWBH,LCQX from news.ZZ_ZGZWB where ZGBH='"
				+ uid + "'";
		if (!Orgid.equals("-1"))
			sql += " and BMBH='" + Orgid + "'";
		String right = "";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			while (rs.next())//取得职务表权限
			{
				String czqx = ds.toString(rs.getString("LCQX"));
				String bmbh = ds.toString(rs.getString("BMBH"));
				String zwbh = ds.toString(rs.getString("ZWBH"));
				if (czqx.equals(""))//当职务表中权限为空时,去部门职务表权限
				{
					sql = "select LCQX from news.ZZ_ZWB where BMBH='" + bmbh
							+ "' and ZWBH=" + zwbh + " and ZWZT=0";
					ResultSet rs_t = selectRecord(sql);
					try {
						if (rs_t.next())
							czqx = ds.toString(rs_t.getString("LCQX"));
					} catch (Exception e) {
						System.out.println("运行时出错:" + e);
					} finally {
						if (rs_t != null)
							try {
								stmt = rs_t.getStatement();
								rs_t.close();
							} catch (Exception e) {
								System.out.println("关闭记录集rs时出错" + e);
							}
						if (stmt != null)
							try {
								stmt.close();
							} catch (Exception e) {
								System.out.println("关闭声明时statement出错" + e);
							}
					}
				}
				if (!right.equals("") && !czqx.equals(""))
					right += ",";
				if (!czqx.equals(""))
					right += czqx;
			}
		} catch (Exception e) {
			System.out.println("运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("关闭声明时statement出错" + e);
				}
		}

		if (right.equals(""))//当职务权限集合为空时查询字典
		{
			rs = selectRecord("select MKBH from news.CODE_LCQXB where MRCZ=1 and SYZT=0");
			try {
				while (rs.next()) {
					vect.add(rs.getString(1));
				}
			} catch (Exception e) {
				System.out.println("运行时出错:" + e);
			} finally {
				if (rs != null)
					try {
						stmt = rs.getStatement();
						rs.close();
					} catch (Exception e) {
						System.out.println("关闭记录集rs时出错" + e);
					}
				if (stmt != null)
					try {
						stmt.close();
					} catch (Exception e) {
						System.out.println("关闭声明时statement出错" + e);
					}
			}
		} else {
			String str[] = ds.splitStr(right, ',');
			for (int i = 0; i < str.length; i++) {
				vect.add(str[i]);
			}
		}

		return vect;
	}

	/** 是否有操作button对模块mode的权限 */
	public boolean isRightMode(String mode, String button) {
		boolean bool = false;
		ResultSet rs = selectRecord("select ID from news.CODE_ANCZQXB where MKMC='"
				+ ds.toString(mode)
				+ "' and ANMC='"
				+ ds.toString(button)
				+ "'");
		String mkbh = "";
		Statement stmt = null;
		try {
			if (rs.next()) {
				mkbh = ds.toString(rs.getString("ID"));
			}
		} catch (Exception e) {
			System.out.println("运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("关闭声明时statement出错" + e);
				}
		}
		Vector vect = getRightMode();
		int index = vect.indexOf(mkbh);
		if (index != -1)
			bool = true;

		return bool;
	}

	public boolean isRightFlow(String flow)//是否有操作流程flow的权限
	{
		boolean bool = false;
		ResultSet rs = selectRecord("select MKBH from news.CODE_LCQXB where MKMC='"
				+ ds.toString(flow) + "'");
		String mkbh = "";
		Statement stmt = null;
		try {
			if (rs.next()) {
				mkbh = ds.toString(rs.getString("MKBH"));
			}
		} catch (Exception e) {
			System.out.println("运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("关闭声明时statement出错" + e);
				}
		}
		Vector vect = getRightFlow();
		int index = vect.indexOf(mkbh);
		if (index != -1)
			bool = true;
		return bool;
	}

	/** 机要权限 */
	public Vector getRightConfidential() {
		Vector vect = new Vector();
		ResultSet rs = selectRecord("select CKQX from news.ZZ_BMB where BMBH ='"
				+ Orgid + "'");
		String right = "";
		Statement stmt = null;
		try {
			if (rs.next())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -