package New;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Hashtable;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;
import Bean.SQL_Bean;
public class NewBean {
private String Title="",Content="",Image="",Pms="";
private int NewsID=0, CategoryID=0,DeptID=0,UserID=0, Hits=0,Auditing=0,Pmstype=0,ID=0,CheckImage=0,FixUp=0,Type=0;
private Hashtable table = null;
private ArrayList list = null;
private Connection con=null;
private Statement stmt=null;
private PreparedStatement stmt1=null;
private ResultSet rs = null;
private PageContext pageContext;
//该类别下新闻的集合
public int getPage(int categoryID,int id,int type) {
int allCol=0;
String sql = "SELECT COUNT(*) FROM News where CategoryID="+categoryID;
if(type==1)
{
DeptID = id;
sql+=" and DeptID="+DeptID;
}else if(type==2)
{
UserID = id;
sql+=" and UserID = "+UserID;
}else if(type==3)
{
sql+=" and Auditing =2 ";
}
try{
SQL_Bean sqlbean = new SQL_Bean();
con = sqlbean.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
if(rs.next())
{
allCol=rs.getInt(1);
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
}
return allCol;
}
//新闻的集合
public ArrayList getselectnews(int ipage,int cpage,int categoryID,int id,int type) {
// type 为区分登陆人身份不同查询不同的新闻
// type=1时部门主管登陆查询整个属于该部门用户录入的新闻
// type=2时普通职工登陆查询自己录入的新闻
// type=3时查询审核全部通过的新闻
// 系统管理员可以查询所有用户录入的新闻
// 传入的id 可以是部门的标识 可以是用户的标识
list = new ArrayList();
String sql = "select Top "+ipage+" * from News where CategoryID="+categoryID;
if(type==1)
{
DeptID = id;
sql+=" and DeptID="+DeptID;
}else if(type==2)
{
UserID = id;
sql+=" and UserID = "+UserID;
}else if(type==3)
{
sql+=" and Auditing =2 ";
}
sql+= " and NewsID not in (select top "+(cpage-1)*ipage+" NewsID from News where CategoryID="+categoryID;
if(type==1)
{
DeptID = id;
sql+=" and DeptID="+DeptID;
}else if(type==2)
{
UserID = id;
sql+=" and UserID = "+UserID;
}else if(type==3)
{
sql+=" and Auditing =2 ";
}
sql+=" order by NewsID desc)order by NewsID desc";
try{
SQL_Bean sqlbean = new SQL_Bean();
con = sqlbean.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
table = new Hashtable();
NewsID = rs.getInt("NewsID");
Title = rs.getString("Title");
java.util.Date PublishTime=rs.getDate("PublishTime");
Auditing = rs.getInt("Auditing");
DeptID = rs.getInt("DeptID");
table.put("newsid",NewsID+"");
table.put("title",Title);
table.put("publishtime",PublishTime+"");
table.put("auditing",Auditing+"");
table.put("deptid",DeptID+"");
list.add(table);
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
}
return list;
}
//站内搜索新闻的集合
public ArrayList getselectnewsSearch(String title) {
list = new ArrayList();
String sql = "select * from News where Title like '%"+ title +"%'";
sql+=" order by NewsID desc";
try{
SQL_Bean sqlbean = new SQL_Bean();
con = sqlbean.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
table = new Hashtable();
NewsID = rs.getInt("NewsID");
Title = rs.getString("Title");
CategoryID = rs.getInt("CategoryID");
java.util.Date PublishTime=rs.getDate("PublishTime");
Auditing = rs.getInt("Auditing");
DeptID = rs.getInt("DeptID");
table.put("newsid",NewsID+"");
table.put("title",Title);
table.put("categoryid",CategoryID+"");
table.put("publishtime",PublishTime+"");
table.put("auditing",Auditing+"");
table.put("deptid",DeptID+"");
list.add(table);
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
}
return list;
}
//新闻的添加
public int inserttable(HttpServletRequest request,String dir) throws Exception{
HttpSession session = request.getSession();
// SmartUpload mySmartUpload = new SmartUpload();
//
// //初始化
// mySmartUpload.initialize(pageContext);
// mySmartUpload.setMaxFileSize(500 * 1024 * 1024 * 1024);
// mySmartUpload.upload();
// System.out.println(mySmartUpload.getFiles().getCount() + "个文件上传成功!<br>");
// //=mySmartUpload.getRequest().getParameter("xxzt");
//
//
// String SaveName="",strImageName="",newFileNameUrl="";
// Title = mySmartUpload.getRequest().getParameter("Title");
System.out.println("titile==="+session.getAttribute("Image"));
if(session.getAttribute("Image")==null)
{
Image="";
}else
{
Image = session.getAttribute("Image").toString();
}
Title = request.getParameter("Title");
String userid=request.getParameter("userid");
UserID=Integer.parseInt(userid);
String categoryid=request.getParameter("categoryid");
CategoryID=Integer.parseInt(categoryid);
// String oldFileNameUrl = request.getParameter("Image");
// if(oldFileNameUrl!=null&&!"".equals(oldFileNameUrl))
// {
// strImageName = oldFileNameUrl.substring(oldFileNameUrl.lastIndexOf("\\")+1);
// newFileNameUrl = dir+"\\"+strImageName;
// copyFile(oldFileNameUrl,newFileNameUrl);
// }
// Image = strImageName;
Content = request.getParameter("Content");
if(Content.equals(""))
{
Content=" ";
}
String pmstype=request.getParameter("pmstype");
Pmstype=Integer.parseInt(pmstype);
String type=request.getParameter("Type");
Type=Integer.parseInt(type);
if(Pmstype==1)
{
String[] result = request.getParameterValues("pms1");
for (int i = 0; result!=null && i<result.length;i++){
String resultStr = result[i];
ID=Integer.parseInt(resultStr);
Pms=Pms+ID+",";
}
if(!Pms.equals(""))
{
Pms=Pms.substring(0,Pms.length()-1);
}
}else
{
String[] result = request.getParameterValues("pms0");
for (int i = 0; result!=null && i<result.length;i++){
String resultStr = result[i];
ID=Integer.parseInt(resultStr);
Pms=Pms+ID+",";
}
if(!Pms.equals(""))
{
Pms=Pms.substring(0,Pms.length()-1);
}
}
String deptid = request.getParameter("deptid");
DeptID = Integer.parseInt(deptid);
String checkimage = request.getParameter("CheckImage");
CheckImage = Integer.parseInt(checkimage);
int returnvalues = 0;
String sql = "insert into News (Title,CategoryID,Image,Content,PublishTime,UserID,Type,DeptID,Pmstype,Pms,CheckImage) values( '"+Title +"',"+CategoryID+",'"+Image+"',?,'"+new SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date())+"',"+UserID+","+Type+","+DeptID+ ","+Pmstype+",'"+Pms+"',"+CheckImage+")";
try{
SQL_Bean sqlbean=new SQL_Bean();
con=sqlbean.getConnection();
stmt1=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
stmt1.setString(1,Content);
returnvalues=stmt1.executeUpdate();
sqlbean.CloseStatement(stmt1);
sqlbea
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
公司真实项目源码(java) (938个子文件)
spellchecker.cfm 5KB
NewBean.class 16KB
NewServlet.class 11KB
EditorTag.class 11KB
UserBean.class 10KB
ConnectorServlet.class 10KB
UserServlet.class 8KB
SimpleUploaderServlet.class 7KB
Editor.class 5KB
PermissionBean.class 5KB
NetWorkServlet.class 5KB
NetWorkBean.class 5KB
NetCategoriesBean.class 5KB
NewCategoriesBean.class 5KB
LoginServlet.class 4KB
RoleBean.class 4KB
DeptBean.class 4KB
RelatBean.class 4KB
LoginBean.class 3KB
SQL_Bean.class 2KB
MD5.class 2KB
EditorConfigurations.class 2KB
.classpath 842B
css.css 5KB
fck_contextmenu.css 4KB
fck_contextmenu.css 4KB
fck_contextmenu.css 4KB
fck_editor.css 3KB
fck_editor.css 3KB
fck_editor.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
cnitc.css 2KB
fck_internal.css 2KB
browser.css 2KB
fck_dialog_common.css 2KB
fck_editorarea.css 1KB
fck_showtableborders_gecko.css 1KB
fck_universalkey.css 1KB
spellerStyle.css 888B
Thumbs.db 388KB
Thumbs.db 105KB
index2_bj.gif 34KB
欢乐冬日送.gif 31KB
1w.gif 31KB
index_201.gif 14KB
index_54.gif 14KB
20071118215849.gif 14KB
20071118220311.gif 14KB
index_54(1).gif 14KB
index_201.gif 13KB
index_10.gif 10KB
index_54.gif 9KB
index_06.gif 8KB
index_14.gif 8KB
index_67.gif 8KB
index_51.gif 7KB
index_69.gif 7KB
index_72.gif 6KB
index_69.gif 6KB
index_112.gif 6KB
index_51.gif 6KB
gsdt.gif 6KB
index_72.gif 6KB
title_znss.gif 5KB
title_zxtz.gif 5KB
title_bdfz.gif 5KB
title_ztjj.gif 5KB
zhfw.gif 5KB
title_spzs.gif 5KB
index_67.gif 5KB
title_ldjh.gif 4KB
ldjh.gif 4KB
qywh.gif 4KB
xxyy.gif 4KB
title_zxdt.gif 4KB
gsgk.gif 4KB
title_tzgg.gif 4KB
title_jcxw.gif 4KB
gzjh.gif 4KB
bzh.gif 4KB
aqsc.gif 4KB
index_190.gif 4KB
index_186.gif 4KB
index_131.gif 4KB
index_191.gif 3KB
index_171.gif 3KB
index_192.gif 3KB
index_90.gif 3KB
index_13.gif 3KB
index_173.gif 3KB
index_150.gif 3KB
keyboard_layout.gif 3KB
ydxy.gif 3KB
index_34.gif 3KB
index_188.gif 3KB
xghy.gif 3KB
txzcxx.gif 3KB
index_169.gif 3KB
共 938 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
ywxowen999
- 粉丝: 4
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页