<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim NCheck:NCheck=true
Dim rs
Dim eStr:eStr=""
%>
<!--#include file="cgi/Config.asp"-->
<%


Dim act:act=Request.Form("act")
if act="" then act=request("act")
DIm q_sn:q_sn=request("q_sn")
if not mobj.testreg(q_sn,"^(\w|-){36}$") then q_sn=""

Select case act
	case "save"
	g_id				=trim(Request.Form("g_id"))
	g_qudao				=trim(Request.Form("g_qudao"))
	g_name				=trim(Request.Form("g_name"))
	g_mprice				=trim(Request.Form("g_mprice"))
	g_price				=trim(Request.Form("g_price"))
	g_note				=trim(Request.Form("g_note"))
	g_default			=trim(Request.Form("g_default"))
	if not mobj.testreg(g_default,"^[0-1]$") then g_default=0
	
	
	'新增产品
		if g_qudao="" or g_name=""  then eStr=eStr&"<br>产品渠道，名称必填"
		if eStr="" then
			mobj.crs rs
			rs.open "select * from b2c_goods where g_qudao='"&g_qudao&"' and g_name='"&g_name&"' and g_delete=0",dstr,1,3
			if rs.eof and rs.bof then
				g_guid=mobj.GenerateGuid()
				rs.addnew()
				rs("g_guid")=g_guid
				rs("g_qudao")=g_qudao
				rs("g_name")=g_name
				rs("g_price")=g_price
				rs("g_mprice")=g_mprice
				rs("g_note")=g_note	
				rs("g_default")=g_default				
				rs.update
				act="ok"
				eStr="商品添加成功"
				if g_default=1 then mobj.cexe "update b2c_goods set g_default=0 where g_qudao='"&g_qudao&"' and g_guid<>'"&g_guid&"'"
			else
				act="error"
				eStr="数据库中已经存在此商品"
			end if
			mobj.drs rs
		else
			act="error"
		end if
	

	case else	
End Select
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>管理页面</title>
<meta http-equiv="Expires" Content="0"/>
<meta http-equiv="Cache-Control" Content="no-cache"/>
<meta http-equiv="Pragma" Content="no-cache"/>
<link href="/images/skin_1/style.css" type="text/css" rel="stylesheet"/>

<script language=javascript type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>

<base target="_self"/>
</head>
<body class="htmlbody">

<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<td class="tableline linetitle" width="200" align="left">产品频道</td>
		<td class="tableline" width="*" align="right"><a href="admin_goods.asp">频道首页</a>
			 - <a href="admin_goods_add.asp?act=add">添加商品</a>
			 - <a href="admin_goods_list.asp?ChannelID=1&order=0">商品列表</a>
			 - <a href="admin_goods_cat.asp?act=add">添加渠道</a>
			 - <a href="admin_goods_cat.asp?act=list">渠道管理</a>
			 <select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}">
<option value="admin_goods_list.asp">≡选择详细分类≡</option>
<%
mobj.crs rs
rs.open "select q_id,q_name from b2c_qudao  where q_del=0 ",dstr,1,1
do while not rs.eof
%>
<option value="admin_goods_list.asp?cid=<%=rs("q_id")%>"><%=rs("q_name")%></option>

<%


rs.movenext
loop
mobj.drs rs
%>

<option value='admin_goods_list.asp'>≡返回全部列表≡</option>
</select>
		</td>
	</tr>
</table>




<div>
<%
if act="add" then 
%>
<table  border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
        <tr>
          <th colspan="4">添加产品</th>
        </tr>
		<form action="admin_goods_add.asp" method="Post"  name="myform">
<input type="Hidden" name="act" value="save">
        <tr>
          <td width="13%" align="right" nowrap class="tablerow1"><b>所属渠道：</b></td>
          <td colspan="3" class="tablerow1">
<select name="g_qudao" id="g_qudao" style="padding:3px; font-size:14px;">

<option value="">≡选择详细分类≡</option>
<%
mobj.crs rs
rs.open "select q_id,q_name,q_sn from b2c_qudao where q_del=0 order by q_id desc ",dstr,1,1
do while not rs.eof
%>
<option value="<%=rs("q_sn")%>" <%if q_sn=rs("q_sn") then response.Write(" selected='selected'")%>><%=rs("q_name")%></option>

<%


rs.movenext
loop
mobj.drs rs
%>
</select> <font color="red">*</font>		  </td>
          </tr>
        <tr>
          <td align="right" class="tablerow2"><b>产品标题：</b></td>
          <td colspan="3" class="tablerow2"><span style="position:relative"><input name="g_name" type="text" id="searchwordbox" value="" size="60" maxlength="120">
          <font color="red">*</font><div style="display:none" id="sugAutoComplete" onselectstart="return false">&nbsp;</div></span></td>
        </tr>
        
        <tr>
          <td align="right" class="tablerow1"><b>市场价格：</b></td>
          <td width="22%" class="tablerow1"><input name="g_mprice" type="text" id="g_mprice" size="20"></td>
			<td width="9%" align="right" class="tablerow1"><b>网站价格：</b></td>
          <td class="tablerow1"><input name="g_price" type="text" id="g_price" size="20"></td>
        </tr>
         <tr>
          <td align="right" class="tablerow2"><b>是否默认：</b></td>
          <td colspan="3" class="tablerow2">
            <label>
              <input name="g_default" type="radio" id="g_default_0" value="1" />
              默认</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           
            <label>
              <input name="g_default" type="radio" id="g_default_1" value="0" checked="checked" />
              非默认</label>
           </td>
        </tr>
        <tr>
          <td align="right" class="tablerow1"><b>内部备注：</b></td>
          <td colspan="3" class="tablerow1"><textarea name="g_note" cols="80" rows="5" id="g_note"></textarea></td>
        </tr>
        <tr align="center">
          <td colspan="4" class="tablerow2">
	  <input type="button" name="Submit4" onclick="javascript:history.go(-1)" value="返回上一页" class="button">
	  <input type="submit" name="btnSubmit" value="保存产品" class="button"></td>
        </tr></form>
      </table>
      
      <%end if%>
      
      <%if act="ok" then%>
      <table align="center" border="0" cellpadding="3" cellspacing="1" class="table2">
    <tr> 
      <th colspan="2" align="left"> 成功提示信息!</th>
    </tr>
  <tr><td align="center" width="20%" class="tableline1"><img src="/images/suc.gif" width="95" height="97" border="0"></td><td width="80%" class="tableline1"> <b style="color:blue"><%=eStr%>。</b></td></tr>
  <tr><td colspan="2" align="center" height="25" class="tableline2">
 
  <a href="admin_goods_add.asp?act=add&q_sn=<%=g_qudao%>">继续添加产品</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

 
  <a href="admin_goods_edit.asp?act=edit&g_id=<%=g_guid%>">返回修改</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 

   
  <a href="admin_goods_list.asp?act=list&qudao=<%=g_qudao%>">返回产品列表</a>
  
  
  </td></tr>
</table>

      <%end if%>
      <%if act="error" then%>
<table align="center" border="0" cellpadding="3" cellspacing="1" class="table2">
    <tr> 
      <th colspan="2" align="left"> 错误提示信息!</th>
    </tr>
  <tr><td align="center" width="20%" class="tableline1"><img src="/images/err.gif" width="95" height="97" border="0"></td><td width="80%" class="tableline1"> <b style="color:blue">产生错误的可能原因：</b><br><%=eStr%></td></tr>
  <tr><td colspan="2" align="center" height="25" class="tableline2"><a href="javascript:history.go(-1)">返回上一页...</a></td></tr>
</table><p>&nbsp;</p>
<%end if%>
      
</div>





<!--#include file="end.asp"-->
</body></html>
