<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/util.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<HTML>
<HEAD>
<TITLE>修改计划</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size: 12pt;
}
</style>
<script type="text/javascript">
function check(obj){
	if(obj.task_name.value==""){
		alert("任务名称不能为空!");
		obj.task_name.focus();
		return false;
	}
	if(obj.task_date.value==""){
		alert("日期不能为空!");
		obj.task_date.focus();
		return false;
	}
}
</script>
<script language="JavaScript" src="../js/PublicJS.js"></script>
</HEAD>
<BODY>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
'call checkPrevilege(Session("Name"),"p0000")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim id,act,adminname,PassWord,RoleId,t_date
if not isempty(request("id")) then
	id=Clng(request("id"))
else
	response.Write("<script>alert(""没有记录"");history.back();</script>")
	response.End()
end if

act=request.QueryString("act")

if(act="mod") then	
	task_name=trim(request.Form("task_name"))
	task_content=Replace(Trim(Request.Form("task_content")),"'","")
	task_date=Cdate(request.Form("task_date"))
	'添加到库
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 * from t_task where task_name='"&task_name&"' and admin_name='"&UserName&"' and id<>"&id&" order by id desc "
	rs.open sql,conn,3,3
	if not rs.eof then
		response.Write("<script>alert(""该任务已存在!"");history.back();</script>")
		response.End()
	end if
	rs.close
		rs.open "select top 1 * from t_task where id="&id&" order by id desc",conn,3,3
		if not rs.eof and not rs.bof then
			rs("admin_name")=UserName
			rs("task_name")=task_name
			rs("task_content")=task_content
			rs("task_date")=task_date
			rs("ModiTime")=now	
			rs.update
		end if
		rs.close
		set rs=nothing
		response.Write("<p align=""center"">修改计划任务成功~!</p>")
		response.Write("<br><p align=""center""><a href=task_add.asp>添加新任务</a>&nbsp;&nbsp;<a href=calender.asp>管理任务</a></p>")	
else
	set rs=server.createobject("adodb.recordset")
	sql="select top 1 * from t_task where admin_name='"&UserName&"' and id="&id&" order by id desc "
	rs.open sql,conn,3,1
	if not rs.eof then
		task_name=rs("task_name")
		task_content=rs("task_content")
		task_date=rs("task_date")	
	end if
	rs.close
	set rs=nothing
%>
<FORM method="POST" name="form1" action="?act=mod" style="margin:0 0 0 0;" onSubmit="return check(this)">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style1">修改计划</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="14%"><div align="center">任务名称：</div></TD>
  <TD width="86%"><input name="task_name" type="text" id="task_name" size="30" value="<%=task_name%>"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">计划内容：</div></TD>
  <TD><div align="left">
    <textarea name="task_content" cols="50" rows="6" id="task_content"><%=task_content%></textarea>
</div></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD><div align="center">计划日期：</div></TD>
  <TD><input name="task_date" type="text" id="task_date" size="30" value="<%=task_date%>">
    <input name="sdaf" type="button" id="sdaf" onClick="OpenWindowAndSetValue('Inc/SelectDate.asp',280,120,window,document.form1.task_date);document.form1.task_date.focus();" value="选择日期"></TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD height="50" align=right bgcolor="#F5F5F5">&nbsp;	  </TD>
    <TD align=right bgcolor="#F5F5F5"><div align="left"> 
		<input type="hidden" name="id" value="<%=id%>">
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end if
%>
</BODY>
</HTML>
<%
call connclose()
%>