
<!--#include file="../checkLogin.asp"-->
<!--#include file="../SQLconn.asp"-->
 

<%  

   id=request("id")

   grade=request("grade")
   banbie=request("banbie")   
   xingqi=request("xingqi")   
   jieci=request("jieci")
   
 
   kemu=request("kemu")
   tname=request.cookies("tname")
   
   '清除失效的课程表
   set rsdel=server.createobject("adodb.recordset")
   sqldel="delete   from kechengbiao  where 星期='"&xingqi& "'  and 节次 not in (select vname from  varset where name='作息时间') and 教师='"&request.cookies("tname")& "'"
   rsdel.open sqldel,conn,1,1
   rsdel.close
       
  if  trim(kemu)=""  then 
          set rsdel=server.createobject("adodb.recordset")
          sqldel="delete   from  kechengbiao  where     ID='"&id& "'"
          rsdel.open sqldel,conn,1,1
          rsdel.close
   
   else
    
			   set Rs=server.createobject("adodb.recordset")
			   Rssql="select * from keren where  years='"&request.cookies("nowxueqi") & "'  and grade='"&grade& "' and class='"&banbie& "'  and subject='"&kemu& "'"
			   Rs.open Rssql,conn,1,3
			   if  Rs("teacher")="" then 
					 response.redirect   "FindError.asp?tname=科任名单还没有设置，请先设置"
			   end if
			   
			  set rscheck=server.createobject("adodb.recordset")
			  rscheckSQL="select * from teachers where TName ='"&Rs("teacher")&"'" 
			  rscheck.open rscheckSQL,conn,1,3
			  if  rscheck.eof and  rscheck.bof then
				  response.redirect   "FindError.asp?tname="&Rs("teacher")
			  end if 
			
				
			   set RsPlan=server.createobject("adodb.recordset")
			   RsPlansql="select * from kechengbiao where  星期='"&xingqi& "'  and 节次='"&jieci& "' and 教师='"&request.cookies("tname")& "'"
			   RsPlan.open RsPlansql,conn,1,3
			   
			   RsPlan.addnew
			   RsPlan("学期")=request.cookies("nowxueqi") 
			   RsPlan("星期")=xingqi
			   RsPlan("节次")=jieci
			   RsPlan("年级")=grade
			   RsPlan("班别")=banbie
			   RsPlan("自录科目")=kemu
			   RsPlan("教师")= Rs("teacher")
			   RsPlan("upname")=request.cookies("tname")
			   RsPlan.update
			   RsPlan.close
	end if
				
   set RsPlan=nothing  
 
   conn.close
   set conn=nothing
   response.redirect   "KeChengBiaoQuanXiao.asp?grade="&grade&"&xingqi="&xingqi
%>
<%=RsPlansql%> 

 