📄 zlxzfunc.java~29~
字号:
package com.j2ee.func.zlxz;
import java.util.Vector;
import java.sql.SQLException;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import com.j2ee.func.systemvia.SystemviaInfo;
import com.j2ee.func.systemvia.SystemviaFunc;
import com.j2ee.func.qyzp.ZpBean;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ZlxzFunc {
public static String searchkey="";
public static String typep="";
public String sortid;
public String sorttype;
public int ptype; //哪一种类型;
public int pageno; //分页的页数;
public String type;
public int id;
public int flag; //是否过期的推荐新闻或文章;
public ZlxzInfo wif;
public ZlxzFunc() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public ZlxzFunc(String type) {
this.type=type;
}
public ZlxzFunc(int id) {
this.id=id;
}
public ZlxzFunc(String type, int page,int ptype) {
this.type = type;
this.pageno = page ;
this.ptype=ptype;
}
public ZlxzFunc(int ptype, int pageno, String sortid, String sorttype) { //选出所有新闻
this.ptype = ptype;
this.pageno = pageno;
this.sortid = sortid;
this.sorttype = sorttype;
}
public ZlxzFunc(ZlxzInfo wif) {
this.wif = wif;
}
public int getAllXzcount() throws SQLException {
String sql = "select count(*) from zlxz";
ZpBean zb = new ZpBean();
int count = zb.getpositionCount(sql);
return count;
}
public int getPagesize() throws SQLException {
SystemviaFunc svf = new SystemviaFunc();
Vector vct = svf.getPagesize();
SystemviaInfo svi = (SystemviaInfo) vct.firstElement();
int pagestart = 0, pagesize = 0;
if (this.ptype == 1) {
pagestart = (this.pageno - 1) * svi.getPagesizeone(); //一级页面
pagesize = svi.getPagesizeone();
} else if (this.ptype == 2) {
pagestart = (this.pageno - 1) * svi.getPagesizetwo(); //2级页面
pagesize = svi.getPagesizetwo();
} else if (this.ptype == 3) {
pagestart = (this.pageno - 1) * svi.getPagesizethree(); //3级页面
pagesize = svi.getPagesizethree();
} else if (this.ptype == 4) {
pagestart = (this.pageno - 1) * svi.getPagesizeback(); //后台页面大小;
pagesize = svi.getPagesizeback();
}
return pagesize;
}
public String selectZlxzInfosql() throws SQLException {
SystemviaFunc svf = new SystemviaFunc();
Vector vct = null;
vct = svf.getPagesize();
SystemviaInfo svi = (SystemviaInfo) vct.firstElement();
int pagestart = 0, pagesize = 100;
if (this.ptype == 1) {
pagestart = (this.pageno - 1) * svi.getPagesizeone(); //一级页面
pagesize = svi.getPagesizeone();
} else if (this.ptype == 2) {
pagestart = (this.pageno - 1) * svi.getPagesizetwo(); //2级页面
pagesize = svi.getPagesizetwo();
} else if (this.ptype == 3) {
pagestart = (this.pageno - 1) * svi.getPagesizethree(); //3级页面
pagesize = svi.getPagesizethree();
} else if (this.ptype == 4) {
pagestart = (this.pageno - 1) * svi.getPagesizeback(); //后台页面大小;
pagesize = svi.getPagesizeback();
}
String sql = "select * from zlxz where type like '%" + this.type +
"%' order by sentdate desc limit " + pagestart + ","+pagesize;
return sql;
}
public int SelectCount() throws SQLException {
String sql = "select count(*) from zlxz where type like '%" + this.type + "%'";
ZlxzBean nb = new ZlxzBean();
int count = nb.selectCount(sql);
return count;
}
public Vector SelectZlxzInfo() throws SQLException {//取出type类型的数据
ZlxzBean zb=new ZlxzBean();
Vector vct=zb.selectZlxzInfo(selectZlxzInfosql());
return vct;
}
public String selectdetailZlxzinfosql(){
String sql="select * from zlxz where id="+this.id+"";
return sql;
}
public Vector SelectdetailZlxzinfo() throws SQLException {//显示详细信息
ZlxzBean zb=new ZlxzBean();
Vector vct= zb.selectZlxzInfo(selectdetailZlxzinfosql());
return vct;
}
public boolean increaseCount(){
String sql="update zlxz set seecount=seecount+1 where id='"+this.id+"'";
ZlxzBean zb=new ZlxzBean();
boolean bl=zb.updateSeecount(sql);
return bl;
}
public String selecttalltitle(){
String sql="select * from zlxz order by sentdate desc limit 10";
return sql;
}
public Vector selectTalltitle() throws SQLException {
ZlxzBean zb=new ZlxzBean();
Vector vct=zb.selectZlxzInfo(selecttalltitle());
return vct;
}
//************ 添加xinwen类
public String addXzSql() {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date = sdf.format(now.getTime());
String sql = "insert into zlxz values(null,'" + wif.getTitle() + "','" +
wif.getType() +
"','" + wif.getLarge() + "','" + wif.getLink() + "','" +
wif.getShortbrief() + "','" +wif.getLoadman() + "','" +
date + "',0,0)";
return sql;
}
public boolean addXz() {
ZlxzBean nb = new ZlxzBean();
boolean bl = nb.insertXz(addXzSql());
return bl;
}
//*************************************************
public Vector getAllXz() throws SQLException {
SystemviaFunc svf = new SystemviaFunc();
Vector vct = svf.getPagesize();
SystemviaInfo svi = (SystemviaInfo) vct.firstElement();
int pagestart = 0, pagesize = 100;
if (this.ptype == 1) {
pagestart = (this.pageno - 1) * svi.getPagesizeone(); //一级页面
pagesize = svi.getPagesizeone();
} else if (this.ptype == 2) {
pagestart = (this.pageno - 1) * svi.getPagesizetwo(); //2级页面
pagesize = svi.getPagesizetwo();
} else if (this.ptype == 3) {
pagestart = (this.pageno - 1) * svi.getPagesizethree(); //3级页面
pagesize = svi.getPagesizethree();
} else if (this.ptype == 4) {
pagestart = (this.pageno - 1) * svi.getPagesizeback(); //后台页面大小;
pagesize = svi.getPagesizeback();
}
ZlxzBean nb = new ZlxzBean();
String sql = " select * from zlxz where (title like '%"+this.searchkey+"%'"+
" or loadman like '%"+this.searchkey+"%' or type like '%"+this.searchkey+"%'"+
" or sentdate like '%"+this.searchkey+"%' or shortbrief like '%"+this.searchkey+"%' )"+
" and type like '%"+this.typep+"%' order by " +
this.sortid + " " +
this.sorttype + " limit " + pagestart + "," + pagesize;
Vector vctall = nb.selectZlxzInfo(sql);
return vctall;
}
public boolean upDateZl() {
String sql = " update zlxz set title='" + wif.getTitle() +
"', shortbrief='" + wif.getShortbrief() +
"', loadman='" + wif.getLoadman() + "',type='" + wif.getType() +
"' where id=" + wif.getId();
ZlxzBean nb = new ZlxzBean();
boolean bl = nb.updateSeecount(sql);
return bl;
}
public boolean deleteZl() {
String sql = "delete from zlxz where id=" + this.id;
ZlxzBean nb = new ZlxzBean();
boolean bl = nb.deleteZl(sql);
return bl;
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -