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

📄 listmanage.asp

📁 学生档案与成绩管理(1)学生档案管理:记录每个学生的档案信息
💻 ASP
字号:
<!-- #include file = "../include/asphead.asp" -->
<!-- #include file = "../include/function.asp" -->
<%CheckUser()%>
<link href="../include/main.css" rel="stylesheet" type="text/css">
<script src="../include/function.js" type="text/javascript"></script>
<%
	dim WExcel
	set WExcel=server.CreateObject("WExcel.Sheet")

	dim SheetID,BodyStr
	SheetID=Request.Cookies("Temp")("SheetID")
	BodyStr=WExcel.GetViewArray(cint(UserID),cint(SheetID),cstr(Admin))
	Response.Write BodyStr
	CheckErr
%>

<script ID="clientEventHandlersJS" LANGUAGE="javascript">  
<!--
	var ParentSelectedID;
	var Item,ItemListIndex;
	var DeletedIDs="";
	var HasChanged;
	
	ns4=(document.layers)?true:false
	ie4=(document.all)?true:false
	
	function ItemDef(){
		this.ID=0;
		this.Code="";
		this.Name="";
		this.SonCount=0;
		this.AllSonCount=0;
	}

	function InitArray()
	{
		if (ItemCount>0)
		{
			Item=new Array();
			for (var i=0;i<ItemCount;i++)
			{
				Item[i]=new ItemDef();
				Item[i].ID=ItemID[i];
				Item[i].Code=ItemCode[i];
				Item[i].Name=ItemName[i];
				Item[i].SonCount=ItemSonCount[i];
				Item[i].AllSonCount=ItemAllSonCount[i];
			}
		}
	}
	
	function ParentList_onchange() 
	{
		ParentSelectedID=Item[parseInt(ParentList[ParentList.selectedIndex].value)].ID;
		SetList();
	}
	
	function SetSelect()
	{
		var v,t;
		var ParentListLength;

		ParentListLength=0;

		for(var i=0;i<ItemCount;i++)
		{
			if(Item[i].Code.length==3)
			{
				v=i;
				t=Item[i].Name;
				ParentList.options[ParentListLength]=new Option(t,v);
				ParentListLength=ParentListLength+1;
			}
		}
		for(var i=0;i<ParentListLength;i++)
		{
			if(ParentSelectedID==Item[ParentList[i].value].ID)
			{
				ParentList.selectedIndex =i;
				break;
			}
		}
	}

	function SetList()
	{
		var Index,ParentCode,ParentCodeLen;
		var v,t
		var SonListLength;
		
		SonListLength=0
		Index=ParentList.selectedIndex;
		ParentCode=Item[ParentList[Index].value].Code
		ParentCodeLen=ParentCode.length;
		for (var i=0;i<ItemCount;i++)
		{
			if(Item[i].Code.substr(0,ParentCodeLen)==ParentCode && Item[i].Code.length==ParentCodeLen+3)
			{
				if(!ItemDeleted(Item[i].ID))
				{
					v=i;
					t=Item[i].Name;
					SonList.options[SonListLength]=new Option(t,v);
					SonListLength=SonListLength+1;
				}
			}
		}
		SonList.length=SonListLength;
	}

	function MoveUP()
	{
		var TempText,TempValue,Diff
		if(CheckItemList()==true)
		{
			if (ItemListIndex>0)
			{
				ItemListIndex=ItemListIndex-1
				Diff=Item[SonList[ItemListIndex+1].value].AllSonCount-Item[SonList[ItemListIndex].value].AllSonCount
				TempText=SonList[ItemListIndex].text
				SonList[ItemListIndex].text=SonList[ItemListIndex+1].text
				SonList[ItemListIndex+1].text=TempText
				SonList.selectedIndex=ItemListIndex
				TempValue=parseInt(SonList[ItemListIndex+1].value)+Diff
				Exchange(SonList[ItemListIndex].value,SonList[ItemListIndex+1].value)
				SonList[ItemListIndex+1].value=TempValue
				SetSelect();
				HasChanged=true
			}
		}
		else
		{
			alert("要调整哪个视图的顺序?请选择。");
		}
	}

	function MoveDown()
	{
		var TempText,TempValue,Diff
		if(CheckItemList()==true)
		{
			if (ItemListIndex<SonList.length-1)
			{
				Diff=Item[SonList[ItemListIndex+1].value].AllSonCount-Item[SonList[ItemListIndex].value].AllSonCount
				ItemListIndex=ItemListIndex+1
				TempText=SonList[ItemListIndex].text
				SonList[ItemListIndex].text=SonList[ItemListIndex-1].text
				SonList[ItemListIndex-1].text=TempText
				TempValue=parseInt(SonList[ItemListIndex].value)+Diff
				SonList.selectedIndex=ItemListIndex
				Exchange(SonList[ItemListIndex].value,SonList[ItemListIndex-1].value)
				SonList[ItemListIndex].value=TempValue
				SetSelect();
				HasChanged=true
			}
		}
		else
		{
			alert("要调整哪个视图的顺序?请选择。");
		}
	}

	function Delete()
	{
		var TempText,TempValue,Diff
		if(CheckItemList()==true)
		{
			if (ItemListIndex<SonList.length)
			{
				var DeletedID;
				DeletedID=Item[SonList.options[ItemListIndex].value].ID;
				if(DeletedIDs=="")
					DeletedIDs=JTrim(DeletedID);
				else
					DeletedIDs=DeletedIDs + "," + JTrim(DeletedID);

				var ListCount=SonList.length
				for (var i= ItemListIndex+1;i<ListCount;i++)
				{
					var v,t
					v=SonList.options[i].value
					t=SonList.options[i].text
					SonList.options[i-1]=new Option(t,v)
				}
				SonList.length=ListCount-1
				SetSelect();
				HasChanged=true
			}
		}
		else
		{
			alert("要删除哪个视图?请选择。");
		}
	}


	function CheckItemList()
	{
		ItemListIndex=SonList.selectedIndex
		if(ItemListIndex == -1)
			return false;
		else
			return true;
	}

	function ItemDeleted(ItemID)
	{
		var Deleted;
		Deleted=false;
		if (!isEmpty(DeletedIDs))
		{
			var myfind;
			myfind=DeletedIDs.indexOf(ItemID);
			if(myfind>=0)
				Deleted=true;
		}
		return(Deleted);
	}
	
	function Exchange(index1,index2)
	{
		index1=parseInt(index1)
		index2=parseInt(index2)
		//index1、index2的合法性检查
		if (index1==index2||index1<0||index1>=ItemCount||index2<0||index2>=ItemCount)
		{
			return false;
		}
		else
		{
			//确保index1在index2的上面
			if (index1>index2)
			{
				var indextmp
				indextmp=index1;
				index1=index2;
				index2=indextmp;
			}
			
			//备份被移动的数据
			var itemtmp1,SonCounttmp1,itemtmp2,SonCounttmp2
			itemtmp1=new Array();
			itemtmp2=new Array();
			SonCounttmp1=parseInt(Item[index1].AllSonCount);
			SonCounttmp2=parseInt(Item[index2].AllSonCount);
			for (var i=0;i<=SonCounttmp1;i++)
			{
				itemtmp1[i]=new ItemDef();
				itemtmp1[i]=Item[index1+i];
			}
			for (var i=0;i<=SonCounttmp2;i++)
			{
				itemtmp2[i]=new ItemDef();
				itemtmp2[i]=Item[index2+i];
			}

			var start,end,diff

			//处理中间数据
			start=index1+SonCounttmp1+1;
			end=index2-1;
			diff=SonCounttmp2-SonCounttmp1;
			if (end>=start)
			{
				if(diff>=0)
				{
					//index2对应的数量多,中间数据往下推,需要自下往上逐个下移
					for (var i=end;i>=start;i--)
					{
						Item[i+diff]=Item[i];
					}
				}
				else
				{
					//index2对应的数量少,中间数据往上推,需要自上往下逐个上移
					for (var i=start;i<=end;i++)
					{
						Item[i+diff]=Item[i];
					}
				}
			}

			//拿回index2的数据到原index1处
			start=index1;
			end=start+SonCounttmp2;
			for (var i=start;i<=end;i++)
			{
				Item[i]=itemtmp2[i-start];
			}
			
			//拿回index1的数据到新位置
			start=index2+diff;
			end=start+SonCounttmp1;
			for (var i=start;i<=end;i++)
			{
				Item[i]=itemtmp1[i-start];
			}
			return true;
		}
	}

	function Save() 
	{
		if(HasChanged==true)
		{
			var Result
			Result=""
			for(var i=0;i<ItemCount;i++)
			{
				if(!ItemDeleted(Item[i].ID))
					Result=Result+","+Item[i].ID
			}
			Result=Result.substr(1,Result.length-1);
			parent.window.returnValue = true;
			document.frmData.ItemResult.value = Result;
			document.frmData.DeletedIDs.value = DeletedIDs;
			discard=true;
			if(DeletedIDs!="")
			{
				var parts
				parts=DeletedIDs.split(",");
				discard=confirm(parts.length + "个视图将被删除,您确定要删除吗?");
			}
			if(discard==true)
			{
				btnSave.disabled =true;
				btnCancel.disabled =true;
				document.frmData.target ="SaveArea";
				document.frmData.action="savelistmanage.asp";
				document.frmData.submit();
			}
		}
		else
		{
			discard=confirm("您未作任何更改,退出吗?");
			if(discard==true)
			{
				parent.window.returnValue = false;
				parent.window.close();
			}
		}
	}

	function Cancel()
	{
		if(HasChanged==true)
		{
			discard=confirm("您已经修改了某些信息,但尚未保存。放弃您所作的修改吗?");
			if(discard==true)
			{
				parent.window.returnValue = false;
				parent.window.close();
			}
		}
		else
		{
			parent.window.returnValue = false;
			parent.window.close();
		}
	}

	function window_onload() 
	{
		ParentSelectedID=0;
		InitArray();
		SetSelect();
		SetList();
		MOVEUPP.disabled =false;
		MOVEDOWNP.disabled =false;
		btnSave.disabled =false;
		btnCancel.disabled =false;
		return true;
	}

//-->
</script>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	</head>
	<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" LANGUAGE=javascript onload="return window_onload()">
		<table width=100% border=0>
			<tr height="35" valign="center">
				<td align="center" colspan=2>
					<b>
						视图整理
					</b>
				</td>
			</tr>
			<tr>
				<td align="center"> 
					<select id="ParentList" name="ParentList" size="1"  style="width:200px;" LANGUAGE=javascript onchange="return ParentList_onchange()">
					</select>
				</td>
				<td>
				</td>
			</tr>
			<tr>
				<td align="center"> 
					<select id="SonList" name="SonList" size="12" style="width:200px;">
					</select>
				</td>
				<td width="15%" nowrap> 
					<INPUT TYPE="BUTTON"  disabled VALUE="↑" ID = "MOVEUPP" NAME = "MOVEUPP" style="cursor:hand;" language="javascript" OnClick = "MoveUP();">
					<br><img src="../images/space.gif" height="10"><br>顺序<br>
					<br><INPUT TYPE="BUTTON"  disabled VALUE="↓" ID = "MOVEDOWNP" NAME = "MOVEDOWNP"  style="cursor:hand;" language="javascript" OnClick = "MoveDown();">
					<br>
					<br>
					<br><input id="btnDel" type="button" value="删除" name="btnDel" style="cursor:hand; WIDTH: 40px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return Delete()">
				</td>
			</tr>
			<tr height=40 valign="bottom">
				<td colspan="2">
					<table width="100%">
						<tr>
							<td width="25%"></td>
							<td width="25%"><input id="btnSave" type="button" disabled value="确定" name="btnSave" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return Save()"></td>
							<td width="25%"><input id="btnCancel" type="button" disabled value="取消" name="btnCancel" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return Cancel()"></td>
							<td width="25%"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<form action method="POST" name="frmData">
			<input type="hidden" name="ItemResult">
			<input type="hidden" name="DeletedIDs">
		</form>
		<iframe id="SaveArea" name="SaveArea" style="visibility:hidden" width="0" height="0" frameborder="0" src="">
		</iframe>
	</body>
</html>

⌨️ 快捷键说明

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