<%@ page autoeventwireup="false" inherits="WebExam.Web.grade, App_Web_plgfti2c" language="vb" masterpagefile="~/Page.master" title="成绩等级" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="mainCopy">

    <script type="text/javascript">
// <!CDATA[
     function load(mode){
	          switch (mode){
	            case 1:
	             document.forms[0].grade1.value ="优"
	             document.forms[0].min1.value ="90"
	             
	             document.forms[0].grade2.value ="良"
	             document.forms[0].min2.value ="80"
	            
	             document.forms[0].grade3.value ="中"
	             document.forms[0].min3.value ="70"
	             
	             document.forms[0].grade4.value ="及格"
	             document.forms[0].min4.value ="60"
	             
	             document.forms[0].grade5.value ="差"
	             document.forms[0].min5.value ="0"
	             
	             break
	            case 2:
	             document.forms[0].grade1.value ="三级"
	             document.forms[0].min1.value ="90"
	             
	             document.forms[0].grade2.value ="二级"
	             document.forms[0].min2.value ="80"
	            
	             document.forms[0].grade3.value ="一级"
	             document.forms[0].min3.value ="60"
	             
	             document.forms[0].grade4.value ="见习级"
	             document.forms[0].min4.value ="0"
	             
	             document.forms[0].grade5.value =""
	             document.forms[0].min5.value =""
	             
	             
	             break 
	          }
	          
	       
	       
	       
	       
	       }
	       function save_onclick() {
  var max=6
  for (var i=1;i<max;i++){
    var objs="document.forms[0].min"+i
    var obj=eval(objs)
    obj.value=parseFloat(obj.value)
    if (obj.value=="NaN")
    obj.value=""
  }//整理数据
  for (var i=1;i<max;i++){
    var objs="document.forms[0].min"+i
    var obj=eval(objs)
    var objgrade=eval("document.forms[0].grade"+i)
    if ((obj.value=="")||(objgrade.value=="")){
      for(var j=i;j<max;j++)
       {objs="document.forms[0].min"+j
        obj=eval(objs)
        obj.value=""
        objgrade=eval("document.forms[0].grade"+j)
        objgrade.value=""
       }
       break
    }
  }//整理数据2
  
 
  
  var obj1=eval("document.forms[0].min1")
  for (var i=2;i<max;i++){
    var objs="document.forms[0].min"+i
    var obj=eval(objs)

    if (eval(obj.value)>=eval(obj1.value))
    {
      alert("分数设置有错误，应降序排列，且不应重复！")
      return false
    }
   obj1=obj
  }//是否降序排列
  
   for (var i=1;i<max;i++){
    var objs="document.forms[0].min"+i
    var obj=eval(objs)
    
    if ((obj.value=="")&&(i<3))
    {
      alert("至少应该有两个分级！")
      return false
    }
  }//是否至少有两个分级
  
  var minobj
  for (var i=1;i<max;i++){
    var objs="document.forms[0].min"+i
    var obj=eval(objs)
    
    if (obj.value=="")
    {
      minobj=eval("document.forms[0].min"+eval(i-1))
      break
    }
    else
    minobj=eval("document.forms[0].min5")
  }
  if (eval(minobj.value)>0)
  {alert("最小值应为0！");minobj.focus();return false}
  
  //最下级是否是0
  
  return true
}

function window.onload() {
    var gradeXML=new ActiveXObject ("Microsoft.XMLDOM");//等级情况
	gradeXML.async = false
	
	gradeXML.load("gradexml.aspx?id="+requestQueryString("id"));
	var gradeNodes  =gradeXML.selectNodes("/grade/gradename")
	var gradeLength=gradeNodes.length
  
    for(var i=0;i<gradeLength;i++)
	{
	  var gradeObj=eval("document.forms[0].grade"+eval(i+1));
	  var gNode=gradeNodes(i);
	  gradeObj.value=gNode.text
	  var minObj=eval("document.forms[0].min"+eval(i+1))
	  minObj.value=gNode.getAttribute("minvalue");
	  
	}
	
	
	
	for(var i=1;i<gradeLength;i++)
	{
	  var gradeObj1=eval("document.forms[0].grade"+i)
	 
	  var minObj1=eval("document.forms[0].min"+i)
	  
	  for(var j=i+1;j<=gradeLength;j++)
	  {
	    var gradeObj2=eval("document.forms[0].grade"+j)
	 
	    var minObj2=eval("document.forms[0].min"+j)
	   
	    if(eval(minObj2.value)>eval(minObj1.value))
	    { 
	      var objT=minObj1.value
	      minObj1.value=minObj2.value
	      minObj2.value=objT
	      
	      objT=gradeObj1.value
	      gradeObj1.value=gradeObj2.value
	      gradeObj2.value=objT
	    }
	  }
	}//排序
	
}

function Button_del_onclick() {
 if (!confirm("确定在显示成绩时，不分等级吗？"))
 return false;
 else
 return true;
}
// ]]>
    </script>

    <h2 style="text-align: center; width: 100%">
        成绩等级</h2>
    <div style="width: 100%">
        <table style="width: 414px; height: 216px">
            <tr>
                <td>
                    <table id="Table1" align="center" border="0" cellpadding="0" cellspacing="0" style="width: 148px;
                        height: 189px" width="148">
                        <tr>
                            <td colspan="3" style="width: 74px;font-weight: bold;font-size:12pt ">
                                考试：<asp:Label ID="L_name" runat="server"></asp:Label>
                            </td>
                            
                        </tr>
                        <tr>
                            <td style="width: 74px">
                                <font face="宋体">等级名称</font>
                            </td>
                            <td style="width: 27px">
                            </td>
                            <td>
                                <font face="宋体">分数</font>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 74px">
                                <input maxlength="5" name="grade1" size="5" type="text">
                            </td>
                            <td style="width: 27px">
                                <font face="宋体">&gt;=</font>
                            </td>
                            <td>
                                <font face="宋体">
                                            <input class="sjtk" name="min1" type="text"></font>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 74px">
                                <input maxlength="5" name="grade2" size="5" type="text">
                            </td>
                            <td style="width: 27px">
                                <font face="宋体">&gt;=</font>
                            </td>
                            <td>
                                <font face="宋体">
                                            <input class="sjtk" name="min2" type="text"></font>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 74px">
                                <input maxlength="5" name="grade3" size="5" type="text">
                            </td>
                            <td style="width: 27px">
                                <font face="宋体"><font face="宋体">&gt;=</font></font>
                            </td>
                            <td>
                                <input class="sjtk" name="min3" type="text">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 74px">
                                <input maxlength="5" name="grade4" size="5" type="text">
                            </td>
                            <td style="width: 27px">
                                <font face="宋体">&gt;=</font>
                            </td>
                            <td>
                                <input class="sjtk" name="min4" type="text">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 74px">
                                <input maxlength="5" name="grade5" size="5" type="text">
                            </td>
                            <td style="width: 27px">
                                <font face="宋体">&gt;=</font>
                            </td>
                            <td>
                                <input class="sjtk" name="min5" type="text">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" style="width: 100%">
                                <asp:Button ID="Butn_save" Text="保存" runat="server" OnClientClick="return save_onclick()" />
                                <input type="reset" value="重置">
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <a href="javascript:load(1)">载入预设值1</a> <a href="javascript:load(2)">载入预设值2</a>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
