/************************* Funcion#05 *************************************
Funcion PB: Campos con estilo DropDownDataWindow relacionados.
Comentario: DropDownDataWindow relacionadas. (DropDownDataWindow=dddw)
Si en el campo ciudad.dddw se selecciona la clave 2500, que
el campo colonia.dddw solo presente colonias de la ciudad 2500.
Actualmente los dddw solo pueden ser relacionados a un campo,
falta poder CONDICIONAR por 1 o mas valores para casos
especificos
donde la informacion va de clasificada en capas.
(ciudad>>>>>>>calles)
(carrera>>>grupos>>>alunmos)
(bibliotecas>>>>seccion>>>>materia>>>libro)
(bibliotecas>>>>autor>>>libro)
Autor : Lic. Victor Arreola //:-)
Sintaxis: Ponganse en los Eventos indicados.
**************************************************************************/
SQL de DW_captura: select clave_alumno,nombre,cve_poblacion_id,cve_calle_id
from alumno
SQL de DropDownDataWindow: select cve_poblacion_id,nom_poblacion from
ca_poblacion
SQL de DropDownDataWindow y dwc_calles : select
cve_poblacion_id,cve_calle_id,nom_calle from ca_calles
---------------------------------------------------------------------------
A una W_ventana ponga una DW_captura
--------------------------------------------------------------------------
DECLARE INSTANCE/INSTANCIAS VARIABLES
DataWindowChild dwc_calles
string is_sql_calles
////////////W_ventana en evento Open /////////
dw_captura.SetTransObject(SQLCA) //DW principal
dw_captura.GetChild("cve_calle_id", dwc_calles) //Coneccion del campo de
dddw
dwc_calles.SetTransObject(SQLCA) //DW hija
is_sql_calles = dwc_calles.Describe("DataWindow.Table.Select") //Lectura del
SQL de DWHIJA
//EL dddw DE POBLACIONES NO REQUIERE SER dw_hija.
///////////DW_captura en evento RetrieveEnd/////////////
// AL HACER EL RETRIEVE INICIAL O POSTERIORES EL LISTADO DE CALLES ESTARA
// CORRECTAMENTE CONDICIONADO.
////////////////////////////////////////////////////////
string ls_domicilio='',ls_letra=''
long ll_num_int=0,ll_pobl=0
long ll_calle=0,ll_reg_existe=0
string rc, mod_string
constant string where_clause=' WHERE ca_calles.cve_poblacion_id = '
if rowcount>0 then RETURN
ll_pobl=dw_captura.GetItemNumber(1,'cve_poblacion_id') //SE EVALUA LA
INFORMACION DEL 1ER REGISTRO.
if isnull(ll_pobl) then ll_pobl=0
if ll_pobl<>0 then // si la clave de poblacion es cero no se captura calle.
mod_string =
"DataWindow.Table.Select='"+is_sql_calles+where_clause+string(ll_pobl)+"'"
////////Calle
ll_calle=dw_captura.GetItemNumber(1,'cve_calle_id')
rc = dwc_calles.Modify(mod_string)
IF rc <> "" THEN
MessageBox("Error", "No se puede hacer la relacion Poblaciones-Calles~r"
+ rc)
END IF
dwc_calles.SetTransObject(SQLCA)
if dwc_calles.Retrieve()>0 then
ll_reg_existe= dwc_calles.Find( "cve_calle_id = "+string(ll_calle),1,
dwc_calles.RowCount())
if isnull(ll_reg_existe) or ll_reg_existe<=0 then
ll_calle= dwc_calles.GetItemNumber(1,'cve_calle_id')
dw_captura.SetItem(1,'cve_calle_id', ll_calle )
else
dwc_calles.SetRow( ll_reg_existe )
end if
else
dw_captura.SetItem(1,'cve_calle_id', 0 )
end if
//////// DW_captura en evento ItemChanged//////////////
//CADA VEZ QUE SE CAMBIE LA POBLACION SE CONDICIONAN NUEVAMENTE LAS CALLES.
///////////////////////////////////////////////////////
if row>0 then RETURN
if dwo.name='cve_poblacion_id' and long(data)<>0 then
long ll_pob=0,ll_calle=0,ll_reg_existe=0
string rc, mod_string
constant string where_clause=' WHERE ca_calles.cve_poblacion_id = '
ll_pob =long(data)
if isnull(ll_pob) then ll_pob=0
mod_string = "DataWindow.Table.Select='"+is_sql_calles+where_clause+string(ll_pob)+"'"
////Calle
ll_calle=dw_captura.GetItemNumber(row,'cve_calle_id')
rc = dwc_calles.Modify(mod_string)
IF rc <> "" THEN
MessageBox("Error", "No se puede hacer la relacion Poblaciones-Calles~r" + rc)
END IF
dwc_calles.SetTransObject(SQLCA)
if dwc_calles.Retrieve()>0 then
ll_reg_existe= dwc_calles.Find( "cve_calle_id = "+string(ll_calle),1,
dwc_calles.RowCount())
if isnull(ll_reg_existe) or ll_reg_existe<=0 then
ll_calle= dwc_calles.GetItemNumber(1,'cve_calle_id')
dw_captura.SetItem(row,'cve_calle_id', ll_calle )
else
dwc_calles.SetRow( ll_reg_existe )
end if
else
dw_captura.SetItem(row,'cve_calle_id', 0 )
end if
////////DW_captura en evento ItemFocusChanged////////
//CADA VEZ QUE PIERDE EL FOCO LA POBLACION SE CONDICIONAN NUEVAMENTE LAS
CALLES.
// ESTO ES UTIL CUANDO SE NAVEGA SOLO CON MOUSE (SIN TAB).
///////////////////////////////////////////////////
if row>0 then RETURN
if dwo.name='cve_poblacion_id' and
dw_captura.GetItemNumber(row,'cve_poblacion_id')<>0 then
long ll_pob=0,ll_calle=0,ll_reg_existe=0
string rc, mod_string
constant string where_clause=' WHERE ca_calles.cve_poblacion_id = '
ll_pob =dw_captura.GetItemNumber(row,'cve_poblacion_id')
if isnull(ll_pob) then ll_pob=0
mod_string = "DataWindow.Table.Select='"+is_sql_calles+where_clause+string(ll_pob)+"'"
/////Calle
ll_calle=dw_captura.GetItemNumber(row,'cve_calle_id')
rc = dwc_calles.Modify(mod_string)
IF rc <> "" THEN
MessageBox("Error", "No se puede hacer la relacion Poblaciones-Calles~r"
+ rc)
END IF
dwc_calles.SetTransObject(SQLCA)
if dwc_calles.Retrieve()>0 then
ll_reg_existe= dwc_calles.Find( "cve_calle_id = "+string(ll_calle),1,
dwc_calles.RowCount())
if isnull(ll_reg_existe) or ll_reg_existe<=0 then
ll_calle= dwc_calles.GetItemNumber(1,'cve_calle_id')
dw_captura.SetItem(row,'cve_calle_id', ll_calle )
else
dwc_calles.SetRow( ll_reg_existe )
end if
else
dw_captura.SetItem(row,'cve_calle_id', 0 )
end if
///////////////////////////////////////////////////////////
/*eof F05. */
Comentarios sobre la versión: Versión 1 (1)