package com.bean;
/**
* 新闻管理
*
*/
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import com.util.Constant;
import com.util.DBO;
public class NewsBean {
private String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
private List list;
private ResultSet rs = null;
//不置顶新闻分页
private int EVERYPAGENUM = 2;
private int count = -1;
private int qq = 0;
private String sql="select count(*) from news where up='0' ";
private String sql2="select * from news where up='0' order by id desc ";
private String sql3="select count(*) from news where up='1' ";
private String sql4="select * from news where up='1' order by id desc ";
public void setEVERYPAGENUM(int EVERYPAGENUM){
this.EVERYPAGENUM=EVERYPAGENUM;
}
public int getMessageCount() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery(sql);
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public int getPageCount() { //得到共多少页(根据每页要显示几条信息)
if (count % EVERYPAGENUM == 0) {
return count / EVERYPAGENUM;
} else {
return count / EVERYPAGENUM + 1;
}
}
public List getMessage(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery(sql2);
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
qq++;
List list2=new ArrayList();
list2.add(rs.getInt(1));
list2.add(rs.getString(2));
list2.add(rs.getString(3));
list2.add(rs.getString(5));
list2.add(rs.getString(6));
list2.add(rs.getInt(7));
list2.add(rs.getInt(8));
list2.add(rs.getInt(9));
list.add(list2);
} else {
break; //减少空循环的时间
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return list;
} finally {
dbo.close();
}
}
/////////////////////////////////////////
//置顶新闻分页
public int getMessageCountUp() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery(sql3);
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public List getMessageUp(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery(sql4);
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
qq++;
List list2=new ArrayList();
list2.add(rs.getInt(1));
list2.add(rs.getString(2));
list2.add(rs.getString(3));
list2.add(rs.getString(5));
list2.add(rs.getString(6));
list2.add(rs.getInt(7));
list2.add(rs.getInt(8));
list2.add(rs.getInt(9));
list.add(list2);
} else {
break; //减少空循环的时间
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return list;
} finally {
dbo.close();
}
}
//add news
public int addNews(String title,String pic,String content,String adder,String ifhide){
String sql = "insert into news (title,pic,content,addtime,adder,ifhide,visit,up) " +
"values ('"+title+"','"+pic+"','"+content+"','"+date+"','"+adder+"','"+ifhide+"','0','0')";
String sql2 = "update news set ifhide='0' where pic!='无'";
DBO dbo = new DBO();
dbo.open();
try{
if(!pic.equals("无")){
dbo.executeUpdate(sql2);
}
int i = dbo.executeUpdate(sql);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//update news no pic
public int updateNews(int id,String title,String content,String adder,String ifhide){
String sql = "update news set title = '"+title+"',content='"+content+"',addtime='"+date+"'," +
"adder='"+adder+"',ifhide='"+ifhide+"' where id = '"+id+"' ";
DBO dbo = new DBO();
dbo.open();
try{
int i = dbo.executeUpdate(sql);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
// update news with pic
public int updateNewsWithPic(int id,String title,String pic,String content,String adder,String ifhide){
String sql = "update news set title = '"+title+"',pic='"+pic+"',content='"+content+"',addtime='"+date+"'," +
"adder='"+adder+"',ifhide='"+ifhide+"' where id = '"+id+"' ";
DBO dbo = new DBO();
dbo.open();
try{
int i = dbo.executeUpdate(sql);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//delete news
public int delNews(int id[],String dir){
DBO dbo = new DBO();
dbo.open();
try{
for(int i = 0;i<id.length;i++){
rs = dbo.executeQuery("select pic from news where id='"+id[i]+"'");
rs.next();
String str=rs.getString(1);
del(dir+str);
dbo.executeUpdate("delete from news where id = '"+id[i]+"'");
}
return Constant.SUCCESS;
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
public void del(String filepath) {
try{
File f = new File(filepath);//定义文件路径
if(f.exists()){//判断是文件还是目录
f.delete();//递归调用
}
}catch(Exception e){
}
}
//屏蔽、显示新闻
public int hideNews(int id){
String sql = "update news set ifhide='1' where id='"+id+"'";
String sql2 = "update news set ifhide='0' where id='"+id+"'";
String sql3 = "select ifhide,pic from news where id='"+id+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql3);
rs.next();
int i = rs.getInt(1);
String pic=rs.getString(2);
if(!pic.trim().equals("无")){
dbo.executeUpdate("update news set ifhide='0' where pic!='无'");
}
if(i == 1){
int flag = dbo.executeUpdate(sql2);
if(flag == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
else{
int flag = dbo.executeUpdate(sql);
if(flag == 1)
return Constant.SUCCESS;
else
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//置顶 取消置顶 新闻
public int upNews(int id){
String sql = "upd
没有合适的资源?快使用搜索试试~ 我知道了~
JSP+SQL失物招领系统(毕业设计)
共628个文件
gif:194个
js:181个
jsp:59个
3星 · 超过75%的资源 需积分: 45 136 下载量 5 浏览量
2016-03-17
15:59:27
上传
评论 10
收藏 3.49MB ZIP 举报
温馨提示
失主可以通过网络进入到本系统,查询自己丢失的物品是否已被好心人拾到并交给了招领中心和对好心人的感谢等;拾到物品的人可以通过该系统直接发布拾到物品的信息;管理员可通过本系统对失物信息、报失信息、留言信息等方便的进行管理
资源推荐
资源详情
资源评论
收起资源包目录
JSP+SQL失物招领系统(毕业设计) (628个子文件)
class_upload.asp 6KB
class_upload.asp 6KB
commands.asp 5KB
upload.asp 3KB
connector.asp 3KB
io.asp 2KB
basexml.asp 2KB
config.asp 2KB
config.asp 2KB
util.asp 1KB
io.asp 836B
connector.aspx 1KB
upload.aspx 1KB
connector.cfm 11KB
spellchecker.cfm 6KB
upload.cfm 6KB
config.cfm 3KB
config.cfm 3KB
connector.cgi 4KB
SmartUpload.class 16KB
MemberBean.class 13KB
AfficheBean.class 12KB
NewsBean.class 12KB
TraveBean.class 12KB
MemberManageBean.class 12KB
GuestBookBean.class 9KB
NewsServlet.class 8KB
SystemBean.class 8KB
AdminBean.class 7KB
AdminServlet.class 7KB
MemberServlet.class 6KB
SmartFile.class 6KB
GuestBookServlet.class 5KB
ProServlet.class 5KB
MemberManageServlet.class 4KB
AfficheServlet.class 4KB
CommonServlet.class 4KB
LoginServlet.class 4KB
DBO.class 3KB
Common.class 2KB
SmartRequest.class 2KB
SmartFiles.class 2KB
Log.class 1KB
MD5.class 1KB
Filter.class 936B
CheckCode.class 887B
Constant.class 674B
SmartUploadException.class 364B
.classpath 709B
css.css 10KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
Admin_Style.css 6KB
Admin_Style.css 6KB
style.css 4KB
style.css 4KB
fck_internal.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
fck_editorarea.css 2KB
browser.css 2KB
fck_dialog_common.css 2KB
fck_showtableborders_gecko.css 1KB
spellerStyle.css 888B
default.css 463B
Thumbs.db 67KB
Thumbs.db 17KB
Thumbs.db 16KB
Thumbs.db 10KB
Thumbs.db 8KB
MainBg.gif 25KB
MainBg.gif 25KB
fck_strip.gif 9KB
girl.gif 7KB
boy.gif 6KB
fck_strip.gif 4KB
fck_strip.gif 4KB
5.gif 4KB
4.gif 3KB
8.gif 3KB
11.gif 2KB
Key.gif 2KB
logo_fckeditor.gif 2KB
6.gif 2KB
10.gif 2KB
7.gif 2KB
zhuce.gif 2KB
Title.gif 2KB
1.gif 2KB
qq_22.gif 2KB
qq_22.gif 2KB
Title.gif 2KB
html.gif 1KB
htm.gif 1KB
rdp.gif 1KB
12.gif 1KB
back.gif 1KB
sub.gif 1KB
共 628 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
- weixin_416630762018-04-01代码不全,需要加QQ
- linyufengxiao2021-02-09感觉还可以
- c188431935842017-12-25好好好好好好好好
pcsj83
- 粉丝: 8
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功