Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/12/2011, 09:51
homedit
 
Fecha de Ingreso: mayo-2009
Mensajes: 29
Antigüedad: 15 años
Puntos: 0
Respuesta: Actualizar un campo para controlar el stock

Hola de nuevo y gracias por responder.

el código completo de la página es este: no consigo actualizar....

<%
Response.Buffer=True
if Session("IDCLIENTE")=Cint(0) then
Response.Redirect("sinacceso.asp")
Response.End
end if
%>

<%Server.ScriptTimeout = 1000%>
<!-- #include file="conexion.asp" -->
<!-- #include file="cgi-bin/mailconf.asp" -->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>EMPRESA</title>
<link href="style.css"rel="stylesheet"type="text/css" />
</head>

<body>
<div id="contenidopagina">
<div id="encabezado">
<table width="1000" border="0" id="encabezado">
<tr>
<td width="150" rowspan="3">&nbsp;</td>
</tr>
<tr>

</tr>
<tr>
<td colspan="5" align="right" id="banner"><p>&nbsp;</p></td>
</tr>
</table>
</div>
<div id="menudearriba">
<table width="1000" border="0">
<tr>
<td width="200" class="boton2"><%=Session("IDCLIENTE")%></td>
<td width="200">&nbsp;</td>
<td width="200" align="center"><a href="index.asp">PRINCIPAL</a></td>
<td width="200">&nbsp;</td>
<td width="200">&nbsp;</td>
</tr>
</table>
</div>

<div id="cuerpo">
<table border="0" width="1000" id="cuerpo">
<tr>
<td width="1000">
<%
response.expires=0
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4

if trim(request.form("cliente"))="" then response.redirect "finpresupcli.asp?msg=Usuario o password incorrecta"


If IsArray(Session("inmobili")) = false Then
response.redirect "index.asp"
else
inmobili=Session("inmobili")
end if

cliente=replace(request.form("cliente"),"'","")
autorizacion=false

set rs = CreateObject("ADODB.Recordset")
sqltxt="Select * from CLIENTES where USUARIO='"&cliente&"' "

rs.Open sqltxt, conn
if not rs.eof then
if rs("usuario")=cliente then

autorizacion=true
CODIGOC=rs("codigoc")
NIF=rs("nif")
NOMBRE=rs("nombre")
DIRECCION=rs("direccion")
TELEFONO=rs("telefono")
POBLACION=rs("poblacion")
PROVINCIA=rs("provincia")
POSTAL=rs("postal")
MAIL=rs("mail")
else
autorizacion=false
end if
else
autorizacion=false


end if
rs.close

if autorizacion=false then

response.redirect "finpresupcli.asp?msg=Usuario o password incorrecta"
else




tabla="ARTICULOS"
campocodigo="codigoi"
campoalmacen="almaceni"
%>
<%

mensaje="<html><head>"


mensaje=mensaje& " <body> "
mensaje=mensaje& " <bgcolor=#ffffff> "
mensaje=mensaje& "<table width=90% border=1"
mensaje=mensaje& " bordercolor=#000000"
mensaje=mensaje& " bgcolor=#ffffff> "
mensaje=mensaje& " <tr><td colspan=2 align=left"
mensaje=mensaje& " bgcolor=#ffffff> "
mensaje=mensaje& " <br><font face=Trebuchet MS size=2 color=#000000>"
mensaje=mensaje& " Cliente : "&cliente
mensaje=mensaje& "<br>"
mensaje=mensaje& "Fecha : "&now()
mensaje=mensaje& "<br>"
mensaje=mensaje&"Nif : "&nif
mensaje=mensaje& "<br>"
mensaje=mensaje&"Nombre : "&nombre
mensaje=mensaje& "<br>"
mensaje=mensaje&"Telefono : "&telefono
mensaje=mensaje& "<br>"
mensaje=mensaje&"Direccion : "&direccion
mensaje=mensaje& "<br>"
mensaje=mensaje&"Poblacion : "&poblacion
mensaje=mensaje& "<br>"
mensaje=mensaje&"Provincia : "&provincia
mensaje=mensaje& "<br>"
mensaje=mensaje&"Codigo Postal : "&postal
mensaje=mensaje& "<br>"
mensaje=mensaje&"Email : "& mail
mensaje=mensaje & "</td></tr></table>"

for i=0 to ubound(inmobili)
if inmobili(i,0)<>"" and inmobili(i,1)<>"" and inmobili(i,2)<>"" then
sqltxt="select "&campocodigo&", "&campoalmacen&", pvpi, referenciai, tipoi from " &tabla& " where "&campocodigo&" ="&inmobili(i,0)

set rs=conn.execute(sqltxt)

mensaje=mensaje & "<table width=90% border=1"
mensaje=mensaje & " bordercolor=#000000"
mensaje=mensaje & " bgcolor=#ffffff> "&vbcrlf
mensaje=mensaje & " <tr><td colspan=2 align=left"&vbcrlf
mensaje=mensaje & " bgcolor=#ffffff> "&vbcrlf

mensaje=mensaje & " <td valign=top align=""left"">"&vbcrlf
mensaje=mensaje & " <font color=#000000 size=2 >"
mensaje=mensaje&"Tipo:"&rs("tipoi")&vbcrlf
mensaje=mensaje&"Código:"&inmobili(i,0)&vbcrlf
mensaje=mensaje&"Referencia:"&rs("referenciai")&vb crlf
mensaje=mensaje&"<br>N de unidades:"&inmobili(i,1)&vbcrlf
mensaje=mensaje&"<br>Precio por unidad:"&rs("pvpi")&" Euros"&vbcrlf

mensaje=mensaje & "</td></tr></table>"&vbcrlf
mensaje=mensaje & "</center> "&vbcrlf
mensaje=mensaje & "</body>"&vbcrlf
rs.close
end if
next


if enviarcorreo="SI" then

strHost = servidorcorreo
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Username=usernamecorreo
Mail.Password=passwordcorreo
Mail.Host = strHost
Mail.From = usernamecorreo
Mail.FromName = request.querystring("cliente")
Mail.AddAddress usernamecorreo

titulo="Pedidos tienda virtual"
Mail.Subject = titulo
Mail.IsHTML = True
Mail.Body = mensaje
Mail.Send

end if
%>

<p align="center" class="label">Pedido registrado correctamente </p>
<p align="center" class="label">En breve nuestro departamento comercial se pondrá en contacto
con Usted para confirmar el envío de la mercancía</p>
<p align="center" class="label"><i>Muchas gracias por confiar en nosotros</i></p>


<%
end if

%>

&nbsp;</blockquote> </td>

</tr>

</table>

<%
'aquí es dónde intento actualizar el campo almaceni de la tabla ARTICULOS
'inmobili(i,0) corresponde al código del artículo
'inmobili(i,1) corresponde a una variable donde se aloja la cantidad
'inmobili(i,2) corresponde a otra variable donde guardo lo que hay en el campo almaceni de la tabla ARTICULOS, lo utilizo sólo para mostrar el stock disponible.
sSQL="select * from ARTICULOS"
rs=conn.execute(sSQL)
do while not rs.EOF
for i=0 to ubound(inmobili)
if rs("codigoi")=inmobili(i,0) then
rs("almaceni")=rs("almaceni") - inmobili(i,1)
end if
rs.update
next
rs.movenext
loop
rs.close
conn.Close
%>

<%
session.abandon
%>

</div>
<div id="pie"></div>

</div>
</body>
</html>