    <!--#include file="../SQLconn.asp"-->
	
	
	<%      
		  
		  
	  Set MyOAASPObj = Server.CreateObject("YFSchoolOApro2.YFSchoolDll2")
		MyOAASPObj.KaoqinNew
	   set MyOAASPObj=nothing
   
	 	
	
	
	
	    w=request("w") '图像宽度
		h=request("h") '图像高度
		pix=request("pix") '颜色值
		photo_name=request.cookies("tname")&"-"&year(now())&"-"&month(now())&"-"&day(now())&"-"&hour(now())&"-"&minute(now())&"-"&second(now()) 
		'request("photo_name") '当前签到次序Format_Time(now,2)&"-"&hour(now())&"-"&minute(now())&"-"&second(now()) 
		cs=split(pix,",")
		dim s,t,i,q,photo_path,photo_name

		photo_path="picture/"

		'私有函数，将接收的16进制RGB格式转换并添加到图象数据区

		Function To3(nums) 
			Dim myArray()
			Dim iii, tmp
			For iii=1 To 3
				tmp=Mid(nums,iii*2-1,2)
				Redim Preserve myArray(iii)
				myArray(iii) =chn10(tmp)
			Next
			To3 = ChrB(myArray(3))&ChrB(myArray(2))&ChrB(myArray(1))
		End Function

		'私有函数，将16进制转换为10进制
		Function chn10(nums) 
			Dim tmp, tmpstr, intLoop4
			nums_len=Len(nums)
			For intLoop4=1 To nums_len
				tmp=Mid(nums,intLoop4,1)
					If IsNumeric(tmp) Then
						tmp=tmp * 16 * (16^(nums_len-intLoop4-1))
					Else
						tmp=(ASC(UCase(tmp))-55) * (16^(nums_len-intLoop4))
					End If
				tmpstr=tmpstr+tmp
			Next
			chn10 = tmpstr
		End Function

		Response.Expires = -9999 
		Response.AddHeader "cache-control","no-cache" 
		'文件头开始
		strHeadData=ChrB(66) & ChrB(77) '文件标识
		strHeadData=strHeadData&ChrB(230) & ChrB(4) & ChrB(0) & ChrB(0) '文件大小
		strHeadData=strHeadData & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) '保留，每字节以“00”填写
		strHeadData=strHeadData&ChrB(54) & ChrB(0) & ChrB(0) & ChrB(0) '记录图像数据区的起始位置
		strHeadData=strHeadData & ChrB(40) & ChrB(0) &ChrB(0) & ChrB(0) '图像描述信息块的大小
		strHeadData =strHeadData &ChrB(w) & ChrB(0) & ChrB(0) & ChrB(0) '宽度
		strHeadData =strHeadData & ChrB(h) & ChrB(0) & ChrB(0) & ChrB(0) '高度
		strHeadData =strHeadData & ChrB(1) & ChrB(0) '图像的plane总数
		strHeadData =strHeadData &ChrB(24) & ChrB(0) '图像的位数 
		strHeadData =strHeadData & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) '数据压缩方式
		strHeadData =strHeadData &ChrB(176) & ChrB(4) & ChrB(0) & ChrB(0) '图像区数据的大小
		strHeadData =strHeadData & ChrB(18) & ChrB(11) & ChrB(0) & ChrB(0) '水平每米有多少像素
		strHeadData =strHeadData & ChrB(0) & ChrB(0) &ChrB(0) & ChrB(0) '垂直每米有多少像素
		strHeadData =strHeadData & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) '此图像所用的颜色数
		strHeadData =strHeadData & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) '颜色表
		'文件头结束
		strMainData=""  
		For k=h-1 To 0 Step -1
			For j=0 To w-1
				strMainData=strMainData&to3(cs(k*w+j))
			Next
		Next

		strSaveData=strHeadData+strMainData
		Set Jpeg = Server.CreateObject("Persits.Jpeg")
		Jpeg.OpenBinary strSaveData
		Jpeg.Width = Jpeg.OriginalWidth 
		Jpeg.Height = Jpeg.OriginalHeight
		Jpeg.Save Server.MapPath(photo_path & photo_name & ".jpg")  
		Set Jpeg = Nothing  
		
		%>
		
		
		
		
		<% 
	 
     zubie="默认组"	
     set Rszu=server.createobject("adodb.recordset")
     sqlRszu="select * from teacherGroup where tname='"&request.cookies("tname")&"'  and owner='考勤管理'" 
     Rszu.open sqlRszu,conn,1,3
	 zubie=Rszu("GroupName")
	 zubie.close
	 
	 set Rszuvar=server.createobject("adodb.recordset")
     sqlRszuvar="select * from kaoqinvar where   组名='"&zubie&"' " 
     Rszuvar.open sqlRszuvar,conn,1,3
		  swCD=formatdatetime(now,2)&" "&Rszuvar("早上迟到")    '早上迟到
		  swZT=formatdatetime(now,2)&" "&Rszuvar("早上早退")     '早上早退
		  xwCD=formatdatetime(now,2)&" "&Rszuvar("下午迟到")     '下午迟到 
		  xwZT=formatdatetime(now,2)&" "&Rszuvar("下午早退")     '下午早退
		  wsCD=formatdatetime(now,2)&" "&Rszuvar("晚上迟到")    '晚上迟到 
		  wsZT=formatdatetime(now,2)&" "&Rszuvar("晚上早退")      '晚上早退
		  
		  swCome=formatdatetime(now,2)&" "&Rszuvar("上午上班打卡截止")           '上午上班打卡截止
		  swGo=formatdatetime(now,2)&" "&Rszuvar("上午下班打卡截止")               '上午下班打卡截止
		  xwCome=formatdatetime(now,2)&" "&Rszuvar("下午上班打卡开始")          '下午上班打卡开始
		  xwGo=formatdatetime(now,2)&" "&Rszuvar("下午下班打卡截止")              '下午下班打卡截止
		  wsCome=formatdatetime(now,2)&" "&Rszuvar("晚上上班打卡开始")           '晚上上班班打卡开始
		  wsGo=formatdatetime(now,2)&" "&Rszuvar("晚上下班打卡开始")              '晚上
	 	 
	 Rszuvar.close
				
		'''''''''''''''''''''''''''''''''''''''''''''''''''''varset 放在这里开始
	  	 
   

   dakatype=""
   zhuangtai="正常"
   qdtime=now()
 



   if datediff("s",swCome,qdtime)<0 then 
      dakatype="上午上班"
	  if  datediff("s",swCD,qdtime)>0 then
	      zhuangtai="迟到"
	  end if
   end if 
   
   if datediff("s",swGo,qdtime)>0  and  datediff("s",xwCome,qdtime)<0 then 
      dakatype="上午下班"
	  
   end if 
   
   if datediff("s",xwCome,qdtime)>0  and  datediff("s",xwGo,qdtime)<0 then 
      dakatype="下午上班"
	  if  datediff("s",xwCD,qdtime)>0 then
	      zhuangtai="迟到"
	  end if
   end if 
   
   if datediff("s",xwGo,qdtime)>0  and  datediff("s",wsCome,qdtime)<0 then 
      dakatype="下午下班"
   end if 
   
   if datediff("s",wsCome,qdtime)>0  and  datediff("s",wsGo,qdtime)<0 then 
      dakatype="晚上上班"
	   if  datediff("s",wsCD,qdtime)>0 then
	      zhuangtai="迟到"
	  end if
   end if 
   if datediff("s",wsGo,qdtime)>0 then 
      dakatype="晚上下班"
   end if 
   
	  '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''varset 放在这里结束了
   
   
 
  
    
      
   set Rssave=server.createobject("adodb.recordset")
       Rssavesql="select * from kaoqin where tname='"&request.cookies("tname")&"'  and  convert(datetime,curdate)='"&date()&"'  and  qdtype='"&dakatype&"'" 
       Rssave.open Rssavesql,conn,1,3
	    

       Rssave("qddatetime")=qdtime
	   Rssave("qdimagename")=photo_name
	 '  
	   Rssave("shenbian")=dakatype
	   Rssave("zhuangtai")=zhuangtai
	   strip=Request.ServerVariables("REMOTE_ADDR")
	   Rssave("qdip")=request.cookies("kaoqinzu")

       Rssave.update
       Rssave.close
 
      'response.redirect   "gerenjilu.asp"
   ' response.redirect   "ok.asp?zhuangtai="&zhuangtai
%>
 
