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

📄 setconditionformula.asp

📁 学生档案与成绩管理(1)学生档案管理:记录每个学生的档案信息
💻 ASP
📖 第 1 页 / 共 2 页
字号:
	{
		var parts,newFormula,Count,DelCount;
		newFormula="";
		parts=FormulaStr.split(FormulaSep);
		Count=parts.length;
		DelCount=0;
		if(JTrim(FormulaStr)!='' && Count>0)
		{
			for(var i=1;i<=Count;i++)
			{
				var chkDel;
				eval("chkDel=frmData.chk"+i+".status")
				if(chkDel==true)
				{
					FormulaChanged="1";
					DelCount=DelCount+1;
				}
				else
				{
					if(newFormula=="")
						newFormula=parts[i-1];
					else
						newFormula=newFormula+FormulaSep+parts[i-1];
				}
			}
			if(DelCount>0)
			{
				FormulaStr=newFormula;
				DrawList();
			}
			else
			{
				alert("您要删除哪项条件公式?请选择。")
			}
		}
		else
		{
			alert("不存在任何条件公式可删除。")
		}
	}

	//index should be 1 based
	function EditFormula(index)
	{
		var myScreen,myTop,myLeft;
		myTop=window.screenTop-45;
		myLeft=window.screenLeft+15;
		var ret;
		if(FormulaType==FormulaType_Condition)
		{
			var Args=new Array(5)
			Args[0]=GetFormula(index);
			Args[1]=FieldToNumberFormulaSelectStr;
			Args[2]=FieldToConditionSelectStr;
			Args[3]=FieldToConditionDataTypeStr;
			Args[4]=AllConditionDetailStr;
			myScreen="dialogwidth:500px;dialogheight:290px;dialogtop:"+myTop+"px;dialogleft:"+myLeft+"px;Status:0;center:1;resizable=1;"
			ret=window.showModalDialog("setcondition.asp",Args,myScreen);
		}
		else if(FormulaType==FormulaType_ConditionDateDiff)
		{
			var Args=new Array(6)
			Args[0]=GetFormula(index);
			Args[1]=FieldToDateFromSelectStr;
			Args[2]=FieldToDateToSelectStr;
			Args[3]=FieldToConditionSelectStr;
			Args[4]=FieldToConditionDataTypeStr;
			Args[5]=AllConditionDetailStr;
			myScreen="dialogwidth:500px;dialogheight:295px;dialogtop:"+myTop+"px;dialogleft:"+myLeft+"px;Status:0;center:1;resizable=1;"
			ret=window.showModalDialog("setconditiondatediff.asp",Args,myScreen);
		}
		else if(FormulaType==FormulaType_ConditionDateAdd)
		{
			var Args=new Array(6)
			Args[0]=GetFormula(index);
			Args[1]=FieldToDateFromSelectStr;
			Args[2]=FieldToDateAddSelectStr;
			Args[3]=FieldToConditionSelectStr;
			Args[4]=FieldToConditionDataTypeStr;
			Args[5]=AllConditionDetailStr;
			myScreen="dialogwidth:500px;dialogheight:295px;dialogtop:"+myTop+"px;dialogleft:"+myLeft+"px;Status:0;center:1;resizable=1;"
			ret=window.showModalDialog("setconditiondateadd.asp",Args,myScreen);
		}
		else if(FormulaType==FormulaType_ConditionText)
		{
			var Args=new Array(5)
			Args[0]=GetFormula(index);
			Args[1]=FieldToTextFormulaSelectStr;
			Args[2]=FieldToConditionSelectStr;
			Args[3]=FieldToConditionDataTypeStr;
			Args[4]=AllConditionDetailStr;
			myScreen="dialogwidth:500px;dialogheight:325px;dialogtop:"+myTop+"px;dialogleft:"+myLeft+"px;Status:0;center:1;resizable=1;"
			ret=window.showModalDialog("setconditiontext.asp",Args,myScreen);
		}
		else if(FormulaType==FormulaType_ConditionOption)
		{
			var Args=new Array(5)
			Args[0]=GetFormula(index);
			Args[1]=ItemToOptionFormulaSelectStr;
			Args[2]=FieldToConditionSelectStr;
			Args[3]=FieldToConditionDataTypeStr;
			Args[4]=AllConditionDetailStr;
			myScreen="dialogwidth:500px;dialogheight:255px;dialogtop:"+myTop+"px;dialogleft:"+myLeft+"px;Status:0;center:1;resizable=1;"
			ret=window.showModalDialog("setconditionoption.asp",Args,myScreen);
		}
		if(typeof(ret)!="undefined")
		{
			//ret返回值,公式内部结构串,Condition,SQLDesc,Divisor
			if(ret.charAt(0)=="1")
			{
				ReplaceFormula(index,ret.substr(2))
				FormulaChanged="1";
				DrawList();
			}
		}
	}

	//index should be 1 based
	function GetFormula(index)
	{
		var parts,Formula,Count;
		parts=FormulaStr.split(FormulaSep);
		Count=parts.length;
		if(index<=Count)
		{
			for(var i=1;i<=Count;i++)
			{
				if(i==index)
				{
					Formula=parts[i-1];
				}
			}
		}
		else
		{
			Formula="";
		}
		return(Formula);
	}

	//index should be 1 based
	function ReplaceFormula(index,formula)
	{
		var parts,newFormula,curpart;
		newFormula="";
		parts=FormulaStr.split(FormulaSep);
		Count=parts.length;
		if(index<=Count)
		{
			for(var i=1;i<=Count;i++)
			{
				if(i!=index)
					curpart=parts[i-1];
				else
					curpart=formula;

				if(newFormula=="")
					newFormula=curpart;
				else
					newFormula=newFormula+FormulaSep+curpart;
			}
			FormulaStr=newFormula;
		}
	}

	function SetOrder()
	{
		var parts,Priors,Count;
		Priors="";
		parts=FormulaStr.split(FormulaSep);
		Count=parts.length;
		if(Count>1)
		{
			for(var i=1;i<=Count;i++)
			{
				if(Priors=="")
					Priors=i.toString();
				else
					Priors=Priors+","+i.toString();
			}
		}
		else
		{	
			alert("具有多个条件公式时才有必要调整顺序。")
			return(false);
		}

		var ret;
		ret=window.showModalDialog("setconorder.asp",Priors,"dialogwidth:360px;dialogheight:350px;Status:0;center:1;resizable=1;");
		if(typeof(ret)!="undefined")
		{
			//ret返回值,公式内部结构串,ConFieldID,ConRangeFrom,ConRangeTo,SQLDesc,Divisor
			if(ret.charAt(0)=="1")
			{
				ret=ret.substr(2);
				parts=ret.split(",");
				Count=parts.length;
				if(Count>0)
				{
					var newformula;
					newformula="";
					for(var i=1;i<=Count;i++)
					{
						if(newformula=="")
							newformula=GetFormula(parts[i-1]);
						else
							newformula=newformula + FormulaSep + GetFormula(parts[i-1]);
					}
					FormulaChanged="1";
					FormulaStr=newformula;
					DrawList();
				}
			}
		}
	}

	function SelectAll()
	{
		var FlipTo;
		var parts,Count;

		if(frmData.chkAll.status==true)
			FlipTo="true";
		else
			FlipTo="false";

		parts=FormulaStr.split(FormulaSep);
		Count=parts.length;
		if(JTrim(FormulaStr)!='' && Count>0)
		{
			for(var i=1;i<=Count;i++)
			{
				eval("frmData.chk"+i+".status="+FlipTo);
			}
		}
	}

	function Save()
	{
		if(FormulaChanged==true)
		{
			FormulaStr=JTrim(FormulaStr);
			if(FormulaStr.length>0)
				window.returnValue = "1,"+FormulaStr;
			else
				window.returnValue = "1";
		}
		else
			window.returnValue = "0";

		window.close();
	}
	
	function Cancel()
	{
		window.returnValue = "0";
		window.close();
	}

//-->
</script>
<html>
	<head>
		<title>设置公式</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	</head>
	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" LANGUAGE=javascript onload="return Init()">
		<form METHOD="post" name="frmData">
			<table width="95%" border=0 align=center CELLSPACING=0 CELLPADDING="0">
				<tr height="35">
					<td colspan=2>
						<b id=myTitle>
							设置条件公式
						</b>
					</td>
				</tr>
				<tr height=20>
					<td width="50%">
						<p align="left" id="ConCount">
						</p>
					</td>
					<td width="50%">
						<p align="right">
							<input type="button" name="btnAdd" disabled value="新增" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return AddRecord()">
							<input type="button" name="btnDel" disabled value="删除" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return DelRecord()">
							<input type="button" name="btnSetOrder" disabled value="调整顺序" style="cursor:hand; WIDTH: 80px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return SetOrder()">
						</p>
					</td>
				</tr>
				<tr>
					<td colspan=2>
						<table width=100% cellspacing=1 bgcolor=999999>
							<tr>
								<td bgcolor=white width=1% title='全选/全清'><INPUT name=chkAll onClick=SelectAll() type=checkbox></td>
								<td bgcolor=white width=10%>优先级</td>
								<td bgcolor=white width=54%>计算条件</td>
								<td bgcolor=white width=36%>计算公式</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr height=207 valign="top">
					<td colspan=2>
						<p align="left" id="ConditionList">
						</p>
					</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>
		<div id=ConditionListRow>
			<tr>
				<td bgcolor=white width=1%><INPUT name=chk[RowNum] type=checkbox></td>
				<td bgcolor=white width=10%><a LANGUAGE=javascript onclick="EditFormula('[RowNum]')" style="TEXT-DECORATION: underline;cursor:hand" )>[RowNum]</a></td>
				<td bgcolor=white width=54%>[ConditionDesc]</td>
				<td bgcolor=white width=36%>[FormulaDesc]</td>
			</tr>
		</div>
		<div id=FieldToConditionSelect>
		</div>
		<div id=FieldToTextFormulaSelect>
		</div>
		<div id=ItemToOptionFormulaSelect>
		</div>
		<div id=AllConditionDetail>
		</div>
	</body>                                                                                                           
</html>

⌨️ 快捷键说明

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