%
'dim conexaodb
pag = request("pag")
action = request("action")
%>
<%
IF action = "" Then
SQL = "SELECT * FROM produtos ORDER BY nome ASC"
Call abreconexao
Set RS = conexaodb.execute(SQL)
'SQL = "SELECT * FROM produtossubcategorias ORDER BY id DESC"
'Call abreconexao
'Set RS = conexaodb.execute(SQL)
ELSEIF action = "adicionar" and request("submit") = "Incluir" then
vnome = request("txtnome")
vcategoria = request("txtcategoria")
vsubcategoria = request("txtsubcategoria")
vdescricao = request("txtdescricao")
vimagp = request("imag_peq")
vimagg = request("imag_gr")
' altero ' por " para não dar erro no banco
vnome = replace(vnome,"'",""")
vdescricao = replace(vdescricao,"'",""")
'vnome = replace(vnome,"'",""")
vlancamento = request("txtlancamento")
'response.Write(vnome & vcategoria & vsubcategoria & vdescricao & vimagp & vimagg)
'response.end()
SQL = "INSERT INTO produtos (nome, categoria, subcategoria, descricao, fotop, fotog, lancamento) VALUES ('"&vnome&"', '"&vcategoria&"', '"&vsubcategoria&"', '"&vdescricao&"', '"&vimagp&"', '"&vimagg&"', '"&vlancamento&"')"
Call abreconexao
conexaodb.execute(SQL)
%>
<%
ELSEIF action = "excluir" then
codigo = request("codigo")
SQL = "DELETE * FROM produtos WHERE id="&codigo
Call abreconexao
conexaodb.execute (SQL)
%>
<%
ELSEIF action = "alterar" and request("Submit") <> "Alterar" then
codigodoproduto = request("codigodoproduto")
SQL = "SELECT * FROM produtos WHERE id="&codigodoproduto
Call abreconexao
Set rsproduto = conexaodb.execute(SQL)
'response.Write(request("Submit"))
ELSEIF action = "alterar" and request("Submit") = "Alterar" then
vcodigo = request("codigodoproduto")
vnome = request("txtnome")
vcategoria = request("txtcategoria")
vsubcategoria = request("txtsubcategoria")
vdescricao = request("txtdescricao")
vimagp = request("imag_peq")
vimagg = request("imag_gr")
' altero ' por " para não dar erro no banco
vnome = replace(vnome,"'",""")
vdescricao = replace(vdescricao,"'",""")
'vnome = replace(vnome,"'",""")
vlancamento = request("txtlancamento")
'response.Write(vnome& vcategoria & vsubcategoria & vdescricao & vimagp & vimagg & vcodigo)
'response.End()
SQL = "UPDATE produtos SET nome='"&vnome&"', categoria="&vcategoria&", subcategoria="&vsubcategoria&", descricao='"&vdescricao&"', fotop='"&vimagp&"', fotog='"&vimagg&"', lancamento='"&vlancamento&"' WHERE id= "&vcodigo
Call Abreconexao
set Rs = conexaodb.execute(SQL)
Call Fechaconexao
Set RS = Nothing
%>
<%
END IF
'soaltera = request("txtalterasocategoria")
'if soaltera = "sim" then
'vcategoria = request("txtcategoria")
'vcodigo = request("codigodoproduto")
' SQL = "UPDATE produtos SET categoria="&vcategoria&"' WHERE id= "&vcodigo
' Call Abreconexao
' set Rs = conexaodb.execute(SQL)
' 'Call Fechaconexao
' Set RS = Nothing
'
'end if
%>