<!--#include file="../../fy.Function.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>content</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 心情指数管理</div>
    <div class="opers">
    	当前心情
    	<a href="?" class="btn<%If request("A")="" Then echo " btn_primary" %>">查看心情</a>
    	<a href="?A=Add" class="btn<%If request("A")="Add" Then echo " btn_primary" %>">添加心情指数</a>
    </div>
   <% 

Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Dim Action,ID,Rs,UploadSize,UploadPath,UnlockTime,FormCode,StartTime,UserGroupList,SubmitNum,i,Status ,EndTime
			 Dim  TitleContent,PicContent
ID = ChkNumeric(Request("ID"))
	If Not fycms.fycms_QXYZ(0,"mood_fy","") Then   Call fycms.Alert("对不起，你没有操作权限！","") 
	Action = Request.QueryString("A")
	 if ID=0 or ID="" Then ID=1
	Select Case Action
		   Case "AddSave","ESave"
		   		Call AddSave()
			Case "Add","E"
				Call AddEdit()
			Case Else
				Call Main()
	End Select
	
	
	IF Action = "Del" Then
			fycms.ACTEXE("Delete From Mood_Plus_fy Where ID=" & ID)		
			Call fycms.ActErr("删除心情成功","Sys_fy/Mood/Index.asp","")
 	End IF
	
	
	Sub AddSave()
		 Dim Title,ModeTable,sql,ChannelRS,ChannelRSSql,ModeNote
		 Title = fycms.S("Title")
 		 UnlockTime = ChkNumeric(fycms.S("UnlockTime"))
		 StartTime = fycms.S("StartTime")
		 EndTime = fycms.S("EndTime")
 		 SubmitNum = ChkNumeric(fycms.S("SubmitNum"))
		 Status = ChkNumeric(fycms.S("Status"))
 		 IF fycms.S("Title") = "" Then
		 	Call fycms.Alert("心情名称为空!",""):Exit Sub
		 End if
		 IF Not IsDate(StartTime) Then StartTime=Now
		 IF Not IsDate(EndTime) Then EndTime=Now+10

		 For i=0 To 14

			TitleContent=TitleContent&fycms.s("Name"&i)&"@&@"

		 Next 


		 For i=0 To 14

			PicContent=PicContent&fycms.s("Pic"&i)&"@&@"

		 Next 

		 
 		 if Action="AddSave" Then
 			 Set ChannelRS = Server.CreateObject("adodb.recordset")
			  ChannelRSSql = "select * from Mood_Plus_fy"
			  ChannelRS.Open ChannelRSSql, Conn, 1, 3
			  ChannelRS.AddNew
 		 Else
		 	If Not fycms.ACTEXE("SELECT Title FROM Mood_Plus_fy Where ID <>" & ID & " AND  Title='" & Title & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该心情名称-!",""):Exit Sub
			 End if	
			 Set ChannelRS = Server.CreateObject("adodb.recordset")
			  ChannelRSSql = "select * from Mood_Plus_fy Where ID=" &ID
			  ChannelRS.Open ChannelRSSql, Conn, 1, 3
			  if ChannelRS.eof then Call fycms.Alert("错误!",""):Exit Sub
		 End if 
		 	  ChannelRS("StartTime") = StartTime
		 	  ChannelRS("EndTime") = EndTime
		 	  ChannelRS("SubmitNum") = SubmitNum
		 	  ChannelRS("UnlockTime") = UnlockTime
			  ChannelRS("Title") = Title
			  ChannelRS("TitleContent") = TitleContent
			  ChannelRS("PicContent") = PicContent
 			  ChannelRS("Status") = Status
		  ChannelRS.Update
		  ChannelRS.Close:Set ChannelRS = Nothing	
		  Call fycms.ActErr("修改成功","Sys_fy/Mood/Index.asp","")
 	End Sub
	Sub Main()%> <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
		<th>心情编号</th>
		<th>心情名称</th>
		<th>是否开始</th>
		<th>参与人数</th>
		<th>状态</th>
		<th>管理操作</th>
 	  </tr>
    </thead>
     <% 
	  Set Rs =fycms.ACTEXE("SELECT * FROM Mood_Plus_fy order by ID desc")
	 If Rs.EOF  Then
	 	echo	"<tr><td colspan=""7"" align=""center"">没有记录</td></tr>"
	 Else
		Do While Not Rs.EOF	
			 %>

  <tr  >
    <td align="center"><%= Rs("ID") %></td>
    <td align="center"><%= Rs("Title") %></td>
    <td align="center">
	<%If now >Rs("StartTime") Then 
		echo "<font color=green title=结束日期是"& Rs("EndTime")&">已经开始</a>"
	Else
		echo "<font color=red title=开始日期是"& Rs("StartTime")&">还没有开始</font>"
	End if%>
	</td>
	<td align="center"><%=fycms.actexe("select Count(id) from Mood_List_fy where MDID="&Rs("ID")&"")(0) %></td>
	<td align="center"><% IF Rs("Status") = 0 Then echo "<font color=green>正常</font>" else  echo "<font color=red>禁用</font>" %></td>
	<td align="center" >
  	 <a href="?A=E&ID=<%=Rs("ID")  %>" >修改</a>   
	<a href="?A=Del&ID=<%=Rs("ID")  %>"  onClick="{if(confirm('确定删除该心情吗?')){return true;}return false;}">删除</a></td>
  </tr>
  <% 
		
		Rs.movenext
		Loop
	End if	 %>
    </table>
 
<% 	
 
	End Sub
	Sub AddEdit()
	Dim FileFolder,ModeTable,Title,FormCode,ModeNote,A,Template,EndTime,StartTime
	if Action="Add" Then
	A="AddSave"
	StartTime=date()
	EndTime=date()+10
  	Status=0
	SubmitNum=1
	TitleContent=Split("支持@&@高兴@&@震惊@&@愤怒@&@无聊@&@无奈@&@谎言@&@枪稿@&@不解@&@标题党@&@@&@@&@@&@@&@@&@","@&@")
	PicContent=Split("images/Plus/xq1.gif@&@images/Plus/xq2.gif@&@images/Plus/xq3.gif@&@images/Plus/xq4.gif@&@images/Plus/xq5.gif@&@images/Plus/xq6.gif@&@images/Plus/xq7.gif@&@images/Plus/xq8.gif@&@images/Plus/xq9.gif@&@images/Plus/xq10.gif@&@images/Plus/xq11.gif@&@images/Plus/xq12.gif@&@images/Plus/xq13.gif@&@images/Plus/xq14.gif@&@images/Plus/xq15.gif@&@","@&@")
	Else
	Set Rs=server.CreateObject("adodb.recordset") 
	Rs.OPen "Select * from Mood_Plus_fy Where ID = "&ID&" order by ID desc",Conn,1,1
		  StartTime= Rs("StartTime")
		  EndTime = Rs("EndTime")
		  SubmitNum = Rs("SubmitNum")
		  UnlockTime = Rs("UnlockTime")
		  Title = Rs("Title")
		  TitleContent = Split(Rs("TitleContent"),"@&@")
		  PicContent = Split(Rs("PicContent"),"@&@")
		  Status = Rs("Status")
 	A="ESave"
	end if
  %>

<form id="form1" name="form1" method="post" action="?A=<%= A %>&ID=<%= Request.QueryString("ID") %>">
    <div class="divtable"> 
        <dl>
            <dt>项目状态</dt>
            <dd>
                <input <% IF Status = 0 Then echo "Checked" %> id="Status1" type="radio" name="Status" value="0" />
     <label for="Status1"> 正常 </label>
      <input <% IF Status = 1 Then echo "Checked" %>  id="Status2" type="radio" name="Status" value="1" /><label for="Status2">关闭</label>     
            </dd>
         </dl>
        
        <dl>
            <dt>项目名称：</dt>
            <dd>
               <input name="Title"   class="Ainput"  type="text" id="Title" value="<%=Title %>" />
             </dd>
         </dl>
 
        <dl>
            <dt>选项：</dt>
            <dd>
               
<%For i=0 To 14

If i<9 Then echo "0"

%>


<%=i+1%>、名称
<input type="text" value="<%=TitleContent(i)%>" name="Name<%=i%>" class="Ainput">
图片地址
<input type="text" name="Pic<%=i%>" value="<%=PicContent(i)%>" class="Ainput">
<br>
<%Next %>
             </dd>
         </dl>
 
        <dl>
            <dt>启用时间限制：</dt>
            <dd>
               <input onClick=time(1)     <% IF UnlockTime = 0 Then echo "Checked" %> id="UnlockTime1" type="radio" name="UnlockTime" value="0">
        <label for="UnlockTime1">启用</label>
      <input  onClick=time(2)    <% IF UnlockTime = 1 Then echo "Checked" %> id="UnlockTime2"  type="radio" name="UnlockTime" value="1"> 
     <label for="UnlockTime2">不启用</label>
             </dd>
         </dl>
 
        <dl  id="times1"
	<%If UnlockTime<>1 Then echo "style=""DISPLAY: none"""%>>
            <dt>开始时间：</dt>
            <dd>
               <input  class="Ainput"  size=30 name="StartTime" type="text" id="StartTime" value="<%= StartTime %>"  onClick="WdatePicker();" />
             </dd>
         </dl>
 
        <dl id="times2"
	<%If UnlockTime<>1 Then echo "style=""DISPLAY: none"""%>>
            <dt>结束时间：</dt>
            <dd>
               <input  class="Ainput"   size=30  name="EndTime" type="text" id="EndTime" value="<%= EndTime %>"  onClick="WdatePicker();"/>
             </dd>
         </dl>
 
        <dl>
            <dt>每个用户只允许提交一次：</dt>
            <dd>
                 <input  <% IF SubmitNum = 1 Then echo "Checked" %> id="SubmitNum1" type="radio" name="SubmitNum" value="1">
        <label for="SubmitNum1">是</label>
      <input  <% IF SubmitNum = 0 Then echo "Checked" %> id="SubmitNum2"  type="radio" name="SubmitNum" value="0"> 
     <label for="SubmitNum2">否</label>
             </dd>
         </dl>
 
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
 				<input class="btn" type="reset" name="Submit2" value="重置">
            </dd>
         </dl>
        
    </div>
    </form>







 
<script language="javascript">time(<%=""""&UnlockTime&""""%>);</script>

<% end sub  %>

<script language="JavaScript" type="text/javascript">
 
		
function time(n){
	if (n == 2){
		times1.style.display='none';
		times2.style.display='none';
	}
	else{
		times1.style.display='';
		times2.style.display='';
	}
} 

 
function CheckForm()
{ var form=document.form1;
	
	 if (form.Title.value=='')
		{ alert("请输入项目名称!");   
		  form.Title.focus();    
		   return false;
		} 
 	    form.submit();
        return true;
	}
</script>




</div>
</body>
</html>
