<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="CheckAdmin.Asp"-->
<%
If InStr(CompanyAdminPurview, "|24,") = 0 Then
    response.Write ("<br /><br /><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
    response.End
End If
dim Result
Result=request.QueryString("Result")
dim ID,adName,adPic,adUrl,SortName,SortID,price,sprice,SortPath
ID=request.QueryString("ID")
call ad()
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="Images/Admin_style.css">
<script language="javascript" src="../Scripts/Admin.js"></script>
<script language="javascript">
<!--
function setpic(){
    var arr = showModalDialog("eWebEditor/customDialog/img.htm", "", "dialogWidth:30em; dialogHeight:26em; status:0;help=no");
    if (arr ==null){
        alert("系统提示：当前没有上传图片，界面预览图为空，用户可以重新上传图片！");
    }
    if (arr !=null){
        editForm.adPic.value=arr;
    }
}
//-->
</script>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
<form name="editForm" method="post" action="ad.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
  <tr>
    <th height="22" colspan="2" sytle="line-height:150%">【<%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>广告】</th>
  </tr>
  <tr>
    <td width="20%" align="right" class="forumRow">图片标题：</td>
    <td width="80%" class="forumRowHighlight"><input name="adName" type="text" id="adName" style="width: 180" value="<%=adName%>"></td>
  </tr>
      <tr>
      <td align="right" class="forumRow">广告类别：</td>
      <td colspan="2" class="forumRowHighlight"><input name="SortID" type="text" id="SortID" style="width: 18; background-color:#fffff0" value="<%=SortID%>" readonly> <input name="SortPath" type="text" id="SortPath" style="width: 70; background-color:#fffff0" value="<%=SortPath%>" readonly> <input name="SortName" type="text" id="SortName" value="<%=SortName%>" style="width: 180; background-color:#fffff0" readonly> <a href="javaScript:OpenScript('SelectSort.asp?Result=Ad',500,500,'')">选择类别</a> <font color="red">*</font></td>
    </tr>
  <tr>
    <td width="20%" align="right" class="forumRow">广告图片：</td>
    <td width="80%" class="forumRowHighlight"><input name="adPic" type="text" id="adPic" style="width: 280" value="<%=adPic%>"> <input type="button" value="上传图片" onClick="setpic();"> <font color="red">*</font></td>
  </tr>
    <tr>
    <td align="right" class="forumRow">促销价格：</td>
    <td class="forumRowHighlight"><input name="price" type="text" id="price" style="width: 280" value="<%=price%>">      <font color="red">（</font><font color="red">根据需要填写，可不填）</font></td>
  </tr>
    <tr>
    <td align="right" class="forumRow">市场价格：</td>
    <td class="forumRowHighlight"><input name="sprice" type="text" id="sprice" style="width: 280" value="<%=sprice%>">
    <font color="red">（根据需要填写，可不填）</font></td>
  </tr>
  <tr>
    <td align="right" class="forumRow">链接网址：</td>
    <td class="forumRowHighlight"><input name="adUrl" type="text" id="adUrl" style="width: 280" value="<%=adUrl%>"> <font color="red">*</font></td>
  </tr>
 
  <tr>
    <td align="right" class="forumRow"></td>
    <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="保存"> <input type="button" value="返回上一页" onClick="history.back(-1)"></td>
  </tr>
  </form>
</table>
<%
sub ad()
  dim Action,rsCheckAdd,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then
    set rs = server.createobject("adodb.recordset")
    
    if Result="Add" then
	  sql="select * from Shenbi_ad"
      rs.open sql,conn,1,3
		rs.addnew
		  if Request.Form("SortID")="" and Request.Form("SortPath")="" then
        response.write ("<script language='javascript'>alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  else
	    rs("SortID")=Request.Form("SortID")
		rs("SortPath")=Request.Form("SortPath")
	  end if
		  rs("adName")=trim(Request.Form("adName"))
		  rs("adPic") =trim(Request.Form("adPic"))
		  rs("price") =trim(Request.Form("price"))
		  rs("sprice") =trim(Request.Form("sprice"))
		  rs("adUrl") =trim(Request.Form("adUrl"))
		
		rs.update
	rs.close
    set rs=nothing
    response.write "<script language='javascript'>alert('设置成功！');location.href='adlist.asp';</script>"
   end if
  end if
		if Result="Modify" then
		  set rs = server.createobject("adodb.recordset")
		  sql="select * from Shenbi_ad where ID="& ID
		  rs.open sql,conn,1,3
		  adName=rs("adName")
		  adPic=rs("adPic")
		  price=rs("price")
		  sprice=rs("sprice")
		  adUrl=rs("adUrl")
 SortName=SortText(rs("SortID"))
	  SortID=rs("SortID")
	  SortPath=rs("SortPath")
		  if Action="SaveEdit" then
		    if Request.Form("SortID")="" and Request.Form("SortPath")="" then
        response.write ("<script language='javascript'>alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  else
	    rs("SortID")=Request.Form("SortID")
		rs("SortPath")=Request.Form("SortPath")
	  end if
			  rs("adName")=trim(Request.Form("adName"))
			  rs("adPic") =trim(Request.Form("adPic"))
			  rs("adUrl") =trim(Request.Form("adUrl"))
		      rs("price") =trim(Request.Form("price"))
		      rs("sprice") =trim(Request.Form("sprice"))
			 
			rs.update
    response.write "<script language='javascript'>alert('设置成功！');location.href='adlist.asp';</script>"
		  end if
		  rs.close
		  set rs=nothing
	end if
end sub
Function SortText(ID)
  Dim rs,sql
  Set rs=server.CreateObject("adodb.recordset")
  sql="Select * From Shenbi_AdSort where ID="&ID
  rs.open sql,conn,1,1
  SortText=rs("SortName")
  rs.close
  set rs=nothing
End Function
%>