【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-TopicBean.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
/**********************************************************
Version 1.0
Date:2003-10-31
Description:
Other:
Variable List:
1.int type = 0;//系统设置的类型
2.String id = "-1"//记录唯一编号
Function List:
1.public void setType(String t)//设置所设置的系统类型
2.public void setID(String i)//设置记录唯一编号
3.public Vector getData()//取得数据表内容
4.public Hashtable getOneData()//取得数据表中的某一条记录
8.public int addTopic(Hashtable hash)//增加专题列表信息
9.public int modTopic(Hashtable hash)//修改专题列表信息
10.public int delData()//删除专题列表信息
11.public Vector getSort(String id)//根据模块编号取得下面的所有所属类别
History:
***********************************************************/
package oa.bean;
import java.text.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import oa.main.*;
public class TopicBean extends ParentBean
{
int type = 0;
String id = "-1";
//设置记录唯一编号
public void setID(String i)
{
id = i;
}
//得到专题名称
//取得数据表内容
public Vector getData()
{
Vector vect = new Vector();
String sql = "";
sql = "select * from news.NB_TOPIC order by MENUID1,JBXH";
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 getData(String name)
{
Vector vect = new Vector();
String sql = "";
/*
sql = "select * from news.NB_TOPIC where TYPE='"+name+"' and status=0 order by TYPE,JBXH";
ResultSet rs = selectRecord(sql);
//取得列数和列名
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);
}
rs.close(); Statement stmt = rs.getStatement(); if(stmt!=null) stmt.close();
return vect;
*/
int menuid1 = toID("MENU","MENU1","ID1",name);
return getData(menuid1);
}
public Vector getData(int menuid1)
{
Vector vect = new Vector();
String sql = "";
sql = "select * from news.NB_TOPIC where MENUID1='"+menuid1+"' and status=0 order by JBXH";
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 Hashtable getOneData()
{
Hashtable hash = new Hashtable();
String sql = "";
sql = "select * from news.NB_TOPIC where ID = "+id+"";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
if (rs.next())
{
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);
}
}
}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 hash;
}
//增加专题列表信息
public int addTopic(Hashtable hash)
{
//System.out.println("hash:"+hash);
int intId = db.makeID("NB_TOPIC","ID","","",true);
String strName = ds.toString((String)hash.get("NAME"));
String strType = ds.toString((String)hash.get("TYPE"));
String strIntroduce = ds.toString((String)hash.get("INTRODUCE"));
String strAddTime = ds.toString((String)hash.get("ADDTIME"));
String strStatus = ds.toString((String)hash.get("STATUS"));
String strJBXH = ds.toString((String)hash.get("JBXH"));
String strMenuID1 = toName("MENU","MENU1","ID1",strType);
//String strType = toName("MENU","ID1","MENU1",strMenuID1);
String sql ="";
sql = "select * from news.nb_topic where MENUID1 ="+strMenuID1+" and NAME = '"+strName+"'";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
if(rs.next())
return -5;//已经存在此专题
}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);}
}
int intJBXH = setJBXH(strMenuID1,strJBXH);
Vector vect =new Vector();
vect.add("NB_TOPIC");
vect.add(addVector("ID",String.valueOf(intId),"NUM"));
vect.add(addVector("NAME",strName,"CHAR"));
vect.add(addVector("TYPE",strType,"CHAR"));
vect.add(addVector("INTRODUCE",strIntroduce,"CHAR"));
vect.add(addVector("ADDTIME",strAddTime,"CHAR"));
vect.add(addVector("STATUS",strStatus,"NUM"));
vect.add(addVector("JBXH",String.valueOf(intJBXH),"NUM"));
vect.add(addVector("MENUID1",String.valueOf(strMenuID1),"NUM"));
return insertRecord(vect);
}
//新增的时候设置级别序号
public int setJBXH(String strMenuID1,String jbxh)
{
int intJBXH=makeID("NB_TOPIC","MENUID1","JBXH",strMenuID1,false);
if(jbxh.equals("")) jbxh = "0";
int intxh = Integer.parseInt(jbxh);
if(intxh>0&&intxh<intJBXH)
{
int
上一篇:
TopicAdapter.java
下一篇:
传染病防治法修订后“出炉”