Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Evilkenzera

só falta isso pra terminar.

Recommended Posts

Preciso de ajuda com esse código.

 

É quase um carrinho de compras, ele recebe o código do produto via url(querystring), e joga o produto na lista de compras.

O que acontece, é que quando ele joga o produto aqui na lista de compras, ele automaticamente manda para o banco TABELA PEDIDO_ITEM o "cod_pedido", "cod_produto" e "QTD_Pedido".

Tem um botão RECALCULAR, que quando mudo o valor do campo quantidade, ele atualiza o valor.

Porém, eu preciso colocar também além da quantidade, a altura, largura, compromento, M3, Valor, Total.

Só que não consigo atualizar estes campos no carrinho de compras.

 

Alguém pode me ajudar, só falta isso pra mim terminar.

 

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

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

<!--#include file="connections/bib_conexao.asp"-->

 

<%

Dim Conexao, rsMax, rsPedidoItem, strSQL, novo_codPedido, sub_total, field_name, strSQLPed

Dim rsCategoria, strSQL2, varID

 

call abre_conexao

 

If Session("codPed") = "" Then

Set rsMax = Server.CreateObject("ADODB.Recordset")

rsMax.Open "SELECT MAX(COD_pedido) AS max_codPedido FROM Pedidos", Conexao

If IsNull(rsMax("max_codPedido")) Then

novo_codPedido = 1

Else

novo_codPedido = rsMax("max_codPedido") + 1

End If

rsMax.Close

Set rsMax = Nothing

Conexao.Execute "INSERT INTO Pedidos (COD_Pedido) VALUES (" & novo_codPedido & ")"

Session("codPed") = novo_codPedido

End If

 

Set rsPedidoItem = Server.CreateObject("ADODB.Recordset")

If Request.QueryString("prod") <> "" Then

rsPedidoItem.Open "SELECT * FROM Pedido_Item WHERE COD_Pedido = " & Session("codPed") & " AND COD_Produto = " & Request.QueryString("prod"), Conexao

If rsPedidoItem.EOF Then

Conexao.Execute "INSERT INTO Pedido_Item (cod_Pedido, cod_Produto, qtd_Pedido, altura, largura, comprimento, m3, valor, total) VALUES (" & Session("codPed") & ", " & Request.QueryString("prod") & ", 1,1,1,1,1,1,1)"

End If

rsPedidoItem.Close

End If

 

If Request.Form <> "" Then

Conexao.Execute "DELETE FROM Pedido_Item WHERE COD_Pedido = " & Session("codPed")

For Each field_name In Request.Form

If field_name <> "B1" And Request.Form(field_name) <> "0" And Trim(Request.Form(field_name)) <> "" Then

strSQL = "INSERT INTO Pedido_Item (COD_Pedido, COD_Produto, QTD_Pedido) VALUES ("& Session("codPed") & ", " & field_name & ", " & Request.Form(field_name) & ")"

Conexao.Execute strSQL

End If

Next

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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

<style type="text/css">

<!--

body {

margin-left: 0px;

margin-top: 0px;

}

.style41 {font-weight: bold; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif;}

.style45 {font-size: 9px; }

.style48 {font-weight: bold; color: #0066CC; font-family: Verdana, Arial, Helvetica, sans-serif; }

-->

</style>

<link href="isoestilo.css" rel="stylesheet" type="text/css" />

<style type="text/css">

<!--

.style49 {font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; }

.style50 {font-family: Verdana, Arial, Helvetica, sans-serif}

.style52 {color: #000000; border: 1px solid #990000; background-color: #FFFFFF;}

.style54 {font-size: 8pt}

.style46 {font-size: 9pt;

font-family: Verdana, Arial, Helvetica, sans-serif;

}

-->

</style>

</head>

 

<body>

<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">

<!--DWLayoutTable-->

<tr>

<%

strSQLPed = "SELECT Pedido_Item.*, Produto.Produto, "

strSQLPed = strSQLPed & "Produto.VLR_Unitario, Produto.URL_Imagem "

strSQLPed = strSQLPed & "FROM Produto INNER JOIN Pedido_Item "

strSQLPed = strSQLPed & "ON Produto.COD_Produto = Pedido_Item.COD_Produto"

strSQLPed = strSQLPed & " WHERE Pedido_Item.COD_Pedido = " & Session("codPed") & " AND Produto.COD_Produto = Pedido_Item.COD_Produto"

 

Set rsPedidoItem = Conexao.Execute(strSQLPed)

 

If rsPedidoItem.EOF = True then

Response.write ("<br><br><div align=center><b>Não há produtos em sua cesta.</b>")%>

<br><br><input type="button" value="Continuar Compras" onclick="document.location='index.asp'" name="ped" />

<%Else

%>

 

<td width="750" height="400" valign="top"><form method="post" action="<%= Request.ServerVariables("SCRIPT_NAME") %>">

<table width="100%" border="0">

<tr>

<td width="10" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Código </span></div></td>

<td width="28%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Descrição</span></div></td>

<td width="5%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Qtde</span></div></td>

<td width="6%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Altura</span></div></td>

<td width="6%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Largura</span></div></td>

<td width="5%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Comp</span></div></td>

<td width="7%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Qtde M3 </span></div></td>

<td width="10%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Valor Venda </span></div></td>

<td width="11%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Total</span></div></td>

<td width="13%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center" class="style45"><span class="style41">Fornecedor</span></div></td>

<td width="4%" bordercolor="#FFFFFF" bgcolor="#0066CC"><div align="center"><span class="style45"><span class="style48">D</span></span></div></td>

</tr>

</table>

<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">

<%

If not rsPedidoItem.EOF then rsPedidoItem.MoveFirst

sub_total = 0

While Not rsPedidoItem.EOF

%>

<tr align="center">

<td width="5%" align="left" bgcolor="#EEEEEE" class="style49"><div align="center" class="style49"><font color="#000000"><%= rsPedidoItem("cod_Produto") %></font></div></td>

<td width="28%" align="left" bgcolor="#EEEEEE" class="style49"><span class="style50 style54"><font color="#000000"> <%= rsPedidoItem("Produto") %> </font> </span></td>

<td width="5%" align="right" bgcolor="#EEEEEE" class="style49"><div align="center" class="style50 style54">

<input name="<%= rsPedidoItem("cod_Produto") %>" type="text" class="style52" id="<%= rsPedidoItem("cod_Produto") %>" value="<%= rsPedidoItem("QTD_Pedido") %>" size="1" maxlength="2" autocomplete="off" />

</div></td>

<td width="6%" align="center" bgcolor="#EEEEEE" class="style49"><span class="style50 style54">

<input name="altura" type="text" class="style52" id="altura" value="<%= rsPedidoItem("altura") %>" size="1" maxlength="2" autocomplete="off" />

</span></td>

<td width="6%" height="13" align="right" bgcolor="#EEEEEE" class="style49"><div align="center"><span class="style46">

<input name="txtLargura" type="text" class="form" id="txtLargura" value="<%= rsPedidoItem("largura") %>" size="1" maxlength="5" />

</span></div></td>

<td width="5%" align="right" bgcolor="#EEEEEE" class="style49"><div align="center"><span class="style46">

<input name="txtComprimento" type="text" class="form" id="txtComprimento" value="<%= rsPedidoItem("comprimento") %>" size="1" maxlength="5" />

</span></div></td>

<td width="7%" align="right" bgcolor="#EEEEEE" class="style49"><div align="center"><span class="style46">

<input name="txtM3" type="text" class="form" id="txtM3" value="<%= rsPedidoItem("m3") %>" size="2" maxlength="5" />

</span></div></td>

<td width="10%" align="right" bgcolor="#EEEEEE" class="style49"><div align="center"><span class="style46">

<input name="txtValor" type="text" class="form" id="txtValor" value="<%= rsPedidoItem("valor") %>" size="6" maxlength="10" />

</span></div></td>

<td width="101" align="right" bgcolor="#EEEEEE" class="style49"><div align="center"><span class="style46">

<input name="txtTotal" type="text" class="form" id="txtTotal" value="<%= rsPedidoItem("total") %>" size="7" maxlength="10" />

</span></div></td>

<td width="13%" align="right" bgcolor="#EEEEEE" class="style49"> </td>

<td width="4%" height="13" align="center" bgcolor="#EEEEEE" class="style49"><a href="ExcluiItem.asp?prod=<%= rsPedidoItem("cod_Produto")%>" class="style54 style50"><img src="lixeira.jpg" width="15" height="20" border="0" /></a> </td>

</tr>

<%

'Calcula subtotal e peso total

sub_total = sub_total + rsPedidoItem("QTD_Pedido") * rsPedidoItem("VLR_Unitario")

rsPedidoItem.MoveNext

Wend

rsPedidoItem.Close

Session("sub_total") = sub_total

sub_total = replace(sub_total, ",",".")

Conexao.Execute "UPDATE Pedidos SET sub_total = " & sub_total & " WHERE cod_Pedido = " & Session("codPed")

'Conexao.Close

%>

</table>

<table width="605" border="0" align="center">

<tr>

<td height="31"><div align="center">

<input type="button" value="Continuar Compras" onclick="document.location='os_passo2.asp'" name="button" />

    

<input type="submit" value="Recalcular" name="B1" />

    

<input type="button" value="Excluir Carrinho" onclick="document.location='excluir_carrinho.asp'" name="button2" />

</div></td>

</tr>

</table>

<table width="605" border="0" align="center">

<tr>

<td><label></label></td>

</tr>

<tr>

<td><div align="center"> </div></td>

</tr>

</table>

</form>

<%

End If

%>

</td>

</tr>

</table>

<%

Conexao.Close

%>

</body>

</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Depende do ponto de vista... ;)

Não sei onde depende, mas beleza...Acho que aprender é tudo!Caro Evilkenzera,Tenho um mini curso que ensina a fazer uma loja virtual, passo-a-passo, caso esteja interessando me manda uma MP que eu de dou meu e-mail ai te mando por e-mail!Abraços t+

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.