<!--#include file="conn.asp"-->
<script src="js/jquery.min.js"></script>

<% 
if session("login")<>"1" then
response.write("<script>alert('未登录或者登陆超时，请重新登陆！');window.location.href='login.asp';</script>")   
response.end() 
end if

 %>

<% 

conn.open Str
sql = "select * from articulo where articuloid='"&request.Form("ArticuloID")&"'"
set rs = conn.execute(sql)

  If not(rs.bof and rs.eof) then
response.write("<script>alert('此条形码已有记录!\nCodigo barra repetido!');window.location.href='index.asp?get=good';window.android.playFailed();</script>")   
    rs.close
    set rs=nothing
    response.End()
   End If
  rs.close
  conn.close
  set rs=nothing  







if request.QueryString("ac")="anadir" and request.QueryString("ArticuloID")<>"" then
 %> 


<form id="form1" name="form1" method="post" action="?ac=add">
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
            <td height="40" colspan="4" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;"><div align="center"><span class="Menu1">添加商品</span><br /><span class="Menu2">NUEVO PRODUCTO </div>

    </tr>
    <tr bgcolor="#F5F5F5">
      <td width="30%" height="35"><div align="right">商品编码：<br />
      <div align="center" class="STYLE15">PRO.ID </div>
      </div></td>
      <td height="35" colspan="2" bgcolor="#F5F5F5"><label>
        <input name="articuloid" type="text" id="ArticuloID" style="width:130px;height:20px;" value="<%= request.QueryString("ArticuloID")  %>" autocomplete="off"/>
      *</label>        </td>
      <td rowspan="2"><div align="center">
        <label><input type="submit" name="Submit" value="OK保存" style="background-color:<%= bgcolor %>;opacity:<%= opacity %>;" class="Menu1" /></label>
      </div></td>
    </tr>
    <tr>
      <td height="35" bgcolor="#F5F5F5"><div align="right">商品条码：<br />
            <div align="center" class="STYLE15">CODIGO</div>
      </div></td>
      <td height="35" colspan="2" bgcolor="#F5F5F5"><label>
        <input name="Codigobarra" type="text" id="articuloid" style="width:130px;height:20px;" autocomplete="off"/>
      </label></td>
    </tr>
    <tr>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">西文名称：<br />
      <div align="center" class="STYLE15">NOMBRE ES </div>
      </div></td>
      <td height="35" colspan="2" bgcolor="#F5F5F5"><input name="NombreES" type="text" id="nombrees" style=" width:130px;height:20px;" autofocus="autofocus" autocomplete="off"/>
      *</td>
      <td height="35" bgcolor="#F5F5F5"><div align="center">
	  <% if autoprint="1" then %>
          <input name="print" type="checkbox" id="print" value="1" checked="checked" />
		<% else %>  
		<input name="print" type="checkbox" id="print" value="1" />
		<% end if %>
		打印价签
        </div></td>
    </tr>
    <tr bgcolor="#F5F5F5">
      <td width="30%" height="35" bgcolor="#F5F5F5" ><div align="right">中文名称：<br />
      <div align="center" class="STYLE15">NOMBRE CH</div>
      </div></td>
      <td height="35" bgcolor="#F5F5F5" ><input name="NombreCN" type="text" id="nombrecn" style=" width:100px;height:20px;" autocomplete="off" /></td>
      <td height="35" bgcolor="#F5F5F5"><div align="right">始库存：<br />
            <div align="center" class="STYLE15">STOCK INICIAL</div>
      </div></td>
      <td height="35" bgcolor="#F5F5F5" ><input name="stock" type="number" step="0.001" pattern="\d*"/  id="stock" style=" width:60px;height:20px;" value="1" autocomplete="off" /></td>
    </tr>
	    <tr>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">类别：<br />
        <div align="center" class="STYLE15">CATEGORIA</div></div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5">
	   <%
	  conn.open Str
 sql = "select * from articuloclase "
set rs = conn.execute(sql)
   %>
    <label>
        <select name="ClaseID" id="ClaseID" style=" width:60px;height:20px;">
		<%
       while not rs.eof
   %>
          <option value="<%= rs("ClaseID") %>" ><%= left(rs("NombreES"),20) %></option>
<% 
  rs.movenext
  wend
  rs.close
  conn.close
  set rs=nothing 

%>
        </select>
      </label>	  </td>
      <td height="35" bgcolor="#F5F5F5"><div align="right">供应商：<br />
      <div align="center" class="STYLE15">PROVEEDOR</div></div></td>
	  <td height="35" bgcolor="#F5F5F5">
	  <%
	  conn.open Str
 sql = "select * from proveedor "
set rs = conn.execute(sql)
   %>
    <label>
        <select name="Empresaid" id="Empresaid" style=" width:60px;height:20px;">

		<%
       while not rs.eof
   %>
          <option value="<%= rs("EmpresaID") %>" ><%= left(rs("NombreES"),20) %></option>
<% 
  rs.movenext
  wend
  rs.close
  conn.close
  set rs=nothing 

%>
        </select>
      </label></td>
    </tr>
    <tr>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">进货价：<br />
      <div align="center" class="STYLE15">P.ENTRADA</div>
      </div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5"><input name="PrecioCoste" type="number" step="0.001"/ id="PrecioCoste"  style=" width:60px;height:20px;" pattern="\d*" autocomplete="off" /></td>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">零售价：<br />
      <div align="center" class="STYLE15">P.VENTA</div>
      </div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5"><input name="PrecioDetalle" type="number" step="0.001"/ id="PrecioDetalle" style=" width:60px;height:20px;" pattern="\d*" autocomplete="off" /></td>
    </tr>

    <tr bgcolor="#F5F5F5">
      <td width="30%" height="35"><div align="right">批发价：<br />
      <div align="center" class="STYLE15">P. AL MAYOR</div>
      </div></td>
      <td width="25%" height="35"><input type="number" step="0.001"/ id="PrecioMayor" name="PrecioMayor" style=" width:60px;height:20px;" pattern="\d*" autocomplete="off" /></td>
      <td width="30%" height="35"><div align="right">特别价：<br />
      <div align="center" class="STYLE15">P..ESP</div>
      </div></td>
      <td width="25%" height="35"><input   type="number" step="0.001"/  id="PrecioEspecial" name="PrecioEspecial" style=" width:60px;height:20px;" pattern="\d*" autocomplete="off" /></td>
    </tr>
    <tr>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">发票价：<br />
      <div align="center" class="STYLE15">P. FACTURA </div>
      </div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5"><input name="PrecioFactura"  type="number" step="0.001"/  id="PrecioFactura" style=" width:60px;height:20px;" pattern="\d*" autocomplete="off" /></td>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">会员价：<br />
      <div align="center" class="STYLE15">P.SOCIO</div>
      </div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5"><input name="PrecioSocio"  type="number" step="0.001"/  id="PrecioSocio" style=" width:60px;height:20px;" pattern="\d*" autocomplete="off" /></td>
    </tr>
    <tr>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">整包数：<br />
      <div align="center" class="STYLE15">CANT.PAQUETE</div></div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5"><input name="CantidadPorUnidad"  type="number" step="0.001" pattern="\d*"/  id="CantidadPorUnidad" style=" width:60px;height:20px;" value="1" autocomplete="off" /></td>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">整箱数：<br />
      <div align="center" class="STYLE15">CANT.CAJA</div></div></td>
      <td width="25%" height="35"><input name="CantidadPorUnidad2"  type="number" step="0.001" pattern="\d*"/  id="CantidadPorUnidad2" style=" width:60px;height:20px;" value="1" autocomplete="off"/></td>
    </tr>
	
	
    <tr>
      
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">折扣%：<br />
      <div align="center" class="STYLE15">DESCUENDO</div></div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5"><input name="Descuento"  type="number" step="0.001" pattern="\d*"/  id="Descuento" style=" width:60px;height:20px;" autocomplete="off" /></td>
    <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">销售规则：<br />
          <div align="center" class="STYLE15">CANT.VENTA</div>
    </div></td>
      <td width="25%" height="35" bgcolor="#F5F5F5"><label>
        <select name="UnidadUsarRegla" id="UnidadUsarRegla">
          <option value="0">不使用</option>
          <option value="1">整包销售</option>
          <option value="2">整箱销售</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">库存上限：<br />
              <div align="center" class="STYLE15">STOCK.MAX</div>
      </div></td>
      <td height="35" bgcolor="#F5F5F5"><input name="MaxiStock" type="text" id="NombreCN" style=" width:60px;height:20px;" autocomplete="off" /></td>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">库存下限：<br />
              <div align="center" class="STYLE15">STOCK.MINI</div>
      </div></td>
      <td height="35" bgcolor="#F5F5F5"><input name="MiniStock" type="text" id="NombreCN2" style=" width:60px;height:20px;" autocomplete="off" /></td>
    </tr>
    <tr>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">仓库位置：<br />
              <div align="center" class="STYLE15">SITIO.ALMACEN</div>
      </div></td>
      <td height="35" bgcolor="#F5F5F5"><input name="SitioEnAlmacen" type="text" id="SitioEnAlmacen" style=" width:80px;height:20px;" autocomplete="off" /></td>
      <td width="30%" height="35" bgcolor="#F5F5F5"><div align="right">货架位置：<br />
              <div align="center" class="STYLE15">SITIO.ESTANTE</div>
      </div></td>
      <td height="35" bgcolor="#F5F5F5"><input name="SitioEnEstante" type="text" id="SitioEnEstante" style=" width:80px;height:20px;" autocomplete="off" /></td>
    </tr>
	<tr>
      <td width="25%" height="34"><div align="right">单位名称：<br />
              </div>        <div align="center" class="STYLE15">
          <div align="right">UNIDAD NOMBRE </div>
        </div></td>
      <td height="34"><select name="UnidadNombre" id="UnidadNombre" style=" width:100px;height:20px;">
        <option value="" selected="selected"></option>
		<option value="El Kilo">El Kilo</option>
        <option value="El Litro">El Litro</option>
               </select></td>
      <td height="34">
      <div align="right">
        <div align="right">重量容量：<br />
        </div>
        <div align="center" class="STYLE15">
          <div align="right">VOLUMEN PESO </div>
        </div>
      </div>      </td>
      <td height="34"><input name="VolumenPeso" type="text" id="VolumenPeso" style=" width:60px;height:20px;" value="0" autocomplete="off" /></td>
	    </tr>
    <tr>
      <td height="35" bgcolor="#F5F5F5"><div align="right">禁止修改折扣：<br />
      </div>
      <div align="center" class="STYLE15"></div></td>
      <td height="35" bgcolor="#F5F5F5"><label>
        <input name="DescuentoCambioProhibido" type="checkbox" id="DescuentoCambioProhibido" value="-1" />
      </label></td>
      <td height="35" bgcolor="#F5F5F5"><div align="right">禁用：<br />
            <div align="center" class="STYLE15">BLOQUEADO</div>
      </div></td>
      <td height="35" bgcolor="#F5F5F5"><label>
        <input name="Bloqueado" type="checkbox" id="Bloqueado" value="-1" />
      </label></td>
    </tr>
    <tr>
      <td height="40"><div align="right">备注：<br />
      </div>
        <div align="center" class="STYLE15">
          <div align="right">Nota</div>
      </div></td>
      <td height="40" colspan="3"><input name="photo" type="text" id="photo" style=" width:220px;height:25px;" autocomplete="off" /></td>
    </tr>
    <tr>
      <td height="40" colspan="4" align="center">&nbsp;</td>
    </tr>
  </table>
</form>

<% 
end if


if request.QueryString("ac")="add" and request.Form("ArticuloID")="" then
response.write("<script>alert('商品编码不能为空！\nCodigo barra no puede dejar en blanco!');window.history.go(-1);window.android.playFailed();</script>")
response.End()
end if
if request.QueryString("ac")="add" and request.Form("NombreES")="" then
response.write("<script>alert('商品名称不能为空！\nNombre articulo no puede dejar en blanco!');window.history.go(-1);window.android.playFailed();</script>")
response.End()
end if



if request.QueryString("ac")="add" and request.Form("ArticuloID")<>"" and request.Form("NombreES")<>"" then
conn.open Str

if request.Form("PrecioDetalle")="" then
PrecioDetalle="0"
else 
PrecioDetalle=request.Form("PrecioDetalle")
end if

if request.Form("PrecioCoste")="" then
PrecioCoste="0"
else 
PrecioCoste=request.Form("PrecioCoste")
end if

if request.Form("PrecioMayor")="" then
PrecioMayor="0"
else 
PrecioMayor=request.Form("PrecioMayor")
end if

if request.Form("PrecioEspecial")="" then
PrecioEspecial="0"
else 
PrecioEspecial=request.Form("PrecioEspecial")
end if

if request.Form("PrecioFactura")="" then
PrecioFactura="0"
else 
PrecioFactura=request.Form("PrecioFactura")
end if

if request.Form("PrecioSocio")="" then
PrecioSocio="0"
else 
PrecioSocio=request.Form("PrecioSocio")
end if

if request.Form("MiniStock")="" then
MiniStock="0"
else 
MiniStock=request.Form("MiniStock")
end if

if request.Form("MaxiStock")="" then
MaxiStock="0"
else 
MaxiStock=request.Form("MaxiStock")
end if

if request.Form("Descuento")="" then
Descuento="0"
else 
Descuento=request.Form("Descuento")
end if

if request.Form("DescuentoCambioProhibido")="" then
DescuentoCambioProhibido="0"
else 
DescuentoCambioProhibido=request.Form("DescuentoCambioProhibido")
end if

if request.Form("Bloqueado")="" then
Bloqueado="0"
else 
Bloqueado=request.Form("Bloqueado")
end if

set addnewpro=conn.execute("insert into articulo(ArticuloID,Codigobarra,NombreES,NombreCN,PrecioDetalle,PrecioCoste,PrecioMayor,PrecioEspecial,PrecioFactura,PrecioSocio,CantidadPorUnidad,CantidadPorUnidad2,ClaseID,FechaPrecioCoste,Descuento,EmpresaID,UnidadUsarRegla,MiniStock,MaxiStock,SitioEnAlmacen,SitioEnEstante,DescuentoCambioProhibido,Bloqueado,Descripcion,UnidadNombre,VolumenPeso)values('"& request.Form("ArticuloID") &"','"& request.Form("Codigobarra") &"','"& request.Form("NombreES") &"','"& request.Form("NombreCN") &"','"& PrecioDetalle &"','"&PrecioCoste &"','"&PrecioMayor &"','"& PrecioEspecial &"','"& PrecioFactura &"','"& PrecioSocio &"','"& request.Form("CantidadPorUnidad") &"','"& request.Form("CantidadPorUnidad2") &"','"& request.Form("ClaseID") &"','"& date() &"','"& Descuento &"','"& request.Form("EmpresaID") &"','"& request.Form("UnidadUsarRegla") &"','"& MiniStock &"','"& MaxiStock &"','"& request.Form("SitioEnAlmacen") &"','"& request.Form("SitioEnEstante") &"','"& DescuentoCambioProhibido &"','"& Bloqueado &"','"& request.Form("photo") &"','"& request.Form("UnidadNombre") &"','"& request.Form("VolumenPeso") &"')")

set addstock=conn.execute("insert into stock (ArticuloID,stock)values('"& request.Form("ArticuloID") &"','"& request.Form("stock") &"')")
add="ok"
conn.close


if request.Form("print")="1" then

	if ventamode="1" then
	precio=request.Form("preciodetalle")
	else
	precio=request.Form("preciomayor")
	end if

if precio="" then  
response.write("<script>alert('商品添加成功，产品价格为空，无法打印！\nProducto guardado!No se impremir articulo con precio vacio!');window.location.href='index.asp?get=good';</script>")  
response.End()
end if

	if billetecode="1" then
	precioxs=formatnumber(precio,2,-1,-1,0)
	else
	precioxs=precio
	end if

 if modelo="0" and style="1"  then
tipo="1"
papel="普通58MM连续纸"
papeles="Papel 58MM Continuo"
end if

 if modelo="0" and style="2"  then
tipo="9"
papel="普通58MM连续纸"
papeles="Papel 58MM Continuo"
end if

 if modelo="0" and style="3"  then
tipo="13"
papel="普通58MM连续纸"
papeles="Papel 58MM Continuo"
end if

 if modelo="0" and style="80"  then
tipo="10"
papel="普通80MM连续纸"
papeles="Papel 80MM Continuo"
end if

if modelo="1" and style="13" then
tipo="6"
papel="58MM*40MM间隙贴纸"
papeles="58MM*40MM Pegatina Adhesivo"
end if

if modelo="1" and style="18" then
tipo="18"
papel="58MM*40MM间隙贴纸"
papeles="58MM*40MM Pegatina Adhesivo"
end if

if modelo="1" and style="14" then
tipo="14"
papel="58MM*40MM间隙贴纸"
papeles="58MM*40MM Pegatina Adhesivo"
end if
	


if EName2IgualEName1="0" then
name1=left(request.Form("nombrees"),EName1MAX)
name2=left(request.Form("nombrecn"),EName2MAX)
else
name1=left(request.Form("nombrees"),EName1MAX)
name2=mid(request.Form("nombrees"),EName1MAX+1,EName2MAX)
end if

if request.Form("UnidadNombre")="" then
UnidadNombre="Litro/Kg"
else
UnidadNombre=request.Form("UnidadNombre")
end if

if request.Form("VolumenPeso")="" or request.Form("VolumenPeso")="0" then
nota1=nota
else
nota1=UnidadNombre&":"&formatnumber(1/formatnumber(request.Form("VolumenPeso"),2,-1,-1,0)*formatnumber(precio,2,-1,-1,0),2,-1,-1,0)&billete
end if

if notaxs="1" then
notaprint=nota
end if

if notaxs="2" then
notaprint=date()
end if

if notaxs="3" then
notaprint=nota1
end if

if notaxs="4" then
notaprint=request.Form("SITIOENALMACEN")&"-"&request.Form("SitioEnEstante")
end if

if Printidocodigo="2" and request.Form("Codigobarra")<>"" then
code=request.Form("Codigobarra")
else
code=request.Form("ArticuloID")
end if

if tipo="10" then
response.Redirect("almacen.asp?ac=print&tipo="&tipo&"&articuloid="&code&"&preciodetalle="&precioxs&"&Url=index&nombrees="&Server.URLEncode(name1)&"&nota="& notaprint &"&name2="&Server.URLEncode(name2)&"&tiendaname="& Server.URLEncode(tiendaname)&"&billete="& billete &"&tiendanamesize="& tiendanamesize &"&tiendanamealign="& tiendanamealign &"&name1size="& name1size &"&name1align="& name1align &"&name2size="& name2size &"&name2align="& name2align &"&preciosize="& preciosize &"&precioalign="& precioalign &"&fxsize="& fxsize &"&fxalign="& fxalign &"&notasize="& notasize &"&notaalign="& notaalign &"&codesize="& codesize &"&codealign="& codealign &"&billetesize="& billetesize &"&billetealign="& billetealign &"&codebarwidth="& codebarwidth &"&codebarheight="& codebarheight &"&fx="& fx &"&BilleteAntes="& BilleteAntes &"&estado=商品添加成功\nProducto guardado!  ")
else
response.Redirect("impremir.asp?ac=imp&tipo="&tipo&"&articuloid="&code&"&preciodetalle="&precioxs&"&Url=index&nombrees="&Server.URLEncode(name1)&"&nota="& notaprint &"&name2="&Server.URLEncode(name2)&"&tiendaname="& Server.URLEncode(tiendaname)&"&billete="& billete &"&tiendanamesize="& tiendanamesize &"&tiendanamealign="& tiendanamealign &"&name1size="& name1size &"&name1align="& name1align &"&name2size="& name2size &"&name2align="& name2align &"&preciosize="& preciosize &"&precioalign="& precioalign &"&fxsize="& fxsize &"&fxalign="& fxalign &"&notasize="& notasize &"&notaalign="& notaalign &"&codesize="& codesize &"&codealign="& codealign &"&billetesize="& billetesize &"&billetealign="& billetealign &"&codebarwidth="& codebarwidth &"&codebarheight="& codebarheight &"&fx="& fx &"&BilleteAntes="& BilleteAntes &"&estado=商品添加成功\nProducto guardado!  ")
end if
end if

response.write("<script>alert('商品添加成功\nProducto guardado!');window.location.href='index.asp?get=good';window.android.playSuccess();</script>")  
response.End()
end if

 %>
<div style="height:300px"/></div>


<!--#include file="fooder.asp"-->