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

📄 describe.java

📁 JSP移动商品管理平台源代码.........
💻 JAVA
字号:
package cmis.common;

import cmis.database.DBPoolManager;
import java.sql.*;

public class Describe {

	public Describe() {
	}

	public String getNameDescription(int type, int code) {
		String res = "";
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select description from code_info where type = "
					+ type + " and code = " + code;
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString(1);
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			System.err.println("Get Description info SQLException : "
					+ ex.getMessage());
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}

	public String getTypeDescription(int type) {
		String res = "";
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select name from code_info where type = " + type;
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString(1);
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			System.err.println("Get Type Description info SQLException : "
					+ ex.getMessage());
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}

	public String getDepartment(int dept) {
		String res = "";
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select OrganName from organ where OrganID = " + dept;
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString(1);
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			System.err.println("Get Department info SQLException : "
					+ ex.getMessage());
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}


	
	public int getUserDepartment(String user) {
		int dept = 0;
		if (user == null) {
			return 0;
		}
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select a.OrganID from organ a, Staff b where "
					+ "b.OrganID = a.OrganID and b.UserCode = '" + user + "'";
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				dept = rest.getInt(1);
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			System.err.println("Get User Department info SQLException : "
					+ ex.getMessage());
		} finally {
			dbpool.freeConnection();
		}
		return dept;
	}

	public String getUserName(String userId) {
		String res = userId;
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select UserName from Staff where UserCode = '"
					+ userId + "'";
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString(1);
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			System.err.println("Get User Name SQLException : "
					+ ex.getMessage());
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}
	
	public boolean isAdmin(String userId) {
		boolean  reflag = false;
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select UserName from Staff a, Staff_role b where a.UserId=b.UserId and a.UserCode = '"
					+ userId + "' and b.RoleId= 0 ";
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				reflag = true ;
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			System.err.println("IsAdmin SQLException : "
					+ ex.getMessage());
		} finally {
			dbpool.freeConnection();
		}
		return reflag;
	}
	
	
	

}

⌨️ 快捷键说明

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