<!--#include file="../Inc/conn.asp"-->
<!--#include file="../Inc/saveimage.asp"-->
<!--#include file="../Inc/Function_Page1.asp"-->
<!--#include file="Admin_check.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equtv="Content-Type" content="text/html; charset=gb2312" />
<title>网站后台管理</title>
<link href="images/Admin_css.css" type=text/css rel=stylesheet>
<link rel="shortcut icon" href="<%=SitePath%>images/myfav.ico" type="image/x-icon" />
<script src="js/admin.js"></script>
<SCRIPT src="<%=SitePath%>inc/Ajax.js" language="javascript"></SCRIPT>
<script language="JavaScript" src="js/Jquery.js"></script>
</head>

<body>
<script language=javascript>
function CheckForm()
{
  if (document.myform.Title.value==""){
	alert("请填写标题！");
	document.myform.Title.focus();
	return false;
  }
}
</script>
<%
	if request("action") = "add" then
		call add()
	elseif request("action")="edit" then
		call edit()
	elseif request("action")="savenew" then
		call savenew()
	elseif request("action")="savedit" then
		call savedit()
	elseif request("action")="yn1" then
		call yn1()
	elseif request("action")="yn2" then
		call yn2()
	elseif request("action")="del" then
		call del()
	elseif request("action")="delAll" then
		call delAll()
	else
		call List()
	end if

sub List()
%>
<form name="myform" id="myform" method="POST" action="Admin_Product.asp?action=delAll">
<table width="95%" border="0"  align=center cellpadding="3" cellspacing="1" bgcolor="#F2F9E8" class="admintable">
<tr>
  <td colspan="5" align=left class="admintitle">商品列表　[<a href="?action=add">添加</a>]</td></tr>
    <tr bgcolor="#f1f3f5" style="font-weight:bold;">
    <td width="5%" height="30" align="center" class="ButtonList">&nbsp;</td>
    <td width="53%" align="center" class="ButtonList">商品名称</td>
    <td width="20%" height="25" align="center" class="ButtonList">发布时间</td>
    <td width="7%" height="25" align="center" class="ButtonList">浏览次数</td>
    <td width="15%" height="25" align="center" class="ButtonList">管理</td>
    </tr>
<%
Set mypage=new xdownpage
mypage.getconn=conn
mysql="select * from "&tbname&"_shop"
mysql=mysql&" order by "
mysql=mysql&"ID desc"
mypage.getsql=mysql
mypage.pagesize=15
set rs=mypage.getrs()
for i=1 to mypage.pagesize
    if not rs.eof then
%>
    <tr bgcolor="#ffffff" onMouseOver="this.style.backgroundColor='#EAFCD5';" onMouseOut="this.style.backgroundColor='';this.style.color=''">
    <td height="25" align="CENTER"><input type="checkbox" value="<%=rs(0)%>" name="ID" onClick="unselectall(this.form)" style="border:0;"></td>
    <td height="25"><a href="<%=SitePath%><%If html=3 then Response.Write("cp_"&rs(0)&".html") else Response.Write("cp.asp?ID="&rs(0)&"") End if%>" target="_blank"><%=rs(1)%></a></td>
    <td height="25" align="center"><%=rs(3)%></td>
    <td height="25" align="center"><%=rs(4)%></td>
    <td align="center"><a href="?action=edit&id=<%=rs(0)%>&page=<%=page%>">编辑</a></td>
    </tr>
<%
        rs.movenext
    else
         exit for
    end if
next
%>
<tr><td align="center" bgcolor="f7f7f7"><input name="Del" type="submit" class="bnt" id="Del" value="删除"></td>
  </tr><tr><td bgcolor="f7f7f7" colspan="5">
<div id="page">
	<ul style="text-align:left;">
    <%=mypage.showpage()%>
    </ul>
</div>
</td></tr></table>
</form>
<%
	rs.close
	set rs=nothing
end sub

sub add()
%>
<table width="95%" border="0"  align=center cellpadding="3" cellspacing="2" bgcolor="#FFFFFF" class="admintable">
<form onSubmit="return CheckForm();" action="?action=savenew" name="myform" method=post>
<tr>
    <td colspan="2" align=left class="admintitle">添加产品</td></tr>
<tr>
<td width="20%" class="b1_1">商品名称</td>
<td class="b1_1"><input name="Title" type="text" id="Title" size="40" maxlength="50" onBlur="CheckName();" onChange="CheckName();"></td>
</tr>
<tr>
  <td class="b1_1">市场价格</td>
  <td class="b1_1">
    <input name="price" type="text" id="price" size="10" maxlength="200">元</td>
</tr>
<tr>
  <td class="b1_1">本站价格</td>
  <td class="b1_1"><input name="sprice" type="text" id="sprice" size="10" maxlength="200">元</td>
</tr>
<tr>
  <td class="b1_1">分类</td>
  <td class="b1_1">
  <select ID="ClassID" name="ClassID">
  	<option value="" selected="selected">选择商品分类</option>
  	<%
	set rs1=server.createobject("ADODB.Recordset")
	sql1="select * from "&tbname&"_leixing order by ID desc"
	rs1.open sql1,conn,1,3
	If Not rs1.Eof Then
	do while not (rs1.eof or err)
	%>
    <option value="<%=rs1("ID")%>"><%=rs1("Title")%></option>
	<%
	rs1.movenext
	loop
	end if
	rs1.close
	set rs1=nothing
	%>
    </select>
	</td>
</tr>
<tr>
  <td class="b1_1">浏览次数</td>
  <td class="b1_1"><input name="Hits" type="text" id="Hits" value="0" size="6" maxlength="10"></td>
</tr>
<tr>
  <td rowspan="2" class="b1_1">图片上传</td>
  <td class="b1_1"><input name="Images" type="text" id="Images" size="40" maxlength="200"></td>
</tr>
<tr>
  <td class="b1_1"><iframe src="upload.asp?action=simg" width="400" height="25" frameborder="0" scrolling="no"></iframe></td>
</tr>
<tr>
  <td valign="top" class="b1_1"><p>内容</p>
    <p>发布时间<br>
      <input name="DateAndTime" type="text" id="DateAndTime" value="<%=NOW()%>">
    </p>
	</td>
  <td class="b1_1"><textarea name="Content" cols="80" rows="10" id="Content" style="display:none"></textarea><IFRAME ID="eWebEditor" SRC="../Editor/ewebeditor.htm?id=Content&style=8586" FRAMEBORDER="0" SCROLLING="no" WIDTH="600" HEIGHT="350"></IFRAME></td>
</tr>
<tr>
  <td class="b1_1">附加选项</td>
  <td class="b1_1">
    推荐
    <input name="IsHot" type="checkbox" class="noborder" id="IsHot" value="1">
    </td>
</tr>
<tr>
<td width="20%" class="b1_1"></td>
<td class="b1_1"><input name="Submit" type="submit" class="bnt" value="添 加"></td>
</tr>
</form>
</table>
<%
end sub

sub savenew()
	Title			=Replace(trim(request.form("Title")),"'","")
	Hits			=trim(request.form("Hits"))
	ClassID			=trim(request.form("ClassID"))
	Content			=request.form("Content")
	price			=trim(request.form("price"))
	sprice			=trim(request.form("sprice"))
	IsHot			=request.form("IsHot")
	Images			=trim(request.form("Images"))
	DateAndTime		=trim(request.form("DateAndTime"))

	
	if Title="" or ClassID="" then
		Call Alert ("请填写完整再提交",-1)
	end if
	If ClassID="" then
		Call Alert ("请选择正确的分类！",-1)
	End if		
	If Content="" then
		Call Alert ("你没有填写内容",-1)
	End if

	set rs = server.CreateObject ("adodb.recordset")
	sql="select * from "&tbname&"_shop where Title='"&Title&"'"
	rs.open sql,conn,1,3
	if rs.eof and rs.bof then
		rs.AddNew
		rs("Title")				=Title
		rs("Hits")				=Hits
		rs("ClassID")			=ClassID
		rs("price")				=price
		rs("sprice")			=sprice
		If IsHot=1 then
			rs("IsHot")				=1
		else
			rs("IsHot")				=0
		end if
		rs("Images")			=Images
		rs("DateAndTime")		=DateAndTime
      	Rs("Content")=Content

		rs.update
		session("AngelClassID")=ClassID
		Call Alert ("添加成功！","Admin_Product.asp")
	else
		Call Alert ("该产品已存在！",-1)
	end if
	rs.close
	set rs=nothing
end sub

sub edit()
id=request("id")
set rs = server.CreateObject ("adodb.recordset")
sql="select * from "&tbname&"_shop where id="& id &""
rs.open sql,conn,1,1
%>
<table width="95%" border="0"  align=center cellpadding="3" cellspacing="2" bgcolor="#FFFFFF" class="admintable">
<form onSubmit="return CheckForm();" name="myform" action="?action=savedit" method=post>
<tr>
    <td colspan="5" class="admintitle">修改商品</td></tr>
<tr>
  <td width="20%" bgcolor="#FFFFFF" class="b1_1">商品名称</td>
  <td colspan=4 class=b1_1><input name="Title" type="text" value="<%=rs("Title")%>" size="40" maxlength="50"></td>
</tr>
<tr>
  <td bgcolor="#FFFFFF" class="b1_1">市场价格</td>
  <td colspan=4 class=b1_1><input name="price" type="text" id="price" value="<%=rs("price")%>" size="10">元</td>
</tr>
<tr>
  <td bgcolor="#FFFFFF" class="b1_1">本站价格</td>
  <td colspan=4 class=b1_1><input name="sprice" type="text" id="sprice" value="<%=rs("sprice")%>" size="10">元</td>
</tr>
<tr>
  <td bgcolor="#FFFFFF" class="b1_1">分类</td>
  <td colspan=4 class=b1_1>
  <select ID="ClassID" name="ClassID">
   <%
   Set Rsp=server.CreateObject("adodb.recordset")
   Sqlp ="select * from "&tbname&"_leixing"
   rsp.open sqlp,conn,1,1
   Response.Write("<option value="""">请选择分类</option>")
   If Rsp.Eof and Rsp.Bof Then
      Response.Write("<option value="""">请先添加分类</option>")
   Else
      Do while not Rsp.Eof
         Response.Write("<option")
         If rs("ClassID")=Rsp("ID") Then
            Response.Write(" selected")
         End If
		 Response.Write(" value="& Rsp("ID") & " style='color:#0000ff;'")
         Response.Write(">|-" & Rsp("Title") & "</option>")  & VbCrLf
      Rsp.Movenext
      Loop
   End if
   rsp.close
   set rsp=nothing
   %>
  </select>
  </td></tr>
<tr>
  <td bgcolor="#FFFFFF" class="b1_1">浏览次数</td>
  <td colspan=4 class=b1_1><input name="Hits" type="text" id="Hits" value="<%=rs("Hits")%>" size="6" maxlength="5"></td>
</tr>
<tr>
  <td rowspan="2" bgcolor="#FFFFFF" class="b1_1">图片上传</td>
  <td colspan=4 class=b1_1><input name="Images" type="text" id="Images" value="<%=rs("Images")%>" size="40" maxlength="200"></td></tr>
<tr>
  <td colspan=4 class=b1_1><iframe src="upload.asp?action=simg" width="400" height="25" frameborder="0" scrolling="no"></iframe></td>
</tr>
  <td valign="top" bgcolor="#FFFFFF" class="b1_1"><p>内容</p>
    <p>发布时间<br>
      <input name="DateAndTime" type="text" id="DateAndTime" value="<%=rs("DateAndTime")%>">
</p>
  </td>
  <td colspan=4 class=b1_1><textarea name="Content" cols="80" rows="10" id="Content" style="display:none;"><%=server.htmlencode(rs("Content"))%></textarea><IFRAME ID="eWebEditor" SRC="../Editor/ewebeditor.htm?id=Content&style=8586" FRAMEBORDER="0" SCROLLING="no" WIDTH="600" HEIGHT="350"></IFRAME></td>
</tr>
<tr>
  <td bgcolor="#FFFFFF" class="b1_1">附加选项</td>
  <td colspan=4 class=b1_1>
推荐
<input name="IsHot" type="checkbox" class="noborder" id="IsHot" value="1"<%if rs("IsHot")=1 then Response.Write("checked") end if%>>
</td>
</tr>
<tr>
<td width="20%" class="b1_1"></td>
<td colspan=4 class=b1_1><input name="id" type="hidden" value="<%=rs("ID")%>"><input name="page" type="hidden" value="<%=page%>"><input name="Submit" type="submit" class="bnt" value="编 辑"></td>
</tr>
</form>
</table>
<%
rs.close
set rs=nothing
end sub

sub savedit()
	Dim Title
	id=request.form("id")
	page=request.form("page")
	Title			=trim(request.form("Title"))
	Hits			=trim(request.form("Hits"))
	ClassID			=trim(request.form("ClassID"))
	Content			=request.form("Content")
	price			=trim(request.form("price"))
	sprice		=trim(request.form("sprice"))
	IsHot			=request.form("IsHot")
	Images			=trim(request.form("Images"))
	DateAndTime		=trim(request.form("DateAndTime"))
	
	if Title="" or ClassID="" then
		Call Alert ("请填写完整再提交","-1")
	end if
	If ClassID="" then
		Call Alert ("请选择正确的分类！",-1)
	End if		
	If Content="" then
		Call Alert ("你没有填写内容","-1")
	End if
	set rs = server.CreateObject ("adodb.recordset")
	sql="select * from "&tbname&"_shop where ID="&id&""
	rs.open sql,conn,1,3
	if not(rs.eof and rs.bof) then
	
		rs("Title")				=Replace(Title,CHR(34),"&quot;")
		rs("Hits")				=Hits
		rs("ClassID")			=ClassID
		rs("price")			=price
		rs("sprice")			=sprice

		If IsHot=1 then
			rs("IsHot")				=1
		else
			rs("IsHot")				=0
		end if

		rs("Images")			=Images
		rs("DateAndTime")		=DateAndTime
      	Rs("Content")=Content
		
		rs.update
		Call Alert("修改成功！",-2)
	else
		Call Alert("修改错误！",-2)
	end if
	rs.close
	set rs=nothing
end sub



Sub delAll
ID=Trim(Request("ID"))
ytype=Request("ytype")
page=request("page")
If ID="" Then
	  Call Alert("请选择文章!",-1)
ElseIf Request("Del")="删除" Then
	'set rs=conn.execute("delete from "&tbname&"_Article where ID In(" & ID & ")")
			for i=1 to request("ID").count
				if request("ID").count=1 then
				ArticleID=request("ID")
				else
				ArticleID=replace(request("id")(i),"'","")
				end if
				'对用户分值操作
				Call EditUserMn(ArticleID,money3,0)
				'删除文章
				Conn.Execute("Delete From ["&tbname&"_shop] where ID = "&ArticleID&"")
			next
End If
Dim Angel_aspOK
Angel_aspOK=request.servervariables("http_referer")
If Angel_aspOK="" then Angel_aspOK=-1
Call Alert("操作成功",Angel_aspOK)
End Sub
%>
<!--#include file="Admin_copy.asp"-->
</body>
</html>