<% connect_db() check_admin_login() check_admin_task("任务管理") module = Request("module") Select Case module Case "list_task" list_task() Case "new_task" new_task() Case "add_task" add_task() Case "delete_task" delete_task() Case "modify_task" modify_task() Case "update_task" update_task() Case Else list_task() End Select Function list_task() Dim intCurrentPage, str_color sql = "select id, task_name, application, description, flag from tasks where parent_id = 0 order by order_id desc, id" set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 3 beginAdminHtml() %> <%beginAdminTitle("系统管理 > 任务管理")%>
<% While Not rs.EOF If rs("flag") = 0 Then str_color = "#000000" Else str_color = "#FF0000" End If %> <% sql = "select id, task_name, application, description, flag from tasks where parent_id = " & rs("id") & " order by order_id desc, id" set rs1 = Server.CreateObject("ADODB.Recordset") rs1.Open sql, conn, 3 While Not rs1.EOF If rs1("flag") = 0 Then str_color = "#000000" Else str_color = "#FF0000" End If %> <% rs1.MoveNext Wend rs.MoveNext Wend %>
任务名 应用程序 描述 操作
<%=formatHtml(rs("task_name"))%> <%=formatHtml(rs("application"))%>  <%=formatHtml(rs("description"))%>  "> " onClick="return do_delete('确定要删除任务吗?');">
  <%=formatHtml(rs1("task_name"))%> <%=formatHtml(rs1("application"))%>  <%=formatHtml(rs1("description"))%>  "> " onClick="return do_delete('确定要删除任务吗?');">
<% Set rs = Nothing Set rs1 = Nothing Set conn = Nothing Response.End End Function Function new_task() beginAdminHtml() %> <%beginAdminTitle("系统管理 > 任务管理 > 添加任务")%>
任务信息
 任务:
 应用程序:
 描述:
 所属任务:
 排序: (数值越大,排名越靠前;默认值为100)
 当前状态: 冻结
<% Set rs = Nothing Set conn = Nothing Response.End End Function Function add_task Dim task_name, application, description, flag Dim parent_id, order_id task_name = Request("task_name") application = Request("application") description = Request("description") parent_id = Request("parent_id") order_id = Request("order_id") description = Request("description") flag = Request("flag") If task_name = "" Then goBack("任务不能为空,请重新输入!") End If If strLength(task_name) > 50 Then goBack("任务不能超过20个字符,请重新输入!") End If sql = "select id from tasks where task_name = '" & replaceSQLString(task_name) & "'" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 3 If Not (rs.BOF And rs.EOF) Then goBack("该任务已存在,请使用其它名称!") End If If strLength(application) > 100 Then goBack("应用程序不能超过100个字符,请重新输入!") End If If strLength(description) > 200 Then goBack("描述不能超过200个字符,请重新输入!") End If If Not isNumeric(parent_id) Then parent_id = 0 End If parent_id = CLng(parent_id) If Not isNumeric(order_id) Then order_id = 100 End If order_id = CLng(order_id) If flag <> "0" And flag <> "1" Then flag = 0 End If If Not isNumeric(flag) Then flag = 0 End If flag = CLng(flag) sql = "insert into tasks (task_name, application, description, parent_id, order_id, flag) values ('" &_ replaceSQLString(task_name) & "', '" & replaceSQLString(application) & "', '" & replaceSQLString(description) & "', " &_ parent_id & ", " & order_id & ", " & flag & ")" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 2, 1 Set rs = Nothing list_task() End Function Function modify_task Dim id id = Request("id") If Not isNumeric(id) Then goBack("输入错误!") End If id = CLng(id) sql = "select id, task_name, application, description, parent_id, order_id, flag from tasks where id = " & id Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 3 If rs.BOF And rs.EOF Then goBack("该任务不存在!") End If beginAdminHtml() %> <%beginAdminTitle("系统管理 > 任务管理 > 修改任务")%>
">
任务信息
 任务: ">
 应用程序: ">
 描述: " size="40">
 所属任务:
 排序: "> (数值越大,排名越靠前;默认值为100)
 当前状态: <% If rs("flag") = 0 Then %> 冻结 <% Else %> 冻结 <% End If %>
<% Set rs = Nothing Set rs1 = Nothing Set conn = Nothing Response.End End Function Function update_task Dim task_name, application, description, flag Dim parent_id, order_id, id id = Request("id") task_name = Request("task_name") application = Request("application") description = Request("description") parent_id = Request("parent_id") order_id = Request("order_id") description = Request("description") flag = Request("flag") If Not isNumeric(id) Then goBack("输入错误!") End If id = CLng(id) If task_name = "" Then goBack("任务不能为空,请重新输入!") End If If strLength(task_name) > 50 Then goBack("任务不能超过20个字符,请重新输入!") End If sql = "select id from tasks where id = " & id Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 3 If rs.BOF And rs.EOF Then goBack("该任务不存在!") End If sql = "select id from tasks where task_name = '" & replaceSQLString(task_name) & "' and id <>" & id Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 3 If Not (rs.BOF And rs.EOF) Then goBack("该任务已存在,请使用其它名称!") End If If strLength(application) > 100 Then goBack("应用程序不能超过100个字符,请重新输入!") End If If strLength(description) > 200 Then goBack("描述不能超过200个字符,请重新输入!") End If If Not isNumeric(parent_id) Then parent_id = 0 End If parent_id = CLng(parent_id) If Not isNumeric(order_id) Then order_id = 100 End If order_id = CLng(order_id) If flag <> "0" And flag <> "1" Then flag = 0 End If If Not isNumeric(flag) Then flag = 0 End If flag = CLng(flag) If parent_id = id Then parent_id = 0 End If sql = "update tasks set task_name = '" & replaceSQLString(task_name) & "', application = '" & replaceSQLString(application) & "', description = '" & replaceSQLString(description) & "', parent_id = " & parent_id & ", order_id = " & order_id & ", flag = " & flag & " where id = " & id Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 2, 1 Set rs = Nothing list_task() End Function Function delete_task Dim id id = Request("id") If Not isNumeric(id) Then goBack("删除失败,输入错误!") End If id = CLng(id) sql = "select id from tasks where id = " & id Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 3 If rs.BOF And rs.EOF Then goBack("删除失败,该任务不存在!") End If sql = "delete from admin_task where task_id = " & id Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 2, 1 sql = "delete from tasks where id = " & id Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 2, 1 Set rs = Nothing list_task() End Function %>