<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../Include/system_language.asp" -->
<!--#include file="CheckAdmin.Asp"-->
<!--#include file="../Html/html_Config.Asp"-->
<!--#include file="../Html/html_Function.Asp"-->
<!--#include file="../Html/html_To_Product.Asp"-->
<%
'*******************************************************
'软件名称：科蚁企业网站内容管理系统（KEYICMS）
'软件开发：成都神笔天成网络科技有限公司
'网   址：http://www.keyicms.com
'本信息不会影响您网站的正常使用，无论免费用户或是收费用户请保留这里的信息.
'神笔(9)天成网络享有软件著作权，如果您擅自删除这里的版权信息,我们将追究法律责任.
'未经公司同意禁止更改以下代码.
'*******************************************************
Dim Result, Page
Result = request.QueryString("Result")
Page = request.QueryString("Page")
Dim ID, ProductName, ViewFlag, ClassSeo, SortName, SortID, SortPath
Dim ProductNo, Maker, CommendFlag, NewFlag, MobileFlag, SeoTitle, SeoKeywords, SeoDescription
Dim SmallPic, BigPic, OtherPic, Content, ClickNumber, Sequence, OtherDes
ID = request.QueryString("ID")
Call ProductEdit()
Call SiteInfo()
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<%=Keyicms_Lang_Copyright(13)%>">
<meta name="author" content="<%=Keyicms_Lang_Copyright(3)%>">
<title><%=Keyicms_Lang_Copyright(1)%> <%=Str_Soft_Version%></title>
<!--#Include file="Keyicms_css.Asp"-->
<script charset="utf-8" src="KEditor_keyicms/kindeditor.js"></script>
<script charset="utf-8" src="KEditor_keyicms/lang/zh_CN.js"></script>
<script charset="utf-8" src="KEditor_keyicms/plugins/code/prettify.js"></script>
<script>
KindEditor.ready(function(K) {
	var editor = K.create('textarea[name="Content"]', {
		cssPath : 'KEditor_keyicms/plugins/code/prettify.css',
		uploadJson : 'KEditor_keyicms/asp/upload_json.asp',
		fileManagerJson : 'KEditor_keyicms/asp/file_manager_json.asp',
		allowFileManager : true,
		afterBlur : function() {
		this.sync();
		K.ctrl(document, 13, function() {
		K('form[name=editForm]')[0].submit();
		});
		K.ctrl(this.edit.doc, 13, function() {
		K('form[name=editForm]')[0].submit();
		});
		}
	});
	
	K('#BigImage').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#BigPic').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#BigPic').val(url);
					$('#Pic').attr("src", url)
					editor.hideDialog();
				}
			});
		});
	});
	
	K('#selectImage').click(function() {
		editor.loadPlugin('multiimage', function() {
			var aVal=""
			editor.plugin.multiImageDialog({
				clickFn : function(urlList) {
					var div = K('#OtherPic');
					aVal = div.val()
					K.each(urlList, function(i, data) {    
                        o = '<div class="col-sm-1 col-xs-6 Otpic">'
                        o = o + '<div class="img-thumbnail">'
                        o = o + '<img src="' + data.url + '">'
                        o = o + '</div>'
                        o = o + '<input id="appendedPrependedInput" class="form-control" type="text" name="OtherPic" value="' + data.url + '"  readonly>'
                        o = o + '<input id="appendedPrependedInput" class="form-control" type="text" name="OtherDes" value="" placeholder="alt">'
                        o = o + '<div class="otsc"><div class="btn btn-default btn-xs"><i class="fa fa-arrow-circle-up"></i> 填写图片简介</div><a href="JavaScript:;" name="DelPic" class="btn btn-danger btn-xs" style=" float:right">删除</a></div>'
                        o = o + '</div>'
						K('#selectImage').before(o)
						/*if (div.val() == "")
							aVal =aVal + data.url
						else
							aVal =aVal + "|" +  data.url
					
						div.val(aVal);*/
					});
					editor.hideDialog();
				}
			});
		});
	});
});
$(function(){
	$("[name=DelPic]").live("click", function(){
		$(this).parents(".Otpic").remove()
	})
})
</script>
</head>

<body>
<!--#Include file="Keyicms_Top.Asp"-->
<div id="wrap">
	<!--#Include file="Keyicms_Meun.Asp"-->
	<%
	If InStr(CompanyAdminPurview, "|3,") = 0 Then
		response.Write ("<br /><br /><div style='height:100%; text-align:center' class='main'><font style=""color:red; font-size:14px;"")>"&Keyicms_Lang_System(26)&"</font></div>")
		response.End
	End If
	%>
    <div class="main">
        <div class="row">
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i> <%=Keyicms_Lang_Copyright(14)%></li>
                <li class="active"><a href="">功能模块</a></li>
                <li class="active">产品管理</li>
            </ol>	
        </div>
        <div class="row ">
            <div class="col-lg-12 hideInIE8">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-edit"></i><span class="break"></span><strong>产品管理</strong></h2> 
                    </div>
                    <div class="panel-body">
                        <a class="ShortCut1" href="Ky_ProductEdit.Asp?Result=Add">  
                            <i class="fa fa-sign-in"></i>
                            <div class="title">添加产品</div>
                        </a>					
                        <a class="ShortCut2" href="Ky_Product.Asp">  
                            <i class="fa fa-th"></i>
                            <div class="title">产品列表</div>
                        </a>	
                        <a class="ShortCut3" href="Ky_ProductSort.Asp">  
                            <i class="fa fa-sitemap"></i>
                            <div class="title">产品分类</div>
                        </a>													
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
			<div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-gears"></i><span class="break"></span><strong><%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>产品</strong></h2>
                    </div>
                    <div class="panel-body">
                    <form name="editForm" method="post" action="?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>&Page=<%=Page%>" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-md-2 control-label">产品名称：</label>
                            <div class="col-md-4">
                                <input name="ProductName" type="text" id="ProductName" class="form-control" value="<%=ProductName%>" maxlength="100">
                                <label class="checkbox-inline" for="ViewFlag">
                                    <input type="checkbox" id="ViewFlag" name="ViewFlag" value="1" <%if ViewFlag then response.write ("checked")%>> 是否生效
                                </label>                           
                                <label class="checkbox-inline" for="CommendFlag">
                                    <input name="CommendFlag" type="checkbox" id="CommendFlag" value="1" <%if CommendFlag then response.write ("checked")%>> 是否推荐
                                </label>  
                                <label class="checkbox-inline" for="NewFlag">
                                    <input name="NewFlag" type="checkbox" id="NewFlag" value="1" <%if NewFlag then response.write ("checked")%>> 是否新品
                                </label>  
                                <%If mStatus Then%>
                                <label class="checkbox-inline" for="MobileFlag">
                                    <input type="checkbox" id="MobileFlag" name="MobileFlag" value="1" <%if MobileFlag then response.write ("checked")%>> 手机显示
                                </label>
                                <%End If%>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-md-2 control-label">静态文件名：</label>
                            <div class="col-md-4">
                                <%If Result = "Add" then%>
                                <input name="ClassSeo" type="text" id="ClassSeo" class="form-control">
                                <div class="radio">
                                    <label class="radio-inline" for="oAutopinyin_1">
                                        <input name="oAutopinyin" type="radio" id="oAutopinyin_1" value="1" checked="checked"> 自动生成系统默认静态文件名<font color="red">（已填写“静态文件名”则该功能无效）</font>
                                    </label>
                                </div>
								<%If ClassSeoISPY = True Then%>
                                <div class="radio">
                                    <label class="radio-inline" for="oAutopinyin_2">
                                        <input name="oAutopinyin" type="radio" id="oAutopinyin_2" value="2"> 将标题转换为拼音<font color="red">（已填写“静态文件名”则该功能无效）</font>
                                    </label>
                                </div>
								<%End If%>
                                <%elseif Result = "Modify" then%>
                                <input type="text" value="<%= ClassSeo %>" class="form-control" readonly>
                                <%end if%>
                                <span class="help-block"></span>
                            </div>
                        </div> 
                        <%If EnableSeo = True Then%>
                        <div class="form-group">
                            <label class="col-md-2 control-label">关键词：</label>
                            <div class="col-md-6">
                                <input name="SeoKeywords" type="text" id="SeoKeywords" class="form-control" value="<%=SeoKeywords%>" maxlength="250">
                                <span class="help-block">SEO：多个关键词请用“,”半角逗号分开</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">描述：</label>
                            <div class="col-md-6">
                                <input name="SeoDescription" type="text" id="SeoDescription" class="form-control" value="<%=SeoDescription%>" maxlength="250">
                                <span class="help-block">SEO：请填写描述</span>
                            </div>
                        </div>
                        <%End If%>
                        <div class="form-group">
                            <label class="col-md-2 control-label">产品类别：</label>
                            <div class="col-md-5">
                                <select size="1" class="form-control" name="SortSelect" id="SortSelect" onChange="AddSort()">
                                <option value="" valuepath="">请选择...</option>
                                <%Call ProductSort(0, 0)%>
                                </select>
                                <span class="help-block">
                                    <input name="SortID" type="hidden" id="SortID" value="<%=SortID%>" readonly class="form-control">
                                    <input name="SortPath" type="hidden" id="SortPath" value="<%=SortPath%>" readonly class="form-control">
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">产品编号：</label>
                            <div class="col-md-5">
                                <input name="ProductNo" type="text" id="ProductNo" class="form-control" value="<%=ProductNo%>" maxlength="180">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label"></label>
                            <div class="col-md-10" id="num_1_str" style="padding-left:0;">
                                <%For i=0 to (Num_1-1)%>
                                <div style=" margin-bottom:10px; overflow:hidden;">
                                    <div class="col-md-5" style="padding-top:3px;">
                                        <div class="input-group">
                                            <span class="input-group-addon">属性名称</span>
                                            <input type="text" class="form-control" name="Attribute<%=i%>" id="Attribute<%=i%>" value="<%=Attribute_1(i)%>">
                                        </div>
                                    </div>
                                    <div class="col-md-5" style="padding-top:3px;">
                                        <div class="input-group">
                                            <span class="input-group-addon">属性值</span>
                                            <input type="text" class="form-control" name="Attribute<%=i%>_value" id="Attribute<%=i%>_value" value="<%=Attribute_value_1(i)%>">
                                        </div>
                                    </div>
                                </div>
                                <%Next%>
                            </div>
                        </div>
						<div class="form-group">
                            <label class="col-md-2 control-label">出品公司：</label>
                            <div class="col-md-5">
                                <input name="Maker" type="text" class="form-control" value="<%=Maker%>" maxlength="250">
                                <span class="help-block"><a href="javascript:" onClick="document.editForm.Maker.value='<%=ComName%>'"><%=ComName%></a></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">产品缩略图：</label>
                            <div class="col-md-7">
                                <div class="bigpic">
									<div class="bigpicl">
                                    <div class="pickyc">
									<img src="<%=BigPic%>" onerror="this.src='ke01/img/noimg_big.gif'" id="Pic">
                                    </div>
								</div>
									<div class="bigpicr">
									<div class="Uanniu">
                                    <button type="button" id="BigImage" class="btn btn-danger btn-sm">上传图片</button>
                                    </div>
                                    <div class="Srkpic"><input type="text" id="BigPic" name="BigPic" class="form-control" value="<%=BigPic%>"  readonly></div>
									 <div class="help-block">产品缩略图主要用于封面显示使用</div>
                                    </div>
								</div>
                            </div>
                        </div>                      
                        <div class="form-group">
                            <label class="col-md-2 control-label">更多产品图片：</label>
                            <div id="OtherPic" class="OtherPic">
                            	<%
								If OtherPic <> "" Then
								arrPic = split(OtherPic, "|")
								arrDes = split(OtherDes, "|")
								For i = 0 to ubound(arrPic)
								%>
                                <div class="col-sm-1 col-xs-6 Otpic">
                                <div class="img-thumbnail">
                                <img src="<%=arrPic(i)%>" alt="<%=arrDes(i)%>">
                                </div>
                                <input id="appendedPrependedInput" class="form-control" type="text" name="OtherPic" value="<%=arrPic(i)%>"  readonly>
                                <input id="appendedPrependedInput" class="form-control" type="text" name="OtherDes" value="<%=arrDes(i)%>" placeholder="alt">
                                <div class="otsc"><div class="btn btn-default btn-xs"><i class="fa fa-arrow-circle-up"></i> 填写图片简介</div><a href="JavaScript:;" name="DelPic" class="btn btn-danger btn-xs" style=" float:right">删除</a></div>
                                </div>
                                <%
								Next
								End If
								%>
                                <button type="button" id="selectImage" class="btn btn-info" style=" margin-left:10px;">点击增加图片</button>
                            </div>
                           </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">产品详细介绍：</label>
                                <div class="col-md-10">
                                <textarea name="Content" style="width:95%;height:400px;visibility:hidden;" class="form-control"><%=Server.HTMLEncode(Content)%></textarea>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <%If EnableViews = True Then%>  
                        <div class="form-group">
                            <label class="col-md-2 control-label">浏览数：</label>
                            <div class="col-md-4">
                                <input type="text" name="ClickNumber" id="ClickNumber" class="form-control" value="<%=ClickNumber%>" onKeyDown="OnKeyDown()" onChange="OnChange(this, <%=ClickNumber%>)" />
                                <span class="help-block">可以手动输入案例的浏览数量。</span>
                            </div>
                        </div> 
                        <%End If%>
                        <div class="form-group">
                            <label class="col-md-2 control-label">排序：</label>
                            <div class="col-md-4">
                                <input name="Sequence" type="text" id="Sequence" class="form-control" value="<%=Sequence%>" onKeyDown="OnKeyDown()" onChange="OnChange(this, <%=Sequence%>)">
                                <span class="help-block">数字越小排名越靠前。</span>
                            </div>
                        </div>
                        <div class="form-group button-container">
                            <div class="col-md-2 control-label"></div>
                            <div class="col-md-10">
                                <input name="submitSaveEdit" type="submit" id="submitSaveEdit" class="btn btn-danger" value="保存产品信息">
                                <input type="button" class="btn btn-success" value="<%=Keyicms_Lang_System(32)%>" onClick="history.back(-1)">
                            </div>	 
                        </div>
                    </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--#Include file="Keyicms_End.Asp"-->		
</div>
<!--#Include file="Keyicms_js.Asp"-->
</body>
</html>
<%
Sub ProductEdit()
Dim Action, rsRepeat, rs, sql
Action = request.QueryString("Action")
If Action = "SaveEdit" Then
	Set rs = server.CreateObject("adodb.recordset")
	If Len(Trim(request.Form("ProductName")))<1 Then
		Call SweetAlert("warning", "友情提示", "请填写产品名称！", "false", "history.back(-1)")
		response.End
	End If
	If Request.Form("SortID") = "" And Request.Form("SortPath") = "" Then
		Call SweetAlert("warning", "友情提示", "请选择所属分类！", "false", "history.back(-1)")
		response.End
	End If
	If LTrim(request.Form("Maker")) = "" Then
		Call SweetAlert("warning", "友情提示", "请填写出品公司！", "false", "history.back(-1)")
		response.End
	End If
	If LTrim(request.Form("BigPic")) = "" Then
		Call SweetAlert("warning", "友情提示", "请上传产品缩略图！", "false", "history.back(-1)")
		response.End
	End If
	If LTrim(request.Form("Content")) = "" Then
		Call SweetAlert("warning", "友情提示", "请填写产品详细介绍！", "false", "history.back(-1)")
		response.End
	End If

	If Result = "Add" Then
		Set rsRepeat = conn.Execute("select ProductNo from keyicms_Product where ProductNo='" & Trim(Request.Form("ProductNo")) & "'")
		If Not (rsRepeat.bof And rsRepeat.EOF) Then
			Call SweetAlert("warning", "友情提示", Trim(Request.Form("ProductNo")) & "产品编号已存在！", "false", "history.back(-1)")
			response.End
		End If
		rsRepeat.Close : Set rsRepeat = Nothing

		sql = "select * from keyicms_Product"
		rs.Open sql, conn, 1, 3
		rs.addnew
		rs("ProductName") = Trim(Request.Form("ProductName"))
		If Request.Form("ClassSeo") = "" then
			If Request.Form("oAutopinyin") = "1" then rs("ClassSeo") = TimeToName()
			If Request.Form("oAutopinyin") = "2" then rs("ClassSeo") = Left(Pinyin(trim(request.form("ProductName"))),200)
		Else
			rs("ClassSeo") = trim(Request.form("ClassSeo"))
		End If
		If Request.Form("ViewFlag") = 1 Then
			rs("ViewFlag") = Request.Form("ViewFlag")
		Else
			rs("ViewFlag") = 0
		End If
		If Request.Form("CommendFlag") = 1 Then
			rs("CommendFlag") = Request.Form("CommendFlag")
		Else
			rs("CommendFlag") = 0
		End If
		If Request.Form("NewFlag") = 1 Then
			rs("NewFlag") = Request.Form("NewFlag")
		Else
			rs("NewFlag") = 0
		End If
		If Request.Form("MobileFlag") = 1 Then
			rs("MobileFlag") = Request.Form("MobileFlag")
		Else
			rs("MobileFlag") = 0
		End If
		
		rs("SortID") = Request.Form("SortID")
		rs("SortPath") = Request.Form("SortPath")
		rs("ProductNo") = Trim(Request.Form("ProductNo"))
		rs("Maker") = Trim(Request.Form("Maker"))
		rs("SmallPic") = Trim(Request.Form("SmallPic"))
		rs("BigPic") = Trim(Request.Form("BigPic"))
		rs("OtherPic")=replace(replace(Request.Form("OtherPic"), " ", ""), ",", "|")
		rs("OtherDes") = replace(replace(replace(Request.Form("OtherDes"), " ", ""), "|", ""), ",", "|")
		rs("Content") = RTrim(Request.Form("Content"))
		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 = 0 To Num_1 - 1
				If CheckStr(Request.Form("Attribute"&i), 0)<>"" And CheckStr(Request.Form("Attribute"&i&"_value"), 0)<>"" Then
					If Attribute = "" Then
						Attribute = CheckStr(Request.Form("Attribute"&i), 0)
						Attribute_value = CheckStr(Request.Form("Attribute"&i&"_value"), 0)
					Else
						Attribute = Attribute&"§§§"&CheckStr(Request.Form("Attribute"&i), 0)
						Attribute_value = Attribute_value&"§§§"&CheckStr(Request.Form("Attribute"&i&"_value"), 0)
					End If
				End If
			Next
		End If
		rs("Attribute") = Attribute
		rs("Attribute_value") = Attribute_value
		rs("SeoTitle") = Trim(Request.Form("SeoTitle"))
		rs("SeoKeywords") = Trim(Request.Form("SeoKeywords"))
		rs("SeoDescription") = Trim(Request.Form("SeoDescription"))
		
		If EnableViews Then rs("ClickNumber") = trim(Request.Form("ClickNumber"))
		rs("Sequence") = trim(Request.Form("Sequence"))
		rs.update
		rs.close : set rs = nothing
	  
		set rs = server.createobject("adodb.recordset")
		sql = "select top 1 ID,ClassSeo from keyicms_Product order by ID desc"
		rs.Open sql, conn, 1, 1
		ID = rs("ID")
		rs.close : set rs = nothing
	End If
	If Result = "Modify" Then
		sql = "select * from keyicms_Product where ID="&ID
		rs.Open sql, conn, 1, 3
		rs("ProductName") = Trim(Request.Form("ProductName"))
		If Request.Form("ViewFlag") = 1 Then
			rs("ViewFlag") = Request.Form("ViewFlag")
		Else
			rs("ViewFlag") = 0
		End If
		If Request.Form("CommendFlag") = 1 Then
			rs("CommendFlag") = Request.Form("CommendFlag")
		Else
			rs("CommendFlag") = 0
		End If
		If Request.Form("NewFlag") = 1 Then
			rs("NewFlag") = Request.Form("NewFlag")
		Else
			rs("NewFlag") = 0
		End If
		If Request.Form("MobileFlag") = 1 Then
			rs("MobileFlag") = Request.Form("MobileFlag")
		Else
			rs("MobileFlag") = 0
		End If

		rs("SortID") = Request.Form("SortID")
		rs("SortPath") = Request.Form("SortPath")
		rs("ProductNo") = Trim(Request.Form("ProductNo"))
		rs("Maker") = Trim(Request.Form("Maker"))
		rs("SmallPic") = Trim(Request.Form("SmallPic"))
		rs("BigPic") = Trim(Request.Form("BigPic"))
		rs("OtherPic") = replace(replace(Request.Form("OtherPic"), " ", ""), ",", "|")
		rs("OtherDes") = replace(replace(replace(Request.Form("OtherDes"), " ", ""), "|", ""), ",", "|")
		rs("Content") = RTrim(Request.Form("Content"))
		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 = 0 To Num_1 - 1
				If CheckStr(Request.Form("Attribute"&i), 0)<>"" And CheckStr(Request.Form("Attribute"&i&"_value"), 0)<>"" Then
					If Attribute = "" Then
						Attribute = CheckStr(Request.Form("Attribute"&i), 0)
						Attribute_value = CheckStr(Request.Form("Attribute"&i&"_value"), 0)
					Else
						Attribute = Attribute&"§§§"&CheckStr(Request.Form("Attribute"&i), 0)
						Attribute_value = Attribute_value&"§§§"&CheckStr(Request.Form("Attribute"&i&"_value"), 0)
					End If
				End If
			Next
		End If
		rs("Attribute") = Attribute
		rs("Attribute_value") = Attribute_value
		rs("SeoTitle") = Trim(Request.Form("SeoTitle"))
		rs("SeoKeywords") = Trim(Request.Form("SeoKeywords"))
		rs("SeoDescription") = Trim(Request.Form("SeoDescription"))
		
		If EnableViews Then rs("ClickNumber") = trim(Request.Form("ClickNumber"))
		rs("Sequence") = trim(Request.Form("Sequence"))

		ID = rs("ID")
		rs.update
		rs.close : set rs = nothing
	End If

	Call HtmlEdit("Product", ID)
	Call SweetAlert("success", "操作成功", "设置成功，相关静态页面已更新！", "false", "location.replace('Ky_Product.Asp?Page=" & Page & "')")
Else
	If Result = "Modify" Then
		Set rs = server.CreateObject("adodb.recordset")
		sql = "select * from keyicms_Product where ID="& ID
		rs.Open sql, conn, 1, 1
		If rs.bof And rs.EOF Then
			response.Write ("<center>数据库记录读取错误！</center>")
			response.End
		End If
		ProductName = rs("ProductName")
		ViewFlag = rs("ViewFlag")
		ClassSeo = rs("ClassSeo")&Separated&rs("ID")
		SortName = SortText(rs("SortID"))
		SortID = rs("SortID")
		SortPath = rs("SortPath")
		ProductNo = rs("ProductNo")
		Maker = rs("Maker")
		CommendFlag = rs("CommendFlag")
		NewFlag = rs("NewFlag")
		MobileFlag = rs("MobileFlag")
		SmallPic = rs("SmallPic")
		BigPic = rs("BigPic")
		OtherPic = rs("OtherPic")
		OtherDes = rs("OtherDes")
		Content = rs("Content")
		SeoTitle = rs("SeoTitle")
		SeoKeywords = rs("SeoKeywords")
		SeoDescription = rs("SeoDescription")
		ClickNumber = rs("ClickNumber")
		Sequence = rs("Sequence")
		rs.close : set rs = nothing
	Else
		ClickNumber = 10
		Sequence = 10
		randomize timer
		ProductNo = Hour(now) & Minute(now) & Second(now) & "-" & int(900*rnd)+100
	End If
End If
End Sub

Function SortText(ID)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From keyicms_ProductSort where ID="&ID
    rs.Open sql, conn, 1, 1
    SortText = rs("SortName")
	rs.close : set rs = nothing
End Function

Function ProductSort(ID, ClassNum)
	Dim rs
	set rs = Server.CreateObject("adodb.recordset")
	rs.open "select * from Keyicms_ProductSort where ParentID="&ID&" Order by ID asc", conn, 1, 2
	Do Until rs.eof
		If SortID = rs("ID") Then
			response.Write "<option value='"&rs("ID")&"' valuepath='"&rs("SortPath")&"' selected>"
		Else
			response.Write "<option value='"&rs("ID")&"' valuepath='"&rs("SortPath")&"'>"
		End If
		For ClassN = 1 to ClassNum
			response.Write "│"
		Next
		response.Write "│├ "&rs("SortName")
		response.Write "</option>"
		ClassNum = ClassNum + 1
		Call ProductSort(rs("ID"), ClassNum)
		ClassNum = ClassNum - 1
		rs.movenext
	Loop
	rs.close : set rs = nothing
End Function
%>