https://docs.google.com/fileview?id=0BwyEZouFjUWqNjdlMGFiYjgtMDQzNi00NTJjLTlmMzctNjYxZDk5M2NlYTVj&hl=es
Codigo
*********************************************
FORM1
INIT
Public srec
set multilock on
set talk off
set safety off
set exclusive on
SELECT GUIAENC
=cursorsetprop("buffering",3)
set order to tag Nguia
go bottom
thisform.txtnguia.value=right("00000"+alltrim(str(val(nguia)+1)),6)
append blank
replace nguia with thisform.txtnguia.value
Select temporal
dele all
set dele on
append blank
replace nguia with thisform.txtnguia.value
srec=recno()
thisform.grdDetalle.refresh
thisform.txttotal.value=0
*********************************************
FORM1
DESTROY
SELECT GUIAENC
=Tablerevert(.t.)
SELECT TEMPORAL
*********************************************
CMBCLIENTE
CLICK
SELECT GUIAENC
replace cliecod with clientes.cliecod
thisform.grddetalle.coldescripcion.cmbdescripcion.setfocus
*********************************************
CMBDESCRIPCION
CLICK
if len(allt(thisform.grddetalle.coldescripcion.cmbdescripcion.value))>0
thisform.grddetalle.colcantidad.spncantidad.setfocus
else
thisform.grddetalle.coldescripcion.cmbdescripcion.setfocus
endif
thisform.refresh
**********************************************
CMBDESCRIPCION
INTERACTIVECHANGE
SELECT temporal
go srec
replace artcod with articulo.artcod
replace preuni with articulo.artpre
replace subtotal with thisform.grddetalle.colcantidad.spncantidad.value*preuni
sum subtotal to ntotal
go srec
thisform.txttotal.value=ntotal
thisform.grddetalle.colcantidad.spncantidad.value=1
thisform.refresh
**********************************************
CMBDESCRIPCION
LOSTFOCUS
if len(allt(thisform.grddetalle.coldescripcion.cmbdescripcion.value))>0
thisform.grddetalle.colcantidad.spncantidad.setfocus
else
thisform.grddetalle.coldescripcion.cmbdescripcion.setfocus
endif
thisform.refresh
**********************************************
SPNCANTIDAD
CLICK
SELECT GUIAENC
replace cliecod with cliente.cliecod
thisform.grddetalle.coldescripcion.cmbdescripcion.setfocus
THISFORM.REFRESH
**********************************************
SPNCANTIDAD
INTERACTIVECHANGE
select temporal
replace subtotal with thisform.grddetalle.colcantidad.spncantidad.value*preuni
nrec=recno()
sum subtotal to ntotal
go nrec
thisform.txttotal.value=ntotal
thisform.refresh
**********************************************
SPNCANTIDAD
LOSTFOCUS
thisform.grddetalle.coldescripcion.cmbdescripcion.setfocus
**********************************************
CMDNUEVO
CLICK
Public srec
select temporal
dele all
set dele on
append blank
replace nguia with thisform.txtnguia.value
srec=recno()
thisform.grddetalle.refresh
thisform.txttotal.value=0
thisform.refresh
**********************************************
CMDAGREGAR
CLICK
public srec
SELECT TEMPORAL
if len(allt(artdet))>0
append blank
srec=recno()
thisform.grddetalle.colcantidad.spncantidad.value=1
endif
replace nguia with thisform.txtnguia.value
thisform.grddetalle.coldescripcion.cmbdescripcion.setfocus
thisform.refresh
**********************************************
CMDGUARDAR
CLICK
SELECT GUIAENC
replace igv with thisform.txttotal.value*0.18
replace total with thisform.txttotal.value
=tableupdate(.t.)
SELECT TEMPORAL
Scan
insert into guiadet(nguia,artcod,artdet,preuni,cant,subtotal);
values(temporal.nguia,temporal.artcod,temporal.artdet,;
temporal.preuni,temporal.cant,temporal.subtotal)
EndScan
SELECT GUIAENC
set order to tag Nguia
go bottom
thisform.txtnguia.value=right("00000"+alltrim(str(val(nguia)+1)),6)
**********************************************
CMDSALIR
CLICK
SELECT GUIAENC
=tablerevert(.t.)
SELECT TEMPORAL
release thisform
**********************************************
CMBCLIENTE
CLICK
SELECT GUIAENC
replace cliecod with clientes.cliecod
thisform.grddetalle.coldescripcion.cmbdescripcion.setfocus