da_category.jsp
来自「JSP课件以及一个网上书店系统程序,带数据库」· JSP 代码 · 共 159 行
JSP
159 行
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理分类</title>
</head>
<%@ include file="../inc/conn.jsp"%>
<%@ include file="../inc/format.jsp"%>
<link href="../style1.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function check()
{
if(document.form1.BigClassName.value=="")
{
alert("添加类别的名称不能为空");
document.form1.BigClassName.focus();
return false;
}
return true;
}
</script>
<body>
<form name="form1" method="post" action="" onSubmit="return check()">
<%
//添加操作
if(request.getParameter("Submit")!=null)
{
String catename=Bytes(request.getParameter("BigClassName"));
String highid=request.getParameter("BigClassID");
sql="insert into category(categoryName,highLevelID) values('"+catename+"',"+highid+")";
stmt.executeUpdate(sql);
out.print("<script>alert('添加图书类别成功!');window.location='da_category.jsp';</script>");
}
//修改操作
if(request.getParameter("aid")!=null)
{
String catename=Bytes(request.getParameter("name"));
sql="update category set categoryName='"+catename+"' where categoryID="+request.getParameter("aid");
stmt.executeUpdate(sql);
String aid=request.getParameter("aid");
//out.print(request.getParameter("abook"));
//out.print(request.getParameter(aid));
//out.print(catename);
out.print("<script>alert('图书类别修改成功!');window.location='da_category.jsp';</script>");
}
//删除操作
if(request.getParameter("delid")!=null)
{
sql="delete from category where categoryID="+request.getParameter("delid");
//out.print(sql);
stmt.executeUpdate(sql);
out.print("<script>alert('图书类别删除成功!');</script>");
}
%>
<table width="588" border="0" align="center" cellpadding="0" cellspacing="0" ID="Table23">
<tr>
<td background="../pic/Comments.jpg" height="64">
<table height="20" cellspacing="0" cellpadding="0" width="100%" border="0" ID="Table24">
<tr>
<td width="9%" height="38"></td>
<td height="38"><span class="CategoryTitleCn">类别管理</span> <span class="CategoryTitleEn">Management Categoryr</span> </td>
</tr>
</table></td>
</tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #B7B7B7;">
<tr>
<td width="80%" height="1" bgcolor="#ff0000"></td>
</tr>
<tr>
<td height="25" colspan="2" align="center" bgcolor="#E7E7E2"><span class="bt">添加类别</span></td>
</tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" bordercolorlight="#666666" bordercolordark="#ffffff" bgcolor="#C9C9C9">
<tr bgcolor="#FFFFFF">
<td width="100%" colspan="3" align="center"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="115" height="20" align="center" >所属类别:</td>
<td width="139" height="20" align="center" >
<select name="BigClassID" size="1" id="BigClassID">
<option value="0">一级分类</option>
<%sql="select * from category where highLevelID=0";
rs=dbBean.exeSQL(sql);
while(rs.next()){
%><option value="<%=rs.getString("categoryID")%>"><%=rs.getString("categoryName")%></option><%}%>
</select>
</td>
<td width="104" height="20" align="center">栏目名称:</td>
<td width="148" align="center"><input name="BigClassName" type="text" id="BigClassName" size="15"></td>
<td height="20" colspan="4" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="确 认" >
</td>
</tr>
</table></td>
</tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #B7B7B7;">
<tr>
<td width="80%" height="1" bgcolor="#FF00FF"></td>
</tr>
<tr>
<td height="25" colspan="2" align="center" bgcolor="#E7E7E2"><span class="bt">图书类别管理</span></td>
</tr>
<tr>
<td colspan="2" align="center">
<%
sql = "select * from category where highLevelID=0";
rs=dbBean.exeSQL(sql);
while(rs.next()){
String hid=rs.getString("categoryID");
%>
<br>
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#C9C9C9">
<tr bgcolor="#FFFFFF">
<td width="63%" height="23" class="bt">
<%if(request.getParameter("selid")!=null && (request.getParameter("selid").equals(hid))){%>
<input name="name" type="text" id="name" value="<%=rs.getString("categoryName")%>" size="15">
<a href="da_category.jsp?aid=<%=hid%>">更 新</a> <a href='da_category.jsp'>取 消</a>
<%}else{%>
<strong><a href="../Book_Leis.jsp?Cateid=<%=hid%>"><font color="#0099cc"><%=rs.getString("categoryName")%></font></a></strong>
<%}%>
</td>
<td width="19%" bgcolor="#FFFFFF">
<a href="da_category.jsp?selid=<%=hid%>">修 改</a></td>
<td width="18%">
<a href="da_category.jsp?delid=<%=hid%>">删 除</a> </td>
</tr><%
ResultSet rs1;
String sql1= "select * from category where highLevelID="+hid;
rs1=dbBean.exeSQL(sql1);
while(rs1.next()){
String hid1=rs1.getString("categoryID");
%>
<tr bgcolor="#FFFFFF">
<td height="23">
<%if(request.getParameter("selid")!=null && (request.getParameter("selid").equals(hid1))){%>
<input name="name" type="text" id="name" value="<%=rs1.getString("categoryName")%>" size="15">
<a href="da_category.jsp?aid=<%=hid1%>">更 新</a> <a href='da_category.jsp'>取 消</a>
<%}else{%>
<a href="../Book_Leis.jsp?Cateid=<%=hid1%>">
<font color="#000000"><%=rs1.getString("categoryName")%></font></a>
<%}%>
</td>
<td bgcolor="#FFFFFF"><a href="da_category.jsp?selid=<%=hid1%>">修 改</a></td>
<td><a href="da_category.jsp?delid=<%=hid1%>">删除</a></td>
<%}%>
</tr>
</table><%}%>
</td>
</tr>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?