Ir para conteúdo

POWERED BY:

Arquivado

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

José Davi Reges de Souza

Problemas com Soma

Recommended Posts

Caros amigos, por favor eu peço a ajuda de vocês para resolver esse problema, pois o pagamento da minha faculdade depende do pagamento desse cliente...

O problema é o seguinte, estou terminando a implantação da loja no dominio do cliente, e esta quase tudo ok, o problema é que no banco de dados o valor do frete esta como $2,00 pra um determinado estado, mas... quando tento selecionar o estado na lista o valor do frete que aparece é de 122.253.236.256,23 e não consigo encontrar o erro, por favor me ajudem, segue o codigo fonte da pagina em questão:


 

Pedidos = "SELECT Pedidos.*, Produtos.* "

Pedidos = Pedidos & "FROM Pedidos INNER JOIN Produtos ON Pedidos.CodProduto = Produtos.Cod "

Pedidos = Pedidos & "WHERE Secao = '"& VarCliente &"' And Finalizado=False"

Set Pedidos = Banco.Execute(Pedidos)

 

Set SomaTotal = Banco.Execute("Select SUM(PrecoTotal) AS SomaTotal FROM Pedidos WHERE Secao = '"& VarCliente &"'")

 

Set Regioes = Banco.Execute("SELECT * FROM Frete ORDER BY Regiao ASC")

 

If Session("Regiao") = "" Then

 

VarValorBase = 0

 

Else

 

Set Frete = Banco.Execute("Select * From Frete Where Cod="& Session("Regiao"))

 

VarValorBase = Replace(Replace(Frete("ValorBase"),".",""),",",".")

'Response.Write VarValorBase

 

End If

 

%>

<script language="JavaScript" type="text/JavaScript">

<!--

function MM_jumpMenu(targ,selObj,restore){ //v3.0

eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");

if (restore) selObj.selectedIndex=0;

}

 

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+".location='"+args[i+1]+"'");

}

//-->

</script>

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

<tr>

<td><!--#include file="Includes/BarraCima.asp"--></td>

</tr>

<tr>

<td>

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

<tr>

<td width="176" height="100%" valign="top"><!--#include file="Includes/BarraEsq.asp"--></td>

<td width="0" valign="top">

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

<tr>

<td height="9%" align="center"><img src="Imagens/SpacerCima.gif" width="1" height="9"></td>

</tr>

<%If VarAct = "" Then%>

<tr>

<td height="20" align="center" bgcolor="<%=FundoTitulo%>"><div align="left">  <span class="TextTahoma11AzulBold">Carrinho de compras</span></div></td>

</tr>

<tr>

<td height="9%" align="center"> </td>

</tr>

<tr>

<td height="10%" align="center">

<%

 

If Request.QueryString("Mensagem") = "ErroCesta" Then

Response.Write "<center><span class="& Chr(34) &"TextTahoma11VermelhoBold"& Chr(34) &"><br>Quantidade em estoque insuficiente!</span></center><br>"

End If

 

%>

</td>

</tr>

<tr>

<td align="center" valign="middle">

<%

 

If Pedidos.EOF Then

Response.Write "<center><span class="& Chr(34) &"TextTahoma11CinzaBold"& Chr(34) &"><br>Seu carrinho de compras está vazio.</span></center><br><br>" & Voltar

Else

 

%>

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

<form action="AltCesta.asp?Act=Quantidade" method="post" name="AltQuantidade">

<tr bgcolor="<%=TabelaBarraEsq%>">

<td width="7%" height="20" align="center"><span class="TextTahoma11CinzaBold">Qtd</span></td>

<td height="20"><div align="center"><span class="TextTahoma11CinzaBold">Nome</span></div></td>

<td width="9%" height="20" bgcolor="<%=TabelaBarraEsq%>"><div align="center"><span class="TextTahoma11CinzaBold"></span><span class="TextTahoma11CinzaBold"> Remover </span></div></td>

<td width="15%" height="20"><div align="center"><span class="TextTahoma11CinzaBold">Valor unit.</span></div></td>

<td width="16%" height="20" align="center"><div align="center"><span class="TextTahoma11CinzaBold">Sub-Total</span></div></td>

</tr>

<%

 

Dim VarSubTotal

 

WHILE NOT Pedidos.EOF

 

If Session("Regiao") <> "" Then

 

VarFrete = Replace(Replace(Frete("ValorQuilo") * Pedidos("Peso") * Pedidos("Quantidade"),".",""),",",".")

 

Else

 

VarFrete = 0

 

End If

 

Banco.Execute("Update Pedidos Set Frete='"& VarFrete &"', ValorBase='"& VarValorBase &"' Where Cod="& Pedidos("Pedidos.Cod"))

 

VarSubTotal = Pedidos("Preco") * Pedidos("Quantidade")

 

If Linha Then

 

%>

<tr bgcolor="<%=FundoCelula1%>">

<%

 

End If _linenums:0'><!--#include file="Includes/Config.asp"--><link href="Includes/Styles.css" rel="stylesheet" type="text/css"><%Dim PedidosDim LinhaDim VarClienteDim SomaTotalDim FreteDim RegioesDim RegiaoDim VarActDim VarFreteDim VarMethodDim VarValorBaseDim VarValorFreteVarAct = Request.QueryString("Act")VarCliente = Session.SessionIDVarMethod = Request.QueryString("Method")Session("Endereco") = Request.ServerVariables("SCRIPT_NAME") &"?"& Request.ServerVariables("QUERY_STRING")Call AbreBanco'Set Pedidos = Banco.Execute("SELECT * FROM Pedidos WHERE Secao = '"& VarCliente &"' And Finalizado=False")Pedidos = "SELECT Pedidos.*, Produtos.* "Pedidos = Pedidos & "FROM Pedidos INNER JOIN Produtos ON Pedidos.CodProduto = Produtos.Cod "Pedidos = Pedidos & "WHERE Secao = '"& VarCliente &"' And Finalizado=False"Set Pedidos = Banco.Execute(Pedidos)Set SomaTotal = Banco.Execute("Select SUM(PrecoTotal) AS SomaTotal FROM Pedidos WHERE Secao = '"& VarCliente &"'")Set Regioes = Banco.Execute("SELECT * FROM Frete ORDER BY Regiao ASC")If Session("Regiao") = "" Then VarValorBase = 0Else Set Frete = Banco.Execute("Select * From Frete Where Cod="& Session("Regiao")) VarValorBase = Replace(Replace(Frete("ValorBase"),".",""),",",".") 'Response.Write VarValorBaseEnd If%><script language="JavaScript" type="text/JavaScript"><!--function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0;}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+".location='"+args[i+1]+"'");}//--></script><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><!--#include file="Includes/BarraCima.asp"--></td> </tr> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="176" height="100%" valign="top"><!--#include file="Includes/BarraEsq.asp"--></td> <td width="0" valign="top"> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="9%" align="center"><img src="Imagens/SpacerCima.gif" width="1" height="9"></td> </tr> <%If VarAct = "" Then%> <tr> <td height="20" align="center" bgcolor="<%=FundoTitulo%>"><div align="left">  <span class="TextTahoma11AzulBold">Carrinho de compras</span></div></td> </tr> <tr> <td height="9%" align="center"> </td> </tr> <tr> <td height="10%" align="center"> <% If Request.QueryString("Mensagem") = "ErroCesta" Then Response.Write "<center><span class="& Chr(34) &"TextTahoma11VermelhoBold"& Chr(34) &"><br>Quantidade em estoque insuficiente!</span></center><br>" End If %> </td> </tr> <tr> <td align="center" valign="middle"> <% If Pedidos.EOF Then Response.Write "<center><span class="& Chr(34) &"TextTahoma11CinzaBold"& Chr(34) &"><br>Seu carrinho de compras está vazio.</span></center><br><br>" & Voltar Else %> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF"> <form action="AltCesta.asp?Act=Quantidade" method="post" name="AltQuantidade"> <tr bgcolor="<%=TabelaBarraEsq%>"> <td width="7%" height="20" align="center"><span class="TextTahoma11CinzaBold">Qtd</span></td> <td height="20"><div align="center"><span class="TextTahoma11CinzaBold">Nome</span></div></td> <td width="9%" height="20" bgcolor="<%=TabelaBarraEsq%>"><div align="center"><span class="TextTahoma11CinzaBold"></span><span class="TextTahoma11CinzaBold"> Remover </span></div></td> <td width="15%" height="20"><div align="center"><span class="TextTahoma11CinzaBold">Valor unit.</span></div></td> <td width="16%" height="20" align="center"><div align="center"><span class="TextTahoma11CinzaBold">Sub-Total</span></div></td> </tr> <% Dim VarSubTotal WHILE NOT Pedidos.EOF If Session("Regiao") <> "" Then VarFrete = Replace(Replace(Frete("ValorQuilo") * Pedidos("Peso") * Pedidos("Quantidade"),".",""),",",".") Else VarFrete = 0 End If Banco.Execute("Update Pedidos Set Frete='"& VarFrete &"', ValorBase='"& VarValorBase &"' Where Cod="& Pedidos("Pedidos.Cod")) VarSubTotal = Pedidos("Preco") * Pedidos("Quantidade") If Linha Then %> <tr bgcolor="<%=FundoCelula1%>"> <% End If : Linha = not Linha %> <td height="20" align="center"><input name="Quantidade" type="text" class="FormQuantidade" value="<%=Pedidos("Quantidade")%>" size="3" maxlength="3"></td> <td height="20"><span class="TextTahoma11Cinza"> </span><a href="MaisProduto.asp?Produto=<%=Pedidos("CodProduto")%>" class="LinkTahoma11Cinza"><%=Pedidos("Produto")%><input name="Pedido" type="hidden" id="Pedido" value="<%=Pedidos("Pedidos.Cod")%>"></a> <input name="Produto" type="hidden" id="Produto" value="<%=Pedidos("CodProduto")%>"></td> <td width="9%" height="20"><div align="center"><a href="AltCesta.asp?Act=Deletar&Pedido=<%=Pedidos("Pedidos.Cod")%>"><img src="Imagens/IcDelete.gif" width="12" height="12" border="0"></a></div></td> <td height="20"> <% valordopedido = FormatCurrency(Pedidos("Preco")) valorr = replace(valordopedido, "R"," ") %> <div align="center"><span class="TextTahoma11Cinza"> <%=valorr%></span><input type="hidden" name="Preco" value="<%=valordopedido%>"></div></td> <td height="20" align="center"> <div align="right"><span class="TextTahoma11Cinza"><%precodosubtotal = FormatCurrency(VarSubTotal)precosubformatado = replace(precodosubtotal, "R"," ")%><%=precosubformatado%> </span></div></td> </tr> <% Pedidos.MOVENEXT : WEND Dim SomaFrete Set SomaFrete = Banco.Execute("Select SUM(Frete) AS SomaFrete FROM Pedidos WHERE Secao = '"& VarCliente &"'") 'Response.Write SomaFrete("SomaFrete") %> <tr bgcolor="#EEEEEE"> <td height="30" colspan="5"><div align="right"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="90"><span class="TextTahoma11Cinza"> Escolha a região: </span></td> <td width="0"><select name="Regiao" onChange="MM_jumpMenu('parent',this,0)" class="FormRegioes"> <% If Session("Regiao") = "" Then Response.Write "<option value="& Chr(34) &"0"& Chr(34) &" selected>- Selecione - </option>" Else Set Regiao = Banco.Execute("SELECT * FROM Frete WHERE Cod = "& Session("Regiao") &"") Response.Write "<option selected>"& Regiao("Regiao") &"</option>" End If WHILE NOT Regioes.EOF Response.Write "<option value="& Chr(34) &"AltCesta.asp?Act=Frete&Regiao="& Regioes("Cod") & Chr(34) &">"& Regioes("Regiao") &"</option>" Regioes.MOVENEXT : WEND %> </select> <span class="TextTahoma11VermelhoBold"> <% If Request.QueryString("Mensagem") = "Erro" Then Response.Write "Informe a Região!" End If %> </span></td> </tr> </table></td> <td width="25%"> <% valordofrete = FormatCurrency(SomaFrete("SomaFrete") + Replace(VarValorBase,".",",")) tirar = replace(valordofrete, "R"," ") %> <div align="right"><span class="TextTahoma11Cinza">Frete total: <%=tirar%>  </span></div></td> </tr> </table> </div></td> </tr> <tr bgcolor="<%=TabelaBarraEsq%>"> <td height="30" colspan="5"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="75%"> <span class="TextTahoma11CinzaBold">Valor total</span></td> <td width="25%"><div align="right"><span class="TextArial18CinzaBold"> <% valortotal = SomaTotal("SomaTotal") + SomaFrete("SomaFrete") + Replace(VarValorBase,".",",")'Response.Write(FormatCurrency(SomaTotal("SomaTotal") + SomaFrete("SomaFrete") + Replace(VarValorBase,".",",")))valorsemr = replace(valortotal,"R"," ") Response.Write(valortotal) %></span><span class="TextaArial11Cinza"> </span></div></td> </tr> </table></td> </tr> <tr bgcolor="#FFFFFF"> <td height="20" colspan="5"><div align="right"> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td width="72%"><input name="Submit2" type="button" class="FormBotao2" onClick="MM_goToURL('parent','Default.asp');return document.MM_returnValue" value="Continuar comprando"></td> <td width="72%"><div align="right"> <input name="Submit2" type="button" class="FormBotao" onClick="MM_goToURL('parent','Finaliza.asp');return document.MM_returnValue" value="Finalizar Pedido"> </div></td> <td width="14%"><div align="right"> <input name="Submit22" type="button" class="FormBotao" onClick="MM_goToURL('parent','AltCesta.asp?Act=Apagar');return document.MM_returnValue" value="Apagar Tudo"> </div></td> <td width="14%"><div align="right"> <input name="Submit" type="submit" class="FormBotao" value="Recalcular"> </div></td> </tr> </table> </div></td> </tr> </form> </table> <% Pedidos.Close SomaTotal.Close Regioes.Close Set Pedidos = Nothing Set SomaTotal = Nothing Set Regioes = Nothing End If %> </td> </tr> <%End If%> </table> </td> <td width="148" height="100%" valign="top"><!--#include file="Includes/BarraDir.asp"--></td> </tr> </table> </td> </tr> <tr> <td><!--#include file="Includes/Rodape.asp"--></td> </tr></table><%Call FechaBanco%>

aguardo a ajuda de vocês

Compartilhar este post


Link para o post
Compartilhar em outros sites

pq essa linha esta comentada?

 

'Response.Write(FormatCurrency(SomaTotal("SomaTotal") + SomaFrete("SomaFrete") + Replace(VarValorBase,".",",")))

Abraços

Compartilhar este post


Link para o post
Compartilhar em outros sites

o FormatCurrency ( )

Devolve uma expressão formatada para currency.

Moeda = FormatCurrency(valor)

se seu campo no banco for do tipo texto você tem que converter para numerico ai ficaria assim:

Moeda = FormatCurrency(CDBL(Valor))

Abraços

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.