<!--#include file="../conn/conn.asp"-->
<!--#include file="../conn/nosql.asp"-->
<!--#include file="../conn/config.asp"-->
<!--#include file="../conn/md5.asp"-->

<%if Not ChkPosturl then response.redirect ("login.asp")
if session("adminname")="" then
  response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
  response.End
end if
  action=request.QueryString("action")
  minilx=nosql(trim(request("minilx")))
  mininame=nosql(trim(request("mininame")))
  minijg=nosql(trim(request("minijg")))
  pic=nosql(trim(request("pic")))
  pic2=nosql(trim(request("pic2")))
  mininame2=nosql(trim(request("mininame2")))
  minijg2=nosql(trim(request("minijg2")))
  bigclassid=nosql(trim(request("bigclassid")))
  smllclassid=nosql(trim(request("smllclassid")))
  sydate=nosql(trim(request("sydate")))
  sydate2=nosql(trim(request("sydate2")))
if action= "minisave" then
if isChkInteger(request.QueryString("id")) then
id=request("id")
else
Response.Redirect ("../index.asp")
end if
  set rs=server.CreateObject("adodb.recordset")
  rs.Open "select * from mini_minilist where id="&id,conn,1,3
  rs("mininame")=mininame
  rs("minijg")=minijg
  rs("minilx")=minilx
  rs("bigclassid")=bigclassid
  rs("smllclassid")=smllclassid
  rs("minipic")=pic
  rs("sydate")=sydate
  rs("mininew")=int(request("mininew"))
  rs.Update
  rs.Close
  set rs=nothing
    response.write "<script language='javascript'>"
    response.write "alert('操作成功，正在返回！');"
    response.write"this.location.href='mini_minilist.asp';</SCRIPT>"
    response.End
end if
'//添加新数据
if action= "miniadd" then
  set rs=server.CreateObject("adodb.recordset")
  rs.open "select * from mini_minilist",conn,1,3
  rs.addnew
  rs("mininame")=mininame2
  rs("minijg")=minijg2
  rs("minipic")=pic2
  rs("minilx")=minilx
  rs("sydate")=sydate2
  rs("bigclassid")=bigclassid
  rs("smllclassid")=smllclassid
  rs("mininew")=int(request("mininew2"))
  rs.update
  rs.close
  set rs=nothing
    response.write "<script language='javascript'>"
    response.write "alert('添加成功，正在返回！');"
    response.write"this.location.href='mini_list_save.asp?action=add';</SCRIPT>"
    response.End
end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../css.css" rel="stylesheet" type="text/css">
</head>
<%dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from mini_smllclass order by smllid ",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("smllname"))%>","<%= rs("bigclassid")%>","<%= rs("id")%>");
<%
        count = count + 1
        rs.movenext
        loop
        rs.close
%>
		
onecount=<%=count%>;

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

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { //这句不是很理解
             document.myform.smllclassid.options[document.myform.smllclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }
</script>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/right_top2.gif">
  <tr>
    <td width="1%">&nbsp;</td>
    <td width="99%"><table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="30%" style="font-size:14px;color:#ffffff">&nbsp;<strong><font color="#000000">商品管理</font></strong></td>
          <td width="70%" align="right">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
</table>
<br><%if action="save" then%>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#9DB2D4">
  <%if isChkInteger(request.QueryString("id")) then
id=request("id")
else
Response.Redirect ("../index.asp")
end if
  set rs2=server.CreateObject("adodb.recordset")
        rs2.Open "select * from mini_minilist where id="&id,conn,1,1
        do while not rs2.EOF
		%>
  <form name="myform" method="post" action="?action=minisave&id=<%=int(rs2("id"))%>">
    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8"><div align="center"> </div>&nbsp;&nbsp;        <%
        rs.open "select * from mini_bigclass order by bigid",conn,1,1
	if rs.eof and rs.bof then
	response.write "请先添加栏目。"
	response.end
	else
%>
所属大类
<select name="bigclassid" size="1" id="bigclassid" onChange="changelocation(document.myform.bigclassid.options[document.myform.bigclassid.selectedIndex].value);xx(myform.smllclassid.value);" class="wenbenkuang">


    <option selected value="<%=rs("id")%>"><%=trim(rs("bigname"))%></option>
    <%      dim selclass
         selclass=rs("id")
        rs.movenext
        do while not rs.eof
%>
    <option value="<%=rs("id")%>" <%if rs2("bigclassid")=rs("id") then%>selected<%end if%>><%=trim(rs("bigname"))%></option>
    <%
        rs.movenext
        loop
	end if
        rs.close
%>
</select>
　所性小类
<select name="smllclassid" class="wenbenkuang" id="smllclassid" onChange="xx(myform.smllclassid.value)">
<script language="javascript">
function xx(DDDD){
SS1.innerHTML= "<a href=# onclick=\"window.open('../upload.asp?formname=myform&editname=pic&infoname="+DDDD+"','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')\">上传图片</a>"
}
</script>

    <%rs.open "select * from mini_smllclass where bigclassid="&rs2("bigclassid") ,conn,1,1
if not(rs.eof and rs.bof) then
mini_id=rs("id")
%>
    <option selected value="<%=rs("id")%>"><%=rs("smllname")%></option>
    <% rs.movenext
do while not rs.eof%>
    <option value="<%=rs("id")%>" <%if rs2("smllclassid")=rs("id") then%>selected<%end if%>><%=rs("smllname")%></option>
    <% rs.movenext
loop
end if
        rs.close
        set rs = nothing
%>
</select>

类型<font color="#FF0000">
<select name="minilx" id="minilx">
  <option value="0" <%if rs2("minilx")=0 then%>selected<%end if%>>普通</option>
  <option value="1" <%if rs2("minilx")=1 then%>selected<%end if%>>场景</option>
  <option value="2" <%if rs2("minilx")=2 then%>selected<%end if%>>地板</option>
  <option value="3" <%if rs2("minilx")=3 then%>selected<%end if%>>壁纸</option>
  <option value="4" <%if rs2("minilx")=4 then%>selected<%end if%>>心情</option>
  <option value="5" <%if rs2("minilx")=5 then%>selected<%end if%>>表情</option>
  <option value="6" <%if rs2("minilx")=6 then%>selected<%end if%>>上装</option>
  <option value="7" <%if rs2("minilx")=7 then%>selected<%end if%>>下装</option>
  <option value="8" <%if rs2("minilx")=8 then%>selected<%end if%>>头发</option>
  <option value="9" <%if rs2("minilx")=9 then%>selected<%end if%>>装饰</option>
</select>
</font><div align="center"> </div></td>
    </tr>
    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8">&nbsp;&nbsp; 商品名称
        <input name="mininame" type="text" class="wenbenkuang" id="mininame3" value="<%=trim(rs2("mininame"))%>" size="32">
&nbsp;&nbsp;商品图片
<input name="pic" type="text" class="wenbenkuang" id="pic" value="<%=trim(rs2("minipic"))%>" size="32">
<font id=SS1><a href=# onClick="window.open('../upload.asp?formname=myform&editname=pic&infoname=<%=mini_id%>','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">上传图片</a></font> </td>
    </tr>    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8">&nbsp;&nbsp; 使用期限
        <input name="sydate" type="text" class="wenbenkuang" id="sydate2" value="<%=trim(rs2("sydate"))%>" size="16">
价格
<input name="minijg" type="text" class="wenbenkuang" id="minijg" value="<%=trim(rs2("minijg"))%>" size="16">
&nbsp;&nbsp;新品
<%select case rs2("mininew")
                case "1"
                response.Write "<input type=radio name=mininew value=1 checked>是&nbsp;<input name=mininew type=radio value=0 >否"
                case "0"
                response.Write "<input type=radio name=mininew value=1>是&nbsp;<input name=mininew type=radio value=0 checked>否"
                end select%>
&nbsp;&nbsp;
<input type="submit" name="Submit" value="修 改" class="go-wenbenkuang">
&nbsp; </td>
    </tr>

  </form>
  <%rs2.movenext
        loop
        rs2.close
        set rs2=nothing
        %>
</table>
<%end if%>
<br>
<%if action="add" then%>
<br>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#9DB2D4">
  <form name="myform" method="post" action="?action=miniadd">
    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8"> &nbsp;&nbsp;
        <%
        rs.open "select * from mini_bigclass order by bigid",conn,1,1
	if rs.eof and rs.bof then
	response.write "请先添加栏目。"
	response.end
	else
%>
所属大类
<select name="bigclassid" size="1" id="bigclassid" onChange="changelocation(document.myform.bigclassid.options[document.myform.bigclassid.selectedIndex].value);xx(myform.smllclassid.value);" class="wenbenkuang">
  <option selected value="<%=rs("id")%>"><%=trim(rs("bigname"))%></option>
  <% 
         selclass=rs("id")
        rs.movenext
        do while not rs.eof
%>
  <option value="<%=rs("id")%>"><%=trim(rs("bigname"))%></option>
  <%
        rs.movenext
        loop
	end if
        rs.close
%>
</select>
　所性小类
<select name="smllclassid" class="wenbenkuang" id="smllclassid" onChange="xx(myform.smllclassid.value)">
<script language="javascript">
function xx(DDDD){
SS1.innerHTML= "<a href=# onclick=\"window.open('../upload.asp?formname=myform&editname=pic2&infoname="+DDDD+"','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')\">上传图片</a>"
}
</script>
  <%rs.open "select * from mini_smllclass where bigclassid="&selclass ,conn,1,1
if not(rs.eof and rs.bof) then
mini_id=rs("id")
%>
  <option selected value="<%=rs("id")%>"><%=rs("smllname")%></option>
  <% rs.movenext
do while not rs.eof%>
  <option value="<%=rs("id")%>"><%=rs("smllname")%></option>
  <% rs.movenext
loop
end if
        rs.close
        set rs = nothing
%>
</select>
类型<font color="#FF0000">
<select name="minilx" id="minilx">
  <option value="0" selected>普通</option>
  <option value="1">场景</option>
  <option value="2">地板</option>
  <option value="3">壁纸</option>
  <option value="4">心情</option>
  <option value="5">表情</option>
  <option value="6">上装</option>
  <option value="7">下装</option>
  <option value="8">头发</option>
  <option value="9">装饰</option>
</select>
</font> </td>
    </tr>
    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8">&nbsp;&nbsp; 商品名称
        <input name="mininame2" type="text" class="wenbenkuang" id="mininame22" size="32">
&nbsp;&nbsp;商品图片
<input name="pic2" type="text" class="wenbenkuang" id="pic2" size="32">
<font id=SS1><a href=# onClick="window.open('../upload.asp?formname=myform&editname=pic2&infoname=<%=mini_id%>','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">上传图片</a></font></td>
    </tr>
    <tr bgcolor="#F0F3F8">
      <td colspan="2" bgcolor="#F0F3F8">&nbsp;&nbsp; 使用期限
        <input name="sydate2" type="text" class="wenbenkuang" id="minijg2" value="30" size="16">
        价格
        <input name="minijg2" type="text" class="wenbenkuang" id="minijg22" size="16" value="">
&nbsp;&nbsp;新品
<input type="radio" name="mininew2" value="1">
是
<input name="mininew2" type="radio" value="0" checked>
否&nbsp;&nbsp;
<input type="submit" name="Submit2" value="添 加" class="go-wenbenkuang"></td>
    </tr>
  </form>
</table>
<%end if%>
</body>
</html>
<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>
<script language=javascript>
function mm1()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>
