<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
else
if request.cookies("sundxshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
end if
end if

 function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13),"")
	fString = Replace(fString, CHR(10) & CHR(10),"")
	fString = Replace(fString, CHR(10),"")
        fString = replace(fString,   ">","")   
        fString = replace(fString,   "<","")   
        fString = replace(fString,   "&", "")   
        fString = replace(fString,   "   ","")   
        fString = replace(fString,   """","")
        fString = replace(fString, "%20","")
        
       HTMLEncode2 = fString
end function 

dim id,rs1
id=SafeRequest("id",1)

set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from product where id="&id,conn,1,1



psortsid="|"&HTMLEncode2(replace(Trim(rs1("sortsid")),", ","|"))&"|"

%>

<title>编辑商品属性</title>
<link href="css.css" rel="stylesheet" type="text/css">
<body>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" BGCOLOR="#39867B">
  <tr> 
    <td BGCOLOR="#39867B" align="center"><font color="#FFFFFF">编辑商品属性</font></td>
  </tr>
  <tr><form name="myform" method="post" action="saveaddpro.asp?action=edit&id=<%=id%>">
    <td bgcolor="#FFFFFF">
        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="0">
           <tr BGCOLOR="#ffffff"> 
    <td width="5%">选择分类： </td>
    <td height="30" >
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style='PADDING-LEFT: 6px;BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid;  BORDER-LEFT: #cccccc 1px solid; COLOR: #333333; BORDER-BOTTOM: #cccccc 1px solid; '>
   
    <% 
		  set menurs=server.CreateObject("adodb.recordset")
		  menurs.open "select * from category order by categoryorder",conn,1,1
		 if menurs.eof and menurs.bof then
               response.write "请先添加商品大类。"

             else      
           do while not menurs.eof
    %>
    <tr> 
     <td width="120" style='PADDING-LEFT: 6px;BORDER-RIGHT: #cccccc 1px solid;  BORDER-BOTTOM: #cccccc 1px solid; '>        
   
<font color=#333333> <strong><%=trim(menurs("category"))%></strong></font></td> 
             <% 

             menurs1
		  set menurs1=server.CreateObject("adodb.recordset")
		  menurs1.open "select * from sorts where categoryid="&menurs("categoryid")&"  order by sortsorder",conn,1,1
              if menurs1.eof and menurs1.bof then
          
           
               else%>
        <td style='PADDING-LEFT: 6px;BORDER-BOTTOM: #cccccc 1px solid; '>  
           <%  do while not menurs1.eof%>
  <%
sortsid=replace(rs1("sortsid"),"|",",")
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from sorts where   sortsid in ("&sortsid&")  and sortsid="&menurs1("sortsid")&" ",conn,1,1
if rs2.eof and rs2.bof then


 %>
 <% = Trim(menurs1("sorts")) %> <input type="checkbox" name="sortsid" id="sortsid"   value="<% = Trim(menurs1("sortsid")) %>" > &nbsp;&nbsp;
  <%else %>
 <% = Trim(menurs1("sorts")) %> <input type="checkbox" name="sortsid" id="sortsid"   value="<% = Trim(menurs1("sortsid")) %>"  checked> &nbsp;&nbsp;

   <% end if
rs2.close
set rs2=nothing
 %>

          
              <%  menurs1.movenext
		  loop
                 end if
		  menurs1.close
		  set menurs1=nothing %>
          </td>    </tr> 
   
   
             <%  menurs.movenext
		  loop
                end if
		  menurs.close
		  set menurs=nothing %>

</table>
</td>
  </tr>
              </select> 
          
            </td>
          </tr>
          <tr> 
            <td> <input name="prename" type="text" id="prename" size="12" value="<%=trim(rs1("prename"))%>"> 
            </td>
            <td><input name="name" type="text" id="name" size="30" value="<%=trim(rs1("name"))%>"> 商品类别:<select name="recommend" id="recommend">
			<option value="0" <% if rs1("recommend")=0 Then Response.write("Selected") %>>普通</option>
                        <option value="1" <% if rs1("recommend")=1 Then Response.write("Selected") %>>新品</option>
                        <option value="2" <% if rs1("recommend")=2 Then Response.write("Selected") %>>推荐</option>
                        <option value="3" <% if rs1("recommend")=3 Then Response.write("Selected") %>>特价</option>
                        <option value="4" <% if rs1("recommend")=4 Then Response.write("Selected") %>>赠品</option>
                  </select></td>
          </tr>
          <tr> 
            <td> <input name="company" type="text" id="company" size="12" value="<%=trim(rs1("company"))%>"> 
            </td>
            <td><input name="brand" type="text" id="brand" size="30" value="<%=trim(rs1("brand"))%>">
			<%
set rsbrand=server.createobject("adodb.recordset")
rsbrand.open "select * from sundxbrand order by brandTop ",conn,1,1
%>
              <select name="Selectbrand" onChange="(document.myform.brand.value=this.options[this.selectedIndex].value)">
                <option selected>请选择品牌</option>
				<% Do While Not rsbrand.Eof %>
                <option value="<% = Trim(rsbrand("brandName")) %>"><% = rsbrand("brandName")%></option>
                <%
rsbrand.movenext
Loop
rsbrand.close
set rsbrand=nothing
%></select>
</td>
          </tr>
          <tr> 
            <td><input name="intro" type="text" id="intro" size="12" value="<%=trim(rs1("intro"))%>"> 
            </td>
            <td><input name="introduce" type="text" id="introduce" size="30" value="<%=trim(rs1("introduce"))%>"></td>
          </tr>
          <tr> 
            <td> <input name="predate" type="text" id="predate" size="12" value="<%=trim(rs1("predate"))%>"> 
            </td>
            <td><select name="productdateyear" id="productdateyear">
                <% dim i
				for i=1980 to 2020 
				  response.write  "<option value="&i
  if int(left(rs1("productdate"),4))=i then response.write " selected "
  response.write ">"&i&"</option>" 
				next
			%>
              </select>
              年 
              <select name="productdatemonth" id="productdatemonth">
				<option value="01" <% if int(right(left(rs1("productdate"),7),2))=1 Then Response.write("Selected") %>>1</option>
        		<option value="02" <% if int(right(left(rs1("productdate"),7),2))=2 Then Response.write("Selected") %>>2</option>
				<option value="03" <% if int(right(left(rs1("productdate"),7),2))=3 Then Response.write("Selected") %>>3</option>
				<option value="04" <% if int(right(left(rs1("productdate"),7),2))=4 Then Response.write("Selected") %>>4</option>
				<option value="05" <% if int(right(left(rs1("productdate"),7),2))=5 Then Response.write("Selected") %>>5</option>
				<option value="06" <% if int(right(left(rs1("productdate"),7),2))=6 Then Response.write("Selected") %>>6</option>
				<option value="07" <% if int(right(left(rs1("productdate"),7),2))=7 Then Response.write("Selected") %>>7</option>
				<option value="08" <% if int(right(left(rs1("productdate"),7),2))=8 Then Response.write("Selected") %>>8</option>
				<option value="09" <% if int(right(left(rs1("productdate"),7),2))=9 Then Response.write("Selected") %>>9</option>
				<option value="10" <% if int(right(left(rs1("productdate"),7),2))=10 Then Response.write("Selected") %>>10</option>
				<option value="11" <% if int(right(left(rs1("productdate"),7),2))=11 Then Response.write("Selected") %>>11</option>
				<option value="12" <% if int(right(left(rs1("productdate"),7),2))=12 Then Response.write("Selected") %>>12</option>
              </select>
              月<select name="productdateday" id="productdateday">
				<option value="01" <% if int(right(left(rs1("productdate"),10),2))=1 Then Response.write("Selected") %>>1</option>
        		<option value="02" <% if int(right(left(rs1("productdate"),10),2))=2 Then Response.write("Selected") %>>2</option>
				<option value="03" <% if int(right(left(rs1("productdate"),10),2))=3 Then Response.write("Selected") %>>3</option>
				<option value="04" <% if int(right(left(rs1("productdate"),10),2))=4 Then Response.write("Selected") %>>4</option>
				<option value="05" <% if int(right(left(rs1("productdate"),10),2))=5 Then Response.write("Selected") %>>5</option>
				<option value="06" <% if int(right(left(rs1("productdate"),10),2))=6 Then Response.write("Selected") %>>6</option>
				<option value="07" <% if int(right(left(rs1("productdate"),10),2))=7 Then Response.write("Selected") %>>7</option>
				<option value="08" <% if int(right(left(rs1("productdate"),10),2))=8 Then Response.write("Selected") %>>8</option>
				<option value="09" <% if int(right(left(rs1("productdate"),10),2))=9 Then Response.write("Selected") %>>9</option>
				<option value="10" <% if int(right(left(rs1("productdate"),10),2))=10 Then Response.write("Selected") %>>10</option>
				<option value="11" <% if int(right(left(rs1("productdate"),10),2))=11 Then Response.write("Selected") %>>11</option>
				<option value="12" <% if int(right(left(rs1("productdate"),10),2))=12 Then Response.write("Selected") %>>12</option>
				<option value="13" <% if int(right(left(rs1("productdate"),10),2))=13 Then Response.write("Selected") %>>13</option>
        		<option value="14" <% if int(right(left(rs1("productdate"),10),2))=14 Then Response.write("Selected") %>>14</option>
				<option value="15" <% if int(right(left(rs1("productdate"),10),2))=15 Then Response.write("Selected") %>>15</option>
				<option value="16" <% if int(right(left(rs1("productdate"),10),2))=16 Then Response.write("Selected") %>>16</option>
				<option value="17" <% if int(right(left(rs1("productdate"),10),2))=17 Then Response.write("Selected") %>>17</option>
				<option value="18" <% if int(right(left(rs1("productdate"),10),2))=18 Then Response.write("Selected") %>>18</option>
				<option value="19" <% if int(right(left(rs1("productdate"),10),2))=19 Then Response.write("Selected") %>>19</option>
				<option value="20" <% if int(right(left(rs1("productdate"),10),2))=20 Then Response.write("Selected") %>>20</option>
				<option value="21" <% if int(right(left(rs1("productdate"),10),2))=21 Then Response.write("Selected") %>>21</option>
				<option value="22" <% if int(right(left(rs1("productdate"),10),2))=22 Then Response.write("Selected") %>>22</option>
				<option value="23" <% if int(right(left(rs1("productdate"),10),2))=23 Then Response.write("Selected") %>>23</option>
				<option value="24" <% if int(right(left(rs1("productdate"),10),2))=24 Then Response.write("Selected") %>>24</option>
				<option value="25" <% if int(right(left(rs1("productdate"),10),2))=25 Then Response.write("Selected") %>>25</option>
				<option value="26" <% if int(right(left(rs1("productdate"),10),2))=26 Then Response.write("Selected") %>>26</option>
				<option value="27" <% if int(right(left(rs1("productdate"),10),2))=27 Then Response.write("Selected") %>>27</option>
				<option value="28" <% if int(right(left(rs1("productdate"),10),2))=28 Then Response.write("Selected") %>>28</option>
				<option value="29" <% if int(right(left(rs1("productdate"),10),2))=29 Then Response.write("Selected") %>>29</option>
				<option value="30" <% if int(right(left(rs1("productdate"),10),2))=30 Then Response.write("Selected") %>>30</option>
				<option value="31" <% if int(right(left(rs1("productdate"),10),2))=31 Then Response.write("Selected") %>>31</option>
              </select>
              日</td>
          </tr>
          <tr> 
            <td><input name="price" type="text" id="price" size="12" value="<%=trim(rs1("price"))%>"></td>
            <td>市场价： 
              <input name="price1" type="text" id="price1" size="6" onkeypress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))" value="<%=rs1("price1")%>">
              元，网店价： 
              <input name="price2" type="text" id="price2" size="6" onkeypress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))" value="<%=rs1("price2")%>">
              元, 平衡费（商品邮寄超重超体积时用）： 
              <input name="vipprice" type="text" id="vipprice" size="6" onkeypress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))" value="<%=rs1("vipprice")%>">
              元，是否参与折扣： <select name="amount" id="amount">
                <option value="0" <% if rs1("amount")=0 Then Response.write("Selected") %>>否</option>
                <option value="1" <% if rs1("amount")=1 Then Response.write("Selected") %>>是</option>
              </select></td>
          </tr>
          <tr> 
            <td><input name="prestock" type="text" id="prestock" size="12" value="<%=trim(rs1("prestock"))%>"></td>
            <td>库　存： 
              <input name="stock" type="text" id="stock" size="6" value="<%=trim(rs1("stock"))%>">
              件，赠送积分： 
              <INPUT NAME="score" VALUE="<%=trim(rs1("score"))%>" SIZE="4" TYPE="text" ONKEYPRESS	= "return regInput(this,	/^[0-9]*$/,		String.fromCharCode(event.keyCode))"
		ONPASTE		= "return regInput(this,	/^[0-9]*$/,		window.clipboardData.getData('Text'))"
		ONDROP		= "return regInput(this,	/^[0-9]*$/,		event.dataTransfer.getData('Text'))">
              分</td>
          </tr>
          <tr> 
            <td><input name="other" type="text" id="other" size="12" value="<%=trim(rs1("other"))%>"></td>
            <td><input name="grade" type="text" id="grade" size="12" value="<%=trim(rs1("grade"))%>"></td>
          </tr>
          <tr> 
            <td><input name="pretype" type="text" id="pretype" size="12" value="<%=trim(rs1("pretype"))%>"></td>
            <td><input name="type" type="text" id="type" value="<%=trim(rs1("type"))%>" size="30"> 
            </td>
          </tr>
          <tr> 
            <td><input name="graph" type="text" id="graph" size="12" value="<%=trim(rs1("graph"))%>"> 
            </td>
            <td><input name="pic" type="text" id="pic" size="30" value="<%=trim(rs1("pic"))%>">
              <input type="button" name="Submit11" value="上传图片" onClick="window.open('proupfile.asp?formname=myform&editname=pic&uppath=images/upfile&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')"></td>
          </tr>
           <tr> 
            <td><input name="graph01" type="text" id="graph01" size="12" value="<%=trim(rs1("graph"))%>"> 
            </td>
            <td><input name="pic1" type="text" id="pic1" size="30" value="<%=trim(rs1("pic1"))%>">
             <input type="button" name="Submit119" value="上传图片" onClick="window.open('pproupfile.asp?formname=myform&editname=pic1&uppath=images/upfile&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')"> (如果开启缩略图功能只要上传大图，自动生成小图地址)
          </tr>
           <tr> 
            <td><input name="graph02" type="text" id="graph02" size="12" value="<%=trim(rs1("graph"))%>"> 
            </td>
            <td><input name="pic2" type="text" id="pic2" size="30" value="<%=trim(rs1("pic2"))%>">
              <input type="button" name="Submit11" value="上传图片" onClick="window.open('proupfile.asp?formname=myform&editname=pic2&uppath=images/upfile&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')"></td>
          </tr>
          <tr> 
            <td><input name="graph2" type="text" id="graph2" size="12" value="<%=trim(rs1("graph2"))%>"> 
            </td>
            <td><input name="photo" type="text" id="photo" size="30" value="<%=trim(rs1("photo"))%>">
            <input type="button" name="Submit119" value="上传图片" onClick="window.open('proupfile.asp?formname=myform&editname=photo&uppath=images/upfile&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')"> 
            </td>
          </tr>
          <tr> 
            <td><input name="link" type="text" id="link" size="12" value="<%=trim(rs1("link"))%>"></td>
            <td><input name="addlink" type="text" id="addlink" value="<%=trim(rs1("addlink"))%>" size="30"></td>
          </tr>
            <tr> 
            <td><input name="webaddress" type="text" id="webaddress" size="12" value="演示网址"></td>
            <td><input name="weblink" type="text" id="weblink" value="<%=trim(rs1("weblink"))%>" size="30"></td>
          </tr>
          <tr> 
            <td><input name="webaddress" type="text" id="webaddress" size="12" value="免费试用"></td>
            <td><input name="downloadlink" type="text" id="downloadlink" value="<%=trim(rs1("downloadlink"))%>" size="30"></td>
          </tr>
          <tr> 
            <td valign="top"> <input name="description" type="text" id="description2" size="12" value="<%=trim(rs1("description"))%>"><br>
            </td>
            <td>
		  <INPUT type="hidden" name="detail" value="<% = Server.HtmlEncode(rs1("detail")) %>">	
          <iframe ID="detail" src="htmledit/ewebeditor.asp?id=detail&style=standard" frameborder="0" scrolling="no" width="550" HEIGHT="350"></iframe> 
		  </td></tr>
          <tr> 
            <td></td>
            <td>
                
                <input type="submit" name="Submit" value="修 改" onClick="return check();">
              </td>
          </tr>
        </table>
      </td></form>
  </tr>
</table><%rs1.close
set rs1=nothing
conn.close
set conn=nothing%>
<!--#include file="footer.asp"-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function check()
{
   if(checkspace(document.myform.name.value)) {
	document.myform.name.focus();
    alert("请输入商品名称！");
	return false;
  }
     if(checkspace(document.myform.price1.value)) {
	document.myform.price1.focus();
    alert("请输入市场价！");
	return false;
  }
  if(checkspace(document.myform.price2.value)) {
	document.myform.putongjia.focus();
    alert("请输入普通会员价！");
	return false;
  }
     if(checkspace(document.myform.vipprice.value)) {
	document.myform.price2.focus();
    alert("请输入VIP会员价！");
	return false;
  }
 
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//-->
</script>
<script>
	function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}
</script>
