⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jswzfunc.java~44~

📁 c++通信编程学习1
💻 JAVA~44~
字号:
package com.j2ee.func.jswz;
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 JswzFunc {
    public String sortid;
    public String sorttype;
    public int ptype; //哪一种类型;
    public int pageno; //分页的页数;
    public String type;
    public int id;
    public WzInfo wif;
    public JswzFunc(){
    }

    public JswzFunc(int ptype, int pageno, String sortid, String sorttype) { //选出所有新闻
        this.ptype = ptype;
        this.pageno = pageno;
        this.sortid = sortid;
        this.sorttype = sorttype;
    }
    public JswzFunc(String type) {
      this.type=type;
    }
    public JswzFunc(int id){
      this.id=id;
    }
    public JswzFunc(String type, int page,int ptype) {
      this.type = type;
      this.pageno = page ;
      this.ptype=ptype;
    }
    public JswzFunc(WzInfo wif) {
        this.wif = wif;
    }

    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 selectWzInfosql() 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 jswzinfo where type like '%" + this.type +
                     "%' order by sentdate desc limit " + pagestart + ","+pagesize;
    return sql;
}
    public int SelectCount() throws SQLException {
    String sql = "select count(*) from jswzinfo where type like '%" + this.type + "%'";
    WzBean nb = new WzBean();
    int count = nb.selectCount(sql);
    return count;
    }
    public Vector SelectWzInfo() throws SQLException {//取出type类型的数据
    WzBean wb=new WzBean();
    Vector vct=wb.selectWzInfo(selectWzInfosql());
    return vct;
}
    public String selectdetailWzinfosql(){
    String sql="select * from jswzinfo where  id='"+this.id+"'";
    return sql;
}
    public Vector SelectdetailWzinfo() throws SQLException {//显示详细信息
    WzBean wb=new WzBean();
    Vector vct= wb.selectWzInfo(selectdetailWzinfosql());
    return vct;
}

    public boolean increaseCount(){
    String sql="update jswzinfo set seecount=seecount+1 where id='"+this.id+"'";
     WzBean wb=new WzBean();
    boolean bl=wb.updateSeecount(sql);
    return bl;
}
    public String selecttalltitle(){
        String sql="select * from jswzinfo order by sentdate desc limit 10";
        return sql;
    }

    public Vector selectTalltitle() throws SQLException {
        WzBean wb=new WzBean();
       Vector vct=wb.selectWzInfo(selecttalltitle());
       return vct;
}
  //*****************推荐文章
    public String selecttjwz() {
     String sql = "select * from jswzinfo,tjwz  where jswzinfo.type='" + this.type +
                  "' and jswzinfo.id=tjwz.wzid order by jswzinfo.sentdate desc limit 3";
     return sql;
    }

    public Vector SelectTjwz() throws SQLException {
     WzBean wb=new WzBean();
     Vector vct = null;
     vct = wb.selectTjwz(selecttjwz());
     return vct;
 }
 //************ 热点
      public String selectTopWz() {
          String sql = "select * from jswzinfo order by seecount desc limit 10";
          return sql;
      }

     public Vector SelectTopWz() throws SQLException { //显示详细信息
         WzBean nb = new WzBean();
         Vector vct = nb.selectWzInfo(selectTopWz());
         return vct;
     }
 //*************最新
  public String selectttoptitle() {
      String sql = "select * from jswzinfo order by newsdate desc limit 5";
      return sql;
  }

  public Vector selectToptitle() throws SQLException {
      WzBean nb = new WzBean();
      Vector vct = nb.selectWzInfo(selectttoptitle());
      return vct;
    }
 //************ 添加xinwen类
      public String addWzSql() {
          Calendar now = Calendar.getInstance();
          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
          String date = sdf.format(now.getTime());
          String sql = "insert into jswzinfo values(null,'" + wif.getTitle() + "','" +
                       wif.getContent() +
                       "','" + wif.getAuthor() + "','" + wif.getType() + "','" +
                       wif.getComefrom() + "','" +
                       date + "',0)";
          return sql;
      }

     public boolean addWz() {
         WzBean nb = new WzBean();
         boolean bl = nb.insertWz(addWzSql());
         return bl;
    }
//************
     public Vector getAllWz() 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();
         }
         WzBean nb = new WzBean();
         String sql = " select * from jswzinfo order by " + this.sortid + " " +
                      this.sorttype + " limit " + pagestart + "," + pagesize;
         Vector vctall = nb.selectWzInfo(sql);
         return vctall;
    }
      //*****************
     //***************选出所有的进行管理

      public int getAllWzcount() throws SQLException {
          String sql = "select count(*) from jswzinfo";
          ZpBean zb = new ZpBean();
          int count = zb.getpositionCount(sql);
          return count;
      }

//**************
    public boolean upDateWz() {
        String sql = " update jswzinfo set title='" + wif.getTitle() +
                     "', content='" + wif.getContent() +
                     "', author='" + wif.getAuthor() + "',type='" + wif.getType() +
                     "', comefrom='" + wif.getComefrom() + "' where id=" +
                     wif.getId();
        WzBean nb = new WzBean();
        boolean bl = nb.updateSeecount(sql);
        return bl;
    }
 //*****************




//*************shanchu
    public boolean deleteWz(){
        String sql="delete from jswzinfo where id="+this.id;
        WzBean nb=new WzBean();
        boolean bl=nb.deleteWz(sql);
        return bl;
    }
/*public String selectTjnews(){
    String sql="select * from news,tjnews where news.id=tjnews.newsid order by news.newsdate desc";
    return sql;
}
public Vector SelectTjnews() throws SQLException {
    NewsBean nb=new NewsBean();
    Vector vct = null;
    vct = nb.selectTjnews(selectTjnews());
    return vct;
}*/


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -