PK

ADDRLIN : /HMFS2/WEB/DTC038/v0071350.ferozo.com/public_html/administrador/tacho/
FLL :
Current File : //HMFS2/WEB/DTC038/v0071350.ferozo.com/public_html/administrador/tacho/showroom_venta_add1.asp

<!--#include file="includes/openconn.asp" -->

<!--#include file="includes/checkadmin.asp" -->

<%dim tot,ppp,xIDVENTA,ax

'------------------ VERIFICAR STOCK

dim xmensaje
xmensaje = ""

for a = 1 to 10
	if request("idarticulo" & a) <> "" then
		rs.open "SELECT * FROM Q_articulos WHERE idarticulo = " & request("idarticulo" & a),conn,3,1
		rs.movefirst
		
		if rs("art_stock" & request("talle" & a)) < cint(request("cantidad" & a)) then
			xmensaje = xmensaje & (request("cantidad" & a) - rs("art_stock" & request("talle" & a))) & " - " & rs("art_nombre") & " " &  rs("col_nombre") & " ( talle : " & request("talle" & a) & ")<br>"
		end if 
		
		rs.Close
	end if
next

if xmensaje <> "" then
	xmensaje = "FALTA STOCK<bR>Faltantes : " & xmensaje

	conn.close
			
	response.Redirect("showroom_venta_err.asp?xmensaje=" & xmensaje)
end if

'----------------- ALTA PEDIDO

rs.open "SELECT * FROM Ventas WHERE idventa = 0",conn,2,2
rs.addnew

rs("ven_now") = now()
rs("ven_IP") = request.ServerVariables("REMOTE_ADDR")%>

<!--#include file="includes/datos_venta.asp" -->

<%rs.update
rs.close

'------------------------------------------ TOMA CODIGO

rs.open "SELECT TOP 1 idventa FROM Ventas ORDER BY idventa DESC",conn,3,1
rs.movefirst

session("idventa") = rs("idventa")
xIDVENTA = rs("idventa")

rs.close

'------------------------- ALTA ITEMS y QUITAR STOCK

for a = 1 to 10
	if request("idarticulo" & a) <> "" then
		'if session("sss_cantidad_" & a & "_1") <> 0 then
			rs.open "SELECT * FROM Q_Articulos WHERE idarticulo = " & request("idarticulo" & a),conn,2,2
			rs.movefirst
			
				rs1.open "SELECT * FROM Ventas_items WHERE iditem = 0",conn,2,2
				rs1.addnew
				
				rs1("xidventa") = xIDVENTA
				rs1("xidarticulo") = request("idarticulo" & a)
				rs1("item_cantidad" & request("talle" & a)) = request("cantidad" & a)
				
				rs("art_stock" & request("talle" & a)) = rs("art_stock" & request("talle" & a)) - request("cantidad" & a)
							
				rs1("item_precio") = rs("art_precio")
				rs1("item_nombre") = rs("art_nombre")
				rs1("item_codigo") = rs("art_codigo")
				rs1("item_color") = rs("col_nombre")
				
				rs1.update
				rs1.Close
				
			rs.update
			rs.close
		'end if
	end if
next

Response.Redirect ("Showroom_ventas.asp")%>


PK 99