<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.BaseFunCls.asp"-->
<!--#include file="../HSK_Cls/HSK.AdministratorCls.asp"-->
<!--#include file="../HSK_Cls/HSK.UpFileCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%

Dim KSCls
Set KSCls = New Admin_EnterPrise
KSCls.HSK_Run()
Set KSCls = Nothing

Class Admin_EnterPrise
        Private KS,Param,KSCls
		Private Action,i,strClass,sFileName,RS,SQL,maxperpage,CurrentPage,totalPut,TotalPageNum
        Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		End Sub

		Public Sub HSK_Run()
		 With Response
			  .Write "<html>"
			  .Write"<head>"
			  .Write"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
			  .Write"<link href=""Include/Admin_Style.CSS"" rel=""stylesheet"" type=""text/css"">"
			  .Write "<script src=""../HSK_JS/common.js"" language=""JavaScript""></script>"
			  .Write "<script src=""../HSK_JS/jquery.js"" language=""JavaScript""></script>"
			  .Write"</head>"
			  .Write"<body leftmargin=""0"" topmargin=""0"" marginwidth=""0"" marginheight=""0"">"
			  .Write "<ul id='menu_top'>"
			  .Write "<li class='parent' onclick=""window.parent.frames['BottomFrame'].location.href='Split.asp?OpStr='+escape('团购系统 >> <font color=red>添加团购主题</font>')+'&ButtonSymbol=GOSave';location.href='?action=Add';""><span class=child onmouseover=""this.parentNode.className='parent_border'"" onMouseOut=""this.parentNode.className='parent'""><img src='images/ico/a.gif' border='0' align='absmiddle'>添加团购</span></li>"
			  .Write "<li class='parent' onclick=""location.href='GroupBuyInt.asp';""><span class=child onmouseover=""this.parentNode.className='parent_border'"" onMouseOut=""this.parentNode.className='parent'""><img src='images/ico/move.gif' border='0' align='absmiddle'>兴趣活动分类管理</span></li>"
			  .Write "<li style='margin-left:30px;margin-top:10px'><strong>查看方式:</strong><a href=""GroupBuy.asp"">所有团购</a> <a href=""GroupBuy.asp?flag=1"">进行中的团购</a>  <a href=""GroupBuy.asp?flag=2"">已结束的团购</a> <a href=""GroupBuy.asp?flag=3"">已锁定的团购</a></li>"

			  .Write "</ul>"
		End With
		
		   	 If Not KS.ReturnPowerResult(0, "M530001") Then          '检查是权限
					 Call KS.ReturnErr(1, "")
					 .End
			 End If

		maxperpage = 30 '###每页显示数
		If Not IsNumeric(Request("page")) And Len(Request("page")) <> 0 Then
			Response.Write ("错误的系统参数!请输入整数")
			Response.End
		End If
		If Not IsEmpty(Request("page")) And Len(Request("page")) <> 0 Then
			CurrentPage = CInt(Request("page"))
		Else
			CurrentPage = 1
		End If
		If CInt(CurrentPage) = 0 Then CurrentPage = 1
		
		Param=" where 1=1"
		If KS.G("KeyWord")<>"" Then
		  If KS.G("condition")=1 Then
		   Param= Param & " and Subject like '%" & KS.G("KeyWord") & "%'"
		  Else
		   Param= Param & " and Intro like '%" & KS.G("KeyWord") & "%'"
		  End If
		End If
		If KS.G("Flag")<>"" Then
		  If KS.G("Flag")="1" Then Param=Param & " and locked=0 and endtf=0"
		  If KS.G("Flag")="2" Then Param=Param & " and endtf=1"
		  If KS.G("Flag")="3" Then Param=Param & " and locked=1"
		  
		End If

		totalPut = Conn.Execute("Select Count(id) From KS_GroupBuy " & Param)(0)
		TotalPageNum = CInt(totalPut / maxperpage)  '得到总页数
		If TotalPageNum < totalPut / maxperpage Then TotalPageNum = TotalPageNum + 1
		If CurrentPage < 1 Then CurrentPage = 1
		If CurrentPage > TotalPageNum Then CurrentPage = TotalPageNum
		Select Case KS.G("action")
		 Case "Add","Edit" 
		    Call SubjectManage()
		 Case "EditSave" Call DoSave()
		 Case "Del"  
		    Call BlogDel()
		 Case "lock"  
		  Call BlogLock()
		 Case "unlock"  
		   Call BlogUnLock()
		 Case "recommend"  
		   Call Blogrecommend()
		 Case "Cancelrecommend" 
		   Call BlogCancelrecommend()
		 Case Else
		  Call showmain
		End Select
End Sub

Private Sub showmain()
%>
<table width="100%" border="0" align="center" cellspacing="0" cellpadding="0">
<tr height="25" align="center" class='sort'>
	<td width='5%' nowrap>选择</th>
	<td nowrap>团购主题</th>
	<td nowrap>团购发布时间</th>
	<td nowrap>团购商品</th>
	<td nowrap>报名情况(人)</th>
	<td nowrap>团购状态</th>
	<td nowrap>管理操作</th>
</tr>
<%
	sFileName = "GroupBuy.asp?"
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "select * from KS_GroupBuy " & Param & " order by id desc"
	If DataBaseType = 1 Then
		If CurrentPage > 100 Then
			Rs.Open SQL, Conn, 1, 1
		Else
			Set Rs = Conn.Execute(SQL)
		End If
	Else
		Rs.Open SQL, Conn, 1, 1
	End If
	If Rs.bof And Rs.EOF Then
		Response.Write "<tr><td height=""25"" align=center bgcolor=""#ffffff"" colspan=7>还没有添加任何团购信息！</td></tr>"
	Else
		If TotalPageNum > 1 then Rs.Move (CurrentPage - 1) * maxperpage
		i = 0
%>
<form name=selform method=post action=?action=Del>
<%
	Do While Not Rs.EOF And i < CInt(maxperpage)
		If Not Response.IsClientConnected Then Response.End
		
%>
<tr height="25" class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'">
	<td align="center" class="splittd"><input type=checkbox name=ID value='<%=rs("id")%>'></td>
	<td  class="splittd"><%=Rs("Subject")%>
	</td>
	<td align="center" class="splittd"><%=Rs("adddate")%></td>
	<td align="center" class="splittd"><a href="#" onclick="javascript:window.parent.frames['BottomFrame'].location.href='Split.asp?OpStr='+escape('团购系统 >> <font color=red>查看商品</font>')+'&ButtonSymbol=Disabled';location.href='GroupBuyPro.asp?subjectid=<%=RS("ID")%>'">查看</a> <a href="#" onclick="javascript:window.parent.frames['BottomFrame'].location.href='Split.asp?OpStr='+escape('团购系统 >> <font color=red>添加商品</font>')+'&ButtonSymbol=GOSave';location.href='GroupBuyPro.asp?action=Add&subjectid=<%=RS("ID")%>'">添加商品</a></td>
	<td align="center" class="splittd">
	 <span style="color:red;font-weight:bold"><%=LFCls.GetSingleFieldValue("Select Count(*) From KS_GroupBuyBM Where SubjectID=" & RS("ID"))%></span>
	(<a href="#" onclick="javascript:window.parent.frames['BottomFrame'].location.href='Split.asp?OpStr='+escape('团购系统 >> <font color=red>查看报名</font>')+'&ButtonSymbol=Disabled';location.href='GroupBuyBm.asp?subjectid=<%=RS("ID")%>'">查看</a>)
	
	</td>
	<td align="center" class="splittd"><%
	
	if rs("locked")=0 and rs("endtf")=0 then
	 response.write "<font color=red>进行中</font>"
	else
		if rs("locked")=1 then
		  response.write "<font color=blue>锁定</font>"
		end if
		if rs("endtf")=1 then
		  response.write " <font color=#cccccc>已结束</font>"
		end if
	end if
	%></td>
	<td align="center" class="splittd"><a href="?action=Edit&ID=<%=RS("ID")%>"  onclick="window.parent.frames['BottomFrame'].location.href='Split.asp?OpStr='+escape('团购系统 >> <font color=red>修改团购信息</font>')+'&ButtonSymbol=GOSave';">修改</a> <a href="?Action=Del&ID=<%=rs("id")%>" onclick="return(confirm('确定删除该团购吗？'));">删除</a> 
	
	&nbsp;<%if rs("locked")=0 then%><a href="?Action=lock&id=<%=rs("id")%>">锁定</a><%else%><a href="?Action=unlock&id=<%=rs("id")%>">解锁</a><%end if%>
		
		&nbsp;<%IF rs("endtf")="1" then %><a href="?Action=Cancelrecommend&id=<%=rs("id")%>"><font color=red>打开</font></a><%else%><a href="?Action=recommend&id=<%=rs("id")%>">结束</a><%end if%>

	</td>
</tr>
<%
		Rs.movenext
			i = i + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close:Set Rs = Nothing
%>
<tr>
	<td class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'" height='25' colspan=7>
	&nbsp;&nbsp;<input id="chkAll" onClick="CheckAll(this.form)" type="checkbox" value="checkbox"  name="chkAll">全选
	<input class=Button type="submit" name="Submit2" value=" 删除选中的团购主题 " onclick="{if(confirm('此操作不可逆，确定要删除选中的记录吗?')){this.document.selform.submit();return true;}return false;}"></td>
</tr>
</form>
<tr>
	<td  colspan=7 align=right>
	<%
	 Call KSCLS.ShowPage(totalPut, MaxPerPage, "GroupBuy.asp", True, "个", CurrentPage, KS.QueryParam("page"))
	%></td>
</tr>
</table>
<div>
<form action="GroupBuy.asp" name="myform" method="get">
   <div style="border:1px dashed #cccccc;margin:3px;padding:4px">
      &nbsp;<strong>快速搜索=></strong>
	 &nbsp;关键字:<input type="text" class='textbox' name="keyword">&nbsp;条件:
	 <select name="condition">
	  <option value=1>按团购主题</option>
	  <option value=2>按团购介绍</option>
	 </select>
	  &nbsp;<input type="submit" value="开始搜索" class="button" name="s1">
    </div>
</form>
</div>
<%
End Sub

Sub SubjectManage()
Dim Subject,ActiveDate,ActiveTime,AddDate,Address,BusRoute,Telphone,Intro,Highlights,Protection,BuyFlow,Notes,Locked,EndTF,PhotoUrl,TypeName,AllowBMFlag,AllowArrGroupID
Dim ID:ID=KS.ChkClng(KS.G("ID"))
Dim RS:Set RS=server.createobject("adodb.recordset")
If KS.G("Action")="Edit" Then
	RS.Open "Select * From KS_GroupBuy Where ID=" & ID,conn,1,1
	 If RS.Eof And RS.Bof Then
	  RS.Close:Set RS=Nothing
	  Response.Write "<script>alert('参数传递出错！');history.back();</script>"
	  Response.End
	 Else
	   Subject=RS("Subject")
	   ActiveDate=RS("ActiveDate")
	   ActiveTime=RS("ActiveTime")
	   AddDate=RS("AddDate")
	   Address=RS("Address")
	   BusRoute=RS("BusRoute")
	   Telphone=rs("Telphone")
	   Intro=RS("Intro")
	   PhotoUrl=RS("PhotoUrl")
	   If PhotoUrl="" Or IsNull(PhotoUrl) Then PhotoUrl="../images/nophoto.gif"
	   Highlights=RS("Highlights")
	   Protection=RS("Protection")
	   TypeName=RS("TypeName")
	   BuyFlow=RS("BuyFlow")
	   Notes=RS("Notes")
	   Locked=RS("Locked")
	   EndTF=RS("EndTF")
	   AllowArrGroupID=RS("AllowArrGroupID")
	   AllowBMFlag=RS("AllowBMFlag")
	 End If
Else
  AllowBMFlag=0
  AddDate=Now
  ActiveDate=Now+10
  Locked=0:EndTF=0
  Intro=" "
  PhotoUrl="../images/nophoto.gif"
 End If
%>
<script>
function CheckForm()
{
	if ($('#Subject').val()=='')
	{
	 alert('请输入团购主题!');
	 $("#Subject").focus();
	 return false;
	}
	if ($('#Address').val()=='')
	{
	 alert('请输入活动地点!');
	 $("#Address").focus();
	 return false;
	}
	if ($('#Telphone').val()=='')
	{
	 alert('请输入咨询热线!');
	 $("#Telphone").focus();
	 return false;
	}
	if (CKEDITOR.instances.Intro.getData()=="")
	{
	 alert('请输入活动介绍!');
	 CKEDITOR.instances.Intro.focus();
	 return false;
	}
document.myform.submit();
}
</script>
<br>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="ctable">
 <form name="myform" action="?action=EditSave" method="post" enctype="multipart/form-data">
   <input type="hidden" value="<%=ID%>" name="id">
   <input type="hidden" value="<%=request.servervariables("http_referer")%>" name="comeurl">
          <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>团购主题：</strong></td>
           <td width="435" height='30'>&nbsp;<input type='text' name='Subject' id='Subject' value='<%=Subject%>' size="40"> <font color=red>*</font></td>
           <td width="217" rowspan="6" align="center"><div id="pic" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);height:100px;width:95px;border:1px solid #777777">
						<img src="<%=PhotoUrl%>" style="height:100px;width:95px;">
		    </div></td>
          </tr>  
          <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td height='30' align='right' class='clefttitle'><strong>团购分类：</strong></td>
            <td height='30'>&nbsp;<input type='text' name='TypeName' id='TypeName' value='<%=TypeName%>' size="20" />
              << <select name='sUnit' onchange="$('TypeName').value=this.value;">"
		 <option value=''>请选择</option>"
		<%Response.Write KSCls.Get_O_F_D("KS_GroupBuy","Distinct Top 20 TypeName","TypeName<>'' Group by TypeName")%>
		</select>如:家电团购,汽车团购等</td>
          </tr>
          <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>活动日期：</strong></td>
            <td height='30'>&nbsp;<select name="ActiveDate1">
                               <%
					  for i=year(now) to year(now)+1
					   if trim(year(ActiveDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "年</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "年</option>"
					   end if
					  next
					  %>
                    </select>
							 
                             <select name="ActiveDate2">
                               <%
					  for i=1 to 12
					   if trim(month(ActiveDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "月</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "月</option>"
					   end if
					  next
					  %>
                             </select>
                             <select name="ActiveDate3">
                               <%
					  for i=1 to 31
					   if trim(day(ActiveDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "日</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "日</option>"
					   end if
					  next
					  %>
                             </select>                           </td>
          </tr> 
		  
          <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td height='30' align='right' class='clefttitle'><strong>活动时间：</strong></td>
            <td height='30'>&nbsp;<input type='text' name='ActiveTime' value='<%=ActiveTime%>' size="40" /> 
            如9:00-12:00 </td>
          </tr>
          <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>发布时间：</strong></td>
            <td height='30'>&nbsp;<select name="AddDate1">
                               <%
					  for i=year(now) to year(now)+1
					   if trim(year(AddDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "年</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "年</option>"
					   end if
					  next
					  %>
                    </select>
							 
                             <select name="AddDate2">
                               <%
					  for i=1 to 12
					   if trim(month(AddDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "月</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "月</option>"
					   end if
					  next
					  %>
                             </select>
                             <select name="AddDate3">
                               <%
					  for i=1 to 31
					   if trim(day(AddDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "日</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "日</option>"
					   end if
					  next
					  %>
                             </select>
                             <select name="AddDate4">
                               <%
					  for i=0 to 23
					   if trim(hour(AddDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "时</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "时</option>"
					   end if
					  next
					  %>
                             </select>
                             <select name="AddDate5">
                               <%
					  for i=0 to 59
					   if trim(minute(AddDate))=trim(i) then
					   response.write "<option value=" & i & " selected>" & i & "分</option>"
					   else
					   response.write "<option value=" & i & ">" & i & "分</option>"
					   end if
					  next
					  %>
                           </select>						   </td>
          </tr> 
		  
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
		     <td height='30' align='right' class='clefttitle'><strong>封面图片：</strong></td>
		     <td height='30'><input class="textbox" type="file" name="photo" size="40" onchange='document.getElementById(&quot;pic&quot;).innerHTML=&quot;&quot;;document.getElementById(&quot;pic&quot;).filters.item(&quot;DXImageTransform.Microsoft.AlphaImageLoader&quot;).src=this.value;' />
               <font color="red">*</font> <br />
             &nbsp;&nbsp;<font color="blue">请上传少于200K的图片,支持jpg,gif,png格式</font></td>
  </tr>
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>活动地点：</strong></td>
           <td height='30' colspan="2">&nbsp;<input type='text' name='Address' id='Address' value='<%=Address%>' size="40"> <font color=red>*</font></td>
          </tr>  
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>公交路线：</strong></td>
           <td height='30' colspan="2">&nbsp;<input type='text' name='BusRoute' value='<%=BusRoute%>' size="40"> </td>
          </tr>  
 
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>咨询热线：</strong></td>
           <td height='30' colspan="2">&nbsp;<input type='text' name='Telphone' id='Telphone' value='<%=Telphone%>' size="40"><font color=red>*</font></td>
          </tr>  
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>团购活动简介：</strong></td>
           <td height='30' colspan="2"><%			
		    Response.Write "<textarea id=""Intro"" name=""Intro"" style=""display:none"">" &  KS.HTMLCode(Intro) &"</textarea>"
			%>	
			<script type="text/javascript" src="../editor/ckeditor.js" mce_src="../editor/ckeditor.js"></script>
			<script type="text/javascript">
             CKEDITOR.replace('Intro', {width:"98%",height:"160px",toolbar:"Basic",filebrowserBrowseUrl :"Include/SelectPic.asp?from=ckeditor&Currpath=<%=KS.GetUpFilesDir()%>",filebrowserWindowWidth:650,filebrowserWindowHeight:290});
			 </script> 
			</td>
          </tr>
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>活动亮点：</strong></td>
           <td height='30' colspan="2">&nbsp;<textarea name='Highlights' cols="60" rows="4"><%=Highlights%></textarea></td>
          </tr>  
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>团购保障：</strong></td>
           <td height='30' colspan="2">&nbsp;<textarea name='Protection' cols="60" rows="4"><%=Protection%></textarea></td>
          </tr>  
		   <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>团购流程：</strong></td>
           <td height='30' colspan="2">&nbsp;<textarea name='BuyFlow' cols="60" rows="4"><%=BuyFlow%></textarea></td>
          </tr>  
		  <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>团购注意事项：</strong></td>
           <td height='30' colspan="2">&nbsp;<textarea name='Notes' cols="60" rows="4"><%=Notes%></textarea></td>
          </tr>  
		  <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>允许参加报名的权限：</strong></td>
           <td height='30' colspan="2">	    
		    <label><input type="radio" name="AllowBMFlag" value="0"<%if AllowBMFlag=0 then response.write " checked"%>>允许所有人报名参加,包括游客</label><br/>
			<label><input type="radio" name="AllowBMFlag" value="1"<%if AllowBMFlag=1 then response.write " checked"%>>只允许会员报名参加</label>
			<br/><label><input type="radio" name="AllowBMFlag" value="2"<%if AllowBMFlag=2 then response.write " checked"%>>只允许指定的会员组报名参加</label>
			</td>
          </tr>  
		  <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>允许参加报名的会员组：</strong><br/><font color=blue>当上面选择只允许指定的会员组参加时，请在此指定会员组</font></td>
           <td height='30' colspan="2">&nbsp;<%=KS.GetUserGroup_CheckBox("AllowArrGroupID",AllowArrGroupID,5)%>
			</td>
          </tr>  
		  <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>是否锁定：</strong></td>
           <td height='30' colspan="2">&nbsp;
		    <input type="radio" name="locked" value="0"<%if locked=0 then response.write " checked"%>>否
			<input type="radio" name="locked" value="1"<%if locked=1 then response.write " checked"%>>是		   </td>
          </tr>  
		  <tr class="tdbg" onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
            <td  width='296' height='30' align='right' class='clefttitle'><strong>是否结束：</strong></td>
           <td height='30' colspan="2">&nbsp;
		    <input type="radio" name="endtf" value="0"<%if endtf=0 then response.write " checked"%>>否
			<input type="radio" name="endtf" value="1"<%if endtf=1 then response.write " checked"%>>是		   </td>
          </tr>  
		 </table>    
 
<%
End Sub

Sub DoSave()
		  	Dim Fobj:Set FObj = New UpFileClass
			on error resume next
			FObj.GetData
			if err.number<>0 then
			 call ks.alerthistory("出错了,文件超出大小",-1)
			 response.End()
			end if

       Dim ID:ID=KS.ChkClng(Fobj.Form("id"))
	   Dim Subject:Subject=KS.LoseHtml(Fobj.Form("Subject"))
       Dim ActiveDate:ActiveDate=Fobj.Form("ActiveDate1") & "-" & Fobj.Form("ActiveDate2") & "-" & Fobj.Form("ActiveDate3") 
			if not isdate(ActiveDate) then
			 Response.Write "<script>alert('活动日期格式不正确！');history.back();</script>"
			 Exit Sub
			End If	  
       Dim AddDate:AddDate=Fobj.Form("AddDate1") & "-" & Fobj.Form("AddDate2") & "-" & Fobj.Form("AddDate3") & " " & Fobj.Form("AddDate4") & ":" & Fobj.Form("AddDate5")
			if not isdate(AddDate) then
			 Response.Write "<script>alert('发布时间格式不正确！');history.back();</script>"
			 Exit Sub
			End If	 
			
			Dim MaxFileSize:MaxFileSize = 200   '设定文件上传最大字节数
			Dim AllowFileExtStr:AllowFileExtStr = "gif|jpg|png"
			Dim FormPath:FormPath = KS.GetUpFilesDir() & "/groupbuy/"
			Call KS.CreateListFolder(FormPath) 
			Dim ReturnValue:ReturnValue = FObj.UpSave(FormPath,MaxFileSize,AllowFileExtStr,"fm" & right(Year(Now),2) & right("0" & Month(Now),2) & right("0" & Day(Now),2) & right("0"&Hour(Now),2) & right("0"&Minute(Now),2) & right("0"&Second(Now),2))
			Select Case ReturnValue
			  Case "errext" Call KS.AlertHistory("文件上传失败,文件类型不允许\n允许的类型有" + AllowFileExtStr + "\n",-1):exit sub
	          Case "errsize"  Call KS.AlertHistory("文件上传失败,文件超过允许上传的大小\n允许上传 " & MaxFileSize & " KB的文件\n",-1):exit sub
			End Select

	   Dim PhotoUrl:PhotoUrl=ReturnValue


			 
	   Dim Address:Address=KS.LoseHtml(Fobj.Form("Address"))
	   Dim BusRoute:BusRoute=KS.LoseHtml(Fobj.Form("BusRoute"))
	   Dim Telphone:TelPhone=KS.LoseHtml(Fobj.Form("TelPhone"))
	   Dim ActiveTime:ActiveTime=Fobj.Form("ActiveTime")
	   Dim Intro:Intro=Fobj.Form("Intro")
	   Dim Fax:Fax=KS.LoseHtml(Fobj.Form("Fax"))
	   Dim Highlights:Highlights=KS.LoseHtml(Fobj.Form("Highlights"))
	   Dim Protection:Protection=KS.LoseHtml(Fobj.Form("Protection"))
	   Dim BuyFlow:BuyFlow=KS.LoseHtml(Fobj.Form("BuyFlow"))
	   Dim Notes:Notes=KS.LoseHtml(Fobj.Form("Notes"))
	   Dim Locked:Locked=KS.ChkClng(Fobj.Form("Locked"))
	   Dim EndTF:EndTF=KS.ChkClng(Fobj.Form("EndTf"))
	   Dim ComeUrl:ComeUrl=Fobj.Form("ComeUrl")
	   Dim TypeName:TypeName=Fobj.Form("TypeName")
	   Dim AllowBMFlag:AllowBMFlag=KS.ChkClng(Fobj.Form("AllowBMFlag"))
	   Dim AllowArrGroupID:AllowArrGroupID=Fobj.Form("AllowArrGroupID")
	   Set Fobj=Nothing
	   
		
	   If Subject="" Then Response.Write "<script>alert('活动主题必须输入');history.back();</script>":response.end

            Dim RS: Set RS=Server.CreateObject("Adodb.RecordSet")
			  RS.Open "Select top 1 * From KS_GroupBuy Where ID=" & ID,Conn,1,3
			  If RS.Eof And RS.Bof Then
			     RS.AddNEW
			  End If
				 RS("AddDate")=AddDate
				 RS("ActiveTime")=ActiveTime
			     RS("Subject")=Subject
				 RS("ActiveDate")=ActiveDate
				 RS("Address")=Address
				 RS("BusRoute")=BusRoute
				 RS("Telphone")=Telphone
				 RS("Intro")=Intro
				 IF PhotoUrl<>"" Then RS("PhotoUrl")=PhotoUrl
				 RS("Highlights")=Highlights
				 RS("Protection")=Protection
				 RS("BuyFlow")=BuyFlow
				 RS("TypeName")=TypeName
				 RS("Notes")=Notes
				 RS("Locked")=Locked
				 RS("EndTF")=EndTF
				 RS("AllowBMFlag")=AllowBMFlag
				 RS("AllowArrGroupID")=AllowArrGroupID
		 		 RS.Update
				 If ID=0 Then
				   RS.MoveLast
                   Call KS.FileAssociation(1005,RS("ID"),Intro&RS("PhotoUrl"),0)
				 Else
                   Call KS.FileAssociation(1005,ID,Intro&RS("PhotoUrl"),1)
				 End If
				 
			     RS.Close
				 Set RS=Nothing
				 If ID=0 Then
				  Response.Write "<script>if (confirm('团购信息发布成功!')){location.href='?action=Add';}else{parent.frames['BottomFrame'].location.href='Split.asp?ButtonSymbol=Disabled&OpStr=" & Server.URLEncode("团购系统 >> <font color=red>管理首页</font>") & "';location.href='GroupBuy.asp';}</script>"
				 Else
				  Response.Write "<script>alert('团购信息修改成功！');parent.frames['BottomFrame'].location.href='Split.asp?ButtonSymbol=Disabled&OpStr=" & Server.URLEncode("团购系统 >> <font color=red>管理首页</font>") & "';location.href='"& ComeUrl & "';</script>"
				 End If

EnD Sub

'删除
Sub BlogDel()
 Dim ID:ID=KS.G("ID")
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Delete From KS_UploadFiles Where ChannelID=1005 and InfoID In("& id & ")")
 Conn.execute("Delete From KS_UploadFiles Where ChannelID=1006 and InfoID In(select id from KS_GroupBuyPro Where subjectid in("& id & "))")
 Conn.execute("Delete From KS_GroupBuy Where id In("& id & ")")
 Conn.execute("Delete From KS_GroupBuyPro Where subjectid In("& id & ")")
 Conn.execute("Delete From KS_GroupBuyBm Where subjectid In("& id & ")")
 Response.Write "<script>alert('删除成功！');location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub

Sub Blogrecommend()
 Dim ID:ID=KS.G("ID")
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Update KS_GroupBuy Set endtf=1 Where id In("& id & ")")
 Response.Write "<script>location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub
Sub BlogCancelrecommend()
 Dim ID:ID=KS.G("ID")
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Update KS_GroupBuy Set endtf=0 Where id In("& id & ")")
 Response.Write "<script>location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub
'锁定
Sub BlogLock()
 Dim ID:ID=KS.G("ID")
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Update KS_GroupBuy Set locked=1 Where id In("& id & ")")
 Response.Write "<script>location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub
'解锁
Sub BlogUnLock()
 Dim ID:ID=KS.G("ID")
 If ID="" Then Response.Write "<script>alert('对不起，您没有选择!');history.back();</script>":response.end
 Conn.execute("Update KS_GroupBuy Set locked=0 Where id In("& id & ")")
 Response.Write "<script>location.href='" & Request.servervariables("http_referer") & "';</script>"
End Sub

End Class
%> 
