📄 tphmtypeimpl.java
字号:
package com.sxit.phonemanager;
import java.util.*;
import java.sql.*;
/**
* <p>类名: TphmtypeImpl</p>
* <p>功能: 类型</p>
* <p>公司: 深讯信科</p>
* <p>版本: 1.0</p>
* @程序 sxit
* @日期 2005-03-22
* @修改纪录
*/
public class TphmtypeImpl
{
public TphmtypeImpl()
{
super();
}
protected long typeid;//型号
protected long brandid;//品牌
protected long modeid;//规格
protected String typename;//型号名
protected int statusid;//状态
protected String brandname;//品牌
protected String modename;//规格
public void setTypeid(long typeid)
{
this.typeid = typeid;
}
public long getTypeid()
{
return typeid;
}
public void setBrandid(long brandid)
{
this.brandid = brandid;
}
public long getBrandid()
{
return brandid;
}
public void setModeid(long modeid)
{
this.modeid = modeid;
}
public long getModeid()
{
return modeid;
}
public void setTypename(String typename)
{
this.typename = typename;
}
public String getTypename()
{
return typename;
}
public void setStatusid(int statusid)
{
this.statusid = statusid;
}
public int getStatusid()
{
return statusid;
}
public void setBrandname(String brandname)
{
this.brandname = brandname;
}
public String getBrandname()
{
return brandname;
}
public void setModename(String modename)
{
this.modename = modename;
}
public String getModename()
{
return modename;
}
/**
* 创建数据,需要初始化类
*/
public void create(Connection con,long typeid) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
try{
sql="select typeid,brandid,modeid,typename,statusid from tphmtype where typeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1,typeid);
rs=stmt.executeQuery();
if(rs.next()){
this.typeid = rs.getLong("typeid");
this.brandid = rs.getLong("brandid");
this.modeid = rs.getLong("modeid");
typename = rs.getString("typename");
statusid = rs.getInt("statusid");
}
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
}
/**
* 插入数据,无需要初始化类
*/
public static int insert(Connection con,long typeid,long brandid,long modeid,String typename,int statusid) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="insert into tphmtype "+
"(typeid,brandid,modeid,typename,statusid) "+
"values (?,?,?,?,?)";
stmt=con.prepareStatement(sql);
stmt.setLong(1, typeid);
stmt.setLong(2, brandid);
stmt.setLong(3, modeid);
stmt.setString(4, typename);
stmt.setInt(5, statusid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 插入数据,需要初始化类,并将设置类的域
*/
public int insert(Connection con) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="insert into tphmtype "+
"(typeid,brandid,modeid,typename,statusid) "+
"values (?,?,?,?,?)";
stmt=con.prepareStatement(sql);
stmt.setLong(1, typeid);
stmt.setLong(2, brandid);
stmt.setLong(3, modeid);
stmt.setString(4, typename);
stmt.setInt(5, statusid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 更新数据,无需要初始化类
*/
public static int update(Connection con,long typeid,long brandid,long modeid,String typename,int statusid) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="update tphmtype set brandid=?,modeid=?,typename=?,statusid=? where typeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1, brandid);
stmt.setLong(2, modeid);
stmt.setString(3, typename);
stmt.setInt(4, statusid);
stmt.setLong(5, typeid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 更新数据,需要初始化类,并将设置类的域
*/
public int update(Connection con) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="update tphmtype set brandid=?,modeid=?,typename=?,statusid=? where typeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1, brandid);
stmt.setLong(2, modeid);
stmt.setString(3, typename);
stmt.setInt(4, statusid);
stmt.setLong(5, typeid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 删除一条数据
*/
public static int delete(Connection con,long typeid) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try{
sql="delete from tphmtype where typeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1,typeid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
return cnt;
}
/**
* 删除多条数据
*/
public static int delete(Connection con, String typeid[]) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
int i=0;
try{
sql="delete from tphmtype where typeid in (";
for (i=0;i<typeid.length;i++ ) {
if(i==0) sql=sql+typeid[i];
else sql=sql+","+typeid[i];
}
sql=sql+")";
stmt = con.prepareStatement(sql);
cnt=stmt.executeUpdate();
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
return cnt;
}
/**
* 外键下拉表单数据
*/
public static String getTypeid(Connection con) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
String str="";
int i=0;
try {
sql="select typeid,typename from tphmtype where statusid=2 order by typeid";
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
str="<option value=\"0\">请选择</option>";
while(rs.next())
{
str=str+
"<option value=\""+
rs.getLong("typeid")+
"\">"+
rs.getString("typename")+
"</option>";
}
stmt.close();
}
finally {
if(stmt!=null) stmt.close();
}
return str;
}
/**
* 外键下拉表单数据(选定)
*/
public static String getTypeid(Connection con,long typeid) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
String str="";
int i=0;
try {
sql="select typeid,typename from tphmtype where statusid=2 order by typeid";
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
str="<option value=\"0\">请选择</option>";
while(rs.next())
{
if(rs.getLong("typeid")==typeid){
str=str+
"<option selected value=\""+
rs.getLong("typeid")+
"\">"+
rs.getString("typename")+
"</option>";
}else{
str=str+
"<option value=\""+
rs.getLong("typeid")+
"\">"+
rs.getString("typename")+
"</option>";
}
}
stmt.close();
}
finally {
if(stmt!=null) stmt.close();
}
return str;
}
/**
* 获取外键名
*/
public static String getTypename(Connection con,long typeid) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
String str="";
int i=0;
try {
sql="select typeid,typename from tphmtype where statusid=2 and typeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1,typeid);
rs=stmt.executeQuery();
str="";
if(rs.next())
{
str=rs.getString("typename");
}
stmt.close();
}
finally {
if(stmt!=null) stmt.close();
}
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -