Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera, estou com um problema para trabalhar com sessions em asp. Vou postar o código pra ficar mais fácil a compreensão. A primeira página é orcamento.asp Nela o cliente seleciona os produtos que deseja inserir no orçamento. Até aí tranquilo. Ao clicar em finalizar, é chamada a pág. fim.asp, que é responsável por finalizar e inserir os dados no bd. Eu quero acrescentar outros campos para especificar o data,solicitante e seus dados. Estou acrescentando o campo data como no exemplo só que ao invés de inserir a data digitada ela insere o valor do CONST DATA = 5 que é o nº 5. Alguém pode me ajudar?
Página orcamento.asp
<%@LANGUAGE="VBSCRIPT"%>
<%
CONST COD_PROD = 0
CONST NOME_PROD = 1
CONST PRECO_PROD = 2
CONST QUANTIDADE_PROD = 3
CONST PRECO_TOT = 4
CONST DATA = 5
IF NOT isArray( Session( "carrinho" ) ) THEN
DIM carrinho_atual( 5, 20 )
ELSE
carrinho_atual = Session( "carrinho" )
END IF
codigo_produto = TRIM( Request( "codigo_produto" ) )
nome_produto = TRIM( Request( "nome_produto" ) )
preco_produto = TRIM( Request( "preco_produto" ) )
IF codigo_produto <> "" THEN
comprado = FALSE
FOR i = 0 TO UBOUND( carrinho_atual )
IF carrinho_atual( COD_PROD, i ) = codigo_produto THEN
carrinho_atual( QUANTIDADE_PROD, i ) = carrinho_atual( QUANTIDADE_PROD, i ) + 1
comprado = TRUE
EXIT FOR
END IF
NEXT
IF NOT comprado THEN
FOR i = 0 TO UBOUND( carrinho_atual, 2 )
IF carrinho_atual( COD_PROD, i ) = "" THEN
carrinho_atual( DATA, i ) = data
carrinho_atual( COD_PROD, i ) = codigo_produto
carrinho_atual( NOME_PROD, i ) = nome_produto
carrinho_atual( PRECO_PROD, i ) = preco_produto
carrinho_atual( QUANTIDADE_PROD, i ) = 1
EXIT FOR
END IF
NEXT
END IF
END IF
IF Request( "atualizar" ) <> "" THEN
FOR i = 0 TO UBOUND( carrinho_atual, 2 )
nova_quantidade = TRIM( Request( "quantidade" & carrinho_atual( COD_PROD, i ) ) )
deletar=TRIM( Request( "deletar" & carrinho_atual( COD_PROD, i ) ) )
IF nova_quantidade = "" or nova_quantidade = "0" or deletar="0" THEN
carrinho_atual( COD_PROD, i ) = ""
ELSE
IF isNumeric( nova_quantidade ) THEN
carrinho_atual( QUANTIDADE_PROD, i ) = nova_quantidade
END IF
END IF
NEXT
END IF
Session( "carrinho" ) = carrinho_atual
%>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css"> margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}</style>
<link href="multyserv.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}</script>
</head>
<body><table width="100%" border="0" id="estrutura">
<tr>
<td height="130"> </td>
</tr>
<tr>
<td height="500"><table width="700" height="500" border="0" align="center" id="meio">
<tr>
<td width="800" valign="top">
<form id="itens" name="itens" method="post" action="">
<input name="atualizar" type="hidden" id="atualizar" value="1" />
<table width="693" border="0" class="formulario">
<tr>
<td width="207">Data:
<label>
<input type="text" name="data" id="data" />
</label></td>
<td width="175"> </td>
<td width="65"> </td>
<td width="81"> </td>
<td width="61"> </td>
<td width="78"> </td>
</tr>
<tr align="center" bgcolor="#333333">
<td colspan="2"><span class="sub_titulos">Produto</span></td>
<td><span class="sub_titulos">Valor</span></td>
<td><span class="sub_titulos">Quantidade</span></td>
<td><span class="sub_titulos">Excluir</span></td>
<td><span class="sub_titulos">Valor Total</span></td>
</tr>
<tr>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="5" align="right" valign="baseline" bgcolor="#000000"><span class="sub_titulos">Total Geral</span></td>
<td> </td>
</tr>
</table>
<p>
<label><span class="branco">.............</span>
<input name="button" type="submit" class="formulario" id="button" value="Atualizar" />
</label>
<label>
<input name="button2" type="button" class="formulario" id="button2" onclick="MM_goToURL('parent','add_prod.asp');return document.MM_returnValue" value="Adicionar outro produto" />
</label>
<input name="button3" type="button" class="formulario" id="button3" onclick="MM_goToURL('parent','add_servico.asp');return document.MM_returnValue" value="Adicionar outro serviço" />
<input name="button5" type="button" class="formulario" id="button5" onclick="MM_goToURL('parent','fim.asp');return document.MM_returnValue" value="Finalizar" />
</p>
</form></td>
</tr>
</table></td>
</tr>
<tr>
<td height="50"> </td>
</tr>
</table>
</body>
</html>
Página fim.asp
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/loja_conexao.asp" -->
<%
Dim pedido__MMColParam
pedido__MMColParam = "1"
If (Request.QueryString("cod_pedido") <> "") Then
pedido__MMColParam = Request.QueryString("cod_pedido")
End If
%>
<%
conexao=MM_loja_conexao_STRING
CONST COD_PROD = 0
CONST NOME_PROD = 1
CONST PRECO_PROD = 2
CONST QUANTIDADE_PROD = 3
CONST PRECO_TOT = 4
CONST DATA = 5
IF NOT isArray( Session( "carrinho" ) ) THEN
DIM carrinho_atual( 6, 20 )
ELSE
carrinho_atual = Session( "carrinho" )
END IF
Session( "carrinho" ) = carrinho_atual
Dim rspedido
Dim rspedido_numRows
Set rspedido = Server.CreateObject("ADODB.Recordset")
rspedido.ActiveConnection = conexao
rspedido.Source = "SELECT * FROM pedido"
rspedido.CursorType = 0
rspedido.CursorLocation = 2
rspedido.LockType = 3
rspedido.Open()
rspedido_numRows = 0
Dim rsdetalhe
Dim rsdetalhe_numRows
Set rsdetalhe = Server.CreateObject("ADODB.Recordset")
rsdetalhe.ActiveConnection = conexao
rsdetalhe.Source = "SELECT * FROM pedido_detalhe"
rsdetalhe.CursorType = 0
rsdetalhe.CursorLocation = 2
rsdetalhe.LockType = 3
rsdetalhe.Open()
rsdetalhe_numRows = 0
action_formulario=Request.ServerVariables("SCRIPT_NAME")
if Request("inserir") <> "" then
Randomize
valor_gerado=Int(Rnd * 1000000000)
rspedido.AddNew
rspedido("campo_gerado")=valor_gerado
rspedido("data")=carrinho_atual( DATA, i )
rspedido("total")=Session("total")
For Each camp_obt in rspedido.Fields
if Len(Request(camp_obt.Name)) > 0 then
camp_obt.Value = Request(camp_obt.Name)
end if
Next
rspedido.Update
rspedido.Requery
rspedido.Filter= "campo_gerado='" & valor_gerado & "'"
Session("OrderID")=rspedido("cod_pedido")
end if
if Request("inserir") <> "" then
valor_unico=Session("OrderID")
sub salvar(RS_pd)
RS_pd.AddNew
RS_pd.Fields("cod_pedido")=valor_unico
RS_pd.Fields("cod_produto")=carrinho_atual( COD_PROD, i )
RS_pd.Fields("quantidade")=carrinho_atual( QUANTIDADE_PROD, i )
RS_pd.Fields("produto")=carrinho_atual( NOME_PROD, i )
RS_pd.Fields("preco")=carrinho_atual( PRECO_PROD, i )
RS_pd.Update
end sub
FOR i = 0 TO UBOUND( carrinho_atual, 2 )
if carrinho_atual(COD_PROD,i) <> "" then
Call salvar(rsdetalhe)
end if
next
Response.Redirect "list_orc.asp"
end if
%>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css"> margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}</style>
<link href="multyserv.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" id="estrutura">
<tr>
<td height="130"> </td>
</tr>
<tr>
<td height="500"><table width="700" height="500" border="0" align="center" id="meio">
<tr>
<td width="800" valign="top">
<form action="<%=action_formulario%>" method="post" name="formulario" id="formulario">
<h3>Teste</h3>
<input type="submit" name="Submit" value="Confirmar" />
<input type="button" name="voltar" value="Voltar" onclick="history.go(-1)" />
<input type="hidden" name="inserir" value="1" />
</form></td>
</tr>
</table></td>
</tr>
<tr>
<td height="50"> </td>
</tr>
</table>
</body>
</html>
<%
rspedido.Close()
Set rspedido = Nothing
rsdetalhe.Close()
Set rsdetalhe = Nothing
%>
Carregando comentários...