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

📄 cateadmin.jsp

📁 Oracle 10g数据库Java开发 源码
💻 JSP
字号:
<%@ page contentType="text/html;charset=gb2312" %>    
<%@include file="InfoComm.jsp"%>
<%
// 判断此用户类型是否为系统管理员,如果不是则不能查看此页面信息
// 这里使用InfoComm.jsp文件中的方法getType()
if(getType((String)session.getValue("user_id"))==2)
{
%>

<%!
//此文件完成对信息类别的设置
	String sTitle, showname;
	String scateid;
	int cateid,Ucateid;
%>
<html>
<head>
<link rel="stylesheet" href="../style.css">
<title>基本设置</title>
</head>
<script language="javascript">

function DeleteName(){
	if (confirm("真的要删除此名称吗?")){
		return true;
	}
	else{
		return false;
	}
}
</script>
<body>
<%
	Vector v_cate = new Vector();
	// 取得类别编号
	scateid = request.getParameter("cid");
	// 将类别编号字符串转换为整型
	if (scateid==null)
		scateid="0";
	else
		cateid = Integer.parseInt(scateid);
	sTitle = request.getParameter("title");		// 新名称
	String sflag = request.getParameter("flag");	// 操作标志

	//定义类别对象
	Categories o_cate = new Categories();
	// 操作标志分为:空值、新建、修改、删除
	if(sflag==null)
		sflag = "new";
	if(sflag.equals("add")&&sTitle!=null){
		try{
			o_cate.setCateTitle(sTitle);
			//判断是否已经存在此名称
			if(o_cate.getCategory())
				out.println("添加失败!已经存在此名称!");
			else{
				//如果不存在此名称,则创建新的名称
				o_cate.CreateCategory();
				out.println("添加成功!");
			}
		}catch (Exception e) {
			System.err.println("Exception class: " + e);
			e.printStackTrace();
			out.println("名称重复或其它原因,修改失败!<p>");
		}
	}
	// 判断是否为修改操作标志,sTitle为新名称
	if(sflag.equals("updateok")&&sTitle!=null){
		try{
			// 设置类别属性,类别编号和名称
			o_cate.setCateTitle(sTitle);
			// 新名称是否存在
			if(o_cate.getCategory())
				out.println("修改失败!已经存在此名称!");
			else{
				// 修改名称
				o_cate.setCateId(cateid);
	//			System.out.println(cateid+","+sTitle);
				o_cate.UpdateCategory();
				out.println("修改成功!");
			}
		}catch (Exception e) {
			System.err.println("Exception class: " + e);
			e.printStackTrace();
			out.println("名称重复或其它原因,修改失败!<p>");
		}
	}
	if(sflag.equals("delete")&&sTitle!=null)
	{
		try{
			//删除名称
			o_cate.setCateId(cateid);
			o_cate.DeleteCategory();
			out.println("删除成功!");
		}
		catch (Exception e) {
			System.err.println("Exception class: " + e);
			e.printStackTrace();
			out.println("名称重复或其它原因,修改失败!<p>");
		}
	}
%>
<%
try{
	// 取得类别的所有数据
	Categories o_Category = new Categories();
	//使用Vector接收到类别名称
	v_cate = o_Category.getMoreCategories();
%>
<p><center><h3>信息分类设置</h3></center></p>
<table border="1" align="center" cellpadding="0" cellspacing="0" width="90%" bordercolorlight="#000080" bordercolordark="#FFFFFF" bordercolor="#000080" style="margin-top: 3; margin-bottom: 3">
<tr>
<td width="60%" bgcolor="#CCFFCC">名称</td>
<td width="20%" align="center" bgcolor="#CCFFCC">修改</td>
<td width="20%" align="center" bgcolor="#CCFFCC">删除</td>
</tr>
<%
	// 执行循环语句,取出Vector中的所有记录
	for(int i=0;i<v_cate.size();i++)
	{
		// 定义Vector中每条记录为一个对象,再取它的属性值
		o_Category = (Categories)v_cate.elementAt(i);
		Ucateid = o_Category.getCateId();
		showname = o_Category.getCateTitle(); // 信息名称
%>
<tr>
<td><%=showname%></td>
<td align="center"><a href="cateAdmin.jsp?flag=update&title=<%=showname%>&cid=<%=Ucateid%>">修改</a></td>
<td align="center"><a href="cateAdmin.jsp?flag=delete&cid=<%=Ucateid%>&title=<%=showname%>" onclick="return DeleteName()">删除</a></td>
</tr>
<%
	}
}catch(Exception e)
 {throw new Exception(e.getMessage());}
%>
</table>
<%// 如果为修改和添加操作,则分别显示下面的内容
if(sflag.equals("update")){%>
	<form name="UFrom" method="post" action="cateAdmin.jsp?cid=<%=cateid%>&flag=updateok">
	  <div align="center">
		<font color="#FFFFFF"><b><font color="#000000">名称</font></b></font> 
		<input type="text" name="title" size="20" value="<%=sTitle%>">
		<input type="submit" name="Submit" value=" 修 改 ">
		</div>
	</form>
<%}else{%>
	<form name="AForm" method="post" action="cateAdmin.jsp?cid=<%=cateid%>&flag=add">
	  <div align="center">
		<font color="#FFFFFF"><b><font color="#000000">名称</font></b></font> 
		<input type="text" name="title" size="20">
		<input type="submit" name="Submit" value=" 添 加 ">
	  </div>
	</form>
<%}%>
</form>
</body>
</html>
<%}
else
	out.println("你没有管理员的权限");		
%>

⌨️ 快捷键说明

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