Está en la página 1de 49

Sys evento open

// Profile bdLogistoca
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='DSN=BDLogistica;UID=sa;PWD='"
connect using sqlca;
open(w_acceso)
structura str_mant

Uo_dw

Uo_dw constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else

this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
uo_dw rowfocuschanged
if this.ib_seleccionar=true then
this.selectrow( 0,false)
this.selectrow( currentrow ,true)
else
this.selectrow( 0,false)
end if
variables de instancia

w_Acceso

Cb_Aceptar evento clicked


integer li_filas

if sle_user.text="" then
messagebox("Error","Usuario en Blanco")
sle_user.setfocus()
return
end if
if sle_pass.text="" then
messagebox("Error","Contrasea en Blanco")
sle_user.setfocus()
return
end if
if len(sle_user.text)< 6 then
messagebox("Error","Debe tener mas de 5 caracteres")
sle_user.setfocus()
return
end if
if len(sle_pass.text)<6 then
messagebox("Error","Debe tener mas de 5 caracteres")
sle_user.setfocus()
return
end if
select id_empleado,nivel into:gs_empleado ,:gs_nivel
from empleado where usuario=:sle_user.text
and password=:sle_pass.text and estado="A";
if gs_empleado="" or isnull(gs_empleado) then
messagebox("Error","Contrasea o Usuario Incorrecto")
return
end if
open(w_principal)
close(w_acceso)
cb_cancelar evento clicked
close(parent)
w_principal

w_principal evento open


if gs_nivel="1" then
m_principal.m_mantenimiento.enabled=false
m_principal.m_reportes.enabled=false
m_principal.m_mantenimiento.m_usuarios.toolbaritemvisible=false
m_principal.m_mantenimiento.m_proveedor.toolbaritemvisible=false
m_principal.m_mantenimiento.m_empleado.toolbaritemvisible=false
m_principal.m_mantenimiento.m_producto.toolbaritemvisible=false
m_principal.m_documentos.m_movimientosdealmacen.toolbaritemvisible=false
m_principal.m_documentos.m_compras.toolbaritemvisible=false
m_principal.m_documentos.m_ordendecompra.toolbaritemvisible=false
else
end if
//this.SetToolbar(1, TRUE, AlignAtLeft!)
Opensheet(w_fondo,w_principal,50,original!)
w_fondo.windowstate=maximized!

W_producto

Ventana w_producto Evento resize


this.dw_1.width=this.width - 100
this.dw_1.height=this.height 400
cb_nuevo evento clicked
str_mant origen
integer li_nums
string ls_cod
SELECT count(id_producto )
INTO :li_nums
FROM producto ;
ls_cod="PR"+string(li_nums +1,"00000000")
origen.nuevo=true
origen.param1=ls_cod
OpenWithParm(w_mantproducto, origen)
parent.dw_1.retrieve( )
cb_editar evento clicked
str_mant origen
string ls_cod
integer li_fila
if dw_1.rowcount( )=0 then
return

end if
li_fila=dw_1.getrow( )
ls_cod=dw_1.getitemstring( li_fila,1)
origen.nuevo=false
origen.param1=ls_cod
OpenWithParm(w_mantproducto, origen)
parent.dw_1.retrieve( )
cb_buscar evento clicked
long ll_filas,ll_fila
ll_filas=dw_1.rowcount( )
ll_fila=dw_1.find( "NomProducto like '" + parent.sle_buscar.text +"%'", 1,ll_filas)
if ll_fila=0 then
messagebox("Aviso del Sistema","Registro no Encontrado")
dw_1.scrolltorow( 1)
else
dw_1.scrolltorow( ll_fila)
end if
cb_ver clicked
dw_1.setfilter( "")
dw_1.filter( )
cb_kardex clicked
str_mant origen
string ls_cod
integer li_fila
if dw_1.rowcount( )=0 then
return
end if
li_fila=dw_1.getrow( )
ls_cod=dw_1.getitemstring( li_fila,1)
origen.nuevo=false
origen.param1=ls_cod
OpenWithParm(w_kardex, origen)
parent.dw_1.retrieve( )
dw_1 evento constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )

end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if

w_mantproducto

W_mantproducto open
str_mant destino
destino=message.powerobjectparm
if destino.nuevo=true then
this.dw_1.retrieve("" )
this.dw_1.insertrow( 1)
this.dw_1.scrolltorow( 1)
this.dw_1.setfocus( )
this.dw_1.setitem( 1,1,destino.param1)
this.dw_1.setitem( 1,2,today())
this.dw_1.setcolumn( 2)
this.title="Nuevo Producto"
else
this.dw_1.retrieve(destino.param1 )

this.dw_1.setfocus()
this.dw_1.setcolumn(2)
this.title="Editar Producto"
dw_1.modify( "stockActual.edit.Style=Edit")
dw_1.modify( "stockActual.edit.displayonly=yes")
end if
cb_1 clicked
string ls_producto,ls_unidad,ls_linea,ls_marca
decimal ld_actual,ld_minimo,ld_compra,ld_venta
dw_1.accepttext( )
ls_producto=dw_1.getitemstring( 1,2)
ls_unidad=dw_1.getitemstring( 1,3)
ls_linea=dw_1.getitemstring( 1,4)
ls_marca=dw_1.getitemstring( 1,5)
ld_compra=dw_1.getitemdecimal( 1,6)
ld_venta=dw_1.getitemdecimal( 1,7)
ld_actual=dw_1.getitemdecimal( 1,8)
ld_minimo=dw_1.getitemdecimal( 1,9)
/////////////////////////////////////////////////////////////////////////////
//////////////VALIDANDO LOS DATOS/////////////////////////////////
if ls_producto="" or isnull(ls_producto) then
messagebox("Aviso del sistema","Debe Ingresar el Nombre del producto")
dw_1.setfocus( )
dw_1.setcolumn( 2)
return
end if
if ls_unidad="" or isnull(ls_unidad) then
messagebox("Aviso del sistema","Debe escoger la unidad de Medida")
dw_1.setfocus( )
dw_1.setcolumn( 3)
return
end if
if ls_linea="" or isnull(ls_linea) then
messagebox("Aviso del sistema","Debe Ingresar escoger la Linea")
dw_1.setfocus( )
dw_1.setcolumn( 4)
return
end if
if ls_marca="" or isnull(ls_marca) then
messagebox("Aviso del sistema","Debe Ingresar Marca")
dw_1.setfocus( )
dw_1.setcolumn( 5)
return
end if
if ld_compra< 1 or isnull(ld_compra) then
messagebox("Aviso del sistema","Debe Ingresar el precio de Compra del
producto")
dw_1.setfocus( )

dw_1.setcolumn( 6)
return
end if
if ld_venta< 1 or isnull(ld_venta) then
messagebox("Aviso del sistema","Debe Ingresar el precio de Compra del
producto")
dw_1.setfocus( )
dw_1.setcolumn( 7)
return
end if
if ld_compra> ld_venta then
messagebox("Aviso del sistema","El precio de Compra no debe ser Mayor al
precio de Venta")
dw_1.setfocus( )
dw_1.setcolumn( 7)
return
end if
if ld_actual< 1 or isnull(ld_actual) then
messagebox("Aviso del sistema","Debe Ingresar el Stock Actual")
dw_1.setfocus( )
dw_1.setcolumn( 8)
return
end if
if ld_minimo< 1 or isnull(ld_minimo) then
messagebox("Aviso del sistema","Debe Ingresar el Stock minimo")
dw_1.setfocus( )
dw_1.setcolumn( 9)
return
end if

///////////////////////////////////////////////////////////////////////////

if dw_1.update()=1 then
//
commit;
uf_kardex()
messagebox("Atencion","Registro Grabado")
commit;
close(parent)
else
messagebox("Atencion","No se Grabaron los Datos")
rollback;
end if
cb_2 clicked

close(parent)
dw_1 itemchanged
this.accepttext( )
decimal ld_compra, ld_stock,ld_valor
if dwo.name= "stockactual" or dwo.name="preccompra" then
ld_compra=this.getitemdecimal( 1,"preccompra")
ld_stock=this.getitemdecimal( 1,"stockactual")
ld_valor=ld_compra * ld_stock
this.setitem( 1,"stockSoles",ld_valor)
end if
w_kardex

Cb_buscar clicked
//dw_1.setfilter( "fecha_mov>=date('"+string(dp_1.value )+"')")
//dw_1.filter( )
dw_1.setfilter("fecha_mov>= date('"+string(dp_1.value,"dd/mm/yyyy") +"') and
fecha_mov<=date('"+string(dp_2.value,"dd/mm/yyyy") +"')")
dw_1.filter( )
cb_regresar clicked
close(parent)
w_proveedor

Cb_nuevo
clicked
str_mant origen
integer li_nums
string ls_cod
SELECT count(id_proveedor )
INTO :li_nums
FROM proveedor ;
ls_cod="PV"+string(li_nums +1,"0000")
origen.nuevo=true
origen.param1=ls_cod
OpenWithParm(w_mantproveedor, origen)
parent.dw_1.retrieve( )
cb_editar clicked
str_mant origen
string ls_cod
integer li_fila
if dw_1.rowcount( )=0 then
return
end if
li_fila=dw_1.getrow( )
ls_cod=dw_1.getitemstring( li_fila,1)

origen.nuevo=false
origen.param1=ls_cod
OpenWithParm(w_mantproveedor, origen)
parent.dw_1.retrieve( )
cb_buscar clicked
long ll_filas,ll_fila
ll_filas=dw_1.rowcount( )
if rb_ruc.checked=true then
ll_fila=dw_1.find( "ruc like '" + parent.sle_buscar.text +"%'", 1,ll_filas)
else
ll_fila=dw_1.find( "RazonSocial like '" + parent.sle_buscar.text +"%'", 1,ll_filas)
end if
if ll_fila=0 then
messagebox("Aviso del Sistema","Registro no Encontrado")
dw_1.scrolltorow( 1)
else
dw_1.scrolltorow( ll_fila)
end if
dw_1 doublecliked
parent.cb_editar.event clicked( )
dw_1 constructor()
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
w_mantproveedor

W_mantproveedor open
str_mant destino
destino=message.powerobjectparm
if destino.nuevo=true then
this.dw_1.retrieve("" )
this.dw_1.insertrow( 1)
this.dw_1.scrolltorow( 1)
this.dw_1.setfocus( )
this.dw_1.setitem( 1,1,destino.param1)
this.dw_1.setitem( 1,2,today())
this.dw_1.setcolumn( 3)
this.title="Nuevo Proveedor"
else
this.dw_1.retrieve(destino.param1 )
this.dw_1.setfocus()
this.dw_1.setcolumn(3)
this.title="EditarProveedor"
end if

dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else

this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
cb_Grabar clicked
string ls_razon,ls_ruc,ls_representante
string ls_ciudad,ls_direccion,ls_cod
dw_1.accepttext( )
ls_cod=dw_1.getitemstring( 1,1)
ls_razon=dw_1.getitemstring( 1,3)
ls_ruc=dw_1.getitemstring( 1,4)
ls_representante=dw_1.getitemstring( 1,5)
ls_direccion=dw_1.getitemstring( 1,6)
ls_ciudad=dw_1.getitemstring( 1,7)
/*validando los datos*/
if ls_razon="" or isnull(ls_razon) then
messagebox("Aviso del Sistema","Debe ingresar la razon Social")
dw_1.setfocus( )
dw_1.setcolumn( 3)
return
end if
if ls_ruc="" or isnull(ls_ruc) then
messagebox("Aviso del Sistema","Debe ingresar el RUC")
dw_1.setfocus( )
dw_1.setcolumn( 4)
return
end if
if len(ls_ruc)<11 then
messagebox("Aviso del Sistema","El ruc debe tener 11 digitos")
dw_1.setfocus( )
dw_1.setcolumn(4)
return
end if
if uf_ruc(ls_ruc,ls_cod)=true then
messagebox("Aviso del Sistema","El ruc debe ya existe")
dw_1.setfocus( )
dw_1.setcolumn(4)

return
end if
if ls_representante="" or isnull(ls_representante) then
messagebox("Aviso del Sistema","Debe ingresar el Representante")
dw_1.setfocus( )
dw_1.setcolumn( 5)
return
end if
if Match(ls_representante, "[0-9]")=true then
messagebox("Aviso del Sistema","Solo se Admiten Letras")
dw_1.setfocus( )
dw_1.setcolumn( 5)
return
end if
if ls_direccion="" or isnull(ls_direccion) then
messagebox("Aviso del Sistema","Debe ingresar la Direccion")
dw_1.setfocus( )
dw_1.setcolumn( 6)
return
end if
if ls_ciudad="" or isnull(ls_ciudad) then
messagebox("Aviso del Sistema","Debe ingresar la Ciudad")
dw_1.setfocus( )
dw_1.setcolumn( 7)
return
end if
if Match(ls_ciudad, "[0-9]")=true then
messagebox("Aviso del Sistema","Solo se Admiten Letras")
dw_1.setfocus( )
dw_1.setcolumn( 7)
return
end if
/**/
if dw_1.update()=1 then
commit;
messagebox("Atencion","Registro Grabado")
close(parent)
else
messagebox("Atencion","No se Grabaron los Datos")
rollback;
end if
cb_cancelar clicked
close(parent)

w_empleado

Cb_nuevo clicked
str_mant origen
integer li_nums
string ls_cod
SELECT count(id_empleado )
INTO :li_nums
FROM empleado ;
ls_cod="EP"+string(li_nums +1,"0000")
origen.nuevo=true
origen.param1=ls_cod

OpenWithParm(w_mantempleado, origen)
parent.dw_1.retrieve( )
cb_editar clicked
str_mant origen
string ls_cod
integer li_fila
if dw_1.rowcount( )=0 then
return
end if
li_fila=dw_1.getrow( )
ls_cod=dw_1.getitemstring( li_fila,1)
origen.nuevo=false
origen.param1=ls_cod
OpenWithParm(w_mantempleado, origen)
parent.dw_1.retrieve( )
cb_buscar clicked
long ll_filas,ll_fila
ll_filas=dw_1.rowcount( )
ll_fila=dw_1.find( "Apellidos like '" + parent.sle_buscar.text +"%'", 1,ll_filas)
if ll_fila=0 then
messagebox("Aviso del Sistema","Registro no Encontrado")
dw_1.scrolltorow( 1)
else
dw_1.scrolltorow( ll_fila)
end if
cbx_filtrar clicked
if this.checked=true then
dw_1.setfilter( "estado='A'")
dw_1.filter( )
else
dw_1.setfilter( "")
dw_1.filter( )
end if
dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then

if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
w_mantempleado

Cb_grabar clicked
string ls_apellidos,ls_nombres,ls_direccion
dw_1.accepttext( )
ls_apellidos=dw_1.getitemstring( 1,3)
ls_nombres=dw_1.getitemstring( 1,4)
ls_direccion=dw_1.getitemstring( 1,5)
if ls_apellidos="" or isnull(ls_apellidos) then
messagebox("Aviso del Sistema","Debe Ingresar los Apellidos")
dw_1.setfocus( )
dw_1.setcolumn( 3)
return
end if

if Match(ls_apellidos, "[0-9]")=true then


messagebox("Aviso del Sistema","Solo se Admiten Letras")
dw_1.setfocus( )
dw_1.setcolumn( 3)
return
end if
if ls_nombres="" or isnull(ls_nombres) then
messagebox("Aviso del Sistema","Debe Ingresar los nombres")
dw_1.setfocus( )
dw_1.setcolumn( 4)
return
end if
if Match(ls_nombres, "[0-9]")=true then
messagebox("Aviso del Sistema","Solo se Admiten Letras")
dw_1.setfocus( )
dw_1.setcolumn( 4)
return
end if
if ls_direccion="" or isnull(ls_direccion) then
messagebox("Aviso del Sistema","Debe Ingresar la direccion")
dw_1.setfocus( )
dw_1.setcolumn( 5)
return
end if
if dw_1.update()=1 then
commit;
messagebox("Atencion","Registro Grabado")
close(parent)
else
messagebox("Atencion","No se Grabaron los Datos")
rollback;
end if
cb_cancelar clicked
close(parent)

w_linea

Cb_nuevo clicked

integer li_nums
string ls_cod
dw_2.retrieve( "")
dw_2.insertrow( 1)
dw_2.scrolltorow( 1)
dw_1.enabled=false
SELECT count(id_linea )
INTO : li_nums
FROM linea;
ls_cod="LI" + string(li_nums +1,"00")
dw_2.setitem( 1,1,ls_cod)
dw_2.setfocus( )
dw_2.setcolumn(
2)
dw_2.modify( "datawindow.readonly=no")
cb_nuevo.enabled=false
cb_editar.enabled=false
cb_cancelar.enabled=true
cb_grabar.enabled=true
cb_editar clicked
dw_2.setfocus( )
dw_2.setcolumn( 2)
dw_2.modify( "datawindow.readonly=no")
dw_1.enabled=false
cb_nuevo.enabled=false
cb_editar.enabled=false
cb_cancelar.enabled=true
cb_grabar.enabled=true
cb_cancelar clicked
dw_2.retrieve("LI01")
dw_1.retrieve( )
//dw_2.retrieve()
dw_2.modify( "datawindow.readonly=yes")
cb_nuevo.enabled=true
cb_editar.enabled=true
cb_cancelar.enabled=false
cb_grabar.enabled=false
dw_1.enabled=true
cb_grabar clicked
string ls_linea
dw_1.accepttext( )
ls_linea=dw_2.getitemstring(1,2)
if ls_linea="" or isnull(ls_linea) then

messagebox("Aviso del Sistema","Debe Ingresra un nombre de


Linea")
dw_2.setfocus( )
dw_2.setcolumn( 2)
return
end if
if dw_2.update( )=1 then
cb_nuevo.enabled=true
cb_editar.enabled=true
cb_cancelar.enabled=false
cb_grabar.enabled=false
dw_1.enabled=true
dw_1.retrieve( )
messagebox("Aviso del Sistema","Registro Grabado")
commit;
dw_2.modify( "datawindow.readonly=yes")
else
messagebox("Error","No se Grabaron los Datos")
rollback;
end if

Cb_nuevo clicked
integer li_nums
string ls_cod
dw_2.retrieve( "")
dw_2.insertrow( 1)
dw_2.scrolltorow( 1)
dw_1.enabled=false
SELECT count(id_unimed )
INTO : li_nums
FROM unidadMedida;
ls_cod="UN" + string(li_nums +1,"00")
dw_2.setitem( 1,1,ls_cod)

dw_2.setfocus( )
dw_2.setcolumn( 2)
dw_2.modify( "datawindow.readonly=no")
cb_nuevo.enabled=false
cb_editar.enabled=false
cb_cancelar.enabled=true
cb_grabar.enabled=true
cb_editar clicked
//dw_2.retrieve( "")
//dw_2.insertrow( 1)
dw_2.setfocus( )
dw_2.setcolumn( 2)
dw_2.modify( "datawindow.readonly=no")
dw_1.enabled=false
cb_nuevo.enabled=false
cb_editar.enabled=false
cb_cancelar.enabled=true
cb_grabar.enabled=true
cb_cancelar clicked
dw_2.modify( "datawindow.readonly=yes")
dw_1.enabled=true
dw_2.retrieve("" )
dw_1.retrieve( )
dw_1.scrolltorow(dw_1.rowcount( ) )
cb_nuevo.enabled=true
cb_editar.enabled=true
cb_cancelar.enabled=false
cb_grabar.enabled=false
cb_grabar clicked
string ls_unidad
dw_2.accepttext( )
ls_unidad=dw_2.getitemstring(1,2)
if ls_unidad="" or isnull(ls_unidad) then
messagebox("aviso del Sistema","Debe ingresar una Unidad de
Medida")
dw_2.setfocus( )
dw_2.SETCOLUMN( 2)
return
end if
if dw_2.update( )=1 then
cb_nuevo.enabled=true
cb_editar.enabled=true
cb_cancelar.enabled=false
cb_grabar.enabled=false
dw_1.enabled=true
dw_1.retrieve( )

dw_2.modify( "datawindow.readonly=yes")
messagebox("Aviso del Sistema","Registro Grabado")
commit;
else
messagebox("Error","No se Grabaron los Datos")
rollback;
end if

Cb_nuevo clicled
ddlb_apellidos.enabled=true
sle_user.enabled=true
sle_pass1.enabled=true
sle_pass2.enabled=true
ddlb_nivel.enabled=true
cb_grabar.enabled=true
cb_nuevo.enabled=false
cb_cancelar.enabled=true
sle_user.text=""
sle_pass1.text=""
sle_pass2.text=""
cb_grabar clicked
if ddlb_apellidos.text="" then
ddlb_apellidos.setfocus( )
return
end if
if sle_user.text="" then
sle_user.setfocus( )
return
end if
if len(sle_user.text)<6 then
messagebox("Aviso del Sistema","El usuario debe tener mas de 5
letras")
sle_user.setfocus( )
return
end if
if sle_pass1.text="" then

messagebox("Aviso del Sistema","Ingrese la Contrasea")


sle_pass1.setfocus( )
return
end if
if sle_pass2.text="" then
messagebox("Aviso del Sistema","Ingrese la Contrasea")
sle_pass2.setfocus( )
return
end if
if len(sle_pass1.text )<6 then
messagebox("Aviso del Sistema","la contrasea debe tener mas de
5 letras")
sle_pass1.setfocus( )
return
end if
//if len(sle_pass2.text )<6 then
//
sle_pass2.setfocus( )
//
return
//end if
if sle_pass2.text<> sle_pass1.text then
messagebox("Aviso del Sistema","las contraseas no coinciden")
sle_pass1.setfocus( )
return
end if
if ddlb_nivel.text="" then
ddlb_nivel.setfocus( )
return
end if
if uf_valusuario(sle_user.text)=true then
messagebox("Error","Este usuario ya existe o ya Tiene un
Usuario")
return
end if
//messagebox("",is_cod)
UPDATE empleado
SET password = :sle_pass1.text ,
usuario = :sle_user.text ,nivel=:ddlb_nivel.text
WHERE empleado.id_empleado = :is_cod ;
if sqlca.sqlcode=0 then
messagebox("Exito","Registro Grabado")
else
messagebox("Error","NO se grabaron los datos")
end if
ddlb_apellidos.enabled=false
sle_user.enabled=false
sle_pass1.enabled=false
sle_pass2.enabled=false
ddlb_nivel.enabled=false

cb_grabar.enabled=false
cb_nuevo.enabled=true
//cb_cancelar.enabled=true
Cb_cancelar clicked
ddlb_apellidos.enabled=false
sle_user.enabled=false
sle_pass1.enabled=false
sle_pass2.enabled=false
ddlb_nivel.enabled=false
cb_grabar.enabled=false
cb_nuevo.enabled=true
cb_cancelar.enabled=false
sle_user.text=""
sle_pass1.text=""
sle_pass2.text=""

Dw_1 clicked
str_mant destino
if dwo.name="b_buscar" then
open(w_buscarproducto)
destino=message.powerobjectparm
IF destino.param1="0" then
messagebox("Error","No Hay Datos")
return
end if

this.setitem( 1,"id_producto",destino.param1)
this.setitem( 1,"producto",destino.param2)
this.setitem( 1,"unidad",destino.param3)
this.setitem( 1,"preccompra",destino.param4)
this.setitem( 1,"stockactual",destino.param5)
this.setitem( 1,"stocksoles",destino.param6)
end if
dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
cb_nuevo clicked
integer li_filas
string ls_cod
select count(id_mov) into: li_filas from movimiento;
li_filas=li_filas +1
ls_cod="MV"+string(li_filas,"000000")
dw_1.retrieve("" )
dw_1.insertrow( 1)
dw_1.scrolltorow( 1)
dw_1.enabled=true
dw_1.setfocus( )
dw_1.setitem( 1,1,ls_cod)
dw_1.setitem( 1,"ID_EMPLEADO",gs_empleado)
DW_1.SETITEM( 1,2,today())
dw_1.setcolumn("Motivo")
this.enabled=false
cb_cancelar.enabled=true
cb_salir.enabled=true
cb_grabar.enabled=true
cb_salir.enabled=false
cb_cancelar cliked
cb_nuevo.enabled=true
this.enabled=false

cb_salir.enabled=true
dw_1.enabled=false
cb_grabar.enabled=true
dw_1.retrieve( "MV000001")
cb_grabar clicked
string ls_mov,ls_tipo,ls_prod,ls_motivo,ls_kardex
date fecha
decimal ld_actual,ld_precio,ld_cantidad
decimal ld_valormov,ld_valorex,ld_nActual
decimal ld_entrada,ld_salida
fecha=today()
dw_1.accepttext( )
ls_mov=dw_1.getitemstring(1,"id_mov")
ls_motivo=dw_1.getitemstring(1,"motivo")
ls_tipo=dw_1.getitemstring(1,"tipo")
ls_prod=dw_1.getitemstring(1,"id_producto")
ld_cantidad=dw_1.getitemdecimal(1,"cantidad")
/////////////////////////////////////////////////////////////////////////////////////////////
////////////////VALIDANDO/////////////////////////////////////////////////////////////
if ls_motivo="" or isnull(ls_motivo) then
messagebox("Aviso del Sistema","Debe Ingresar el Motivo del
Movimiento")
dw_1.setfocus( )
dw_1.setcolumn( "motivo")
return
end if
if ls_tipo="" or isnull(ls_tipo) then
messagebox("Aviso del Sistema","Debe Escoger el tipo de
movimiento")
dw_1.setfocus( )
dw_1.setcolumn( "tipo")
return
end if
if ls_prod="" or isnull(ls_prod) then
messagebox("Aviso del Sistema","Debe Escoger un Producto")
dw_1.setfocus( )
//
dw_1.setcolumn( "motivo")
return
end if
if ld_cantidad< 1 or isnull(ld_cantidad) then
messagebox("Aviso del Sistema","Debe ingresar la cantidad del
producto")
dw_1.setfocus( )
dw_1.setcolumn( "cantidad")
return

end if
ld_actual=dw_1.getitemdecimal( 1,"stockactual")
if dw_1.getitemstring(1,"tipo")="S" then
ld_nActual=ld_Actual - ld_cantidad
if ld_actual < (ld_cantidad) then
dw_1.setitem( 1,"cantidad","0")
dw_1.setfocus( )
dw_1.setcolumn( "cantidad")
messagebox("Aviso del sistema","La cantidad es mayor al Stock
Actual")
return
end if
ld_Salida=ld_cantidad
ld_entrada=0
else
ld_nActual=ld_Actual + ld_cantidad
ld_Salida=0
ld_entrada=ld_cantidad
end if
/////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
////////CALCULANDO LOS DATOS///////////////////////////////////
ld_precio=dw_1.getitemdecimal( 1,"preccompra")
ld_valormov=ld_cantidad * ld_precio
ld_valorex=ld_nActual * ld_precio
/////////////////////////////////////////////////
if dw_1.update( )=1 then
/*aCTUALIZANDO EL STOCK Y EL STOCK SOLES*/
UPDATE producto
SET stockactual = :ld_nactual,
stocksoles = :ld_valorex
WHERE producto.id_producto = :ls_prod ;
//////////////////////////////////////////////////
//KARDEX//////////////////////////////////////
//////////////////////////////////////////////////
ls_kardex=uf_codKardex()
INSERT INTO kardex
( id_kardex, doc_ref, id_producto, fecha_mov,
movimiento, id_empleado, entrada_prod,
salida_prod, precio, valormov, stockactual,
valorexistencia,
observaciones )
VALUES ( :ls_kardex,
:ls_mov,
:ls_prod,
:fecha,
:ls_tipo ,
:gs_empleado,

:ld_entrada,
:ld_salida,
:ld_precio,
:ld_valormov,
:ld_nActual,
:ld_valorex,
:ls_motivo ) ;
//////////////////////////////////////////////////
///////////////////////////////////////////////////
commit;
cb_grabar.enabled=false
cb_cancelar.enabled=false
cb_nuevo.enabled=true
cb_salir.enabled=true
messagebox("Exito","Se Grabaron los Datos")
dw_1.enabled=false
else
messagebox("Error","No se Grabaron los Datos")
end if
cb_salir clicked
close(parent)

Dw_1 clicked
str_mant destino
string ls_producto,ls_unidad,ls_nombrep
decimal cantidad,importe,precio
integer ll_filas,i
if dwo.name="b_buscar" then
open(w_buscarordencompra)
destino=message.powerobjectparm
if destino.param1="0" then
messagebox("Aviso del Sistema","No Hay nada que Ingresar")
return
end if

//

DW_2.RESET( )
this.setitem( 1,"id_ordencompra",destino.param3)
this.setitem( 1,"razonSocial",destino.param1)
this.setitem( 1,"ruc",destino.param2)
this.setitem( 1,"fecha",destino.param8)
messagebox("",destino.param3 )

declare lista cursor for select id_producto,cantidad


from det_ordemcompra where id_ordencompra=:destino.param3 ;
open lista;

fetch lista into :ls_producto,:cantidad;


do while sqlca.sqlcode <>100
ll_filas =dw_2.rowcount( ) + 1
dw_2.insertrow( ll_filas)
dw_2.scrolltorow( ll_filas)
dw_2.setitem( ll_filas, 1,ls_cod)
dw_2.setitem( ll_filas, 2,ls_producto)
dw_2.setitem( ll_filas, 5,cantidad)
fetch lista into :ls_producto,:cantidad;
loop
close lista;
ll_filas=dw_2.rowcount( )
for i=1 to ll_filas
ls_producto=dw_2.getitemstring( i,2)
ls_unidad=UF_getunidad(ls_producto)
//
messagebox(ls_producto,ls_unidad)
select preccompra,nomProducto into:precio,:ls_nombrep from
producto
where id_producto=:ls_producto;
dw_2.setitem( i, 3,ls_nombrep)
dw_2.setitem( i, 4,ls_unidad)
dw_2.scrolltorow( i)
OpenWithParm(w_precio, string(precio))
precio=dec(message.stringparm)
importe=cantidad * precio
dw_2.setitem( i, 6,precio)
dw_2.setitem( i, 7,importe)
next
end if
dw_2 clicked
string ls_cantidad
decimal cantidad, precio, importe
if dw_2.rowcount( )=0 then
return
end if
if row=0 or isnull(row) then
return
end if
ls_cantidad=string(dw_2.getitemdecimal( row,"cantidad"))
OpenWithParm(w_cantidad, ls_cantidad)
ls_cantidad=message.stringparm
cantidad=dec(ls_cantidad)
dw_2.setitem( row,"cantidad",cantidad)
precio=dw_2.getitemdecimal(row,"precio")

importe=precio * cantidad
dw_2.setitem(row,"importe",importe)

cb_insertar clicked
str_mant destino
integer li_filas,li_pos
open(w_buscarproducto)
destino=message.powerobjectparm
li_pos=dw_2.find( "id_producto='"+destino.param1 +"'",1,li_filas)
if li_pos >0 then
messagebox("Aviso del Sistema","Producto ya ingresado")
return
end if
li_filas=dw_2.rowcount( ) +1
dw_2.insertrow( li_filas)
dw_2.scrolltorow(li_filas)
dw_2.setitem( li_filas,1,ls_cod)
dw_2.setitem( li_filas,"id_producto",destino.param1)
dw_2.setitem( li_filas,"producto",destino.param2)
dw_2.setitem( li_filas,"unidad",destino.param3)
dw_2.setitem( li_filas,"cantidad",1)
cb_eliminar clicked
integer row
if dw_2.rowcount( )=0 then
return
end if
row=dw_2.getrow( )
dw_2.deleterow( row)
cb_nuevo clicked
integer li_filas
select count(id_compra) into: li_filas from compra;
li_filas=li_filas +1
ls_cod="CO"+string(li_filas,"00000000")
dw_1.retrieve("" )
dw_1.setfocus( )
this.enabled=false
parent.cb_grabar.enabled=true
cb_cancelar.enabled=true
cb_salir.enabled=false
dw_1.insertrow( 1)
dw_1.scrolltorow( 1)
dw_1.enabled=true

dw_2.enabled=true
dw_1.setitem( 1,1,ls_cod)
dw_1.setitem( 1,2,today())
//dw_1.setitem( 1,"id_empleado",gs_empleado)
pb_insertar.enabled=true
pb_eliminar.enabled=true
DW_2.RESET( )
Cb_grabar clicked
string ls_guia,ls_orden
dw_1.accepttext( )
ls_guia=dw_1.getitemstring( 1,"NumGuia")
ls_orden=dw_1.getitemstring( 1,"id_ordencompra")
if ls_guia="" or isnull(ls_guia) then
messagebox("Aviso del Sistema","Debe Ingresar el numero de
Guia de Remision")
dw_1.setfocus( )
return
end if
if ls_orden="" or isnull(ls_orden) then
messagebox("Aviso del Sistema","Debe Escoger la Orden de
compra")
dw_1.setfocus( )
return
end if
if dw_2.rowcount( )=0 then
messagebox("Aviso del Sistema","Debe escoger por lo menos un
Producto")
return
end if
/*grabando la compra*/
if dw_1.update( )=1 then
if dw_2.update()=1 then
commit;
messagebox("Aviso del Sistema","Orden de Compra Grabada")
uf_grabarkardex()
OpenWithParm(w_printcompras,ls_cod)
else
rollback;
messagebox("Error","No se Grabaron los Datos")
end if
else
messagebox("Error","No se Grabaron los Datos")
//
return
end if
/**/
dw_1.retrieve( "CO00000001")
dw_2.retrieve( "CO00000001")
dw_1.enabled=false

dw_2.enabled=false
parent.cb_grabar.enabled=false
cb_cancelar.enabled=false
cb_salir.enabled=true
cb_nuevo.enabled=true
pb_insertar.enabled=false
pb_eliminar.enabled=false
cb_cancelar clicked
parent.cb_grabar.enabled=false
cb_cancelar.enabled=false
cb_salir.enabled=true
cb_nuevo.enabled=true
dw_1.retrieve( "CO00000001")
dw_1.enabled=false
dw_2.enabled=false
dw_2.retrieve( "CO00000001")
pb_insertar.enabled=false
pb_eliminar.enabled=false
cb_salir clicked
close(parent)
w_precio

Cb_ok clicked
is_cantidad=em_cantidad.text
CloseWithReturn(Parent,is_cantidad)
W_precio open
is_cantidad=message.stringparm
em_cantidad.text=is_cantidad

W_cantidad

Cb_ok clicked
is_cantidad=em_cantidad.text
CloseWithReturn(Parent,is_cantidad)
W_cantidad open
is_cantidad=message.stringparm
em_cantidad.text=is_cantidad

Dw_1 clicked
str_mant destino
if dwo.name="b_buscar" then
open(w_buscarproveedor)
destino=message.powerobjectparm
IF isnull(destino.param1) or destino.param1="0" then

messagebox("Error","No Hay Datos")


return
end if
this.setitem( 1,"id_proveedor",destino.param1)
this.setitem( 1,"razonSocial",destino.param2)
this.setitem( 1,"ruc",destino.param3)
this.setitem( 1,"Representante",destino.param7)
end if
dw_2 clicked
string ls_cantidad
if dw_2.rowcount( )=0 then
return
end if
if row=0 or isnull(row) then
return
end if
ls_cantidad=string(dw_2.getitemdecimal( row,"cantidad"))
OpenWithParm(w_cantidad, ls_cantidad)
ls_cantidad=message.stringparm
dw_2.setitem( row,"cantidad",dec(ls_cantidad))
pb_insertar clicked
str_mant destino
integer li_filas,li_pos
open(w_buscarproducto)
destino=message.powerobjectparm
li_pos=dw_2.find( "id_producto='"+destino.param1 +"'",1,li_filas)
if li_pos >0 then
messagebox("Aviso del Sistema","Producto ya ingresado")
return
end if
li_filas=dw_2.rowcount( ) +1
dw_2.insertrow( li_filas)
dw_2.scrolltorow(li_filas)
dw_2.setitem( li_filas,1,ls_cod)
dw_2.setitem( li_filas,"id_producto",destino.param1)
dw_2.setitem( li_filas,"producto",destino.param2)
dw_2.setitem( li_filas,"unidad",destino.param3)
dw_2.setitem( li_filas,"cantidad",1)
pb_eliminar clicked
integer row
if dw_2.rowcount( )=0 then
return
end if
row=dw_2.getrow( )

dw_2.deleterow( row)

cb_llenar clicked
string ls_producto,ls_codproducto,ls_unidad
decimal ld_cantidad,ld_minimo,ld_actual
dw_2.reset( )
declare lista cursor for select id_producto,unidad,nomproducto,stockactual,stockmin
from producto,unidadMedida
where stockactual <= stockmin and unidadmedida.id_unimed=producto.id_unimed;
integer li_filas,li_pos
//li_pos=dw_2.find( "id_producto='"+destino.param1 +"'",1,li_filas)
if li_pos >0 then
messagebox("Aviso del Sistema","Producto ya ingresado")
return
end if
open lista;
fetch lista into: ls_codproducto,:ls_unidad,:ls_producto,:ld_actual,:ld_minimo;
do while sqlca.sqlcode<>100
//
ls_cantidad=
li_filas=dw_2.rowcount( ) +1
dw_2.insertrow( li_filas)
dw_2.scrolltorow(li_filas)
dw_2.setitem( li_filas,1,ls_cod)
dw_2.setitem( li_filas,"id_producto",ls_codproducto)
dw_2.setitem( li_filas,"producto",ls_producto)
dw_2.setitem( li_filas,"unidad",ls_unidad)
dw_2.setitem( li_filas,"cantidad",ld_cantidad)
fetch lista into: ls_codproducto,:ls_unidad,:ls_producto,:ld_actual,:ld_minimo;
loop
dw_2.setitem( li_filas,"cantidad",1)
close lista;
cb_nuevo clicked
integer li_filas
select count(id_ordencompra) into: li_filas from ordencompra;
li_filas=li_filas +1
ls_cod="OC"+string(li_filas,"00000000")
dw_1.retrieve("" )
dw_1.setfocus( )
this.enabled=false
parent.cb_grabar.enabled=true

cb_cancelar.enabled=true
cb_salir.enabled=false
dw_1.insertrow( 1)
dw_1.scrolltorow( 1)
dw_1.enabled=true
dw_2.enabled=true
dw_1.setitem( 1,"id_ordencompra",ls_cod)
dw_1.setitem( 1,2,today())
dw_1.setitem( 1,"id_empleado",gs_empleado)
pb_insertar.enabled=true
pb_eliminar.enabled=true
cb_llenar.enabled=true
dw_2.retrieve( "")
cb_grabar clicked
string ls_prov
ls_prov=dw_1.getitemstring( 1,"id_proveedor")
if ls_prov="" or isnull(ls_prov) then
messagebox("Aviso del Sistema","Debe escoger un Proveedor")
dw_1.setfocus( )
return
end if
if dw_2.rowcount( )=0 then
messagebox("Aviso del Sistema","Debe escoger por lo menos un
Producto")
return
end if
/*grabando la orden de compra*/
if dw_1.update( )=1 then
if dw_2.update()=1 then
commit;
messagebox("Aviso del Sistema","*----Orden de Compra
Grabada")
OpenWithParm(w_printordencompra,ls_cod)
dw_1.retrieve( "OC00000001")
dw_2.retrieve( "OC00000001")
dw_1.enabled=false
dw_2.enabled=false
parent.cb_grabar.enabled=false
cb_cancelar.enabled=false
cb_salir.enabled=true
cb_nuevo.enabled=true
pb_insertar.enabled=false
pb_eliminar.enabled=false
cb_llenar.enabled=false
else
rollback;
messagebox("Error","No se Grabaron los Datos")
end if
else

messagebox("Error","No se Grabaron los Datos")


return
end if
/**/
Cb_cancelar clicked
parent.cb_grabar.enabled=false
cb_cancelar.enabled=false
cb_salir.enabled=true
cb_nuevo.enabled=true
dw_1.retrieve( "OC00000001")
dw_1.enabled=false
dw_2.enabled=false
dw_2.retrieve( "OC00000001")
pb_insertar.enabled=false
pb_eliminar.enabled=false
cb_llenar.enabled=false
cb_salir clicked
close(parent)
w_reportmas

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then

this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then

this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )
cb_buscar cliked
dw_1.retrieve(em_buscar.text )

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )
cb_buscar cliked
dw_1.retrieve(em_buscar.text )

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )
cb_buscar cliked
dw_1.retrieve(em_buscar.text )

Dw_1 constructor
this.settransobject( sqlca)
if this.ib_retrieve=true then
if this.ib_param=true then
this.retrieve(this.is_param1,this.is_param2,this.is_param3 )
else
this.retrieve( )
end if
else
end if
if this.ib_sololectura=true then
this.modify( "datawindow.readonly=yes")
else
this.modify( "datawindow.readonly=no")
end if
pb_imprimir clicked
dw_1.print( )

W_cproducto :hereda de w_producto

Cb_imprimir clicked
dw_1.print( )

W_ckardex :hereda de w_kardex

W_cordencompra :hereda de w_buscarordencompra

Cb_buscar clicked
dw_1.setfilter( "RazonSocial like '"+ sle_buscar.text +"%'")
dw_1.filter( )
w_buscarordencompra

Cb_regresar clicked
integer li_fila
if dw_1.rowcount( )=0 then
origen.param1="0"
else
li_fila=dw_1.getrow( )
origen.param1=dw_1.getitemstring(li_fila,4)
origen.param2=dw_1.getitemstring(li_fila,5)
origen.param3=dw_1.getitemstring(li_fila,1)
origen.param8=dw_1.getitemdatetime(li_fila,2)
end if
CloseWithReturn(Parent, origen)
Cb_ver clicked
dw_1.setfilter( "")
dw_1.filter( )
cb_buscar cliked
dw_1.setfilter( "RazonSocila like '"+ sle_buscar.text +"%'")
dw_1.filter( )

También podría gustarte