
<%response.expires=-1%>
<!--#include file="../inc/Secure.htm"-->
<!--#include file="../inc/conn.htm"-->
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/main.css">
</HEAD>
<%
selectdate=date()
LoginID=trim(session("LoginID"))
if LoginID="" then response.end

if request("cmdUp")<>"" then
	WriteID=trim(request("WriteID"))
	WriteName=trim(request("WriteName"))
	body=trim(request("body"))
	Title=trim(request("Title"))
	Department=trim(request("Department"))
	if Title="" then
		response.write "记录日志主题不能为空。<a href='javascript:history.back(-1);'>[返回]</a>"
		oconn.close
		response.end
	end if
	AddData()
	response.write "您的安排已经提交，谢谢！<a href=watch_index.htm>[返回]</a>"
	oConn.close
	response.end
end if

set rs=server.createobject("Adodb.recordset")
sql="select * from tblWatch where WatchID="& LoginID &" and Starttime<='"& selectdate&" 23:30:00" &"' and EndTime>='"& selectdate &"' Order by ID desc"
rs.open sql,oConn
if not rs.eof then
	isWatch=true
	WatchOrderID=trim(rs("ID"))
	Department=trim(rs("Department"))
else
	isWatch=false
end if
rs.close
set rs=nothing
%>
<BODY BGCOLOR="#FFFFFF">

<div align=center>

<table border=1 cellpadding=3 cellspacing=0 width="95%" bgcolor=#EEEEEE bordercolordark="#FFFFFF" bordercolorlight="#999999">
<tr>
<td colspan=4 align=center><b>填写值班记录/日志</b></td>
</tr>
<%if isWatch then%>

<form name="OrderForm" method="post" action="">
<tr>
	<td width=80>填写用户：</td>
	<td><input type="text" name="WriteName" size=16 readonly class="input"></td>
	<td width=80>安排部门：</td>
	<td><input type="text" name="DepartmentName" value="<%=GetTableValue("tblDepartment","Name","ID",department)%>" size=16 readonly class="input"></td>
</tr>
<tr>
	<td>记录填写时间</td>
	<td colspan=3><input type="text" name="Times" size=16 readonly class="input"></td>
</tr>
<tr>
	<td>记录日志主题</td>
	<td colspan=3><input type="text" name="Title" value="" size=40 class="input"></td>
</tr>
<tr>
<td>记录内容描述</td>
<td colspan=3>
<textarea name="body" cols=50 rows=5>
</textarea>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan=3 align=center>
<INPUT TYPE="submit" name="cmdUp" value="确  定" class="font9boldwhite">
<INPUT TYPE="button" name="cmdreturn" value="返  回" class="font9boldwhite" onclick="javascript:history.back(-1);">
</td>
</tr>
<INPUT TYPE="hidden" name="WriteID" value="<%=LoginID%>">
<INPUT TYPE="hidden" name="Department" value="<%=Department%>">
</form>
<%else%>
<tr>
<td colspan=4>您今天没有安排值班，不能填写值班记录。<a href="javascript:history.back(-1);">[返回]</a></td>
</tr>
<%end if%>
</table>
</div>

</BODY>
</HTML>
<!--#include file="../inc/conn_close.htm"-->
<%
Function GetTableValue(TableName,Field,ValueField,Value)
	if TableName<>"" and Value<>"" then
		Set RsTmp = Server.Createobject("Adodb.recordset")
		strSql = "Select "& Field &" from "& TableName &" where "& ValueField &"='"& Value &"'"
		Rstmp.open strSql,oConn,1,1
		If not Rstmp.eof then
			GetTableValue=trim(Rstmp(Field))
		else
			GetTableValue=""
		end if
		Rstmp.close
		'set RsTmp = Nothing
	else
		GetTableValue=""
	end if
End Function

Sub AddData()
	sql=" INSERT INTO tblwatchlog(WriteID,Department,WriteName,Title,body) VALUES(" & WriteID & _
		","& Department & _
		",'"& WriteName & _
		"','"& Title & _
		"','"& body & _
		"');"
		'response.write sql
	oConn.execute (sql)
end sub
%>