📄 delcard.java
字号:
package control;
import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import model.*;
import java.util.*;
public class DelCard extends ShowCategory
{
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
int CardID = Integer.parseInt(req.getParameter("CardID"));
String UserName = req.getParameter("UserName");
int pagenum = Integer.parseInt(req.getParameter("pagenum"));
String Sort_Condition = (String)req.getParameter("sortcondition"); //2008.11.19修改 取得排序方式
int pagecount = 0;
int total = 0;
CardCom com = new CardCom("jdbc:mysql://localhost/mybbs","root", "root123");
boolean result;
Vector vc ;
if(((Boolean)req.getSession().getAttribute("AdminOrNot")).booleanValue())//如果是管理员
{
result = com.delCard(CardID);
vc = com.getAllCard(pagenum,Sort_Condition);
CategoryCom com2 = new CategoryCom("jdbc:mysql://localhost/mybbs","root", "root123");
total = com2.getCCount("all");
if((total!=0) && (vc.size()==0)&&(pagenum>1))
{
pagenum = pagenum -1;
vc = com.getAllCard(pagenum,Sort_Condition);
}
if(total % 8==0)
pagecount = total/8;
else
pagecount = ((int)total/8)+1;
req.setAttribute("NewsCount",new Integer(total));
req.setAttribute("allcard", vc);
req.setAttribute("cname","all");
req.setAttribute("cpath","all");
req.setAttribute("pagenum",String.valueOf(pagenum)); //当前页数
req.setAttribute("pagecount", String.valueOf(pagecount));//总共需要多少页面数
req.setAttribute("command", "guanli");
req.setAttribute("sortcondition", Sort_Condition); //2008.11.19修改 取得排序方式
if(result==true)
req.setAttribute("Message","删除文章成功,页面已被刷新");
else
req.setAttribute("Message","删除文章失败,页面已被刷新");
tiaoZhuan(req,res,"/ShowAllCardList.jsp");
}
else if(((String)req.getSession().getAttribute("USER")).equals(UserName))
{
result = com.delCard(CardID);
UserCom com3 = new UserCom("jdbc:mysql://localhost/mybbs","root", "root123");
total = com3.getTieziShuliang(UserName);
if(total % 8==0)
pagecount = total/8;
else
pagecount = ((int)total/8)+1;
vc = com.getCardByUserName(UserName,pagenum,Sort_Condition);
if(total!=0 && vc.size()==0 && pagenum >1)
{
pagenum = pagenum -1;
vc = com.getCardByUserName(UserName,pagenum,Sort_Condition);
}
req.setAttribute("allcard", vc);
req.setAttribute("NewsCount",new Integer(total));
//req.setAttribute("cpath","all");
req.setAttribute("pagenum",String.valueOf(pagenum)); //当前页数
req.setAttribute("pagecount", String.valueOf(pagecount));//总共需要多少页面数
req.setAttribute("command", "guanli");
req.setAttribute("sortcondition", Sort_Condition); //2008.11.19修改 取得排序方式
if(result==true)
req.setAttribute("Message","删除文章成功,页面已被刷新");
else
req.setAttribute("Message","删除文章失败,页面已被刷新");
tiaoZhuan(req,res,"/ShowMyCardList.jsp");
}
else
;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -