<!--#include file="../Inc/Consts.inc" -->
<!--#include file="Admin_htmlconfig.Asp"-->
<!--#include file="../Inc/common.Asp" -->
<!--#include file="../Inc/strfunc.Asp" -->
<!--#include file="Inc/editfunc.Asp" -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="Images/Admin_style.css">
<script language="javascript" src="Images/Disp.js"></script>
<script src="../tqeditor/TQEditor.js" type="text/javascript"></script>
<script language=javascript>
ie = (document.all)? true:false
if (ie){
function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.editForm.submit();}}
}
</script>
<%
' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com
If InStr(SsMasterPurview, "|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, ProductName, ViewFlag, SortName, SortID, SortPath
Dim CommendFlag, NewFlag, SeoKeywords, SeoDescription,OrderNum,proper,proper_value
Dim SmallPic, BigPic, OtherPic, Content
Dim Sorts,tempSort
Dim rs,sql
ID = request.QueryString("ID")
Call ProductEdit()

%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="editForm" method="post" id="editForm" action="Ss_ProductEdit.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="10%" align="right" class="forumRow">产品名称：</td>
      <td width="90%" class="forumRowHighlight"><input name="ProductName" type="text" id="ProductName" style="width: 280" value="<%=ProductName%>" maxlength="250">
        是否生效：
        <input name="ViewFlag" type="checkbox" value="1" <%if ViewFlag then response.write ("checked")%>>
        是否推荐：
        <input name="CommendFlag" type="checkbox" style="height: 13px;width: 13px;" value="1" <%if CommendFlag then response.write ("checked")%>>
        是否新品：
        <input name="NewFlag" type="checkbox" value="1" style="height: 13px;width: 13px;" <%if NewFlag then response.write ("checked")%>>
        <font color="red">*</font> <input type="button" name="btn" value="复制标题" title="复制标题到：MetaDescription、MetaKeywords" onclick="javascript:CopyWebTitle(document.editForm.ProductName.value);"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">MetaKeywords：</td>
      <td class="forumRowHighlight"><input name="SeoKeywords" type="text" id="SeoKeywords" style="width: 500" value="<%=SeoKeywords%>" maxlength="250"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">MetaDescription：</td>
      <td class="forumRowHighlight"><input name="SeoDescription" type="text" id="SeoDescription" style="width: 500" value="<%=SeoDescription%>" maxlength="250"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">产品类别：</td>
      <td class="forumRowHighlight"><select name="Sorts">
      <%=SortSelect("ProductSort",0,SortID)%>
      </select>        <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">产品排序：</td>
      <td class="forumRowHighlight"><input name="OrderNum" type="text" size="8" maxlength="5" value="<%=OrderNum%>" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"  />
        只允许输入数字，默认值为9999</td>
    </tr>
    
<%
If Result = "Modify" Then
   
    sql = "select proper,proper_value from ["&Datapre&"_Products] where ID="& ID
    set rs=db(sql,2)
    If rs.bof And rs.EOF Then  response.Write ("<center>数据库记录读取错误！</center>"):response.End

	Dim proper_1,proper_value_1,Num_1
    If rs("proper")<>"" And rs("proper_value")<>"" Then
        proper_1 = Split(rs("proper"), "§§§")
        proper_value_1 = Split(rs("proper_value"), "§§§")
        Num_1 = UBound(proper_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" nowrap="nowrap">自定义产品属性：</td>
      <td class="forumRowHighlight"><input name="Num_1" type="text" id="Num_1" value="<%=Num_1%>" size="5" />个 <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">
        <%Dim i
		For i=0 to (Num_1-1)%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="28">属性名称：
              <input name="attribute<%=i+1%>" type="text" id="attribute<%=i+1%>" value="<%=proper_1(i)%>" size="18" />
              属性值：
              <input name="attribute<%=i+1%>_value" type="text" id="attribute<%=i+1%>_value" value="<%=proper_value_1(i)%>" size="50" /></td>
          </tr>
        </table>
        <%Next%>
        </span> </td>
    </tr>
    </tr>

    <tr>
      <td align="right" class="forumRow" height="42">产品小图：</td>
      <td class="forumRowHighlight"><div style="float:left;width:270px;height:25px;line-height:25px;"><input name="SmallPic" type="text" id="SmallPic" style="width:200px;" value="<%=SmallPic%>"><input type="checkbox" onClick="display('upload1');" id="box1"/><label for='box1'>上传图片</label></div>
		<div id="upload1" style="float:left;display:none;">			
		<iframe frameborder=0 width=290 height=25 scrolling=no src="Ss_upload.asp?action=SmallPic&filetype=1&flag=reload"></iframe>
		</div>
        <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow" height="42">产品大图：</td>
      <td class="forumRowHighlight"><div style="float:left;width:270px;height:25px;line-height:25px;"><input name="BigPic" type="text" id="BigPic" style="width:200px;" value="<%=BigPic%>"><input type="checkbox" onClick="display('upload2');" id="box2"/><label for='box2'>上传图片</label></div>
		<div id="upload2" style="float:left;display:none;">			
		<iframe frameborder=0 width=290 height=25 scrolling=no src="Ss_upload.asp?action=BigPic&filetype=1&flag=reload"></iframe>
		</div>
        <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">更多图片：</td>
      <td class="forumRowHighlight"><textarea rows="5" cols="80" name="OtherPic" id="OtherPic"><%=OtherPic%></textarea>
        <input type="checkbox" onClick="display('upload3');" id="box3"/><label for='box3'>上传图片</label></div>
		<div id="upload3" style="display:none;">			
		<iframe frameborder=0 width=290 height=25 scrolling=no src="Ss_upload.asp?action=OtherPic&filetype=1&flag=addstr"></iframe>
		</div></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">产品介绍：</td>
      <td class="forumRowHighlight"><textarea id="content" rows="18" cols="100"  name="content" wrap="virtual" onkeydown="ctlent()"><% = Content%></textarea>
<script type="text/javascript" defer> 
 new tqEditor('content', {toolbar:'full', uploadFieldName:'filedata',imageUploadUrl:'./upload.asp', imageFileTypes:'*.jpg;*.gif;*.png;*.jpeg',directInsertUploadImage:'true'}); 
</script>
</td>
    </tr>
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" accesskey="s" value="(Alt+S)保存">
        <input type="button" value="返回上一页" onclick="history.back(-1)"></td>
    </tr>
  </form>
</table>
<%
Sub ProductEdit()
    Dim Action, rsRepeat, numbers
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
       
        If Len(Trim(request.Form("ProductName")))<1 Then call Alert("请填写产品名称！","b-1"):response.End
        If Request.Form("Sorts") = "" Then Call Alert("请选择所属分类！","b-1"):response.End
        If LTrim(request.Form("SmallPic")) = "请上传产品小图！" Then Call Alert("","b-1"):response.End
        If LTrim(request.Form("BigPic")) = "" Then Call Alert("请上传产品大图！","b-1"):response.End        
        If LTrim(request.Form("Content")) = "" Then Call Alert("请填写产品介绍！","b-1"):response.End
        If Result = "Add" Then
            sql = "select ID,ProductName,ViewFlag,SortID,SortPath,CommendFlag,NewFlag,smallPic,BigPic,OtherPic,Content,OrderNum,proper,proper_value,SeoKeywords,SeoDescription from ["&Datapre&"_Products]"
            set rs=db(sql,3)
            rs.addnew
            call savedatas()
            rs.update
			ID = rs("ID")
            rs.Close:Set rs = Nothing

            If ISHTML = 1 Then Call htmll("", "", ""&ProName&""&Separated&""&ID&"."&HTMLName&"", "ProductView.Asp", "ID=", ID, "", "")
        End If
        If Result = "Modify" Then
            sql = "select ID,ProductName,ViewFlag,SortID,SortPath,CommendFlag,NewFlag,smallPic,BigPic,OtherPic,Content,OrderNum,proper,proper_value,SeoKeywords,SeoDescription from ["&Datapre&"_Products] where ID="&ID
            set rs=db(sql,3)
            call savedatas()
            rs.update
            rs.Close
            Set rs = Nothing
            If ISHTML = 1 Then Call htmll("", "", ""&ProName&""&Separated&""&ID&"."&HTMLName&"", "ProductView.Asp", "ID=", ID, "", "")
        End If
        If ISHTML = 1 Then
            Call Alert( "提交成功，相关静态页面已更新！","Ss_ProductList.Asp")
        Else
            Call Alert( "提交成功！","Ss_ProductList.Asp")
        End If
    Else
        If Result = "Modify" Then           
            sql = "select ID,ProductName,ViewFlag,SortID,SortPath,CommendFlag,NewFlag,smallPic,BigPic,OtherPic,Content,OrderNum,proper,proper_value,SeoKeywords,SeoDescription from ["&Datapre&"_Products] where ID="& ID
            set rs=db(sql,2)
            If rs.bof And rs.EOF Then response.Write ("<center>数据库记录读取错误！</center>"):response.End
            ProductName = rs("ProductName")
            ViewFlag = rs("ViewFlag")
            SortID = rs("SortID")
            SortPath=rs("SortPath")
            CommendFlag = rs("CommendFlag")
            NewFlag = rs("NewFlag")
            SmallPic = rs("SmallPic")
            BigPic = rs("BigPic")
            OtherPic = rs("OtherPic")
            Content = rs("Content")
            SeoKeywords = rs("SeoKeywords")
            SeoDescription = rs("SeoDescription")
			OrderNum=rs("OrderNum")
			proper=rs("proper")
			proper_value=rs("proper_value")
            rs.Close:Set rs = Nothing
        End If
    End If
End Sub

sub savedatas()
rs("ProductName") = Trim(Request.Form("ProductName"))
            If Request.Form("ViewFlag") = 1 Then
                rs("ViewFlag") = 1
            Else
                rs("ViewFlag") = 0
            End If
            Sorts=Request.Form("Sorts")
            If Sorts = "" Then 
			Call Alert("请选择所属分类","b-1"):response.End
            Else
			tempSort=split(Sorts,"|")
                rs("SortID") = tempSort(0)
                rs("SortPath") = tempSort(1)
            End If
            if request.Form("OrderNum")="" then
			rs("OrderNum")=9999
			else
			rs("OrderNum")=request.Form("OrderNum")
			end if
            If Request.Form("CommendFlag") = 1 Then
                rs("CommendFlag") = 1
            Else
                rs("CommendFlag") = 0
            End If
            If Request.Form("NewFlag") = 1 Then
                rs("NewFlag") = 1
            Else
                rs("NewFlag") = 0
            End If
           
            rs("SmallPic") = Trim(Request.Form("SmallPic"))
            rs("BigPic") = Trim(Request.Form("BigPic"))
            rs("OtherPic") = Trim(Request.Form("OtherPic"))
            rs("Content") = RTrim(Request.Form("Content"))
            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("attribute"&i), 0)<>"" And CheckStr(Request.Form("attribute"&i&"_value"), 0)<>"" Then
                        If proper = "" Then
                            proper = CheckStr(Request.Form("attribute"&i), 0)
                            proper_value = CheckStr(Request.Form("attribute"&i&"_value"), 0)
                        Else
                            proper = proper&"§§§"&CheckStr(Request.Form("attribute"&i), 0)
                            proper_value = proper_value&"§§§"&CheckStr(Request.Form("attribute"&i&"_value"), 0)
                        End If
                    End If
                Next
            End If
            rs("proper") = proper
            rs("proper_value") = proper_value
            rs("SeoKeywords") = Trim(Request.Form("SeoKeywords"))
            rs("SeoDescription") = Trim(Request.Form("SeoDescription"))
end sub
%>