ComboSearchGrid

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: ComboSearchGrid

Post by andyglezl »

Hola AidTIC

Tienes algún ejemplo funcional de tu problema ?
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
AidTIC
Posts: 117
Joined: Mon Apr 22, 2013 8:29 am
DBs Used: DBF
Contact:

Re: ComboSearchGrid

Post by AidTIC »

Hola andyglezl,

esta es la ventana.

Y cuando le doy valor a "DEFINE COMBOSEARCHGRID NEMP" en la funcion "_CSGItemSelected" con " SetProperty( cParentName, "NEMP" , "VALUE", cListBanEmp ), me hace búsqueda del dato en "COMBOSEARCHGRID" sin haberse salido del primero.

Si os dais cuenta en la imagen el primer combosearchgrid aun esta abierto.

El segundo funciona hasta que le doy a enter que se sale de la aplicación sin mas.


Hello andyglezl,

This is the window.

And when I give value to "DEFINE COMBOSEARCHGRID NEMP" in the function "_CSGItemSelected" with "SetProperty (cParentName," NEMP "," VALUE ", cListBanEmp), I search the data in" COMBOSEARCHGRID "without having left the first one.

If you notice in the image the first combosearchgrid is still open.

The second works until I give to enter that it leaves the application without more.


Image

Code: Select all

Function Gestion_Bancos

aBancos := BancosOpen()	

    DEFINE WINDOW Win_Ban ;
  	AT 10, 20                 ;
                    WIDTH   800 ;
				    HEIGHT  600 ;
					TITLE 'Mantenimiento de Bancos' ;
                    modal  
                    
					
       ON KEY ESCAPE ACTION ThisWindow.Release() 
          	
      DEFINE LABEL label01
             ROW    11
             COL    10
             WIDTH  80
             VALUE  'Banco' 
             FONTNAME fNAME
             FONTSIZE fSIZE
             TOOLTIP ""
             FONTBOLD .T.
             FONTCOLOR BLUE		 
      END LABEL
      
      DEFINE COMBOSEARCHGRID NBAN
             ROW      10
             COL      100
             WIDTH   500
		     ITEMS   aBancos
		     TOOLTIP ""
             FONTBOLD .F.
			 FONTNAME  fNAME
             FONTSIZE  fSIZE  
			 FONTCOLOR BLACK
			 HEADERS { 'Codigo' , 'Banco' , 'Empresa' }
             WIDTHS  {    150    ,   200   ,    300    }
             JUSTIFY {     0    ,     0   ,      0    }
			 ONENTER Win_Ban.tBanDes.SetFocus
		     anywheresearch .t.
             showheaders .t.
			
      END COMBOSEARCHGRID
      
      
      DEFINE LABEL label02
             ROW   41
             COL   10
             WIDTH 150
             VALUE 'Descripcion'
		     FONTNAME fNAME
             FONTSIZE fSIZE
             TOOLTIP ""
             FONTBOLD .T.
			 
             FONTCOLOR BLUE
      END LABEL
      
      DEFINE TEXTBOX tBanDes
             ROW    40
             COL    170
             WIDTH  360
		     FONTNAME fNAME
             FONTSIZE fSIZE
			 ONENTER Win_Ban.NEMP.SetFocus
             TOOLTIP ""
             FONTBOLD .F.
      END TEXTBOX
	 
	  DEFINE LABEL label03
             ROW   71
             COL   10
             WIDTH 150
             VALUE 'Empresa'
		     FONTNAME fNAME
             FONTSIZE fSIZE
             TOOLTIP ""
             FONTBOLD .T.
             FONTCOLOR BLUE
      END LABEL
     
      DEFINE COMBOSEARCHGRID NEMP
             ROW      70
             COL      100
             WIDTH   500
		     ITEMS   aEmpresas
		     TOOLTIP ""
             FONTBOLD .F.
			 FONTNAME  fNAME
             FONTSIZE  fSIZE  
			 FONTCOLOR BLACK
			 HEADERS { 'Codigo' , 'Empresa' }
             WIDTHS  {   50  ,   300  }
             JUSTIFY {     0  ,     0  }
			 ONENTER Win_Ban.tBanCue.SetFocus
		     anywheresearch .t.
             showheaders .t.
			
			
      END COMBOSEARCHGRID
	  
	  DEFINE LABEL label04
             ROW   101
             COL   10
             WIDTH 150
             VALUE 'Cuneta Contable'
		     FONTNAME fNAME
             FONTSIZE fSIZE
             TOOLTIP ""
             FONTBOLD .T.
			 
             FONTCOLOR BLUE
      END LABEL
      
      DEFINE TEXTBOX tBanCue
             ROW    100
             COL    170
             WIDTH  360
		     FONTNAME fNAME
             FONTSIZE fSIZE
			 ONENTER Win_Ban.Btn_Guardar.SetFocus
             TOOLTIP ""
             FONTBOLD .F.
      END TEXTBOX
	  
	  
	  
	  DEFINE GRID Grid_Banc
        ROW    130
        COL    10
        WIDTH  740
		HEIGHT 330
        VALUE Nil
        HEADERS {'Cod.Comun' , 'Cod.Propio' , 'D/H' , 'Concepto' , 'NºAsiento'}
        WIDTHS  {     60     ,      60      ,   40  ,     200    ,    60      }	
	    JUSTIFY { GRID_JTFY_RIGHT, GRID_JTFY_RIGHT , GRID_JTFY_CENTER , GRID_JTFY_LEFT, GRID_JTFY_RIGHT} 
	    //DYNAMICFORECOLOR { fColor  , fColor ,  fColor   , fColor   , fColor  ,    fColor,    fColor  ,  fColor ,  fColor   , fColor      }  
	    //DYNAMICBACKCOLOR { bColor  , bColor ,  bColor   , bColor   , bColor  ,    bColor  ,  bColor  , bColor ,  bColor   , bColor      }  
        FONTNAME fNAME
        FONTSIZE fSIZE
		FONTCOLOR  BLACK
        TOOLTIP ""
		EDITOPTION GRID_EDIT_DEFAULT
       
      END GRID
	  
	  DEFINE BUTTON Btn_Guardar
         ROW 490
         COL 70     
		   CAPTION '&Guardar'
			ACTION  Guardar_Emp ()
			WIDTH 120 
         HEIGHT 27
		   FONTNAME fNAME 
         FONTSIZE fSIZE	
         TOOLTIP "Guardar Cliente"
	 END BUTTON    
	 
     DEFINE BUTTON Btn_Eliminar
         ROW 490
         COL 230     
		 CAPTION '&Eliminar'
		 ACTION Eliminar_Emp ()
		 WIDTH 120 
         HEIGHT 27
		 FONTNAME fNAME 
         FONTSIZE fSIZE
         TOOLTIP "Eliminar Cliente"
	 END BUTTON   
	 
    DEFINE BUTTON Btn_Cancelar
         ROW 490
         COL 390     
		 CAPTION '&Cancelar'
		 ACTION Win_Ban.Release
		 WIDTH 120 
         HEIGHT 27
		 FONTNAME fNAME
         FONTSIZE fSIZE	
         TOOLTIP "Cancelar Registro"
	END BUTTON  
   
	DEFINE STATUSBAR FONT fNAME SIZE 10
    	   STATUSITEM "Consolidador Extractos Bancarios (c) 2017 Skydone Solutions, S.L." STYLE RAISED 
           KEYBOARD
	       DATE 
		   CLOCK WIDTH 100
	END STATUSBAR
   END WINDOW
  
   Win_Ban.CENTER
   Win_Ban.ACTIVATE
   
Return Nil 

Code: Select all

STATIC PROC _CSGItemSelected( cParentName, cTxBName, lTab )
   local lOk := .f.
   local i := 0
   local j := 0
   local cQStr := ''

   if GetProperty( ThisWindow.Name, "_csList", "VALUE" ) > 0 
   
      nListValue  := GetProperty( ThisWindow.Name, '_csList', "VALUE" )
	  
	  Do Case
	     Case cParentName = "Win_Ban" .and. cTxBName = "NBAN"
  MSGINFO("1" , 415)		        
			//	MSGDEBUG(_HMG_CSG_aTable)
	          	  cod_emp     := VAL(_HMG_CSG_aTable [ nListValue, 4 ])
                  cListItem   := _HMG_CSG_aTable [ nListValue, 1 ]
				  cod_ban     := _HMG_CSG_aTable [ nListValue, 1 ]
	              cListBanDes := _HMG_CSG_aTable[ nListValue, 2 ]
	              cListBanEmp := _HMG_CSG_aTable[ nListValue, 3 ]
	              cListBanCue := _HMG_CSG_aTable[ nListValue, 5 ]
	              aLineData   := _HMG_CSG_aTable[ nListValue ]
                  cQStr := 'update itemselected set tblrowid = ( select rowid from ' + cTblName + ' where '
                  for i := 1 to _HMG_CSG_nCols
                     cQStr := cQStr + 'col' + alltrim( str( i ) ) + ' = ' + _HMG_CSG_C2SQL( aLineData[ i ] )
                     if i < _HMG_CSG_nCols
                        cQStr := cQStr + ' and '
                     endif
                  next i
                  cQStr := cQStr + ')'
	             //  msginfo(cQStr)
                  lOk := _HMG_CSG_MiscSQL( _HMG_CSG_DBO, cQStr )
	              
                  if .not. lOk
                     msgstop( 'Error in ComboSearchGrid!' )
                     return nil
                  endif
                  
 //               MSGINFO(cListProGra)
                 
                  SetProperty( cParentName, cTxBName  , "VALUE", cListItem )
	              SetProperty( cParentName, "tBanDes" , "VALUE", cListBanDes )
	              SetProperty( cParentName, "NEMP"    , "VALUE", cListBanEmp )
	              SetProperty( cParentName, "tBanCue" , "VALUE", cListBanCue )
	             
	              mostrar_opciones () 
                  
                  SetProperty(cParentName,cTxBName,"CARETPOS",;
                                LEN( cListItem ) )
                  
                  DoMethod( ThisWindow.Name, "Release" )
                  if pcount() == 3
                     if lTab
                        _Pushkey(VK_TAB)
                     endif
                  endif 
         
		 Case cParentName = "Win_Ban" .and. cTxBName = "NEMP"
	          	  cod_emp     := VAL(_HMG_CSG_aTable [ nListValue, 1 ])
                  cListItem   := _HMG_CSG_aTable [ nListValue, 2 ]
	              	               
                  aLineData := _HMG_CSG_aTable[ nListValue ]
                  cQStr := 'update itemselected set tblrowid = ( select rowid from ' + cTblName + ' where '
                  for i := 1 to _HMG_CSG_nCols
                     cQStr := cQStr + 'col' + alltrim( str( i ) ) + ' = ' + _HMG_CSG_C2SQL( aLineData[ i ] )
                     if i < _HMG_CSG_nCols
                        cQStr := cQStr + ' and '
                     endif
                  next i
                  cQStr := cQStr + ')'
	               
                  lOk := _HMG_CSG_MiscSQL( _HMG_CSG_DBO, cQStr )
	              
                  if .not. lOk
                     msgstop( 'Error in ComboSearchGrid!' )
                     return nil
                  endif
                  
 //               MSGINFO(cListProGra)
                  SetProperty( cParentName, cTxBName    , "VALUE", cListItem )
	                                
                  SetProperty(cParentName,cTxBName,"CARETPOS",;
                                LEN( cListItem ) )
                  
                  DoMethod( ThisWindow.Name, "Release" )
                  if pcount() == 3
                     if lTab
                        _Pushkey(VK_TAB)
                     endif
                  endif 
				  
         OtherWise
	
            	  cod_emp     := VAL(_HMG_CSG_aTable [ nListValue, 1 ])
                  cListItem   := _HMG_CSG_aTable [ nListValue, 2 ]
            	  cListPATCU  := _HMG_CSG_aTable[ nListValue, 3 ]
            	  cListPATDI  := _HMG_CSG_aTable[ nListValue, 4 ]
            	  cListPATEN  := _HMG_CSG_aTable[ nListValue, 5 ]
            	  cListProGra := _HMG_CSG_aTable[ nListValue, 6 ]
            	//MSGINFO(cListProGra , Valtype (cListProGra))
            	  
                  aLineData := _HMG_CSG_aTable[ nListValue ]
                  cQStr := 'update itemselected set tblrowid = ( select rowid from ' + cTblName + ' where '
                  for i := 1 to _HMG_CSG_nCols
                     cQStr := cQStr + 'col' + alltrim( str( i ) ) + ' = ' + _HMG_CSG_C2SQL( aLineData[ i ] )
                     if i < _HMG_CSG_nCols
                        cQStr := cQStr + ' and '
                     endif
                  next i
                  cQStr := cQStr + ')'
            	  
                  lOk := _HMG_CSG_MiscSQL( _HMG_CSG_DBO, cQStr )
            	 
                  if .not. lOk
                     msgstop( 'Error in ComboSearchGrid!' )
                     return nil
                  endif
                  
             //   MSGINFO(cListProGra)
                  SetProperty( cParentName, cTxBName, "VALUE", cListItem )
            	  SetProperty( cParentName, "tCuenta", "VALUE", cListPATCU )
            	  SetProperty( cParentName, "tDiario", "VALUE", cListPATDI )
            	  SetProperty( cParentName, "tElntace", "VALUE", cListPATEN )
            	  SetProperty( cParentName, "rProgram", "VALUE", VAL(cListProGra ))
            	   mostrar_bancos () 
                  
                  SetProperty(cParentName,cTxBName,"CARETPOS",;
                                LEN( cListItem ) )
                  
                  DoMethod( ThisWindow.Name, "Release" )
                  if pcount() == 3
                     if lTab
                        _Pushkey(VK_TAB)
                     endif
                  endif
				  
       EndCase
	   
   ELSE
   
    //  ( GetProperty( ThisWindow.Name, "_cstext", "VALUE" ) )
	  
	  SetProperty( cParentName, cTxBName, "VALUE", GetProperty( ThisWindow.Name, "_cstext", "VALUE" ) )
	//  SetProperty( cParentName, tEnlace, "VALUE", GetProperty( ThisWindow.Name, "_cstext", "VALUE" ) )
	  DoMethod( ThisWindow.Name, "Release" )
      if pcount() == 3
         if lTab
            _Pushkey(VK_TAB)
         endif
      endif 
          	  
   ENDIF  
   
RETURN // _CSGItemSelected()
Attachments
2019-02-07_9-23-29.jpg
2019-02-07_9-23-29.jpg (101.46 KiB) Viewed 3147 times
Skydone Solutions
www.skydone.com
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: ComboSearchGrid

Post by dragancesu »

If I understood correctly

You have data (DBF or MySQL) and you want to quickly load on it

I do not understand what the content of the field is from the program, but for the field character can be TEXTBOX and ON ENTER, when the contents change the filter is made and it works

Can you show/upload little data, it's hard to see something from the blank screen
User avatar
AidTIC
Posts: 117
Joined: Mon Apr 22, 2013 8:29 am
DBs Used: DBF
Contact:

Re: ComboSearchGrid

Post by AidTIC »

A ver si con este video se ve mas claro el problema.
y este es el error, porque coge la anterior array


Let's see if the problem is clearer with this video.
and this is the error, because it takes the previous array

Code: Select all

Date:07-02-2019 Time: 17:29:41
Error BASE/1132 Bound error: array access


Called from _CSGITEMSELECTED(417) 
Called from (b)CREATECSGRID(295) 
Called from _DOCONTROLEVENTPROCEDURE(6056) 
Called from EVENTS(828) 
Called from DOMESSAGELOOP(0) 
Called from _ACTIVATEWINDOW(5717) 
Called from CREATECSGRID(333) 
Called from (b)_DEFINECOMBOSEARCHGRID(187) 
Called from _DOCONTROLEVENTPROCEDURE(6056) 
Called from EVENTS(1861) 
Called from SETWINDOWTEXT(0) 
Called from _SETVALUE(536) 
Called from SETPROPERTY(7931) 
Called from _CSGITEMSELECTED(444) 
Called from (b)CREATECSGRID(319) 
Called from EVENTS(3244) 
Called from DOMESSAGELOOP(0) 
Called from _ACTIVATEWINDOW(5717) 
Called from CREATECSGRID(333) 
Called from (b)_DEFINECOMBOSEARCHGRID(187) 
Called from _DOCONTROLEVENTPROCEDURE(6056) 
Called from EVENTS(1861) 
Called from DOMESSAGELOOP(0) 
Called from _ACTIVATEWINDOW(5717) 
Called from DOMETHOD(9003) 
Called from GESTION_BANCOS(196) 
Called from (b)MAIN(154) 
Called from _DOCONTROLEVENTPROCEDURE(6056) 
Called from EVENTS(1756) 
Called from DOMESSAGELOOP(0) 
Called from _ACTIVATEWINDOW(5717) 
Called from MAIN(300) 
Image
Attachments
2019-02-07_17-47-50.gif
2019-02-07_17-47-50.gif (389.01 KiB) Viewed 3113 times
Skydone Solutions
www.skydone.com
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: ComboSearchGrid

Post by andyglezl »

No entendí, en el combo "BANCO" estás buscando la "Empresa" ???
y después de seleccionarla, te pasas al otro combo para seleccionarla de nuevo ???

Una pregunta:
Cuantos registros de Bancos y de Empresas tienes como para no utilizar
un ComboBox normal. (Que pienso yo, sería más rápido)
*-----------------------------------------------------------------------------------------------------
I did not understand, in the "BANK" combo are you looking for the "Company" ???
and after selecting it, you go to the other combo to select it again ???

A question:
How many records of Banks and Companies do you have so as not to use
a normal ComboBox (What I think, it would be faster)
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
tonton2
Posts: 444
Joined: Sat Jun 29, 2013 1:26 pm
Location: Algerie
Contact:

Re: ComboSearchGrid

Post by tonton2 »

Bonjour,
voici un exemple de cherche client,j’espère que cela
Search_Customer.rar
(21.42 KiB) Downloaded 260 times
va vous aider
L'Algerie vous salut
Y.TABET
User avatar
tonton2
Posts: 444
Joined: Sat Jun 29, 2013 1:26 pm
Location: Algerie
Contact:

Re: ComboSearchGrid

Post by tonton2 »

L'Algerie vous salut
Y.TABET
User avatar
AidTIC
Posts: 117
Joined: Mon Apr 22, 2013 8:29 am
DBs Used: DBF
Contact:

Re: ComboSearchGrid

Post by AidTIC »

a ver andyglezl , si se preve que cuando se trabaje con el , tenga mas de 100 empresa y a una media de 4 o 5 bancos por empresa.

Lo que estoy intentando es que cuando den de alta una cuenta de banco, puedan seleccionar a que empresa corresponde, peo si existe, que me la muestre. Por eso estoy intentando gastar 2 ComboSearchGrid. Cuando el primero detecta que existe el banco, muestra entre otros datos que empresa esta asignada, con intención de poder modificar el resto de datos.

tonton2, gracias, pero ya lo estuve viendo, pero me ese ejemplo no me vale, pues solo gasta un ComboSearchGrid.


to see andyglezl, if it is expected that when you work with it, you have more than 100 companies and an average of 4 or 5 banks per company.

What I am trying to do is that when you register a bank account, you can select which company it corresponds to, if it exists, show it to me. That's why I'm trying to spend 2 ComboSearchGrid. When the first detects that the bank exists, it shows, among other data, which company is assigned, with the intention of being able to modify the rest of the data.

  tonton2, thanks, but I've already seen it, but that example is not worth it, because it only spends a ComboSearchGrid.
Skydone Solutions
www.skydone.com
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: ComboSearchGrid

Post by andyglezl »

Es solo una forma (claro que hay muchas) de como yo hago un busqueda...

Tengo 2 TextBox y 2 ComboBox

Si encuentro el código, despliego la informacion, pero a la
vez lleno los 2 Combobox, uno con los registros que contengan
lo que teclee en el código ( "1254" ), y el otro con los registros
que contengan los nombres iguales ( "OBADIA" ) al registro encontrado.
Y a la vez, en el segundo TextBox puedo hacer cualquier busqueda en el NOMBRE.
(Esta busqueda la hago en un DBF con 20,000 registros.)
*---------------------------------------------------------------------------------------------
It's just one way (of course there are many) of how I do a search ...

I have 2 TextBox and 2 ComboBox

If I find the code, I display the information, but to the
once filled the 2 Combobox, one with the records that contain
what you type in the code ("1254"), and the other with the records
that contain the same names ("OBADIA") to the found record.
And at the same time, in the second TextBox I can do any search in the NAME.
(This search is done in a DBF with 20,000 records.)
demogif.gif
demogif.gif (637.26 KiB) Viewed 3021 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: ComboSearchGrid

Post by dragancesu »

Nice, what program do you use to make this video?
Post Reply