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

📄 checklogin.asp

📁 功能齐全的oa系统
💻 ASP
字号:
<%@ LANGUAGE = VBScript %>
<% Option Explicit %>
<!-- #include virtual="include/DataEnvi.asp" -->
<% 	Dim ObjDB,ObjRS,StrSQL
	Dim act,t,KeyField
	Dim OnTime_AM,OnTime_AM_Min,OffTime_AM,OffTime_AM_Min,OnTime_PM,OnTime_PM_Min,OffTime_PM,OffTime_PM_Min
'----------------------------------------------------------------------------------------------------------------------
'设置时间
	OnTime_AM=8 		'下午准许开始签到时间---小时数
	OnTime_AM_Min=0		'早上准许开始签到时间---分钟数,注:一般应该比上班时间有所提前,系统检查时间段为10分钟一次
	OffTime_AM=12		'上午准许开始签出时间---小时数
	OffTime_AM_Min=0	'上午准许开始签出时间---分钟数
	OnTime_PM=14		'下午准许开始签到时间---小时数
	OnTime_PM_Min=0		'下午准许开始签到时间---分钟数
	OffTime_PM=18		'下午准许开始签出时间---小时数
	OffTime_PM_Min=0	'下午准许开始签出时间---分钟数
'-----------------------------------------------------------------------------------------------------------------------
	If OnTime_PM_Min=0 Then
	OnTime_PM=OnTime_PM-1
	End If

	if session("AccountID")="" then
%>
<script language=javascript>
  	alert("因登录时间过长,会话失效,请退出重新登陆!")
</script>
<%  
   	Response.End
	end if	
%>
<html><head>
<script language="JavaScript1.2" type="text/JavaScript1.2">
function Sign(timespan,action){
	window.open("<%=Application("RootPath")%>OA/Private/event/CheckLogin.asp?ID=<%=Session("AccountID")%>&t="+timespan+"&act="+action,'LoginChecking',"Height=220px; Width=300px;resizable=0;status=0;scroll=0");
	var r=new Array()
	r[0]=timespan
	r[1]=action
	window.returnValue=r
	window.close();
}
function chkTime(){
var d=new Date();var s;if(d.getHours()>=<%=OffTime_AM%>) s=" 下午 ";else s=" 上午 "; t.innerHTML =s+"<font color=#0000FF>"+d.getHours()+"</font>点<font color=#0000FF>"+d.getMinutes()+" </font>分<font color=#0000FF>"+d.getSeconds()+"</font>秒";
window.setTimeout("chkTime()",1000)
}
</script>
</head><body bgcolor="#EEEEEE" ><div align="center">
<%	Set ObjDB = Server.CreateObject ("ADODB.Connection")
	OpenDB ObjDB
IF Request.QueryString("act")<>"" Then
	act=Trim(Request.QueryString("act"))
	t=Trim(Request.QueryString("t"))
	Dim ID
	If Trim(Request.QueryString("ID"))<>"" Then
		ID=Trim(Request.QueryString("ID"))
	End If
	If Trim(Session("AccountID"))<>"" Then
		ID=Trim(Session("AccountID"))
	End If
	IF ID="" Then
	Response.Write("<script language=javascript>alert('身份验证错误!请重试!');window.close();</script>")
	End If
		If act="i" Then
		KeyField=KeyField+"Login_Time_"
		End If
		If act="o" Then
		KeyField=KeyField+"Logout_Time_"
		End If
		If t="am" Then
		KeyField=KeyField+"AM"		
		End If
		If t="pm" Then
		KeyField=KeyField+"PM"		
		End If

	StrSQL="SELECT * FROM t_OA_Private_Sign WHERE Account_ID="&ID&" AND YEAR(Create_Time)=YEAR(GETDATE()) AND MONTH(Create_Time)=MONTH(GETDATE()) AND DAY(Create_Time)=DAY(GETDATE())"
	Set ObjRS = ObjDB.Execute (StrSQL)
	If  ObjRS.EOF Then
		StrSQL="INSERT INTO t_OA_Private_Sign (Account_ID,"
		StrSQL=StrSQL+KeyField		
		StrSQL=StrSQL+",Create_Time) VALUES ("& ID&",GETDATE(),GETDATE())"
		ObjDB.Execute(StrSQL)
		ObjDB.Close
	Response.Write("<script language=javascript>alert('签到成功!');window.close();</script>")
	Else
		StrSQL="UPDATE t_OA_Private_Sign SET "&KeyField&"=(GETDATE()) WHERE Account_ID="&ID&" AND YEAR(Create_Time)=YEAR(GETDATE()) AND MONTH(Create_Time)=MONTH(GETDATE()) AND DAY(Create_Time)=DAY(GETDATE())"
		ObjDB.Execute(StrSQL)
		ObjDB.Close
	Response.Write("<script language=javascript>window.close();</script>")
	End If
Else
	StrSQL="SELECT * FROM t_OA_Private_Sign WHERE Account_ID="& Session("AccountID")&" AND YEAR(Create_Time)=YEAR(GETDATE()) AND MONTH(Create_Time)=MONTH(GETDATE()) AND DAY(Create_Time)=DAY(GETDATE())"
	Set ObjRS = ObjDB.Execute (StrSQL)
	If Not ObjRS.EOF Then
	Dim AllBeDone
	AllBeDone=true%>
		<form>
		<table>
			<tr> 
			  <td width="70"><div align="center">现在时刻</div></td>
			  <td colspan="3" id="t"><script language="javascript">chkTime()</script></td>
			</tr>
		<tr>
		<td>早上签到</td>
		<%If Trim(ObjRS("Login_Time_AM"))<>"" Then%>
		<td colspan="3"><%=Trim(ObjRS("Login_Time_AM"))%></td>
		<%Else%>
		<td width="60"><font color="#FF0000">尚未签到</font></td>
		<td width="70"><input type="button" value="立即签到" name="Login"  onClick="Sign('am','i')"></td>
        <td width="70"><input name="wait" type="button" onClick="window.close()" value="待会儿.."></td>
		<% AllBeDone=false
		End If%>
		</tr>
		<%If hour(now())>=OffTime_AM and minute(now())>=OffTime_AM_Min   Then%>
			<tr>
			<td>早上签出</td>
			<%If Trim(ObjRS("Logout_Time_AM"))<>"" Then%>
			<td colspan="3"><%=Trim(ObjRS("Logout_Time_AM"))%></td>
			<%Else%>
			<td><font color="#FF0000">尚未签出</font></td>
			<td><input type="button" value="立即签出" name="Logout"  onClick="Sign('am','o')"></td>
			<td><input name="wait" type="button" onClick="window.close()" value="待会儿.."></td>
			<% AllBeDone=false
			End If%>
			</tr>
		<%End If
		If hour(now())>=OnTime_PM and minute(now())>=OnTime_PM_Min Then%>
			<tr>
			<td>下午签到</td>
			<%If Trim(ObjRS("Login_Time_PM"))<>"" Then%>
			<td colspan="3"><%=Trim(ObjRS("Login_Time_PM"))%></td>
			<%Else%>
			<td><font color="#FF0000">尚未签到</font></td>
			<td><input type="button" value="立即签到" name="Login"  onClick="Sign('pm','i')"></td>
			<td><input name="wait" type="button" onClick="window.close()" value="待会儿.."></td>
			<% AllBeDone=false
			End If%>
			</tr>
		<%End If
		If hour(now())>=OffTime_PM and minute(now())>=OffTime_PM_Min Then%>
			<tr>
			<td>下午签出</td>
			<%If Trim(ObjRS("Logout_Time_PM"))<>"" Then%>
			<td colspan="3"><%=Trim(ObjRS("Logout_Time_PM"))%></td>
			<%Else%>
			<td><font color="#FF0000">尚未签出</font></td>
			<td><input type="button" value="立即签出" name="Logout"  onClick="Sign('pm','o')"></td>
			<td><input name="wait" type="button" onClick="window.close()" value="待会儿.."></td>
			<% AllBeDone=false
			End If%>
			</tr>
		<%End If%>
		</table>
		</form>
	<%  If AllBeDone Then%>
	<script language="JavaScript">window.close()</script>
	<%	End If	
	Else
	'have not logon in this day
		If hour(now())<=OffTime_AM Then%>
			<form>
		  <table>
			<tr> 
			  <td width="70"><div align="center">现在时刻</div></td>
			  <td colspan="3" id="t"></td>
			</tr>
			<tr> 
			  <td><div align="center">早上</div></td>
			  <td><font color="#FF0000">尚未签到</font></td>
			  <td><input type="button" value="立即签到" name="Login"  onClick="Sign('am','i')">
        		<input name="button2" type="button" onClick="window.close()" value="待会儿.."></td>
			</tr>
		  </table>
		</form>
	<%	Else%>
		<form >
		 <table>
			<tr> 
			  <td width="70"><div align="center">现在时刻</div></td>
			  <td colspan="3" id="t"><script language="javascript">chkTime()</script></td>
			</tr>
		<tr>
		<tr> 
		  <td > 
			<div align="center">早上</div></td>
		  <td><font color="#FF0000">尚未签到</font></td>
		  <td> 
			<input type="button" value="立即签到" name="Login"  onClick="Sign('am','i')">
			<input name="button3" type="button" onClick="window.close()" value="待会儿.."></td>
		</tr>
		<tr> 
		  <td><div align="center">下午</div></td>
		  <td><font color="#FF0000">尚未签到</font></td>
		  <td><input type="button" value="立即签到" name="Login"  onClick="Sign('pm','i')">
        <input name="button4" type="button" onClick="window.close()" value="待会儿.."></td>
		</tr>
	  </table>
	  </form>
	<%	End If
	End If
End IF
	ObjRS.close
	Set ObjRS = Nothing
	ObjDB.Close 
	Set ObjDB = Nothing%>
	</div></body></html>

⌨️ 快捷键说明

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