📄 tphmmodeimpl.java
字号:
package com.sxit.phonemanager;
import java.util.*;
import java.sql.*;
/**
* <p>类名: TphmmodeImpl</p>
* <p>功能: 规格</p>
* <p>公司: 深讯信科</p>
* <p>版本: 1.0</p>
* @程序 sxit
* @日期 2005-03-22
* @修改纪录
*/
public class TphmmodeImpl
{
public TphmmodeImpl()
{
super();
}
protected long modeid;//规格
protected String modename;//规格名
protected int screenlength;//长度
protected int screenwidth;//宽度
protected String ringmode;//铃声
protected String colormode;//颜色
public void setModeid(long modeid)
{
this.modeid = modeid;
}
public long getModeid()
{
return modeid;
}
public void setModename(String modename)
{
this.modename = modename;
}
public String getModename()
{
return modename;
}
public void setScreenlength(int screenlength)
{
this.screenlength = screenlength;
}
public int getScreenlength()
{
return screenlength;
}
public void setScreenwidth(int screenwidth)
{
this.screenwidth = screenwidth;
}
public int getScreenwidth()
{
return screenwidth;
}
public void setRingmode(String ringmode)
{
this.ringmode = ringmode;
}
public String getRingmode()
{
return ringmode;
}
public void setColormode(String colormode)
{
this.colormode = colormode;
}
public String getColormode()
{
return colormode;
}
/**
* 创建数据,需要初始化类
*/
public void create(Connection con,long modeid) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
try{
sql="select modeid,modename,screenlength,screenwidth,ringmode,colormode from tphmmode where modeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1,modeid);
rs=stmt.executeQuery();
if(rs.next()){
this.modeid = rs.getLong("modeid");
modename = rs.getString("modename");
screenlength = rs.getInt("screenlength");
screenwidth = rs.getInt("screenwidth");
ringmode = rs.getString("ringmode");
colormode = rs.getString("colormode");
}
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
}
/**
* 插入数据,无需要初始化类
*/
public static int insert(Connection con,long modeid,String modename,int screenlength,int screenwidth,String ringmode,String colormode) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="insert into tphmmode "+
"(modeid,modename,screenlength,screenwidth,ringmode,colormode) "+
"values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sql);
stmt.setLong(1, modeid);
stmt.setString(2, modename);
stmt.setInt(3, screenlength);
stmt.setInt(4, screenwidth);
stmt.setString(5, ringmode);
stmt.setString(6, colormode);
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 tphmmode "+
"(modeid,modename,screenlength,screenwidth,ringmode,colormode) "+
"values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sql);
stmt.setLong(1, modeid);
stmt.setString(2, modename);
stmt.setInt(3, screenlength);
stmt.setInt(4, screenwidth);
stmt.setString(5, ringmode);
stmt.setString(6, colormode);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 更新数据,无需要初始化类
*/
public static int update(Connection con,long modeid,String modename,int screenlength,int screenwidth,String ringmode,String colormode) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try
{
sql="update tphmmode set modename=?,screenlength=?,screenwidth=?,ringmode=?,colormode=? where modeid=?";
stmt=con.prepareStatement(sql);
stmt.setString(1, modename);
stmt.setInt(2, screenlength);
stmt.setInt(3, screenwidth);
stmt.setString(4, ringmode);
stmt.setString(5, colormode);
stmt.setLong(6, modeid);
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 tphmmode set modename=?,screenlength=?,screenwidth=?,ringmode=?,colormode=? where modeid=?";
stmt=con.prepareStatement(sql);
stmt.setString(1, modename);
stmt.setInt(2, screenlength);
stmt.setInt(3, screenwidth);
stmt.setString(4, ringmode);
stmt.setString(5, colormode);
stmt.setLong(6, modeid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally
{
if(stmt!=null) stmt=null;
}
return cnt;
}
/**
* 删除一条数据
*/
public static int delete(Connection con,long modeid) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
try{
sql="delete from tphmmode where modeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1,modeid);
cnt=stmt.executeUpdate();
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
return cnt;
}
/**
* 删除多条数据
*/
public static int delete(Connection con, String modeid[]) throws SQLException
{
PreparedStatement stmt=null;
String sql="";
int cnt=0;
int i=0;
try{
sql="delete from tphmmode where modeid in (";
for (i=0;i<modeid.length;i++ ) {
if(i==0) sql=sql+modeid[i];
else sql=sql+","+modeid[i];
}
sql=sql+")";
stmt = con.prepareStatement(sql);
cnt=stmt.executeUpdate();
stmt.close();
}
finally{
if(stmt!=null) stmt.close();
}
return cnt;
}
/**
* 外键下拉表单数据
*/
public static String getModeid(Connection con) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
String str="";
int i=0;
try {
sql="select modeid,modename from tphmmode order by modeid";
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
str="<option value=\"0\">请选择</option>";
while(rs.next())
{
str=str+
"<option value=\""+
rs.getLong("modeid")+
"\">"+
rs.getString("modename")+
"</option>";
}
stmt.close();
}
finally {
if(stmt!=null) stmt.close();
}
return str;
}
/**
* 外键下拉表单数据(选定)
*/
public static String getModeid(Connection con,long modeid) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
String str="";
int i=0;
try {
sql="select modeid,modename from tphmmode order by modeid";
stmt=con.prepareStatement(sql);
rs=stmt.executeQuery();
str="<option value=\"0\">请选择</option>";
while(rs.next())
{
if(rs.getLong("modeid")==modeid){
str=str+
"<option selected value=\""+
rs.getLong("modeid")+
"\">"+
rs.getString("modename")+
"</option>";
}else{
str=str+
"<option value=\""+
rs.getLong("modeid")+
"\">"+
rs.getString("modename")+
"</option>";
}
}
stmt.close();
}
finally {
if(stmt!=null) stmt.close();
}
return str;
}
/**
* 获取外键名
*/
public static String getModename(Connection con,long modeid) throws SQLException
{
PreparedStatement stmt=null;
ResultSet rs=null;
String sql="";
String str="";
int i=0;
try {
sql="select modeid,modename from tphmmode where modeid=?";
stmt=con.prepareStatement(sql);
stmt.setLong(1,modeid);
rs=stmt.executeQuery();
str="";
if(rs.next())
{
str=rs.getString("modename");
}
stmt.close();
}
finally {
if(stmt!=null) stmt.close();
}
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -