Beruflich Dokumente
Kultur Dokumente
SISTEMA COMERCIAL
FORMULARIO CLIENTE
WHEN-WINDOW- ACTIVATED : (Tambien para cuando cargue sus datos del form: do_key('execute_query' ); set_item_property('GUARDAR',enabled,property_true); WHEN-NEW-FORM-INSTANCE SET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,window_state,maximize); SET_WINDOW_PROPERTY('MCLIENTE',window_state,maximize); PRE-INSERT select contador_cliente.nextval into :CLIENTE.CODCLIENTE from sys.dual; exception when others then message('Falla en asignacin de Cliente.CodCliente..!!'); raise form_trigger_failure; PRE-QUERY :Cliente.codcliente:=:parameter.codigo; KEY-ENTQRY do_key('execute_query');
Base de datos Ing. Edwin Calle Terrazas -------------------------Botones---------------------------BT_NUEVO WHEN-BUTTON-PRESSED go_block('CLIENTE'); create_record; set_item_property('NUEVO',enabled,property_false); set_item_property('GUARDAR',enabled,property_True); set_item_property('MODIFICAR',enabled,property_false); set_item_property('ELIMINAR',enabled,property_false); BT_GRABAR go_block('CLIENTE'); commit_form; set_item_property('NUEVO',enabled,property_True); set_item_property('GUARDAR',enabled,property_false); MODIFICAR if :System.Mode = 'NORMAL' then go_block('Cliente'); commit_form; end if; clear_block(No_Validate); do_key('enter_query'); ELIMINAR go_block('cliente'); delete_record; commit_form; BUSCAR IF SHOW_LOV('LISTA_CLIENTE') then null; end if; :parameter.codigo:=:cliente.codcliente; clear_block(No_Validate); if :system.mode <> 'Enter-query' then do_key('enter_query'); end if; //Hay q crear un LOVs llamado: LISTA_CLIENTE, que retorne //valor en el campo codcliente
CREACIN DE MENUS
SALIR
exit_form;
CONSULTAR
go_block('CLIENTE'); execute_query; set_item_property('MODIFICAR',enabled,property_true); set_item_property('ELIMINAR',enabled,property_True); set_item_property('GUARDAR',enabled,property_false); set_item_property('NUEVO',enabled,property_true);
PRIMERO
go_block('CLIENTE'); FIRST_RECORD;
ANTERIOR
go_block('CLIENTE'); PREVIOUS_RECORD;
SIGUIENTE
go_block('CLIENTE'); NEXT_RECORD;
ULTIMO
go_block('CLIENTE'); LAST_RECORD;
open_form('d:\proy\frm\cliente');
Antes de crearlo o compilarlo tenemos q introducir codigo a todos los submenu, no debe haber ninguno sueldo. Luego hacemos: File Administracin Compile File
Base de datos Ing. Edwin Calle Terrazas FORMULARIO PEDIDOS ( MAESTRO / DETALLE ) Creamos el bloque pedido y luego aadimos el text NOM_EMP, APE_EMP y NOM_CLI, APE_CLI
NOM_EMP, APE_EMP, NOM_CLI y APE_CLI, no son item de la base de datos, o sea Database item= No
Crear los LOV, luego en la paleta de Prop colocar los LOVs en CODEMP,CODCLIENTE y CODPRO .
ON-CLEAR-DETAILS, se crea por la relacion Maestro / Detalle Tambin, ON-POPULATE-DETAILS y ON-CHECK-DELETE-MASTER WHEN-NEW-FORM- INSTANCE (mejor colocarlo en Nuevo) :pedido.fecha:=sysdate; o tambin para cambiarle formato --:pedido.fecha:=TRUNC(TO_DATE(sysdate,'DD/MM/YY'), 'MONTH'); WHEN-VALIDATE-ITEM (CODEMP) declare cod number; begin cod:=:PEDIDO.CODEMP; select nombre, apellidos into :PEDIDO.NOM_EMP, :PEDIDO.APE_emp from empleado where codemp=cod; end; WHEN-VALIDATE-ITEM (CODCLIENTE) declare cod number; begin cod:=:PEDIDO.CODCLIENTE; select nombre, apellidos into :PEDIDO.NOM_CLI, :PEDIDO.APE_CLI from CLIENTE where codcliente=cod; end;
KEY-ENTQRY go_block('Pedido'); do_key('execute_query'); go_block('Detalle_Pedido'); do_key('execute_query'); PRE-QUERY :Pedido.nroped:=:parameter.codven; PRE-INSERT select contador_pedido.nextval into :PEDIDO.NROPED from sys.dual; exception when others then message('Falla en asignacin de PEDIDO.NROPED..!!'); raise form_trigger_failure;
POST-QUERY: Despus de consultar cada registro de pedido, permite mostrar los nombres y apellidos de Cliente y Empleado (si usamos siguiente, anterior, etc) select nombre, apellidos into :PEDIDO.NOM_CLI, :PEDIDO.APE_CLI from CLIENTE where codcliente=:pedido.codcliente; select nombre, apellidos into :PEDIDO.NOM_emp, :PEDIDO.APE_emp from empleado where codemp=:pedido.codemp;
Base de datos Ing. Edwin Calle Terrazas Luego crear con el asistente el bloque DETALLE_PEDIDO (relacionar con PEDIDO)
Aadir el text DESCRIPCION y SUBTOTAL(database item=No), Crear si no lo creado y en Prop de CODPRO aadir el LOV (L_PRO) Luego colocar los siguientes disparadores: Cuando pierda el enfoque, pero validando sobre el item WHEN-VALIDATE-ITEM (Para el campo CODPRO) select descripcion into :detalle_pedido.descripcion from producto where codpro=:detalle_pedido.codpro; select precio into :detalle_pedido.preciov Propiedades from producto de SUBTOTAL where codpro = :detalle_pedido.codpro;
--Cuando colocamos el item CODPRO hace le calculo
WHEN-VALIDATE-ITEM para CANTIDAD declare cant number; begin select stock into cant from Producto where codpro = :detalle_pedido.codpro; if :detalle_pedido.cantidad > cant then :detalle_pedido.cantidad:=cant; message('No existe la cantidad de produtos'); end if; end; select descripcion, precio into :detalle_pedido.descrip, :detalle_pedido.preciov from producto where codpro = :detalle_pedido.codpro; :detalle_pedido.subtotal:= nvl(:detalle_pedido.preciov * :detalle_pedido.cantidad,0);
nvl(:detalle_pedido.preciov*:detalle_pedido.cantidad,0)
Para el total, crear un nuevo bloque de forma manual: TOTALES Item type : Display item Data type : Number Maximun Length : 16
Luego crear un Bloque manualmente, con el nombre: BOTONES Despus poner los botones en BARRA, sobre el Lienzo, pero tiene q colocarse en los item del bloque BOTONES.
GUARDAR go_block('Pedido'); commit_form; go_block('Detalle_Pedido'); commit_form; set_item_property('NUEVO',enabled,property_true); set_item_property('GUARDAR',enabled,property_false); MODIFICAR go_block('Detalle_Pedido'); if :system.form_status = 'CHANGED' then commit_form; end if; set_item_property('NUEVO',enabled,property_true); set_item_property('GUARDAR',enabled,property_false);
WHEN-WINDOW-ACTIVATED
go_block('proveedor'); do_key('execute_query'); activarbotones;
Despus colocamos los siguientes procedimientos que permite activar y desactivas los botones
PROCEDURE ActivarBotones IS it_nuevo item; it_guardar item; it_modificar item; it_eliminar item; it_buscar item; it_salir item; BEGIN go_block('proveedor'); it_nuevo:=find_item('nuevo'); it_guardar:=find_item('guardar'); it_eliminar:=find_item('eliminar'); it_modificar:=find_item('modificar'); it_buscar:=find_item('buscar'); Set_Item_Property(it_nuevo,enabled,property_true); Set_Item_Property(it_guardar,enabled,property_false); Set_Item_Property(it_modificar,enabled,property_true); Set_Item_Property(it_buscar,enabled,property_true); Set_Item_Property(it_eliminar,label,'&ELIMINAR'); END; PROCEDURE DesactivarBotones IS it_nuevo item; it_guardar item; it_eliminar item; it_modificar item; it_buscar item; it_salir item; BEGIN go_block('proveedor'); it_nuevo:=find_item('nuevo'); it_guardar:=find_item('guardar'); it_eliminar:=find_item('eliminar'); it_modificar:=find_item('modificar'); it_buscar:=find_item('buscar'); Set_Item_Property(it_nuevo,enabled,property_false); Set_Item_Property(it_guardar,enabled,property_true); Set_Item_Property(it_modificar,enabled,property_false); Set_Item_Property(it_buscar,enabled,property_false); Set_Item_Property(it_eliminar,label,'&DESCARTAR'); END;
Despus creamos una alerta con el nombre ALERTA, luego Prop: Title
Para cambiar el text item por un Combo Box, Propiedades del Text item PAIS : List item Element list : Colocar los elementos y un List item value : PopList Column name : PAIS Tambin creamo una lista llamada: L_PROVEEDOR para el campo CODPROVEEDOR
Base de datos Ing. Edwin Calle Terrazas Seguidamente introducimos cdigo a los botones NUEVO declare it_eliminar item; begin it_eliminar:=find_item('ELIMINAR'); :parameter.codigo:=:proveedor.codproveedor; do_key('create_record'); :proveedor.codproveedor:=0; DesactivarBotones; :parameter.estado:='Nuevo'; end; GUARDAR begin --como Tiene contador lo llamamos si el estado es Nuevo if :parameter.estado='Nuevo' then select contador_proveedor.nextval into :proveedor.codproveedor from dual; end if; do_key('commit_form'); ActivarBotones; end; ELIMINAR MODIFICAR declare begin idalerta alert; DesactivarBotones; boton number; :parameter.codigo:=:proveedor. begin codproveedor; idalerta:=find_alert('alerta'); :parameter.estado:='Modificar'; set_alert_property(idalerta,alert_message_text,'Seguro de Salir'); do_key('enter_query'); boton:=show_alert(idalerta); end; if boton=alert_button1 then do_key('delete_record'); do_key('commit_form'); select max(codproveedor) into :parameter.codigo from proveedor; do_key('enter_query'); end if; end;