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

📄 booktype.asp

📁 ASP+SQL Server的图书馆管理系统
💻 ASP
字号:
<!--#include file="ConnDB.asp"-->
<!--#include file="isAdmin.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图书类别管理</title>
<link rel="stylesheet" href="style.css">
</head>
<!--#include file="head.asp"-->
<script language="JavaScript">
function newtype(url) {
  var wth=window.screen.width; 
  var hth=window.screen.heigth;
  var lefth,topth;
  if(wth==1024)
	{
	  hth=200;
	  lefth =212;
	  wth=600;
	  topth=135;
	}
  else if(wth==800)
	{
	  hth=200;
	  lefth =100;
	  wth=600;
	  topth=50;
	}
  if(wth==6400)
	  hth=200
  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 newtype=window.open(url,"newtype",oth);
  newtype.focus();
  return false;
}
function SelectChk()
{
	var s=false;
	var typeid,n=0;
	var strid,strurl;
	var nn = self.document.all.item("type");
	for (j=0;j<nn.length;j++)
	{
		if (self.document.all.item("type",j).checked)
		{
			n = n + 1;
			s=true;
			typeid = self.document.all.item("type",j).id+"";
			if(n==1)
			{
				strid = typeid;
			}
			else
			{
				strid = strid + "," + typeid;
			}
		}
	}
	strurl = "BookType.asp?Oper=delete&type_id=" + strid;
	if(!s)	{
		alert("请选择要删除的图书类别!");
		return false;
	}
	
	if ( confirm("你确定要删除这些图书类别吗?")) {
		form1.action = strurl;
		form1.submit();
	}
}
function sltAll()
{
	var nn = self.document.all.item("type");
	for(j=0;j<nn.length;j++)
	{
		self.document.all.item("type",j).checked = true;
	}
}
function sltNull()
{
	var nn = self.document.all.item("type");
	for(j=0;j<nn.length;j++)
	{
		self.document.all.item("type",j).checked = false;
	}
}
</script>
<body >
<p align="center"><b><font style="font-size: 12pt">图 书 类 别 管 理</font></b>
<td>
<table width=570 height="49" border="0" align="center" cellpadding="0" cellspacing="0">
<form id="form1" name="form1" method="POST">
<%
  '处理添加、修改和删除操作
  Dim Soperate
  '读取参数oper,决定当前要进行的操作
  Soperate = Request.QueryString("oper")
  Operid = Request.QueryString("Type_Id")
  '删除记录
  If Soperate="delete" Then
   sqldelt = "Delete From Book_Type Where Type_Id In("&Cstr(Operid)&")"
    Conn.Execute(sqldelt)
    Response.Write "图书类别已经成功删除!"
  '添加记录
  ElseIf Soperate="add" Then
    newTitle = Request("txttitle")
    '判断数据库中是否存在此类别
    sql = "SELECT * FROM Book_Type WHERE Type_Name='" & newTitle & "'"
    Set rsInsert = Conn.execute(sql)
    '如果没有此类别名称,则创建新记录
    If Not rsInsert.EOF Then
      Response.Write "已经存在此图书类别,添加失败!"
    Else
      sql = "Insert into Book_Type(type_Name) values('"&newTitle&"')"
      Conn.Execute(sql)
      Response.Write"图书类别已经成功添加!"
    End if
  '修改记录 
  ElseIf Soperate = "edit" Then
    newTitle = Request("txttitle")
    orgTitle = Request("sOrgTitle")
    '如果新类别名称和旧的不同则执行
    If newTitle<>orgTitle Then
      '判断数据库中是否存在此类别
      sql = "Select * from Book_Type where Type_Name='"&newTitle&"'"
      Set rsInsert = Conn.Execute(sql)
      If Not rsInsert.EOF Then
        Response.Write "已经存在此图书类别,添加失败!"
      Else
	    Conn.Execute("Update Book_Type Set Type_Name='"&newTitle&"' Where Type_Id="&Cint(Operid))
        Response.Write"图书类别已经成功修改!"
      End If
    End If
  End If
%>

  <td width="570" height="25"></p> <BR>
<center>
<table border="1" cellspacing="0" width="100%"  bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" style='FONT-SIZE: 9pt'>
  <tr>
    <td width="35%" height="27" align="center" bgcolor="#FEEC85"><strong>类 别</strong></td>
    <td width="34%" align="center" bgcolor="#FEEC85"><strong>修 改</strong></td>
    <td width="31%" align="center" bgcolor="#FEEC85"><strong>选 择</strong></td>
  </tr>
<%
  Dim rs

  Set rs = Server.CreateObject("ADODB.RecordSet")
  '读取所有的图书类别数据到记录集rs中
  sql = "SELECT * FROM Book_Type ORDER BY Type_Id"
  rs.Open sql,conn,1,1
  If rs.EOF Then
    Response.Write "<tr><td colspan=3 align=center><font style='COLOR:Red'>目前还没有记录。</font></td></tr></table>"
  Else
    Do While Not rs.EOF
%>
      <tr><td height="25"><%=rs("Type_Name")%></td>
      <td align="center"><a href="BookType.asp?Oper=update&type_id=<%=rs("Type_id")%>&name=<%=rs("Type_Name")%>">修改</a></td>
      <td align="center"><input type="checkbox" name="type" id="<%=rs("Type_id")%>"></td></tr>
<%
      rs.MoveNext()
    Loop
%>
</table>
		<p align=center>
<%  End If
	If rs.RecordCount > 0 Then
		%>

		 <input type="button" value="全 选" onClick="sltAll()">
		 &nbsp;&nbsp;<input type="button" value="清 空" onClick="sltNull()">
		 &nbsp;&nbsp;<input type="submit" value="删 除" name="tijiao" onClick="SelectChk()">
		<%
	End If
%>

</form>

<% 

If Soperate ="update" Then
	sTitle = Request.QueryString("name")
%>
	<form name="UFrom" method="post" action="BookType.asp?type_id=<%=Operid%>&Oper=edit">
	  <div align="center">
		<input type="hidden" name="sOrgTitle" value="<%=sTitle%>">
		<font color="#FFFFFF"><b><font color="#000000">类别名称</font></b></font> 
		<input type="text" name="txttitle" size="20" value="<%=sTitle%>">
        <input type="submit" name="Submit" value=" 修 改 ">
</div>
	</form>
<%Else%>
	<form name="AForm" method="post" action="BookType.asp?Oper=add">
	  <div align="center">
		<font color="#FFFFFF"><b><font color="#000000">类别名称</font></b></font> 
		<input type="text" name="txttitle" size="20">
		<input type="submit" name="Submit" value=" 添 加 ">
	  </div>
	</form>
<%End If%>
<input type="hidden" name="type">

 <tr>
      <td><div align="center">Copyright 2007 </div></td>
    </tr>

</table>
</td>
</tr>
</tbody>

</BODY>
</HTML>

⌨️ 快捷键说明

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