📄 opershowinfo.java
字号:
package com.doone.fj1w.fjmgr.useroperinfo;
import com.doone.data.DacClient;
import com.doone.data.DataTable;
import com.doone.util.FileLogger;
public class Opershowinfo {
private String sshowinfoid = null;
private String scitycode = null;
private String sinfocode = null;
private String sinfocontent = null;
private DacClient _dbClient = null;
private int pageSize = 20;//每页记录数
private int rowCount = 0;//查询数据库中的记录数
private int pageCount = 0;//页数
public Opershowinfo() {
try {
_dbClient = new DacClient();
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
}
}
public void setshowinfoid(String sshowinfoid) {
this.sshowinfoid = sshowinfoid;
}
public void setcitycode(String scitycode) {
this.scitycode = scitycode;
}
public void setsinfocode(String sinfocode) {
this.sinfocode = sinfocode;
}
public void setsinfocontent(String sinfocontent) {
this.sinfocontent = sinfocontent;
}
public int insertshowinfo() {
int doExp = 0;
try {
// XXX 进行sao中字段的有效性检查。
String Sql_Ins_Showinfo = "INSERT INTO td_showinfo(SHOWINFOID, CITYCODE, INFOCODE, INFOCONTENT) VALUES(SEQ_SHOWINFOID.nextval,?,?,?)";
Object[] value = new Object[3];
value[0] = scitycode; //地市编码
value[1] = sinfocode; //信息名称
value[2] = sinfocontent;//信息内容
_dbClient.beginTransaction(10000);
doExp = _dbClient.executeUpdate(Sql_Ins_Showinfo, 1000, value);
_dbClient.endTransaction(true);
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
try {
_dbClient.endTransaction(false);
} catch (Exception ex1) {
}
}
return doExp;
}
public int deleteshowinfo(String tablename, String id) {
int doExp = 0;
try {
// XXX 进行sao中字段的有效性检查。
String Sql_Del_Showinfo = "delete from " + tablename + " where " + id + "=?";
Object[] value = new Object[1];
value[0] = sshowinfoid; //序号
_dbClient.beginTransaction(10000);
doExp = _dbClient.executeUpdate(Sql_Del_Showinfo, 1000, value);
_dbClient.endTransaction(true);
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
try {
_dbClient.endTransaction(false);
} catch (Exception ex1) {
}
}
return doExp;
}
public int updateshowinfo() {
int doExp = 0;
try {
// XXX 进行sao中字段的有效性检查。
String Sql_Upd_Showinfo = "update td_showinfo set CITYCODE=?, INFOCODE=?, INFOCONTENT=? where SHOWINFOID=?";
Object[] value = new Object[4];
value[0] = scitycode; //
value[1] = sinfocode; //地市编码
value[2] = sinfocontent; //信息名称 信息内容
value[3] = sshowinfoid; //序号
_dbClient.beginTransaction(10000);
doExp = _dbClient.executeUpdate(Sql_Upd_Showinfo, 1000, value);
_dbClient.endTransaction(true);
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
try {
_dbClient.endTransaction(false);
} catch (Exception ex1) {
}
}
return doExp;
}
public DataTable queryshowinfo(String tablename, String field1, String field1value) {
DataTable dt = null;
try {
String S_SELECT_TICKET = "select a.*,b.CITYNAME from " + tablename
+ " a,td_city b where 1=? and a." + field1
+ "=? and a.CITYCODE=b.CITYCODE";
Object[] obbb = new Object[2];
obbb[0] = "1";
obbb[1] = field1value;
_dbClient.beginTransaction(10000);
dt = _dbClient.executeQuery(S_SELECT_TICKET, obbb);
_dbClient.endTransaction(true);
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
try {
_dbClient.endTransaction(false);
} catch (Exception ex1) {
}
}
return dt;
}
public DataTable queryshowinfoapp(String tablename, String field1, String field1value,
String field2, String field2value, String pagecount) {
DataTable dt = null;
try {
StringBuffer sql = new StringBuffer();
sql.append("select * from (");
sql.append(" select rownum num,");
sql.append(" a.SHOWINFOID, ");
sql.append(" a.CITYCODE, ");
sql.append(" a.INFOCODE, ");
sql.append(" a.INFOCONTENT, ");
sql.append(" b.CITYNAME ");
sql.append(" from ");
sql.append(tablename);
sql.append(" a, td_city b where ");
sql.append(field1);
sql.append(" = ? ");
sql.append(" and a.");
sql.append(field2);
sql.append(" = ? ");
sql.append(" and a.CITYCODE=b.CITYCODE) t");
sql.append(" where t.num > ?");
sql.append(" and t.num <= ?");
Object[] ap = new Object[4];
ap[0] = field1value;
ap[1] = field2value;
ap[2] = new Integer(pageSize * (Integer.parseInt(pagecount) -1 ) );
ap[3] = new Integer(pageSize * (Integer.parseInt(pagecount)) );
dt = _dbClient.executeQuery(sql.toString(), ap);
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
}
return dt;
}
public String qryexistshowinfo(String tablename, String field1, String field2) {
String doExp = "0";
try {
String S_SELECT_TICKET = "select count(*) from " + tablename + " where 1=? and "
+ field1 + "=" + scitycode + " and " + field2 + "="
+ sinfocode;
Object[] obbb = new Object[1];
obbb[0] = "1";
_dbClient.beginTransaction(10000);
doExp = _dbClient.getStringFromSqlQuery(S_SELECT_TICKET, obbb);
_dbClient.endTransaction(true);
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
try {
_dbClient.endTransaction(false);
} catch (Exception ex1) {
}
}
return doExp;
}
//获得页数 参数:表名
public int getPageCount(String tablename, String field1, String field1value) {
DataTable dt = null;
try {
String str = "select count(*) count from " + tablename + " where " + field1 + "="
+ field1value;
dt = _dbClient.executeQuery(str);
rowCount = dt.getRow(0).getInt("count");
if (rowCount % pageSize == 0)
pageCount = rowCount / pageSize;
else
pageCount = rowCount / pageSize + 1;
} catch (Exception ex) {
FileLogger.getLogger().error(ex);
}
return pageCount;
}
public String buildPageOptions(int pageCount, int pageNo) {
String optionHTML = "";
for (int i = 1; i <= pageCount; i++) {
if (pageNo == i || pageNo == 0)
optionHTML += "<option value='" + i + "' selected/>" + i;
else
optionHTML += "<option value='" + i + "'/>" + i;
}
return optionHTML;
}
public static void main(String args[]) {
Opershowinfo o = new Opershowinfo();
//System.out.println("dt============>"+o.queryshowinfoapp("td_showinfo","1","1","citycode","0591","30")) ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -