RESPUESTA A LA PREGUNTA 6388 - POWER BUILDER int li_ret=0 // ********************** Recibe los parámetros y los asigna //s_dgi_parmcat Prm (instancia) // Se declara una estructura del tipo Parametros Prm=Message.PowerObjectParm // en la estructura Prm se reciben los // valores que se enviaron como parámetros desde el // menú con la instrucción OpenWithParm String PrmSel1, PrmSel2, PrmSel3, PrmFrom, PrmTit1, PrmTit2, PrmTit3 String PrmSel4, PrmSel5, PrmTit4, PrmTit5 String PrmWinT PrmSel1=UPPER(Prm.ParmSel1) // Los ParmSel1, ParmSel2 y ParmSel3 son PrmSel2=UPPER(Prm.ParmSel2) // los que indican que campos se incluyen en PrmSel3=UPPER(Prm.ParmSel3) // el data window, ej tip_clave, tip_desc PrmSel4=UPPER(Prm.ParmSel4) PrmSel5=UPPER(Prm.ParmSel5) PrmFrom=UPPER(Prm.ParmFrom) // Indica de que tabla se toman los datos PrmFrom="~"SJPS~".~""+PrmFrom+"~"" PrmTit1=Prm.ParmTit1 // Indica los títulos para cada una de las PrmTit2=Prm.ParmTit2 // columnas PrmTit3=Prm.ParmTit3 PrmTit4=Prm.ParmTit4 PrmTit5=Prm.ParmTit5 PrmWinT=Prm.ParmWin // Indica el título de la ventana This.Title=PrmWinT HuboCambios=FALSE // Variable de Instancia que indica si se hizo // cambio al datawindow // ********************** Creación del DataWindow String ERRORS, sql_syntax String presentation_str, dwsyntax_str // ¿Cuántos parámetros mandó? int cuantos cuantos=2 IF Not PrmTit3="" Then cuantos+=1 IF Not PrmTit4="" Then cuantos+=1 IF Not PrmTit5="" Then cuantos+=1 // Selecciona la presentación y el SELECT con que va a ser creado // el DataWindow CHOOSE CASE cuantos CASE 2 sql_syntax="SELECT "+PrmFrom+"."+"~""+PrmSel1+"~""+","+& PrmFrom+"."+"~""+PrmSel2+"~""+& " FROM "+PrmFrom CASE 3 sql_syntax="SELECT "+PrmFrom+"."+"~""+PrmSel1+"~""+","+& PrmFrom+"."+"~""+PrmSel2+"~""+","+& PrmFrom+"."+"~""+PrmSel3+"~""+& " FROM "+PrmFrom CASE 4 sql_syntax="SELECT "+PrmFrom+"."+"~""+PrmSel1+"~""+","+& PrmFrom+"."+"~""+PrmSel2+"~""+","+& PrmFrom+"."+"~""+PrmSel3+"~""+","+& PrmFrom+"."+"~""+PrmSel4+"~""+& " FROM "+PrmFrom CASE 5 sql_syntax="SELECT "+PrmFrom+"."+"~""+PrmSel1+"~""+","+& PrmFrom+"."+"~""+PrmSel2+"~""+","+& PrmFrom+"."+"~""+PrmSel3+"~""+","+& PrmFrom+"."+"~""+PrmSel4+"~""+","+& PrmFrom+"."+"~""+PrmSel5+"~""+& " FROM "+PrmFrom END CHOOSE presentation_str="style(type=grid) column(border=5)" // Se puede cambiar la presentación a tabular sin rallado en los // renglones // presentation_str="style(type=tabular) column(border=0)" // La instrucción SyntaxFromSQL completa los datos necesarios para // crear el Datawindow y los coloca en la variable dwsyntax_str dwsyntax_str=SQLCA.SyntaxFromSQL(sql_syntax,presentation_str,ERRORS) If len(ERRORS)>0 Then MessageBox("Error","SyntaxFromSQL causó estos errores: "+ERRORS) This.PostEvent("funciones",0,"cerrar") Return end if // en base a los datos proporcionados por el SyntaxFromSQL se // genera el DataWindow dw_1.create(dwsyntax_str,ERRORS) If len(ERRORS)>0 Then MessageBox("Error","Create causó estos errores: "+ERRORS) This.PostEvent("funciones",0,"cerrar") Return end if // ********************* Modificación al DataWindow dw_1.modify("datawindow.color='74481808'") dw_1.modify("header.height='73'") dw_1.modify("header.color='536870912'") dw_1.modify("summary.height='1'") dw_1.modify("summary.color='536870912") dw_1.modify("footer.height='1'") dw_1.modify("footer.color='536870912'") dw_1.modify("detail.height='77'") dw_1.modify("detail.color='536870912'") dw_1.Modify(PrmSel1+"_t.Text='"+PrmTit1+"'") // Titulo dw_1.Modify(PrmSel1+"_t.Color='0'") dw_1.Modify(PrmSel1+"_t.Border='6'") // Border Titulo dw_1.Modify(PrmSel1+"_t.Font.Face.Color='MS Sans Serif'") dw_1.Modify(PrmSel1+"_t.font.height='-8'") dw_1.Modify(PrmSel1+"_t.font.weight='400'") dw_1.Modify(PrmSel1+"_t.font.family='2'") dw_1.Modify(PrmSel1+"_t.font.pitch='2'") dw_1.Modify(PrmSel1+"_t.font.charset='0'") dw_1.Modify(PrmSel1+"_t.background.mode='1'") dw_1.Modify(PrmSel1+"_t.background.color='553648127'") dw_1.Modify(PrmSel1+".color='0'") dw_1.Modify(PrmSel1+".height='65'") dw_1.Modify(PrmSel1+".Widht='1066'") dw_1.Modify(PrmSel1+".font.face='MS Sans Serif'") dw_1.Modify(PrmSel1+".font.height='-8'") dw_1.Modify(PrmSel1+".font.weight='400'") dw_1.Modify(PrmSel1+".background.mode='2'") dw_1.Modify(PrmSel1+".background.color='16777215'") dw_1.Modify(PrmSel1+".Edit.Case=Upper") dw_1.Modify(PrmSel1+".tabsequence=10") if (not prm.parmeditname1="") then dw_1.Modify(Prmsel1+".name='"+Prm.parmeditname1+"'") end if if (not prm.parmstyle1= "") then dw_1.modify(PrmSel1+".Edit.Style='"+prm.parmstyle1+"'") end if if (not prm.parmddwname1="") then dw_1.modify(prmsel1+".dddw.name='"+prm.parmddwname1+"'") end if if (not prm.parmddwdisplaycolumn1="") then dw_1.modify(prmsel1+".dddw.displaycolumn='"+prm.parmddwdisplaycolumn1+"'") end if if (not prm.parmddwdatacolumn1="") then dw_1.modify(prmsel1+".dddw.datacolumn='"+prm.parmddwdatacolumn1+"'") end if if (not prm.parmddwporcentwidth1=0) then dw_1.modify(prmsel1+".dddw.percentwidth='"+string(prm.parmddwporcentwidth1)+"'") end if if (not prm.parmddwcase1="") then dw_1.modify(prmsel1+".dddw.Case='"+prm.parmddwcase1+"'") end if if (not prm.parmddwlines1=0) then dw_1.modify(prmsel1+".dddw.lines='"+string(prm.parmddwlines1)+"'") end if if (not prm.parmddwlimit1=0) then dw_1.modify(prmsel1+".dddw.limit='"+string(prm.parmddwlimit1)+"'") end if if (not prm.parmddwallowedit1= "") then dw_1.modify(prmsel1+".dddw.allowedit="+prm.parmddwallowedit1) end if if (not prm.parmddwusesasborder1="") then dw_1.modify(prmsel1+".dddw.useasborder='"+prm.parmddwusesasborder1+"'") end if if (not prm.parmddwemptyisnull1="") then dw_1.modify(prmsel1+".dddw.nilisnull="+prm.parmddwemptyisnull1) end if if (not prm.parmddwautohscroll1="") then dw_1.modify(prmsel1+".dddw.autohscroll="+prm.parmddwautohscroll1) end if if (not prm.parmddwvscrollbar1="") then dw_1.modify(prmsel1+".dddw.vscrollbar="+prm.parmddwvscrollbar1) end if dw_1.Modify(PrmSel2+"_t.Text='"+PrmTit2+"'") dw_1.Modify(PrmSel2+"_t.Color='0'") dw_1.Modify(PrmSel2+"_t.Border='6'") // Border Titulo dw_1.Modify(PrmSel2+"_t.Font.Face.Color='MS Sans Serif'") dw_1.Modify(PrmSel2+"_t.font.height='-8'") dw_1.Modify(PrmSel2+"_t.font.weight='400'") dw_1.Modify(PrmSel2+"_t.font.family='2'") dw_1.Modify(PrmSel2+"_t.font.pitch='2'") dw_1.Modify(PrmSel2+"_t.font.charset='0'") dw_1.Modify(PrmSel2+"_t.background.mode='1'") dw_1.Modify(PrmSel2+"_t.background.color='553648127'") dw_1.Modify(PrmSel2+".color='0'") dw_1.Modify(PrmSel2+".height='65'") dw_1.Modify(PrmSel2+".Widht='1066'") dw_1.Modify(PrmSel2+".font.face='MS Sans Serif'") dw_1.Modify(PrmSel2+".font.height='-8'") dw_1.Modify(PrmSel2+".font.weight='400'") dw_1.Modify(PrmSel2+".background.mode='2'") dw_1.Modify(PrmSel2+".background.color='16777215'") dw_1.Modify(PrmSel2+".Edit.Case='Upper'") dw_1.Modify(PrmSel2+".tabsequence=20") if (not prm.parmeditname2="") then dw_1.Modify(Prmsel2+".name='"+Prm.parmeditname2+"'") end if if (not prm.parmstyle2="") then dw_1.modify(PrmSel2+".Edit.Style='"+prm.parmstyle2+"'") end if if (not prm.parmddwname2="") then dw_1.modify(prmsel2+".dddw.name='"+prm.parmddwname2+"'") end if if (not prm.parmddwdisplaycolumn2="") then dw_1.modify(prmsel2+".dddw.displaycolumn='"+prm.parmddwdisplaycolumn2+"'") end if if (not prm.parmddwdatacolumn2="") then dw_1.modify(prmsel2+".dddw.datacolumn='"+prm.parmddwdatacolumn2+"'") end if if (not prm.parmddwporcentwidth2=0) then dw_1.modify(prmsel2+".dddw.percentwidth="+string(prm.parmddwporcentwidth2)+"'") end if if (not prm.parmddwcase2="") then dw_1.modify(prmsel2+".dddw.Case="+prm.parmddwcase2) end if if (not prm.parmddwlines2=0) then dw_1.modify(prmsel2+".dddw.lines='"+string(prm.parmddwlines2)) end if if (not prm.parmddwlimit2=0) then dw_1.modify(prmsel2+".dddw.limit="+string(prm.parmddwlimit2)) end if if (not prm.parmddwallowedit2="") then dw_1.modify(prmsel2+".dddw.allowedit="+prm.parmddwallowedit2) end if if (not prm.parmddwusesasborder2="") then dw_1.modify(prmsel2+".dddw.useasborder="+prm.parmddwusesasborder2) end if if (not prm.parmddwemptyisnull2="") then dw_1.modify(prmsel2+".dddw.nilisnull="+prm.parmddwemptyisnull2) end if if (not prm.parmddwautohscroll2="") then dw_1.modify(prmsel2+".dddw.autohscroll="+prm.parmddwautohscroll2) end if if (not prm.parmddwvscrollbar2="") then dw_1.modify(prmsel2+".dddw.vscrollbar="+prm.parmddwvscrollbar2) end if If Not PrmTit3="" Then dw_1.Modify(PrmSel3+"_t.Text='"+PrmTit3+"'") dw_1.Modify(PrmSel3+"_t.Color='0'") dw_1.Modify(PrmSel3+"_t.Border='6'") // Border Titulo dw_1.Modify(PrmSel3+"_t.Font.Face.Color='MS Sans Serif'") dw_1.Modify(PrmSel3+"_t.font.height='-8'") dw_1.Modify(PrmSel3+"_t.font.weight='400'") dw_1.Modify(PrmSel3+"_t.font.family='2'") dw_1.Modify(PrmSel3+"_t.font.pitch='2'") dw_1.Modify(PrmSel3+"_t.font.charset='0'") dw_1.Modify(PrmSel3+"_t.background.mode='1'") dw_1.Modify(PrmSel3+"_t.background.color='553648127'") dw_1.Modify(PrmSel3+".color='0'") dw_1.Modify(PrmSel3+".height='65'") dw_1.Modify(PrmSel3+".Widht='1066'") dw_1.Modify(PrmSel3+".font.face='MS Sans Serif'") dw_1.Modify(PrmSel3+".font.height='-8'") dw_1.Modify(PrmSel3+".font.weight='400'") dw_1.Modify(PrmSel3+".background.mode='2'") dw_1.Modify(PrmSel3+".background.color='16777215'") dw_1.Modify(PrmSel3+".Edit.Case=Upper") dw_1.Modify(PrmSel3+".tabsequence=30") if (prm.parmeditname3 <> ' ' or not isnull(prm.parmeditname3)) then dw_1.Modify(Prmsel3+".name='"+Prm.parmeditname3+"'") end if if (prm.parmstyle3 <> '' or not isnull(prm.parmstyle3)) then dw_1.modify(PrmSel3+".Edit.Style='"+prm.parmstyle3+"'") end if if (not prm.parmddwname3="") then dw_1.modify(prmsel3+".dddw.name='"+prm.parmddwname3+"'") end if if (not prm.parmddwdisplaycolumn3="") then dw_1.modify(prmsel3+".dddw.displaycolumn='"+prm.parmddwdisplaycolumn3+"'") end if if (not prm.parmddwdatacolumn3="") then dw_1.modify(prmsel3+".dddw.datacolumn='"+prm.parmddwdatacolumn3+"'") end if if (not prm.parmddwporcentwidth3=0) then dw_1.modify(prmsel3+".dddw.percentwidth='"+string(prm.parmddwporcentwidth3)+"'") end if if (NOT prm.parmddwcase3="") then dw_1.modify(prmsel3+".dddw.Case='"+prm.parmddwcase3+"'") end if if (not prm.parmddwlines3=0) then dw_1.modify(prmsel3+".dddw.lines='"+string(prm.parmddwlines3)+"'") end if if (not prm.parmddwlimit3=0) then dw_1.modify(prmsel3+".dddw.limit='"+string(prm.parmddwlimit3)+"'") end if if (not prm.parmddwallowedit3="") then dw_1.modify(prmsel3+".dddw.allowedit="+prm.parmddwallowedit3) end if if (not prm.parmddwusesasborder3="") then dw_1.modify(prmsel3+".dddw.useasborder="+prm.parmddwusesasborder3) end if if (not prm.parmddwemptyisnull3="") then dw_1.modify(prmsel3+".dddw.nilisnull="+prm.parmddwemptyisnull3) end if if (not prm.parmddwautohscroll3="") then dw_1.modify(prmsel3+".dddw.autohscroll="+prm.parmddwautohscroll3) end if if (not prm.parmddwvscrollbar3="") then dw_1.modify(prmsel3+".dddw.vscrollbar="+prm.parmddwvscrollbar3) end if End If If Not PrmTit4="" Then dw_1.Modify(PrmSel4+"_t.Text='"+PrmTit4+"'") dw_1.Modify(PrmSel4+"_t.Color='0'") dw_1.Modify(PrmSel4+"_t.Border='6'") // Border Titulo dw_1.Modify(PrmSel4+"_t.Font.Face.Color='MS Sans Serif'") dw_1.Modify(PrmSel4+"_t.font.height='-8'") dw_1.Modify(PrmSel4+"_t.font.weight='400'") dw_1.Modify(PrmSel4+"_t.font.family='2'") dw_1.Modify(PrmSel4+"_t.font.pitch='2'") dw_1.Modify(PrmSel4+"_t.font.charset='0'") dw_1.Modify(PrmSel4+"_t.background.mode='1'") dw_1.Modify(PrmSel4+"_t.background.color='554648127'") dw_1.Modify(PrmSel4+".color='0'") dw_1.Modify(PrmSel4+".height='65'") dw_1.Modify(PrmSel4+".Widht='1066'") dw_1.Modify(PrmSel4+".font.face='MS Sans Serif'") dw_1.Modify(PrmSel4+".font.height='-8'") dw_1.Modify(PrmSel4+".font.weight='400'") dw_1.Modify(PrmSel4+".background.mode='2'") dw_1.Modify(PrmSel4+".background.color='16777215'") dw_1.Modify(PrmSel4+".Edit.Case=Upper") dw_1.Modify(PrmSel4+".tabsequence=40")//****//// if (prm.parmeditname4 <> ' ' or not isnull(prm.parmeditname4)) then dw_1.Modify(Prmsel4+".name='"+Prm.parmeditname4+"'") end if if (prm.parmstyle4 <> '' or not isnull(prm.parmstyle4)) then dw_1.modify(PrmSel4+".Edit.Style='"+prm.parmstyle4+"'") end if if (not prm.parmddwname4="") then dw_1.modify(prmsel4+".dddw.name='"+prm.parmddwname4+"'") end if if (not prm.parmddwdisplaycolumn4="") then dw_1.modify(prmsel4+".dddw.displaycolumn='"+prm.parmddwdisplaycolumn4+"'") end if if (not prm.parmddwdatacolumn4="") then dw_1.modify(prmsel4+".dddw.datacolumn='"+prm.parmddwdatacolumn4+"'") end if if (not prm.parmddwporcentwidth4=0) then dw_1.modify(prmsel4+".dddw.percentwidth='"+string(prm.parmddwporcentwidth4)+"'") end if if (NOT prm.parmddwcase4="") then dw_1.modify(prmsel4+".dddw.Case='"+prm.parmddwcase4+"'") end if if (not prm.parmddwlines4=0) then dw_1.modify(prmsel4+".dddw.lines='"+string(prm.parmddwlines4)+"'") end if if (not prm.parmddwlimit4=0) then dw_1.modify(prmsel4+".dddw.limit='"+string(prm.parmddwlimit4)+"'") end if if (not prm.parmddwallowedit4="") then dw_1.modify(prmsel4+".dddw.allowedit="+prm.parmddwallowedit4) end if if (not prm.parmddwusesasborder4="") then dw_1.modify(prmsel4+".dddw.useasborder="+prm.parmddwusesasborder4) end if if (not prm.parmddwemptyisnull4="") then dw_1.modify(prmsel4+".dddw.nilisnull="+prm.parmddwemptyisnull4) end if if (not prm.parmddwautohscroll4="") then dw_1.modify(prmsel4+".dddw.autohscroll="+prm.parmddwautohscroll4) end if if (not prm.parmddwvscrollbar4="") then dw_1.modify(prmsel4+".dddw.vscrollbar="+prm.parmddwvscrollbar4) end if End If //*************** If Not PrmTit5="" Then dw_1.Modify(PrmSel5+"_t.Text='"+PrmTit5+"'") dw_1.Modify(PrmSel5+"_t.Color='0'") dw_1.Modify(PrmSel5+"_t.Border='6'") // Border Titulo dw_1.Modify(PrmSel5+"_t.Font.Face.Color='MS Sans Serif'") dw_1.Modify(PrmSel5+"_t.font.height='-8'") dw_1.Modify(PrmSel5+"_t.font.weight='500'") dw_1.Modify(PrmSel5+"_t.font.family='2'") dw_1.Modify(PrmSel5+"_t.font.pitch='2'") dw_1.Modify(PrmSel5+"_t.font.charset='0'") dw_1.Modify(PrmSel5+"_t.background.mode='1'") dw_1.Modify(PrmSel5+"_t.background.color='553658127'") dw_1.Modify(PrmSel5+".color='0'") dw_1.Modify(PrmSel5+".height='65'") dw_1.Modify(PrmSel5+".Widht='1066'") dw_1.Modify(PrmSel5+".font.face='MS Sans Serif'") dw_1.Modify(PrmSel5+".font.height='-8'") dw_1.Modify(PrmSel5+".font.weight='500'") dw_1.Modify(PrmSel5+".background.mode='2'") dw_1.Modify(PrmSel5+".background.color='16777215'") dw_1.Modify(PrmSel5+".Edit.Case=Upper") dw_1.Modify(PrmSel5+".tabsequence=50") if (not prm.parmeditname5="") then dw_1.Modify(Prmsel5+".name='"+Prm.parmeditname5+"'") end if if (not prm.parmstyle5="") then dw_1.modify(PrmSel5+".Edit.Style='"+prm.parmstyle5+"'") end if if (not prm.parmddwname5="") then dw_1.modify(prmsel5+".dddw.name='"+prm.parmddwname5+"'") end if if (not prm.parmddwdisplaycolumn5="") then dw_1.modify(prmsel5+".dddw.displaycolumn='"+prm.parmddwdisplaycolumn5+"'") end if if (not prm.parmddwdatacolumn5="") then dw_1.modify(prmsel5+".dddw.datacolumn='"+prm.parmddwdatacolumn5+"'") end if if (not prm.parmddwporcentwidth5=0) then dw_1.modify(prmsel5+".dddw.percentwidth='"+string(prm.parmddwporcentwidth5)+"'") end if if (not prm.parmddwcase5="") then dw_1.modify(prmsel5+".dddw.Case='"+prm.parmddwcase5+"'") end if if (not prm.parmddwlines5=0) then dw_1.modify(prmsel5+".dddw.lines='"+string(prm.parmddwlines5)+"'") end if if (not prm.parmddwlimit5=0) then dw_1.modify(prmsel5+".dddw.limit='"+string(prm.parmddwlimit5)+"'") end if if (not prm.parmddwallowedit5="") then dw_1.modify(prmsel5+".dddw.allowedit="+prm.parmddwallowedit5) end if if (not prm.parmddwusesasborder5="") then dw_1.modify(prmsel5+".dddw.useasborder="+prm.parmddwusesasborder5) end if if (not prm.parmddwemptyisnull5="") then dw_1.modify(prmsel5+".dddw.nilisnull="+prm.parmddwemptyisnull5) end if if (not prm.parmddwautohscroll5="") then dw_1.modify(prmsel5+".dddw.autohscroll="+prm.parmddwautohscroll5) end if if (not prm.parmddwvscrollbar5="") then dw_1.modify(prmsel5+".dddw.vscrollbar="+prm.parmddwvscrollbar5) end if End If // *********************** Crear la transacción of_centracatalogo(w_catalogo) // para poder actualizar los datos necesita la transacción IF dw_1.SetTransObject(SQLCA)=-1 Then f_manejaerror(SQLCA.SQLDBCode,SQLCA.SQLErrText) This.PostEvent("funciones",0,"cerrar") Return END IF li_ret = dw_1.Retrieve() IF li_ret = -1 THEN f_manejaerror(SQLCA.SQLDBCode,SQLCA.SQLErrText) This.PostEvent("funciones",0,"cerrar") Return ELSEif li_ret=0 then dw_1.insertrow(0) dw_1.SetFocus() elseif li_ret>0 then dw_1.SetFocus() END IF // *** para los catálogos de grid no se deben ver los botones de // *** navegación en el menú m_catalogo.m_edicin.Visible=FALSE m_catalogo.m_edicin.m_registroinicial.ToolBarItemVisible=FALSE m_catalogo.m_edicin.m_registroanterior.ToolBarItemVisible=FALSE m_catalogo.m_edicin.m_registrosiguiente.ToolBarItemVisible=FALSE m_catalogo.m_edicin.m_registrofinal.ToolBarItemVisible=FALSE dw_1.SetSort(PrmSel1) dw_1.Sort() Jesus Ramon Gil Olguin rgil@baja.gob.mx www.lawebdelprogramador.com