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

📄 infoadmin.jsp

📁 Oracle 10g数据库Java开发 源码
💻 JSP
字号:
<%@ page contentType="text/html;charset=gb2312" %>    
<%@include file="InfoComm.jsp"%>
<%
	// 取得当前用户名
	String userId = (String)session.getValue("user_id");
	String pwd = (String)session.getValue("passwd");
// 只有系统用户才可以有权限
if(IsUser(userId,pwd))
{

%>
<%!
	String strTitle,sPostTime,strCate,strCateId,strCateShow,sPoster;
	Vector v_Info,v_Cate;	
	int iTotal,j,cateid,iHits,iCate,iattpic,InfoId;

	int currentpage=1,iNext=0,iFinish=0,iMaxPage=0,iPageStop;
	String strPage;
%>

<html>
<head>
<title>信息管理</title>
<link rel="stylesheet" href="../style.css">
<script language="javascript">

function news90(url) {
  var wth=window.screen.width; 
  var hth=window.screen.heigth;
  var lefth,topth;
  if(wth==1024)
	{
	  hth=500;
	  lefth =147;
	  wth=730;
	  topth=44;
	}
  else if(wth==800)
	{
	  hth=500;
	  lefth =35;
	  wth=730;
	  topth=10;
	}
  else
	{
	  hth=500;
	  wth=730;
	}
  var oth="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left="+lefth+",top="+topth;
  oth = oth+",width="+wth+",height="+hth ;
  var news90=window.open(url,"news90",oth);
  news90.focus();
  return false;
}

function SelectChk(scateid)
{
	var s=false;  //是否有选中记录的标记
	var check1id,n=0;
	var strid,strurl;
	//返回当前页面的check1复选框数量
	var nn = self.document.all.item("check1")
	//依次对每个复选框进行判断
	for (j=0;j<nn.length;j++)
	{
		//判断当前复选框是否被选中
		if (self.document.all.item("check1",j).checked)
		{
			n = n + 1;  // 计数
			s=true;  // 设置标记
			//复选框的id就是信息编号
			check1id = self.document.all.item("check1",j).id+"";
			//设置复选框编号列表
			if(n==1)
				strid = check1id;
			else
				strid = strid + "," + check1id;
		}
	}
	if(scateid==null)
		scateid="-1";
	// 设置删除数据要执行的url
	strurl = "info_delt.jsp?strid=" + strid;
	// 如果没有选择记录,则提示选择
	if(!s)	{
		alert("请选择要删除的信息!");
		return false;
	}
	//确定是否删除
	if ( confirm("你确定要删除这些信息吗?")) {
		form1.action = strurl;
		form1.submit();
	}
}
function sltAll()
{
	var nn = self.document.all.item("check1");
	for(j=0;j<nn.length;j++)
	{
		self.document.all.item("check1",j).checked = true;
	}
}
function sltNull()
{
	var nn = self.document.all.item("check1");
	for(j=0;j<nn.length;j++)
	{
		self.document.all.item("check1",j).checked = false;
	}
}

</script>
</head>

<body link="#000080" vlink="#080080">
<form id="form1" name="form1" method="POST">
<table align=center border='0' width='100%'>
<tr><td align='center'>
<%
	try
	{
		Information o_Info = new Information();
		// 判断用户类型,如果为系统管理员则可以修改所有信息,否则只能修改自己写的信息
		if(getType(userId)==1)
			o_Info.setPoster(userId);  //设置o_Info中Poster属性值为userId,在o_Info.getMoreInformation中将作为查询条件
		//从参数中读取当前的信息分类
		strCateId = request.getParameter("cateid");
		if(strCateId==null)	{
			//如果没指定分类,则显示全部信息
			out.println( "<td><b><font style='FONT-SIZE: 12pt'>信息管理</font></b></td>");
		}
		else {
			//否则,读取分类信息
			iCate = Integer.parseInt(strCateId);  //转换为整型
			Categories o_Cate1 = new Categories();  //定义信息类别对象
			//读取当前信息类别记录
			o_Cate1.setCateId(iCate); 
			if(o_Cate1.getCategory())
				strCateShow = o_Cate1.getCateTitle();
			out.println("<td align=center><b><font style='FONT-SIZE: 12pt'>"+strCateShow+"</font></b></td>");
			//设置o_Info对象的信息类别为iCate,在o_Info.getMoreInformation中将作为查询条件
			o_Info.setCateId(iCate);
		}
		//读取全部或指定分类中的所有信息到数组v_Info
		v_Info = o_Info.getMoreInformation();
		//数组v_Info中的元素数量
		iTotal = v_Info.size();
		//输出“全部信息”超级链接
		out.println("<td align=center><a href='InfoAdmin.jsp'><font style='TEXT-DECORATION: underline'>全部信息</a></font>"+"|");
		//输出所有类别信息
		Categories o_Cate = new Categories();
		v_Cate = o_Cate.getMoreCategories();
		for(int m=0;m<v_Cate.size();m++) {
			o_Cate =(Categories)v_Cate.elementAt(m);
			cateid = o_Cate.getCateId();
			strCate = o_Cate.getCateTitle();
		%>
			<a href="InfoAdmin.jsp?cateid=<%=cateid%>"><font style='TEXT-DECORATION: underline'><%=strCate%></a></font> |
         <%	
		}
%>
</td></tr></table>
<center>
<table border="1" cellspacing="0" width="100%" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF">
  <tr>
   <td width="40%" align="center" bgcolor="#FEEC85"><strong>标 题</strong></td>
   <td width="26%" align="center" bgcolor="#FEEC85"><strong>提交时间</strong></td>
   <td width="16%" align="center" bgcolor="#FEEC85"><strong>提交人</strong></td>
   <td width="6%" align="center"  bgcolor="#FEEC85"><strong>修改</strong></td>
   <td width="6%" align="center"  bgcolor="#FEEC85"><strong>选择</td>
   <td width="6%" align="center"  bgcolor="#FEEC85"><strong>点击</strong></td>
  </tr>
<%		
		//从参数中读取当前的页码
		strPage = request.getParameter("page");
		//如果没有页码参数,则显示第1页
		if(strPage == null )	//|| !strPage.equals("")
			currentpage = 1;
		else
			currentpage = Integer.parseInt(strPage);
		//如果页码无效,则显示第1页
		if(currentpage<1)
			currentpage = 1;
		//计算最大页数
		if ((iTotal%MaxPerPage)==0)
	      iMaxPage = iTotal / MaxPerPage;
	    else
	      iMaxPage = iTotal / MaxPerPage + 1;
		//iPageStor为本页最后一条记录的编号
		if (currentpage==1)
		{
			if(iTotal>MaxPerPage)
				iPageStop = MaxPerPage;
			else
				iPageStop = iTotal;
			iNext = 0;
		}
	    else
		{
		   iNext = (currentpage-1)*MaxPerPage;
		   iFinish = iTotal - iNext ;
		   if(iFinish>MaxPerPage)
			   iPageStop = MaxPerPage;
		   else
			   iPageStop = iFinish;
		}
		//使用for循环依次读取并显示信息,标题长度不超过26个字母;
		for(j=iNext;j<iNext+iPageStop;j++)	
		{
		  o_Info =(Information)v_Info.elementAt(j);
		  InfoId = o_Info.getInfoId();
		  cateid = o_Info.getCateId();
		  strTitle = o_Info.getTitle();
		  if(strTitle.length()>26)
			  strTitle = strTitle.substring(0,25) + "......";
		  iHits = o_Info.getHits();
		  sPostTime = o_Info.getPostTime();
		  iattpic = o_Info.getAttpic();
		  sPoster = o_Info.getPoster();
		  if (!sPoster.equals("--")){
			  User o_User = new User();
			  o_User.setUserId(sPoster);
			  if(o_User.getUser())
				sPoster = o_User.getEmplName();
		  }
		  if (j%2==0)
			strbg = strBG1;
		  else
			strbg = strBG2;
		  //下面的HTML代码将设置(附图)标记、链接和选择复选框
		%>
  <tr>
    <td bgcolor="<%=strbg%>"><a href="../ShowInfo.jsp?id=<%=InfoId%>" onClick="return news90(this.href)"><%=strTitle%></a><%if (iattpic==1){%>(附图)<%}%>
	<%if(isNew(sPostTime)){%><img src="../images/news.gif" border="0"><%}%>
	</td>
	<td align="center" bgcolor="<%=strbg%>"><%=sPostTime%></td>
	<td align="center" bgcolor="<%=strbg%>"><%=sPoster%></td>
    <td align="center" bgcolor="<%=strbg%>"><a href="info_edit.jsp?id=<%=InfoId%>" onclick="return news90(this.href)">修改</a></td>
    <td align="center" bgcolor="<%=strbg%>"><input type="checkbox" name="check1" id="<%=InfoId%>"></td>
    <td align="center" bgcolor="<%=strbg%>"><%=iHits%></td>
  </tr>
	 <%	}//end for%>
</table></center>
   <%
	  //显示页码信息
		if(iMaxPage>1)
	{
		for(int k=1;k<iMaxPage+1;k++)
		{
			if(k==currentpage)
				out.println("[<b>"+k+"</b>]");
			else if(strCateId==null)
				out.println("[<b>"+"<a href='InfoAdmin.jsp?page="+k+"'>"+k+"</a></b>]");
			else
				out.println("[<b>"+"<a href='InfoAdmin.jsp?cateid="+iCate+"&page="+k+"'>"+k+"</a></b>]");
		}
	}
//in the middle page and iTotal%MaxPerPage==0
// System.out.println("----currentpage>1 and condition 1-- iNext="+iNext +", and iFinish="+iFinish);
		if(iTotal==0)
		{
		%>
		<p align=center style='COLOR:Red ;FONT-SIZE: 9pt'> 还 没 有 任 何 信 息</p>
		<%
		}
		%>
		<p align="center">
		<input type="button" value="添加信息"  onclick="news90('info_add.jsp')">
		 &nbsp;&nbsp;<input type="button" value="全 选" onclick="sltAll()">
		 &nbsp;&nbsp;<input type="button" value="清 空"  onclick="sltNull()">
		 &nbsp;&nbsp;<input type="submit" value="删 除" name="tijiao" onclick="SelectChk(<%=strCateId%>)"></p>
		<%
	}
	catch(Exception e)
	{ System.out.println(e.toString());}
%>
<input type=hidden name="check1">
</form>
</BODY>
</HTML>
<%}
else
	out.println("你没有添加的权限");		
%>

⌨️ 快捷键说明

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