<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../images/css.css" type=text/css rel=stylesheet>
<LINK href="../list/newhead.css" type=text/css rel=stylesheet>
<script language="JavaScript" type="text/JavaScript">
function JM_wu(ob){
 ob.style.display="none";
}
function JM_you(ob){
 ob.style.display="";
}
function uppic(model,frmname) {
 id=document.prodtable.ProdId.value;
 if (id=='') {
 alert("请先填写商品编号！");
 document.prodtable.ProdId.focus();
return false;}
window.open("upload.asp?fuptype=pic&fupname="+id+model+"&frmname="+frmname,"blank_","scrollbars=yes,resizable=no,width=650,height=450")
}

function CheckAll(form) {
 for (var i=0;i<form.elements.length;i++) {
 var e = form.elements[i];
 if (e.name != 'chkall') e.checked = form.chkall.checked; 
 }
 }
</script>
</head>
<%
if request.cookies("buyok")("admin")="" then response.write "<meta http-equiv='refresh' content='0;URL=../admin.asp'>"
%>
<!--#include file="../include/config.asp"-->

<script language=javascript src=../include/mouse.js></script>
<%
sub checkmanage(str)
Set mrs = conn.Execute("select * from manage where username='"&request.cookies("buyok")("admin")&"'")
if not (mrs.bof and mrs.eof) then
manage=mrs("manage")
if instr(manage,str)<=0 then
response.write "<script language='javascript'>"
response.write "alert('警告：您没有此项操作的权限！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
else
session("buyok_admin_login")=0
end if
else 
response.write "<script language='javascript'>"
response.write "alert('没有登陆，不能执行此操作！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
end if
set mrs=nothing
end sub
%>
<title>添加新商品</title>
<%
dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from sorts order by sortsorder ",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
   count = 0
   do while not rs.eof 
%>
subcat[<%=count%>] = new Array("<%= trim(rs("sorts"))%>","<%= rs("categoryid")%>","<%= rs("sortsid")%>");
<%
        count = count + 1
        rs.movenext
        loop
        rs.close
%>
		
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.myform.sortsid.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
             document.myform.sortsid.options[document.myform.sortsid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    

function checkpro()
{
    if(checkspace(document.myform.name.value)) {
	document.loginfo.username.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.price2.focus();
    alert("请输入商品会员价格！");
	return false;
  }
      if(checkspace(document.myform.vipprice.value)) {
	document.myform.vipprice.focus();
    alert("请输入VIP月会员商品价格！");
	return false;
  }
 
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
	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>
<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;添加商品</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30><font color="#000000">&nbsp;<a href="http://www.mcvrlab.com/help/index.asp?boardid=2&page=1" target="_blank"></a></font></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>
<%
     Set rsbp=Server.CreateObject("ADODB.Recordset")
	 sql="select * from bproduc"
	 rsbp.open sql,conn,1,3
%>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
  <form name=prodtable method="post" action="">
    <%Dim a,b,c 
set rsmid=server.createobject("adodb.recordset") 
sqlmid="select distinct LarCode,LarSeq,MidCode,midSeq from bclass order by LarSeq,MIdSeq" 
rsmid.Open sqlmid,conn,1,1 

response.write "<TR><TD width=100 align=center bgcolor=#FFFFFF>商品分类</td><td bgcolor=#FFFFFF>"
response.write "<select name='MidCode'>"
response.write"<option value='未归类^未归类' selected>---选择商品所属分类---</option>"
if rsmid.bof and rsmid.eof then
response.write "<option selected value='未归类^未归类'>-暂无商品分类-</option>"
else
Do While Not rsmid.eof
a = rsmid("larcode")
response.write "<option value='"&rsmid("larCode")&"^"&rsmid("MidCode")&"'>"&rsmid("LarSeq")&"-"&rsmid("LarCode")&" >> "&rsmid("MidSeq")&"-"&rsmid("MidCode")&"</option>"
rsmid.movenext
if rsmid.eof then exit do
if rsmid("larcode")<>a then response.write "<option value=''>--------------------------</option>"
loop
end if
rsmid.close
set rsmid=nothing

response.write "</TD></TR>"

'确定商品编号
set rs = server.createobject("adodb.recordset")
sql = "select * from bproduc where ProdId is not null"
rs.cursorlocation = 3
rs.open sql,conn,1,1 
if rs.bof and rs.eof then
 autoid=1
 else
 totalid=rs.RecordCount'根据数据库中商品总数确定下一个商品的编号
 autoid=totalid+1
end if
rs.close
set rs=nothing

autoidtxt=cstr(autoid)
 if len(autoidtxt)=1 then
 autoidtxt="000"&autoidtxt
 elseif len(autoidtxt)=2 then
 autoidtxt="00"&autoidtxt
 elseif len(autoidtxt)=3 then
 autoidtxt="0"&autoidtxt
 end if

for i=1 to totalid
'检查自动生成的编号是否有重复，若有重复则自动加1

set rs=conn.execute("select prodid from bproduc where prodid='"&autoidtxt&"'")
if not (rs.eof and rs.bof) then
 autoid=autoid+1
autoidtxt=cstr(autoid)
 if len(autoidtxt)=1 then
 autoidtxt="000"&autoidtxt
 elseif len(autoidtxt)=2 then
 autoidtxt="00"&autoidtxt
 elseif len(autoidtxt)=3 then
 autoidtxt="0"&autoidtxt
 end if
end if
set rs=nothing
next

ProdName="商品名称"
Prodid="商品编号"
shichang="市场价"
remai="优惠价"
Proddisc="商品简介"
MemoSpec="商品介绍"
Modeltext="商品型号："
prodtext1="商品单位："
prodtext2="商品品牌："
%>
    <%
Set rstxt = conn.Execute("select * from shopsetup") 
mingcheng=rstxt("ProdNametext")
bianhao=rstxt("ProdIdtext")
yuanjia=rstxt("PriceOrigintext")
xianjia=rstxt("PriceListtext")
huiyuanjia=rstxt("zidingyi2")
jifenming=rstxt("jifenname")
jianjie=rstxt("ProdDisctext")
jieshao=rstxt("MemoSpectext")
xinghao=rstxt("Modeltext")
pinpai=rstxt("prodtext1")
chandi=rstxt("prodtext2")
set rstxt=nothing
%>
    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF> <input name="Prodidtext" type="text" value="<%=bianhao%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <input name="ProdId" type="text" value="<%=autoidtxt%>" size="20" maxlength="7" readonly> 
        &nbsp;<img src=../images/admin/memo.gif alt='商品编号不能修改'></TD>
    </TR>
    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF> <input name="Prodnametext" type="text" value="<%=mingcheng%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <input name="ProdName" type="text" value="" size="20" maxlength="50"> 
        &nbsp;<img src=../images/admin/memo.gif alt='必填，不能为空'></TD>
    </TR>
    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF> <input name="Modeltext" type="text" value="<%=xinghao%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <input name="Model" type="text" value=""> &nbsp;<img src=../images/admin/memo.gif alt='选填，填写商品的其它属性<br>如：“商品型号”、“品牌”、“产地”等'></TD>
    </TR>
    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF> <input name="Prodtext1" type="text" value="<%=pinpai%>" size=7> 
      </td>
      <td bgcolor=#FFFFFF> <input name="prod1" type="text" value=""> </TD>
    </TR>
    <TR> 
      <TD width=100 align=center bgcolor=#FFFFFF><input name="Prodtext2" type="text" value="<%=chandi%>" size=7></td>
      <td bgcolor=#FFFFFF> <input name="prod2" type="text" value=""> </TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center> <input name="PriceOrigintext" type="text" value="<%=yuanjia%>" size=7> 
      </td>
      <td> <input name="PriceOrigin" type="text" value="0" size="6" maxlength="10">
        元</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center> <input name="PriceListtext" type="text" value="<%=xianjia%>" size=7> 
      </td>
      <td> <input name="PriceList" type="text" value="0" size="6" maxlength="10">
        元&nbsp;</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD align=center><input name="jifenname" type="text" value="<%=jifenming%>" size=7></td>
      <td><input name="jifenzhi" type="text" value="0" size="6" maxlength="10"></TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center>备货状态</td>
      <td> <input type="radio" name="Quantity" value="1" checked>
        有货&nbsp; <input type="radio" name="Quantity" value="0">
        缺货&nbsp;</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center>商品略图</td>
      <td> <input name="ImgPrev" type="text" value="pic/none.gif" size="40" maxlength="100"> 
        &nbsp; <INPUT alt="请单击“浏览”上传图片<br>或填写图片的网址，如<font color=blue>http://www.mcvrlab.com/pic/mp3.jpg</font><br>或填写站内的图片路径、文件名，如<font color=blue>pic/more/001.jpg</font>" TYPE="button" value="浏览" onClick="javascript:uppic('_sml','ImgPrev');"> 
        &nbsp;&nbsp; <img src=../images/admin/memo.gif alt='<font color=red>何谓“略图”：</font><br>略图也就是商品的小图片，建议制作为130象素宽<br>略图显示在首页、分类页、搜索页、商品介绍页<br><font color=red>大图显示在什么位置？</font><br>点击商品页的“查看大图”按钮可查看所有大图'></TD>
    </TR>
    <TR bgcolor="#FFFFFF">
      <TD align=center>商品大图</td>
      <td> <input name="ImgPrev2" type="text" value="pic/none.gif" size="40" maxlength="100"> 
        &nbsp; <INPUT name="button" TYPE="button" onClick="javascript:uppic('_da','ImgPrev2');" value="浏览" alt="请单击“浏览”上传图片<br>或填写图片的网址，如<font color=blue>http://www.mcvrlab.com/pic/mp3.jpg</font><br>或填写站内的图片路径、文件名，如<font color=blue>pic/more/001.jpg</font>"> 
        &nbsp;&nbsp; <img src=../images/admin/memo.gif alt='<font color=red>何谓“大图”：</font><br>大图也就是商品的大图片，建议制作为260象素宽<br>大图显示在商品介绍页<br><font color=red>大图显示在什么位置？</font><br>点击商品页的“查看大图”按钮可查看所有大图'></TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center valign="top"> <input name="ProdDisctext" type="text" value="<%=jianjie%>" size=7> 
        <br>
        (200字内)</td>
      <td><textarea name="ProdDisc" cols="60" rows="4"></textarea> </TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD align=center valign="top">商品常规信息</td>
      <td>常规属性一： 
        <input type="radio" name="kaiguan1" value="1">
        引用&nbsp; <input type="radio" name="kaiguan1" value="0" checked>
        不引用<br>
        常规属性二： 
        <input type="radio" name="kaiguan2" value="1" >
        引用&nbsp; <input type="radio" name="kaiguan2" value="0" checked>
        不引用<br>
        常规属性三： 
        <input type="radio" name="kaiguan3" value="1">
        引用&nbsp; <input type="radio" name="kaiguan3" value="0" checked>
        不引用<br>
        常规属性四： 
        <input type="radio" name="kaiguan4" value="1">
        引用&nbsp; <input type="radio" name="kaiguan4" value="0" checked>
        不引用<br>
        常规属性五： 
        <input type="radio" name="kaiguan5" value="1">
        引用&nbsp; <input type="radio" name="kaiguan5" value="0" checked>
        不引用</TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center valign="top"> <input name="MemoSpectext" type="text" value="<%=jieshao%>" size=7> 
      </td>
      <td> <br> <textarea name="MemoSpec" style="display:none"></textarea> <iframe ID="edit1" src="../edit/ewebeditor.asp?id=Memospec&style=" frameborder="0" scrolling="no" width="100%" HEIGHT="350"></iframe> 
      </TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center>是否推荐</td>
      <td> <input type="radio" name="Remark" value="0" checked>
        否&nbsp; <input type="radio" name="Remark" value="1">
        是 &nbsp;<img src=../images/admin/memo.gif alt='选择“是”将设为推荐商品'></TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD width=100 align=center>是否特价</td>
      <td> <input type="radio" name="tejia" value="0" checked>
        否&nbsp; <input type="radio" name="tejia" value="1">
        是 &nbsp;<img src=../images/admin/memo.gif alt='特价商品将出现在主页“特价商品”栏目中'></TD>
    </TR>
    <TR bgcolor="#FFFFFF"> 
      <TD colspan=2><INPUT TYPE="hidden" name=add value=ok> <INPUT TYPE="hidden" NAME="more_pic" value="0"> 
        <INPUT TYPE="hidden" NAME="zidingyi2" value="<%=huiyuanjia%>"> <INPUT TYPE="hidden" NAME="zidingyi1" value="<%=huiyuanjia%>"> 
        <INPUT TYPE="hidden" NAME="zdy2" value="自定义2"> <INPUT TYPE="hidden" NAME="zdy1" value="自定义1"> 
        <input type="submit" name="action" value="添加完成"></TD>
    </TR>
  </form>
</TABLE>
