<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
Call chkFlag(14)
Dim act
act=Trim(Request.QueryString("act"))
Opendb
Select Case act
Case "add","modi"
  Call Add()
Case "save"
  Call saves()
Case "del"
  Call del()
Case Else
  Call Main()
End Select
Closedb

Sub saves()
   dim Incentive,FenZ,id
   id=clng(Request.QueryString("id"))
   Incentive=Trim(Request.Form("Incentive"))
   FenZ=Trim(Request.Form("FenZ"))
   
   IF Incentive="" or not isnumeric(FenZ) Then
      Call SendMsg("请正确填写项目和分值")
	  Response.Write("<script>setTimeout(""history.go(-1);"",2000);</script>")
	  Response.End()
   Else
	   IF id>0 then
		  Conn.execute("Update "&predb&"Incentive set Incentive='"&Incentive&"',FenZ="&FenZ&" where id="&id)
		  
		  Call SendMsg("恭喜，修改成功！")
		  Response.Write("<script>setTimeout(""location.href='?act=modi&id="&id&"';"",2000);</script>")
	   Else
		  Conn.execute("insert into "&predb&"Incentive(Incentive,FenZ) values('"&Incentive&"',"&FenZ&")")
		  
		  Call SendMsg("恭喜，添加成功！")
		  Response.Write("<script>setTimeout(""location.href='?act=add';"",2000);</script>")
	   End IF
   End IF
End sub

Sub del()
   dim id
   id=clng(Request.QueryString("id"))
   Conn.execute("delete from "&predb&"Incentive where id="&id)
   
   Call SendMsg("恭喜，删除成功！")
   Response.Write("<script>setTimeout(""location.href='?';"",2000);</script>")
End sub

Sub Add()
dim id,rs,Incentive,FenZ
id=clng(Request.QueryString("id"))
IF id>0 Then
   set rs=conn.execute("select * from "&predb&"Incentive where id="&id)
   Incentive=rs("Incentive")
   FenZ=rs("FenZ")
   set rs=nothing
End IF
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="2" align="left">奖惩项目设置</th>
  </tr>
  <form action="?act=save&id=<%= id %>" method="post">
  <tr>
    <td width="28%" align="right" class="TableRow1"><strong>项目名称：</strong></td>
    <td width="72%" class="TableRow1"><input type="text" name="Incentive" id="Incentive" value="<%= Incentive %>">
    &nbsp; <font color="#FF0000">*</font></td>
  </tr>
  <tr>
    <td align="right" class="TableRow2"><strong>增减分值：</strong></td>
    <td class="TableRow2"><input name="FenZ" type="text" id="FenZ" size="8" value="<%= FenZ %>">
    &nbsp; <font color="#FF0000">*</font> 减分就在数字前填写 “-”</td>
  </tr>
  <tr>
    <td class="TableRow1">&nbsp;</td>
    <td class="TableRow1"><input type="submit" name="button" id="button" value=" <% If id>0 Then %>修 改<% Else %>添 加<% End If %> ">
      &nbsp;<input type="button" name="button4" id="button4" value=" 取 消 " onClick="location.href='?'"></td>
  </tr>
  </form>
</table>
<%
End Sub

Sub Main()
Dim rs,i,c
Set rs=conn.execute("select * from "&predb&"Incentive")
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="4" align="left">奖惩项目设置</th>
  </tr>  
  <tr>
    <td align="center" class="TableRow1"><strong>ID</strong></td>
    <td align="center" class="TableRow1"><strong>项目名称</strong></td>
    <td align="center" class="TableRow1"><strong>增减分值</strong></td>
    <td align="center" class="TableRow1"><strong>管理</strong></td>
  </tr>
<%
do while not rs.eof
i=i+1
if i mod 2=0 then
  c=1
else
  c=2
end if
%>
  <tr>
    <td width="8%" align="center" class="TableRow<%= c %>"><b><%= rs("id") %></b></td>
    <td width="58%" class="TableRow<%= c %>"><%= rs("Incentive") %></td>
    <td width="18%" align="center" class="TableRow<%= c %>"><%= rs("fenz") %></td>
    <td width="16%" align="center" class="TableRow<%= c %>"><a href="?act=modi&id=<%= rs("id") %>">修改</a>&nbsp; <a href="?act=del&id=<%= rs("id") %>" onClick="return confirm('请确认删除么？');">删除</a></td>
  </tr>
<%
rs.movenext
loop
set rs=nothing
%>
  <tr>
    <td colspan="4" class="TableRow1"><input type="button" name="button2" id="button2" value="增加新项目" onClick="location.href='?act=add'"></td>
  </tr>
</table>
<% End Sub %>
<br>
</body>
</html>
