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

📄 chgorder.asp

📁 学生档案与成绩管理(1)学生档案管理:记录每个学生的档案信息
💻 ASP
字号:
<!-- #include file = "../../../include/asphead.asp" -->
<!-- #include file = "../../../include/function.asp" -->
<%CheckUser()%>
<style type="text/css">
	#HideDiv {position:absolute;visibility:hidden;left:0;top:0;width:0;height:0;z-index:-1}
</style>    
<link href="../../../include/main.css" rel="stylesheet" type="text/css">
<%
	dim WExcel
	set WExcel=server.CreateObject("WExcel.System")

	dim SheetID,BodyStr
	SheetID=Request.Cookies("System")("StructureSheetID")
	BodyStr=WExcel.GetFieldArray(cint(SheetID))
	CheckErr
	Response.Write BodyStr
%>

<script ID="clientEventHandlersJS" LANGUAGE="javascript">  
<!--
	var ParentSelectedID;
	var Item,ItemListIndex;
	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() 
	{
		if(ParentList.selectedIndex==0)
		{
			ParentSelectedID=0
		}
		else
		{
			ParentSelectedID=Item[parseInt(ParentList[ParentList.selectedIndex].value)].ID;
		}
		SetList();
	}
	
	function SetSelect()
	{
		var v,t,indent
		var ParentListLength;

		ParentListLength=0;
		ParentList.options[0]=new Option("",0);

		for(var i=0;i<ItemCount;i++)
		{
			if(Item[i].SonCount>0)
			{
				indent = ""
				if (Item[i].Code.length > 3)
				{
				    for (var j=1; j<=Item[i].Code.length-3;j++)
				    {
				        indent = indent + " "
				    }
				}
				v=i;
				t=indent+Item[i].Name;
				ParentList.options[ParentListLength+1]=new Option(t,v);
				ParentListLength=ParentListLength+1;
			}
		}
		ParentList.length=ParentListLength+1;
		if(ParentSelectedID==0)
		{
			ParentList.selectedIndex =0;
		}
		else
		{
			for(var i=1;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;
		if(Index>0)
		{
			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)
				{
					v=i;
					t=Item[i].Name;
					SonList.options[SonListLength]=new Option(t,v);
					SonListLength=SonListLength+1;
				}
			}
		}
		else if(Index==0)
		{
			for (var i=0;i<ItemCount;i++)
			{
				if(Item[i].Code.length==3)
				{
					v=i;
					t=Item[i].Name;
					SonList.options[SonListLength]=new Option(t,v);
					SonListLength=SonListLength+1;
				}
			}
		}
		SonList.length=SonListLength;
	}

	function MoveFirst()
	{
		if(CheckItemList()==true)
		{
			while (ItemListIndex>0)
			{
				MoveUP();
			}
		}
		else
		{
			alert("要调整哪个字段的顺序?请选择。");
		}
	}

	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 MoveLast()
	{
		if(CheckItemList()==true)
		{
			while (ItemListIndex<SonList.length-1)
			{
				MoveDown();
			}
		}
		else
		{
			alert("要调整哪个字段的顺序?请选择。");
		}
	}

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

	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++)
			{
				Result=Result+","+Item[i].ID
			}
			btnSave.disabled =true;
			btnCancel.disabled =true;
			Result=Result.substr(1,Result.length-1);
			parent.window.returnValue = true;
			document.frmData.ItemResult.value = Result;
			document.frmData.target ="SaveArea";
			document.frmData.action="saveorder.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;
		MOVEUPP2.disabled =false;
		MOVEDOWNP2.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">
					<b>
						调整字段的排版顺序
					</b>
				</td>
			</tr>
			<tr>
				<td align="center"> 
					<select id="SonList" name="SonList" size="13" style="width:200px;">
					</select>
				</td>
				<td width="40" nowrap> 
					<INPUT TYPE="BUTTON" title="上移至顶" disabled VALUE="︽" ID = "MOVEUPP2" NAME = "MOVEUPP2" style="FONT-SIZE: small;cursor:hand;" language="javascript" OnClick = "MoveFirst();">
					<br>
					<INPUT TYPE="BUTTON" title="上移" disabled VALUE="︿" ID = "MOVEUPP" NAME = "MOVEUPP" style="FONT-SIZE: small;cursor:hand;" language="javascript" OnClick = "MoveUP();">
					<br><img src="../images/space.gif" height="10"><br>顺序<br>
					<br>
					<INPUT TYPE="BUTTON" title="下移" disabled VALUE="﹀" ID = "MOVEDOWNP" NAME = "MOVEDOWNP"  style="FONT-SIZE: small;cursor:hand;" language="javascript" OnClick = "MoveDown();">
					<br>
					<INPUT TYPE="BUTTON" title="下移至底" disabled VALUE="︾" ID = "MOVEDOWNP2" NAME = "MOVEDOWNP2"  style="FONT-SIZE: small;cursor:hand;" language="javascript" OnClick = "MoveLast();">
				</td>
			</tr>
			<tr height=40 valign="bottom">
				<td colspan="4">
					<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="DictID" value="<%=DictID%>">
		</form>
		<!--
			ParentList在此页面用不上,但为了省得改程序,保留之,不显示出即可。
		//-->
		<div id=HideDiv>
				<select id="ParentList" name="ParentList" size="1"  style="width:200px;" LANGUAGE=javascript onchange="return ParentList_onchange()">
				</select>
		</div>
		<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 + -