📄 selectczqxbean.java
字号:
/*******************************************************************************
* Version 1.0 Date:2003-11-15 Description:组织机构中的职务表:列表查询、单条信息查询、增加记录、修改记录、删除记录
* Other: Variable List:
*
* Function List: 1.public selectczqxBean()//构造函数 2.public vector
* getAllButtons()//取得所有信息 3.public vector getAllMK()//取得所有模块 4.public vector
* getButtons(String mkbh)//取得同一模块编号下所有按钮的信息 5.public String getMRCZBtns();
* //取得所有默认操作的权限
*
* 6.public String getMKBH(Stirng mkmc)//由模块名称得到模块编号
*
* 7.public String getDutyCZQX(String bmbh,String zwbh)//由部门编号、职务编号取得操作权限
* Modification: 1. public Vector getAllMyMK(String PersonNo)//取得指定人拥有权限的模块
* public Vector getMyButtons(String mkbh,String PersonNo)//取得指定人拥有权限的模块下的按钮信息
* public String getAllOper();//取得所有操作信息.
******************************************************************************/
package oa.bean;
import java.util.*;
import java.sql.*;
import oa.main.*;
public class selectczqxBean extends ParentBean {
//构造函数
public selectczqxBean() {
}
//由模块名称得到模块编号
public String getMKBH(String mkmc) {
return String.valueOf(db.toID("CODE_ANCZQXB", "MKMC", "MKBH", mkmc));
}
//取得所有模板
public Vector getAllMK() {
Vector vect = new Vector();
String sql = "select distinct MKBH,MKMC from news.CODE_ANCZQXB order by MKBH";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
while (rs.next()) {
Hashtable hash = new Hashtable();
for (int i = 1; i <= cols; i++) {
String field = ds.toString(rsmd.getColumnName(i));
String value = ds.toString(rs.getString(i));
hash.put(field, value);
}
vect.add(hash);
}
} 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 Vector getButtons(String mkbh) {
Vector vect = new Vector();
String sql = "select * from news.CODE_ANCZQXB where MKBH=" + mkbh
+ " and SYZT=0 order by ANXH";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
while (rs.next()) {
Hashtable hash = new Hashtable();
for (int i = 1; i <= cols; i++) {
String field = ds.toString(rsmd.getColumnName(i));
String value = ds.toString(rs.getString(i));
hash.put(field, value);
}
vect.add(hash);
}
} 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 getMRCZBtns() {
String mrczqx = "";
String sql = "select ID from news.CODE_ANCZQXB where SYZT=0 and MRCZ=1";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
while (rs.next()) {
if (!mrczqx.equals(""))
mrczqx = mrczqx + ","
+ ds.toString(String.valueOf(rs.getInt(1)));
else
mrczqx = ds.toString(String.valueOf(rs.getInt(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);
}
}
return mrczqx;
}
public Vector getMKFromQX(String czqx)//根据操作权限确定模块名称及按钮名称
{
Vector vct = new Vector();
if (czqx.equals(""))
return null;
String sql = "select distinct mkbh,mkmc from news.code_anczqxb where SYZT=0 and id in ("
+ czqx + ") order by mkbh";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
while (rs.next()) {
String mkbh = rs.getString("MKBH");
Hashtable hash = new Hashtable();
hash.put("MKBH", mkbh);
hash.put("MKMC", rs.getString("MKMC"));
vct.add(hash);
sql = "select id,anmc,anxh from news.code_anczqxb where SYZT=0 and id in ("
+ czqx + ") and mkbh =" + mkbh + " order by anxh";
ResultSet rst = selectRecord(sql);
Vector vect = new Vector();
try {
while (rst.next()) {
Hashtable hash1 = new Hashtable();
hash1.put("ID", rst.getString("ID"));
hash1.put("ANMC", rst.getString("ANMC"));
hash1.put("ANXH", rst.getString("ANXH"));
vect.add(hash1);
}
} catch (Exception e) {
System.out.println("运行时出错:" + e);
} finally {
if (rst != null)
try {
stmt = rst.getStatement();
rst.close();
} catch (Exception e) {
System.out.println("关闭记录集rs时出错" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("关闭声明时statement出错" + e);
}
}
vct.add(vect);
}
} 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 vct;
}
public Vector MixMK(String str1, String str2) {//取得按钮的合集模块
Vector vct = new Vector();
String[] first = str1.split(",");
String[] second = str2.split(",");
String both = "", only = "", all = "";
boolean flag;
for (int i = 0; i < second.length; i++) {
flag = true;
for (int j = 0; j < first.length; j++) {
if (second[i].equals(first[j])) {
flag = false;
both += second[i] + ",";
}
}
if (flag)
only += second[i] + ",";
}
all = str1 + "," + only;
all = all.substring(0, all.length() - 1);
first = both.split(",");
second = only.split(",");
String sql = "select distinct mkbh,mkmc from news.code_anczqxb where SYZT=0 and id in ("
+ all + ") order by mkbh";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
while (rs.next()) {
String mkbh = rs.getString("MKBH");
Hashtable hash = new Hashtable();
hash.put("MKBH", mkbh);
hash.put("MKMC", rs.getString("MKMC"));
vct.add(hash);
sql = "select id,anmc,anxh from news.code_anczqxb where SYZT=0 and id in ("
+ all + ") and mkbh =" + mkbh + " order by anxh";
Vector vect = new Vector();
ResultSet rst = selectRecord(sql);
try {
while (rst.next()) {
Hashtable hash1 = new Hashtable();
String id = rst.getString("ID");
hash1.put("ID", id);
hash1.put("ANMC", rst.getString("ANMC"));
hash1.put("ANXH", rst.getString("ANXH"));
flag = false;
for (int i = 0; i < first.length; i++) {
if (first[i].equals(id)) {
flag = true;
break;
}
}
if (flag)
hash1.put("BOTH", "1");
else
hash1.put("BOTH", "0");
flag = false;
for (int i = 0; i < second.length; i++) {
if (second[i].equals(id)) {
flag = true;
break;
}
}
if (flag)
hash1.put("ONLY", "1");
else
hash1.put("ONLY", "0");
vect.add(hash1);
}
} catch (Exception e) {
System.out.println("运行时出错:" + e);
} finally {
if (rst != null)
try {
stmt = rst.getStatement();
rst.close();
} catch (Exception e) {
System.out.println("关闭记录集rs时出错" + e);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception e) {
System.out.println("关闭声明时statement出错" + e);
}
}
vct.add(vect);
}
} 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 vct;
}
public String getAllOper() {//取得所有操作信息.
String mrczqx = "";
String sql = "select ID from news.CODE_ANCZQXB where SYZT=0 order by mkbh";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try {
while (rs.next()) {
if (!mrczqx.equals(""))
mrczqx = mrczqx + ","
+ ds.toString(String.valueOf(rs.getInt(1)));
else
mrczqx = ds.toString(String.valueOf(rs.getInt(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);
}
}
return mrczqx;
}
public String getDutyCZQX(String bmbh, String zwbh)//由部门编号、职务编号取得操作权限
{
String czqx = "";
ResultSet rs = selectRecord(" select czqx from news.zz_zwb where bmbh='"
+ bmbh + "' and zwbh=" + zwbh);
Statement stmt = null;
try {
if (rs.next()) {
czqx = ds.toString(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);
}
}
return czqx;
}
public static void main(String args[]) {
selectczqxBean mb = new selectczqxBean();
//System.out.println(mb.getAllMK());
System.out.println("\r\n\r\nend");
System.out.println(mb.MixMK("1,2,6,22,23,24,7,8,9,10,11,12,13,14",
"1,2,6,7,8,15,16,17,18"));
mb.closeConn();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -