<%@ LANGUAGE = VBScript.Encode %>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<!--#include file="Admin_htmlconfig.asp"-->
<!--#include file="../Include/RemoteImg_save.asp"-->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'微信公众号 ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=gb2312" />
<TITLE>产品编辑</TITLE>
<link rel="stylesheet" href="Images/Admin.css">
<script language="javascript" src="../Script/Admin.js"></script>

<!--kindeditor编辑器-->
		<link rel="stylesheet" href="../KindEditor/themes/default/default.css" />
		<script charset="utf-8" src="../KindEditor/kindeditor.js"></script>
		<script charset="utf-8" src="../KindEditor/lang/zh_CN.js"></script>
		<script>
		KindEditor.ready(function(K) {
				K.create('#editor_ch', {
					urlType : 'absolute',
					afterBlur: function(){this.sync();},//失去焦点执行this获得值					
					uploadJson : '../KindEditor/asp/upload_json.asp?action=product'
				});
				K.create('#editor_en', {
					urlType : 'absolute',
					afterBlur: function(){this.sync();},//失去焦点执行this获得值					
					uploadJson : '../KindEditor/asp/upload_json.asp?action=product'
				});
		});
	</script>
<!--kindeditor编辑器END-->

<script language = "JavaScript">
function CheckForm()
{
	if (document.editForm.ProductNameCH.value.length == 0) {
		alert("中文标题没有填写.");
		document.editForm.ProductNameCH.focus();
		return false;
	}
	<%if chinato=1 then%>
	if (document.editForm.ProductNameEN.value.length == 0) {
		alert("英文标题没有填写.");
		document.editForm.ProductNameEN.focus();
		return false;
	}
	<%end if%>
	if (document.editForm.SeoKeywordsCH.value.length == 0) {
		alert("中文MetaKeywords没有填写.");
		document.editForm.SeoKeywordsCH.focus();
		return false;
	}
	if (document.editForm.SeoDescriptionCH.value.length == 0) {
		alert("中文SeoDescription没有填写.");
		document.editForm.SeoDescriptionCH.focus();
		return false;
	}
	<%if chinato=1 then%>
	if (document.editForm.SeoKeywordsEN.value.length == 0) {
		alert("英文MetaKeywords没有填写.");
		document.editForm.SeoKeywordsEN.focus();
		return false;
	}
	if (document.editForm.SeoDescriptionEN.value.length == 0) {
		alert("英文SeoDescription没有填写.");
		document.editForm.SeoDescriptionEN.focus();
		return false;
	}
	<%end if%>
	if (document.editForm.SortNameCH.value.length == 0) {
		alert("产品类别没有填写.");
		document.editForm.SortNameCH.focus();
		return false;
	}
	if (document.editForm.ProductNo.value.length == 0) {
		alert("产品编号没有填写.");
		document.editForm.ProductNo.focus();
		return false;
	}
	if (document.editForm.ProductModel.value.length == 0) {
		alert("产品型号没有填写.");
		document.editForm.ProductModel.focus();
		return false;
	}
		if (document.editForm.N_Price.value.length == 0) {
		alert("市场价格没有填写.");
		document.editForm.N_Price.focus();
		return false;
	}
	if (document.editForm.M_Price.value.length == 0) {
		alert("会员价格没有填写.");
		document.editForm.M_Price.focus();
		return false;
	}
	if (document.editForm.V_Price.value.length == 0) {
		alert("VIP价格没有填写.");
		document.editForm.V_Price.focus();
		return false;
	}
	if (document.editForm.P_Price.value.length == 0) {
		alert("批发价格没有填写.");
		document.editForm.P_Price.focus();
		return false;
	}
	if (document.editForm.Stock.value.length == 0) {
		alert("库存没有填写.");
		document.editForm.Stock.focus();
		return false;
	}
	if (document.editForm.UnitCH.value.length == 0) {
		alert("中文计价单位没有填写.");
		document.editForm.UnitCH.focus();
		return false;
	}
	<%if chinato=1 then%>
	if (document.editForm.UnitEN.value.length == 0) {
		alert("英文计价单位没有填写.");
		document.editForm.UnitEN.focus();
		return false;
	}
	<%end if%>
	if (document.editForm.MakerCH.value.length == 0) {
		alert("中文出品公司没有填写.");
		document.editForm.MakerCH.focus();
		return false;
	}
	<%if chinato=1 then%>
	if (document.editForm.MakerEN.value.length == 0) {
		alert("英文出品公司没有填写.");
		document.editForm.MakerEN.focus();
		return false;
	}
	<%end if%>
var editor_ch=KindEditor.create('#editor_ch');
if (editor_ch.isEmpty())
	{
	  alert("请填中文产品内容！")	  
	  return false
	 }
	<%if chinato=1 then%>
var editor_en=KindEditor.create('#editor_en');
if (editor_en.isEmpty())
	{
	  alert("请填英文产品内容！")	  
	  return false
	 }
	<%end if%>  
	return true;
}
</script>
</HEAD>
<BODY>
<%
if Instr(session("AdminPurview"),"|13,")=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,ProductNameCh,ProductNameEn,ViewFlagCh,ViewFlagEn,SortNameCH,SortID,SortPath
dim ProductNo,ProductModel,N_Price,M_Price,V_Price,P_Price,Stock,MakerCh,MakerEn,CommendFlag,cart,TopFlag,NewFlag,GroupID,GroupIdName,Exclusive,SeoKeywordsCH,SeoKeywordsEN,SeoDescriptionCH,SeoDescriptionEN,titlecolor
dim BigPic,SmallPic,ContentCH,ContentEn
ID=request.QueryString("ID")
call ProductEdit()
call AdminSiteInfo
If Result = "Add" Then
N_Price=0
M_Price=0
V_Price=0
P_Price=0
End if
%>
<br>
<form name="editForm" method="post" action="ProductEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>" onSubmit="return CheckForm()">
<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">  
    <tr>
      <th height="22" colspan="2">【<%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="ProductNameCH" type="text" id="ProductNameCH" style="width: 280" value="<%=ProductNameCH%>" maxlength="250">
        是否显示：
        <input name="ViewFlagCH" type="checkbox" value="1" checked="checked" <%if ViewFlagCH then response.write ("checked")%>>
        <font color="red">*</font></td>
    </tr>
	<%if chinato=1 then%>
    <tr>
      <td width="20%" align="right" class="forumRow">英文标题：</td>
      <td width="80%" class="forumRowHighlight"><input name="ProductNameEN" type="text" id="ProductNameEN" style="width: 280" value="<%=ProductNameEN%>" maxlength="250">
        是否显示：
        <input name="ViewFlagEN" type="checkbox" id="ViewFlagEN" value="1" <%if ViewFlagEN then response.write ("checked")%>>
        </td>
    </tr>
	<%End if%>
    <tr>
      <td align="right" class="forumRow">标题颜色：</td>
      <td class="forumRowHighlight"><font face="宋体">
          
          <select name="titlecolor" >
            <option style="COLOR: black" value="0" selected>不使用 </option>
            <option style="background: #000088" value="000088" <% if titlecolor="000088" Then Response.write("Selected") %>> </option>
            <option style="background: #0000ff" value="0000ff" <% if titlecolor="0000ff" Then Response.write("Selected") %>> </option>
            <option style="background: #008800" value="008800" <% if titlecolor="008800" Then Response.write("Selected") %>> </option>
            <option style="background: #008888" value="008888" <% if titlecolor="008888" Then Response.write("Selected") %>> </option>
            <option style="background: #0088ff" value="0088ff" <% if titlecolor="0088ff" Then Response.write("Selected") %>> </option>
            <option style="background: #00a010" value="00a010" <% if titlecolor="00a010" Then Response.write("Selected") %>> </option>
            <option style="background: #1100ff" value="1100ff" <% if titlecolor="1100ff" Then Response.write("Selected") %>> </option>
            <option style="background: #111111" value="111111" <% if titlecolor="111111" Then Response.write("Selected") %>> </option>
            <option style="background: #333333" value="333333" <% if titlecolor="333333" Then Response.write("Selected") %>> </option>
            <option style="background: #50b000" value="50b000" <% if titlecolor="50b000" Then Response.write("Selected") %>> </option>
            <option style="background: #880000" value="880000" <% if titlecolor="880000" Then Response.write("Selected") %>> </option>
            <option style="background: #8800ff" value="8800ff" <% if titlecolor="8800ff" Then Response.write("Selected") %>> </option>
            <option style="background: #888800" value="888800" <% if titlecolor="888800" Then Response.write("Selected") %>> </option>
            <option style="background: #888888" value="888888" <% if titlecolor="888888" Then Response.write("Selected") %>> </option>
            <option style="background: #8888ff" value="8888ff" <% if titlecolor="8888ff" Then Response.write("Selected") %>> </option>
            <option style="background: #aa00cc" value="aa00cc" <% if titlecolor="aa00cc" Then Response.write("Selected") %>> </option>
            <option style="background: #aaaa00" value="aaaa00" <% if titlecolor="aaaa00" Then Response.write("Selected") %>> </option>
            <option style="background: #ccaa00" value="ccaa00" <% if titlecolor="ccaa00" Then Response.write("Selected") %>> </option>
            <option style="background: #ff0000" value="ff0000" <% if titlecolor="ff0000" Then Response.write("Selected") %>> </option>
            <option style="background: #ff0088" value="ff0088" <% if titlecolor="ff0088" Then Response.write("Selected") %>> </option>
            <option style="background: #ff00ff" value="ff00ff" <% if titlecolor="ff00ff" Then Response.write("Selected") %>> </option>
            <option style="background: #ff8800" value="ff8800" <% if titlecolor="ff8800" Then Response.write("Selected") %>> </option>
            <option style="background: #ff0005" value="ff0005" <% if titlecolor="ff0005" Then Response.write("Selected") %>> </option>
            <option style="background: #ff88ff" value="ff88ff" <% if titlecolor="ff88ff" Then Response.write("Selected") %>> </option>
            <option style="background: #ee0005" value="ee0005" <% if titlecolor="ee0005" Then Response.write("Selected") %>> </option>
            <option style="background: #ee01ff" value="ee01ff" <% if titlecolor="ee01ff" Then Response.write("Selected") %>> </option>
            <option style="background: #3388aa" value="3388aa" <% if titlecolor="3388aa" Then Response.write("Selected") %>> </option>
            <option style="background: #000000" value="000000" <% if titlecolor="000000" Then Response.write("Selected") %>> </option>
          </select>
         
        </font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">中文MetaKeywords：</td>
      <td class="forumRowHighlight"><input name="SeoKeywordsCH" type="text" id="SeoKeywordsCH" style="width: 400" value="<%=SeoKeywordsCH%>" maxlength="250"> <input type="button" name="btn" value="从标题复制" title="复制标题到中文：MetaDescription、MetaKeywords" onClick="CopyWebTitleCH(document.editForm.ProductNameCH.value);"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">中文MetaDescription：</td>
      <td class="forumRowHighlight"><input name="SeoDescriptionCH" type="text" id="SeoDescriptionCH" style="width: 400" value="<%=SeoDescriptionCH%>" maxlength="250"></td>
    </tr>
	<%if chinato=1 then%>
    <tr>
      <td align="right" class="forumRow">英文MetaKeywords：</td>
      <td class="forumRowHighlight"><input name="SeoKeywordsEN" type="text" id="SeoKeywordsEN" style="width: 400" value="<%=SeoKeywordsEN%>" maxlength="250"> <input type="button" name="btn2" value="从标题复制" title="复制标题到英文：MetaDescription、MetaKeywords" onClick="CopyWebTitleEN(document.editForm.ProductNameEN.value);"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">英文MetaDescription：</td>
      <td class="forumRowHighlight"><input name="SeoDescriptionEN" type="text" id="SeoDescriptionEN" style="width: 400" value="<%=SeoDescriptionEN%>" maxlength="250"></td>
    </tr>
	<%End if%>
    <tr>
      <td align="right" class="forumRow">产品类别：</td>
      <td 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="SortNameCH" type="text" id="SortNameCH" value="<%=SortNameCH%>" style="width: 180; background-color:#fffff0" readonly>
        <a href="javaScript:OpenScript('SelectSort.asp?Result=Products',500,500,'')">点此选择类别</a> <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">产品编号：</td>
      <td class="forumRowHighlight"><input name="ProductNo" type="text" style="width: 180;" value="<%=ProductNo%>" maxlength="180">
        <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">产品型号：</td>
      <td class="forumRowHighlight"><input name="ProductModel" type="text" style="width: 180;" value="<%=ProductModel%>" maxlength="180">
        <font color="red">*</font> &lt;= <%If session("ProductModel")<>"" Then response.write "<a href=""javascript:"" onClick=""document.editForm.ProductModel.value='"&session("ProductModel")&"'"">【"&session("ProductModel")&"】</a>"%></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">市场价格：</td>
      <td class="forumRowHighlight"><input name="N_Price" type="text" style="width: 80;" value="<%=N_Price%>" maxlength="80" onKeyUp="if(isNaN(value)){alert('只允许输入数字');value='';}" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        <font color="red">*</font>（0为面议。未注册游客或已注册但被确认为临时游客的客户以此价计算）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">会员价格：</td>
      <td class="forumRowHighlight"><input name="M_Price" type="text" style="width: 80;" value="<%=M_Price%>" maxlength="80" onKeyUp="if(isNaN(value)){alert('只允许输入数字');value='';}" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        <font color="red">*</font>（0为面议。注册的普通客户以此价计算）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">VIP价格：</td>
      <td class="forumRowHighlight"><input name="V_Price" type="text" style="width: 80;" value="<%=V_Price%>" maxlength="80" onKeyUp="if(isNaN(value)){alert('只允许输入数字');value='';}" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        <font color="red">*</font>（0为面议。已注册且被确认为VIP的客户以此价计算）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">批发价格：</td>
      <td class="forumRowHighlight"><input name="P_Price" type="text" style="width: 80;" value="<%=P_Price%>" maxlength="80" onKeyUp="if(isNaN(value)){alert('只允许输入数字');value='';}" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        <font color="red">*</font>（0为面议。已注册且被确认为合作伙伴的客户以此价计算）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">库存数量：</td>
      <td class="forumRowHighlight"><input name="Stock" type="text" style="width: 80;" value="<%=Stock%>" maxlength="80" onKeyUp="if(isNaN(value)){alert('只允许输入数字');value='';}" onafterpaste="this.value=this.value.replace(/\D/g,'')">
        <font color="red">*</font></td>
    </tr>
<%Dim Unit_CH
Unit_CH=conn.Execute("Select UnitCH From TianTianCMS_Config")(0)
Unit_CH=replace(Unit_CH,"，",",")
Unit_CH=split(Unit_CH,",")%>
    <tr>
      <td align="right" class="forumRow">计价单位[中文]：</td>
      <td class="forumRowHighlight"><input name="UnitCH" type="text" style="width: 80;" value="<%=UnitCH%>" maxlength="80">
	   &lt;= <%If session("UnitCH")<>"" Then response.write "<a href=""javascript:"" onClick=""document.editForm.UnitCH.value='"&session("UnitCH")&"'"">【"&session("UnitCH")&"】</a>"%>
<%for N=0 to UBound(Unit_CH)
response.write"<a href=""javascript:"" onClick=""document.editForm.UnitCH.value='"&Unit_CH(N)&"'"">【"&Unit_CH(N)&"】</a> "
next%>	
	<font color="red">*</font></td>
    </tr>
<%if chinato=1 Then
Dim Unit_EN
Unit_EN=conn.Execute("Select UnitEN From TianTianCMS_Config")(0)
Unit_EN=replace(Unit_EN,"，",",")
Unit_EN=split(Unit_EN,",")%>
    <tr>
      <td align="right" class="forumRow">计价单位[英文]：</td>
      <td class="forumRowHighlight"><input name="UnitEN" type="text" style="width: 80;" value="<%=UnitEN%>" maxlength="80">
	  &lt;= <%If session("UnitEN")<>"" Then response.write "<a href=""javascript:"" onClick=""document.editForm.UnitEN.value='"&session("UnitEN")&"'"">【"&session("UnitEN")&"】</a>"%>
<%for N=0 to UBound(Unit_EN)
response.write"<a href=""javascript:"" onClick=""document.editForm.UnitEN.value='"&Unit_EN(N)&"'"">【"&Unit_EN(N)&"】</a> "
next%>
</td>
    </tr>
	<%End if%>
	<tr>
      <td align="right" class="forumRow">出品公司[中文]：</td>
      <td class="forumRowHighlight"><input name="MakerCH" type="text" style="width: 250;" value="<%=MakerCH%>" maxlength="250">
	  &lt;= <%If session("MakerCH")<>"" Then response.write "<a href=""javascript:"" onClick=""document.editForm.MakerCH.value='"&session("MakerCH")&"'"">【"&session("MakerCH")&"】</a>"%>
        <a href="javascript:" onClick="document.editForm.MakerCH.value='<%=AdminComNameCH%>'">【<%=AdminComNameCH%>】</a> <font color="red">*</font></td>
    </tr>
	<%if chinato=1 then%>
	<tr>
      <td align="right" class="forumRow">出品公司[英文]：</td>
      <td class="forumRowHighlight"><input name="MakerEN" type="text" id="MakerEN" style="width: 250;" value="<%=MakerEN%>" maxlength="250">
	  &lt;= <%If session("MakerEN")<>"" Then response.write "<a href=""javascript:"" onClick=""document.editForm.MakerEN.value='"&session("MakerEN")&"'"">【"&session("MakerEN")&"】</a>"%>
        <a href="javascript:" onClick="document.editForm.MakerEN.value='<%=AdminComNameEN%>'">【<%=AdminComNameEN%>】</a> <font color="red">*</font></td>
    </tr><%End if%>
<%
if Result="Modify" then
set rs = server.createobject("adodb.recordset")
sql="select * from TianTianCMS_Products where ID="& ID
rs.open sql,conn,1,1
if rs.bof and rs.eof then
	response.write ("<center>数据库记录读取错误！</center>")
	response.end
end If
if rs("attribute1CH")<>"" and rs("attribute1CH_value")<>"" then
	attribute1CH_1=Split(rs("attribute1CH"),"§§§")
	attribute1CH_value_1=Split(rs("attribute1CH_value"),"§§§")
	Num_1=ubound(attribute1CH_1)+1
Else
	Num_1=0
End If
rs.close
set rs=Nothing
Else
	Num_1=0
End If
%>
    <tr>
      <td align="right" class="forumRow">中文自定义产品属性：</td>
      <td class="forumRowHighlight"><input name="Num_1" type="text" id="Num_1" value="<%=Num_1%>" size="5" onKeyUp="if(isNaN(value)){alert('只允许输入数字');value='';}" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>个 <input name="button2" type="button" id="button2" value="设置" onClick="num_1()" /> <input type="button" name="button7" id="button7" value="增加一个" onClick="num_1_1()" /> 上面没有合适阐述时自定义设置
        <br>
        <span id="num_1_str">
        <%For i=0 to (Num_1-1)%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="28">属性名称：
              <input name="attributeCH<%=i+1%>" type="text" id="attributeCH<%=i+1%>" value="<%=attribute1CH_1(i)%>" size="18" />
              属性值：
              <input name="attributeCH<%=i+1%>_value" type="text" id="attributeCH<%=i+1%>_value" value="<%=attribute1CH_value_1(i)%>" size="50" /></td>
          </tr>
        </table>
        <%Next%>
        </span> </td>
    </tr>
<%
if Result="Modify" then
set rs = server.createobject("adodb.recordset")
sql="select * from TianTianCMS_Products where ID="& ID
rs.open sql,conn,1,1
if rs.bof and rs.eof then
	response.write ("<center>数据库记录读取错误！</center>")
	response.end
end If
if rs("attribute1EN")<>"" and rs("attribute1EN_value")<>"" then
	attribute1EN_1=Split(rs("attribute1EN"),"§§§")
	attribute1EN_value_1=Split(rs("attribute1EN_value"),"§§§")
	Num_2=ubound(attribute1EN_1)+1
Else
	Num_2=0
End If
rs.close
set rs=Nothing
Else
	Num_2=0
End If
%><%if chinato=1 then%>
    <tr>
      <td align="right" class="forumRow">英文自定义产品属性：</td>
      <td class="forumRowHighlight"><input name="Num_2" type="text" id="Num_1" value="<%=Num_2%>" size="5" onKeyUp="if(isNaN(value)){alert('只允许输入数字');value='';}" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>个 <input name="button2" type="button" id="button2" value="设置" onClick="num_2()" /> <input type="button" name="button7" id="button7" value="增加一个" onClick="num_2_1()" /> 上面没有合适阐述时自定义设置
        <br>
        <span id="num_2_str">
        <%For i=0 to (Num_2-1)%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="28">属性名称：
              <input name="attributeEN<%=i+1%>" type="text" id="attributeEN<%=i+1%>" value="<%=attribute1EN_1(i)%>" size="18" />
              属性值：
              <input name="attributeEN<%=i+1%>_value" type="text" id="attributeEN<%=i+1%>_value" value="<%=attribute1EN_value_1(i)%>" size="50" /></td>
          </tr>
        </table>
        <%Next%>
        </span> </td>
    </tr><%End if%>
      <tr>
        <td align="right" class="forumRow">状　　态：</td>
        <td class="forumRowHighlight"><input name="CommendFlag" type="checkbox" style="HEIGHT: 13px;WIDTH: 13px;" value="1" <%if CommendFlag then response.write ("checked")%>>&nbsp;推荐&nbsp;<input name="TopFlag" type="checkbox" value="1" style="HEIGHT: 13px;WIDTH: 13px;" <%if TopFlag then response.write ("checked")%>>&nbsp;置顶&nbsp;<input name="NewFlag" type="checkbox" value="1" style="HEIGHT: 13px;WIDTH: 13px;" <%if NewFlag<>"" And  NewFlag=true then%><% response.write ("checked")%><%ElseIf NewFlag="" then%><%response.write ("checked")%><%End if%>>&nbsp;最新</td>
      </tr>
  <tr>
    <td align="right" class="forumRow">显示购物按钮：</td>
    <td class="forumRowHighlight"><input name="cart" type="radio" value="True" <%if cart=True then%> checked<%end if%>>显示 <input name="cart" type="radio" value="False" <%if cart=False then%> checked<%end if%>>隐藏 <font color="red">*</font></td>
  </tr>
	  <tr>
      <td align="right" class="forumRow">阅读权限：</td>
      <td class="forumRowHighlight"><select name="GroupID">
          <% call SelectGroup() %>
        </select>
        <input name="Exclusive" type="radio" value="&gt;=" <%if Exclusive="" or Exclusive=">=" then response.write ("checked")%>>
        隶属
        <input type="radio" <%if Exclusive="=" then response.write ("checked")%> name="Exclusive" value="=">
        专属（隶属：权限值≥可查看，专属：权限值＝可查看）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">产品小图：</td>
      <td class="forumRowHighlight"><input class="smallInput" name="SmallPic" size="45" value="<%=SmallPic%>"><iframe style="top:2px" ID="UploadFiles" src="upload_ttkj.asp?PhotoUrlID=1" frameborder=0 scrolling=no width="370" height="21"></iframe>	  
        <font color="red">*</font> （小图建议200*150像素）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">产品大图：</td>
      <td class="forumRowHighlight"><input class="smallInput" name="BigPic" size="45" value="<%=BigPic%>"><iframe style="top:2px" ID="UploadFiles" src="upload_ttkj.asp?PhotoUrlID=2" frameborder=0 scrolling=no width="370" height="21"></iframe>
        <font color="red">*</font> （产品扩大镜和详图看到的，建议文件2MB内）</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">中文内容：</td>
      <td class="forumRowHighlight"><textarea id="editor_ch" name="ContentCH" style="width:670px;height:400px;"><%=ContentCH%></textarea></td>
    </tr>
	<%if chinato=1 then%>
	<tr>
      <td align="right" class="forumRow">英文内容：</td>
      <td class="forumRowHighlight"><textarea id="editor_en" name="ContentEN" style="width:670px;height:400px;"><%=ContentEN%></textarea></td>
    </tr>
	<%End if%>
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input type="checkbox" name="T_SaveImg" value="1" /> 保存内容中远程图片到本地&nbsp;&nbsp;<input type="checkbox" name="AspJpeg" value="1" checked/>给上传图片加水印&nbsp;&nbsp;（<font color="red">注:<%if Result="Modify" then%>当距发布时间超过<%=Watermark_interval%>分钟时去掉勾确保图片不重复加水印。<%end if%>上传图片等宽度勿超760像素，否则页面变形</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>
</BODY>
</HTML>
<%
sub ProductEdit()
  dim Action,rsRepeat,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" Then
  ContentCh=trim(Request.Form("ContentCh"))
  ContentEn=trim(Request.Form("ContentEn"))  
    set rs = server.createobject("adodb.recordset")
    if len(trim(request.Form("ProductNameCh")))<1 then
      Call Alert ("中文标题为必填项目！","-1")
      response.end
    end if
    if request.Form("ViewFlagEn")=1 then
      if len(trim(request.Form("ProductNameEn")))<1 then
     Call Alert ("英文标题为必填项目！","-1")
      response.end
      end if
    end If
    


    if Result="Add" Then
	session("UnitCh")=request.form("UnitCh")
    session("UnitEn")=request.form("UnitEn")
	session("MakerCh")=request.form("MakerCh")
    session("MakerEn")=request.form("MakerEn")
    session("ProductModel")=request.form("ProductModel")	
	  set rsRepeat = conn.execute("select ProductNo from TianTianCMS_Products where ProductNo='" & trim(Request.Form("ProductNo")) & "'")
	  if not (rsRepeat.bof and rsRepeat.eof) then
		response.write "<script language='javascript'>alert('" & trim(Request.Form("ProductNo")) & "产品编号已存在！');history.back(-1);</script>"
		response.End
	  End If
	  rsRepeat.close
	  set rsRepeat=Nothing
	  sql="select * from TianTianCMS_Products"
      rs.open sql,conn,1,3
      rs.addnew
      rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
      rs("ProductNameEn")=trim(Request.Form("ProductNameEn"))
	  if Request.Form("ViewFlagCh")=1 then
        rs("ViewFlagCh")=Request.Form("ViewFlagCh")
	  else
        rs("ViewFlagCh")=0
	  end if
	  if Request.Form("ViewFlagEn")=1 then
        rs("ViewFlagEn")=Request.Form("ViewFlagEn")
	  else
        rs("ViewFlagEn")=0
	  end if
      rs("SortID")=Request.Form("SortID")
      rs("SortPath")=Request.Form("SortPath")
      rs("ProductNo")=trim(Request.Form("ProductNo"))
      rs("ProductModel")=trim(Request.Form("ProductModel"))
      rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
	  rs("M_Price")=Round(trim(Request.Form("M_Price")),2)
	  rs("V_Price")=Round(trim(Request.Form("V_Price")),2)
      rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
      rs("Stock")=Round(trim(Request.Form("Stock")),2)
	  rs("UnitCh")=trim(Request.Form("UnitCh"))
	  rs("UnitEn")=trim(Request.Form("UnitEn"))
	  rs("MakerCh")=trim(Request.Form("MakerCh"))
	  rs("MakerEn")=trim(Request.Form("MakerEn"))	  
      if Request.Form("CommendFlag")=1 then
		rs("CommendFlag")=Request.Form("CommendFlag")
      else
		rs("CommendFlag")=0
      end If
      if Request.Form("TopFlag")=1 then
		rs("TopFlag")=Request.Form("TopFlag")
      else
		rs("TopFlag")=0
      end if      
      if Request.Form("NewFlag")=1 then
		rs("NewFlag")=Request.Form("NewFlag")
      else
		rs("NewFlag")=0
      end If
      rs("cart")=trim(Request.Form("cart"))
      GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
      rs("GroupID")=GroupIdName(0)
      rs("Exclusive")=trim(Request.Form("Exclusive"))
      rs("BigPic")=trim(Request.Form("BigPic"))
      rs("SmallPic")=trim(Request.Form("SmallPic"))
	  rs("ContentCh")=ContentCh
	  rs("ContentEn")=ContentEn
	  rs("titlecolor")=Request.Form("titlecolor")
      rs("AddTime")=now()
      rs("UpdateTime")=now()
      Num_1=CheckStr(Request.Form("Num_1"),1)
      if Num_1="" then Num_1=0
      if Num_1>0 then
		For i=1 to Num_1
			If CheckStr(Request.Form("attributeCH"&i),0)<>"" and  CheckStr(Request.Form("attributeCH"&i&"_value"),0)<>"" Then
				If attribute1CH="" then
					attribute1CH=CheckStr(Request.Form("attributeCH"&i),0)
					attribute1CH_value=CheckStr(Request.Form("attributeCH"&i&"_value"),0)
				Else
					attribute1CH=attribute1CH&"§§§"&CheckStr(Request.Form("attributeCH"&i),0)
					attribute1CH_value=attribute1CH_value&"§§§"&CheckStr(Request.Form("attributeCH"&i&"_value"),0)
				End if
			End If
		Next
      end if
      Num_2=CheckStr(Request.Form("Num_2"),1)
      if Num_2="" then Num_2=0
      if Num_2>0 then
		For i=1 to Num_2
			If CheckStr(Request.Form("attributeEN"&i),0)<>"" and  CheckStr(Request.Form("attributeEN"&i&"_value"),0)<>"" Then
				If attribute1EN="" then
					attribute1EN=CheckStr(Request.Form("attributeEN"&i),0)
					attribute1EN_value=CheckStr(Request.Form("attributeEN"&i&"_value"),0)
				Else
					attribute1EN=attribute1EN&"§§§"&CheckStr(Request.Form("attributeEN"&i),0)
					attribute1EN_value=attribute1EN_value&"§§§"&CheckStr(Request.Form("attributeEN"&i&"_value"),0)
				End if
			End If
		Next
      end if
	  rs("attribute1CH")=attribute1CH
	  rs("attribute1CH_value")=attribute1CH_value
	  rs("attribute1EN")=attribute1EN
	  rs("attribute1EN_value")=attribute1EN_value
	  rs("SeoKeywordsCH")=trim(Request.Form("SeoKeywordsCH"))
	  rs("SeoDescriptionCH")=trim(Request.Form("SeoDescriptionCH"))
	  rs("SeoKeywordsEN")=trim(Request.Form("SeoKeywordsEN"))
	  rs("SeoDescriptionEN")=trim(Request.Form("SeoDescriptionEN"))
	  rs.update
	  rs.close
	  set rs=Nothing
	  set rs=server.createobject("adodb.recordset")
	  sql="select top 1 ID from TianTianCMS_Products order by ID desc"
	  rs.open sql,conn,1,1
	  ID=rs("ID")
	  rs.close
	  set rs=Nothing
	  if ISHTML = 1 then
	  call html2("/CH/html/","/CH/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductShow.Asp","ID=",ID,"","")
	  if chinato=1 then call html2("/EN/html/","/EN/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductShow.Asp","ID=",ID,"","")
	  End If
	  End If
	  if Result="Modify" then
      sql="select * from TianTianCMS_Products where ID="&ID
      rs.open sql,conn,1,3
      rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
      if chinato=1 then rs("ProductNameEn")=trim(Request.Form("ProductNameEn"))
	  if Request.Form("ViewFlagCh")=1 then
        rs("ViewFlagCh")=Request.Form("ViewFlagCh")
	  else
        rs("ViewFlagCh")=0
	  end if
	  if Request.Form("ViewFlagEn")=1 then
        if chinato=1 then rs("ViewFlagEn")=Request.Form("ViewFlagEn")
	  else
        if chinato=1 then rs("ViewFlagEn")=0
	  end if
	  rs("SortID")=Request.Form("SortID")
	  rs("SortPath")=Request.Form("SortPath")
	  rs("ProductNo")=trim(Request.Form("ProductNo"))
	  rs("ProductModel")=trim(Request.Form("ProductModel"))
	  rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
	  rs("M_Price")=Round(trim(Request.Form("M_Price")),2)
	  rs("V_Price")=Round(trim(Request.Form("V_Price")),2)
	  rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
	  rs("Stock")=Round(trim(Request.Form("Stock")),2)
	  rs("UnitCh")=trim(Request.Form("UnitCh"))
	  if chinato=1 then rs("UnitEn")=trim(Request.Form("UnitEn"))
	  rs("MakerCh")=trim(Request.Form("MakerCh"))
	  if chinato=1 then rs("MakerEn")=trim(Request.Form("MakerEn"))	  
	  if Request.Form("CommendFlag")=1 then
		rs("CommendFlag")=Request.Form("CommendFlag")
	  else
		rs("CommendFlag")=0
	  end If
      if Request.Form("TopFlag")=1 then
		rs("TopFlag")=Request.Form("TopFlag")
      else
		rs("TopFlag")=0
      end if	  
	  if Request.Form("NewFlag")=1 then
		rs("NewFlag")=Request.Form("NewFlag")
	  else
		rs("NewFlag")=0
	  end If
	  rs("cart")=trim(Request.Form("cart"))
      GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
	  rs("GroupID")=GroupIdName(0)
	  rs("Exclusive")=trim(Request.Form("Exclusive"))
	  rs("BigPic")=trim(Request.Form("BigPic"))
	  rs("SmallPic")=trim(Request.Form("SmallPic"))
	  rs("ContentCh")=ContentCh
	  if chinato=1 then rs("ContentEn")=ContentEn
	  rs("titlecolor")=Request.Form("titlecolor")
	  rs("UpdateTime")=now()
	  Num_1=CheckStr(Request.Form("Num_1"),1)
	  if Num_1="" then Num_1=0
	  if Num_1>0 then
		For i=1 to Num_1
			If CheckStr(Request.Form("attributeCH"&i),0)<>"" and  CheckStr(Request.Form("attributeCH"&i&"_value"),0)<>"" Then
				If attribute1CH="" then
					attribute1CH=CheckStr(Request.Form("attributeCH"&i),0)
					attribute1CH_value=CheckStr(Request.Form("attributeCH"&i&"_value"),0)
				Else
					attribute1CH=attribute1CH&"§§§"&CheckStr(Request.Form("attributeCH"&i),0)
					attribute1CH_value=attribute1CH_value&"§§§"&CheckStr(Request.Form("attributeCH"&i&"_value"),0)
				End if
			End If
		Next
	  end if
	  Num_2=CheckStr(Request.Form("Num_2"),1)
	  if Num_2="" then Num_2=0
	  if Num_2>0 then
		For i=1 to Num_2
			If CheckStr(Request.Form("attributeEN"&i),0)<>"" and  CheckStr(Request.Form("attributeEN"&i&"_value"),0)<>"" Then
				If attribute1EN="" then
					attribute1EN=CheckStr(Request.Form("attributeEN"&i),0)
					attribute1EN_value=CheckStr(Request.Form("attributeEN"&i&"_value"),0)
				Else
					attribute1EN=attribute1EN&"§§§"&CheckStr(Request.Form("attributeEN"&i),0)
					attribute1EN_value=attribute1EN_value&"§§§"&CheckStr(Request.Form("attributeEN"&i&"_value"),0)
				End if
			End If
		Next
	  end if
	  rs("attribute1CH")=attribute1CH
	  rs("attribute1CH_value")=attribute1CH_value
	  if chinato=1 then rs("attribute1EN")=attribute1EN
	  if chinato=1 then rs("attribute1EN_value")=attribute1EN_value
	  rs("SeoKeywordsCH")=trim(Request.Form("SeoKeywordsCH"))
	  rs("SeoDescriptionCH")=trim(Request.Form("SeoDescriptionCH"))
	  if chinato=1 then rs("SeoKeywordsEN")=trim(Request.Form("SeoKeywordsEN"))
	  if chinato=1 then rs("SeoDescriptionEN")=trim(Request.Form("SeoDescriptionEN"))
	  rs.update
	  rs.close
	  set rs=Nothing
	  if ISHTML = 1 then
	  call html2("/CH/html/","/CH/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductShow.Asp","ID=",ID,"","")
	  if chinato=1 then call html2("/EN/html/","/EN/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductShow.Asp","ID=",ID,"","")
	  End If
	  End If
	  if ISHTML = 1 then
    response.write "<script language='javascript'>alert('设置成功，接着生成相关静态页！');location.replace('Admin_htmlindex.asp?htmlsc=Admin_htmlsort.asp');</script>"
	  Else
	  response.write "<script language='javascript'>alert('设置成功！');location.replace('ProductEdit.asp?Result="&request.QueryString("Result")&"&ID="&id&"');</script>"
	  End If
  else
  	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from TianTianCMS_Products where ID="& ID
      rs.open sql,conn,1,1
      if rs.bof and rs.eof then
      response.write ("<center>数据库记录读取错误！</center>")
      response.end
      end if
	  ProductNameCh=rs("ProductNameCh")
	  ProductNameEn=rs("ProductNameEn")
	  ViewFlagCh=rs("ViewFlagCh")
	  ViewFlagEn=rs("ViewFlagEn")
      SortNameCH=SortText(rs("SortID"))
      SortID=rs("SortID")
      SortPath=rs("SortPath")
      ProductNo=rs("ProductNo")
      ProductModel=rs("ProductModel")
      N_Price=rs("N_Price")
	  M_Price=rs("M_Price")
	  V_Price=rs("V_Price")
      P_Price=rs("P_Price")
      Stock=rs("Stock")
	  UnitCh=rs("UnitCh")
	  UnitEn=rs("UnitEn")
	  MakerCh=rs("MakerCh")
	  MakerEn=rs("MakerEn")
      CommendFlag=rs("CommendFlag")
	  cart=rs("cart")
	  TopFlag=rs("TopFlag")
      NewFlag=rs("NewFlag")
      GroupID=rs("GroupID")
      Exclusive=rs("Exclusive")
      BigPic=rs("BigPic")
      SmallPic=rs("SmallPic")
      ContentCh=rs("ContentCh")
      ContentEn=rs("ContentEn")
	  SeoKeywordsCH=rs("SeoKeywordsCH")
	  SeoDescriptionCH=rs("SeoDescriptionCH")
	  SeoKeywordsEN=rs("SeoKeywordsEN")
	  SeoDescriptionEN=rs("SeoDescriptionEN")
	  titlecolor=rs("titlecolor")
      rs.close
      set rs=nothing
	  else
      randomize timer
      ProductNo=Hour(now)&Minute(now)&Second(now)&"-"&int(900*rnd)+100
      Stock=10000
    end if
  end if
end sub
sub SelectGroup()
  dim rs,sql
  set rs = server.createobject("adodb.recordset")
  sql="select GroupID,GroupNameCH from TianTianCMS_MemGroup"
  rs.open sql,conn,1,1
  if rs.bof and rs.eof then
    response.write("未设组别")
  end if
  while not rs.eof
    response.write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupNameCH")&"'")
    if GroupID=rs("GroupID") then response.write ("selected")
    response.write(">"&rs("GroupNameCH")&"</option>")
    rs.movenext
  wend
  rs.close
  set rs=nothing
end sub

Function SortText(ID)
  Dim rs,sql
  Set rs=server.CreateObject("adodb.recordset")
  sql="Select * From TianTianCMS_ProductCategory where ID="&ID
  rs.open sql,conn,1,1
  SortText=rs("SortNameCH")
  rs.close
  set rs=nothing
End Function
%>