<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../Images/Admin_style.css">
<script type="text/javascript">
function checktasksedit(){
if (document.edittasks.TDemo.value.replace(/^\s*/g,"")=="") {
    alert("工作或任务不能为空,请认真填写!");
    document.edittasks.TDemo.focus();
    return false;
 }
}
function show_d241()
{
	if (document.getElementById("Task_frame").value=="calendar"){
	document.getElementById("d241").style.display="";
	}
	else
	{
		document.getElementById("d241").style.display="none";
		}
	
}
</script>
<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
<%
Dim Result,TDemo,TEtime,TasksSortID,TKehuID,TChancesID,Task_frame,TCompleted,strReferer
Result = request.QueryString("Result")
ID = request.QueryString("ID")
if request("Referer")<>"" then
   strReferer = Request.ServerVariables("http_referer")
end if
    Call TasksEdit()

%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="edittasks" method="post" action="?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>" onSubmit="return checktasksedit()">
    <tr>
      <th height="22" colspan="2" sytle="line-height:150%">【<%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>事项】</th>
    </tr>
    <tr>
      <td width="20%" align="right" class="forumRow">工作或事项
      <input name="TKehuID" type="hidden" value="<%=TKehuID%>">
      <input name="TChancesID" type="hidden" value="<%=TChancesID%>">
      <input name="strReferer" type="hidden" value="<%=strReferer%>">
      </td>
      <td width="80%" class="forumRowHighlight"><textarea name="TDemo" rows="8" style="width:80%; margin-bottom:8px"><%=TDemo%></textarea> </td>
    </tr>
    <tr>
      <td align="right" class="forumRow">最晚完成时间?</td>
      <td class="forumRowHighlight">
	 <select name="Task_frame" onchange="javascript:show_d241()">
     <option value="today" <%if Task_frame="today" then response.Write"selected"%>>今天</option>
     <option value="tomorrow" <%if Task_frame="tomorrow" then response.Write"selected"%>>明天</option>
     <option value="aftertomorrow" <%if Task_frame="aftertomorrow" then response.Write"selected"%>>后天</option>
     <option value="this_week" <%if Task_frame="this_week" then response.Write"selected"%>>本周</option>
     <option value="next_week" <%if Task_frame="next_week" then response.Write"selected"%>>下周</option>
     <option value="later" <%if Task_frame="later" then response.Write"selected"%>>以后</option>
     <option value="calendar" <%if Task_frame="calendar" then response.Write"selected"%>>设置时间 ...</option>
	   
	 </select>
     <input name="d241" type="text" class="Wdate" id="d241" style="width:150px;
	 <%if Task_frame="calendar" then 
	      response.Write " display:"
	   else
	      response.Write " display:none"
	   end if	  
	 %>
     " onfocus="WdatePicker({skin:'blueFresh',dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<%=TEtime%>"/>
      </td>
    </tr>
<tr>
      <td align="right" class="forumRow">选择一个分类</td>
      <td class="forumRowHighlight"> 
     <select name="TasksSort">
     <option value='0'>无</option>
	   <% call SelectTasksSort() %>
	 </select>
		
      </td>
    </tr>    
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="保存"> <input type="button" value="返回上一页" onclick="history.back(-1)"></td>
    </tr>
  </form>
</table>
<%
Sub TasksEdit()
    Dim Action, rs, sql
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
	    Taskframe=trim(request.Form("Task_frame"))
		select case Taskframe
		      case "today"
			       TEtime=date()&" 23:59:59"
			  case "tomorrow"
			       TEtime=DateAdd("d",+1,Date())&" 23:59:59"
			  case "aftertomorrow"
			       TEtime=DateAdd("d",+2,Date())&" 23:59:59"
			  case "this_week"
			       TEtime=dateadd("d",date,7-weekday(date))&" 23:59:59"
			  case "next_week"
			       TEtime=DateAdd("d",+7,dateadd("d",date,7-weekday(date)))&" 23:59:59"
			  case "later"
			  case "calendar"
			       TEtime=trim(Request.Form("d241"))
			  case else
		end select	  
        Set rs = server.CreateObject("adodb.recordset")
        If Result = "Add" Then
            sql = "select * from Zqj_Tasks"
            rs.Open sql, conn, 1, 3
            rs.addnew           
            rs("Demo")=Request.Form("TDemo")
			rs("TasksSortID")=Request.Form("TasksSort")
			rs("MemName")=session("UserName")
			if trim(Request.Form("TKehuID"))="" then
			    rs("TKehuID")=0
			else
			    rs("TKehuID")=trim(Request.Form("TKehuID"))
			end if
			if trim(Request.Form("TChancesID"))="" then
			    rs("TChancesID")=0
			else
			    rs("TChancesID")=Request.Form("TChancesID")
			end if
			rs("Etime")=TEtime
			rs("Task_frame")=trim(request.Form("Task_frame"))
			rs.update
            rs.Close
            Set rs = Nothing
            response.Write "<script language='javascript'>alert('设置成功！');location.replace('Tasks_todo_list.asp');</script>"
        End If
        If Result = "Modify" Then
		    strReferer=trim(request.Form("strReferer"))
            sql = "select * from Zqj_Tasks where ID="&ID
            rs.Open sql, conn, 1, 3
            rs("Demo")=Request.Form("TDemo")
			rs("TasksSortID")=Request.Form("TasksSort")
			if trim(Request.Form("TKehuID"))="" then
			    rs("TKehuID")=0
			else
			    rs("TKehuID")=trim(Request.Form("TKehuID"))
			end if
			if trim(Request.Form("TChancesID"))="" then
			    rs("TChancesID")=0
			else
			    rs("TChancesID")=Request.Form("TChancesID")
			end if
			rs("Etime")=TEtime
			rs("Task_frame")=trim(request.Form("Task_frame"))
			rs.update
            rs.Close
            Set rs = Nothing
			if strReferer<>"" then
               response.Redirect strReferer
			else
			   response.Write "<script language='javascript'>alert('设置成功！');location.replace('Tasks_todo_list.asp');</script>"
			end if
        End If
        
    Else
        If Result = "Modify" Then
            Set rs = server.CreateObject("adodb.recordset")
            sql = "select * from Zqj_Tasks where ID="& ID
            rs.Open sql, conn, 1, 1
            If rs.RecordCount = 0 Then
                response.Write "<script language='javascript'>alert('无此记录！');history.back(-1)</script>"
                response.End
            End If
              ID = rs("ID")
              TDemo=rs("Demo")
			  TEtime=rs("Etime")
			  TasksSortID=rs("TasksSortID")
			  TKehuID=rs("TKehuID")
			  TChancesID=rs("TChancesID")
			  Task_frame=rs("Task_frame")
			  TCompleted=rs("Completed")
			  rs.Close
            Set rs = Nothing
        End If
    End If
End Sub

Sub TasksEtime() '到期时间
End Sub

Sub SelectTasksSort() '任务分类
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from Zqj_TasksSort where ViewFlag order by ID asc"
    rs.Open sql, conn, 1, 1
    If rs.bof And rs.EOF Then
        response.Write("未设置")
    End If
    While Not rs.EOF
        response.Write("<option value='"&rs("ID")&"'")
		 if rs("ID")=TasksSortID then
		 response.Write " selected"
		 end if
        response.Write(">"&rs("SortName")&"</option>")
        rs.movenext
    Wend
    rs.Close
    Set rs = Nothing
End Sub
%>