DBCOMBO question

DBCOMBO question

Postby ADutheil » Mon Jun 10, 2013 2:05 am

I´ve been using DBCOMBO to include new records and now I´d like to re-use same resource and same code to edit. The problem is when I load the data from the table to fill my GETs the proper item of the dbcombo is not shown and worse if I exit the dialog with saving option without selecting any option from the DBCOMBOs their datas are lost. Is there a workaround to this?
TIA
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: DBCOMBO question

Postby Antonio Linares » Mon Jun 10, 2013 8:38 am

André,

Would you mind to post a screenshot to see how you are using it ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42092
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: DBCOMBO question

Postby ADutheil » Mon Jun 10, 2013 12:20 pm

There are 3 DBCOMBO (TIPO DE PONTO, ÁREA, FATURAMENTO)
For testing purpose I changed the ÁREA COMBO from dropbox to droplist but result is the same

New record:
Image
Fill data and save:
Image
Edit:
Image
TIPO FATURAMENTO shows 03 but I´d like it to show FARMACIA, same for FATURAMENTO. ÁREA shows nothing (droplist).

I´m not loosing data anymore if I don't click the combos when editing. It was my fault because I forced showing the items for the combos. See comented out in source code.
Code: Select all  Expand view

......
aVars[  5 ] := pdvs->CODT //ExtNomeTipPdv( pdvs->CODT )
aVars[  6 ] := pdvs->NCIC
aVars[  7 ] := pdvs->IEST
aVars[  8 ] := pdvs->CODA //ExtNomeArea( pdvs->CODA )
.....
aVars[ 21 ] := pdvs->DINI
aVars[ 22 ] := pdvs->TIPF
aVars[ 23 ] := pdvs->COMI
===========================================================================
REDEFINE GET aGets[ 1 ] VAR aVars[ 1 ] ID 101 OF oFld:aDialogs[ 1 ]
REDEFINE GET aGets[ 2 ] VAR aVars[ 2 ] ID 102 OF oFld:aDialogs[ 1 ] PICTURE "@!"
REDEFINE GET aGets[ 3 ] VAR aVars[ 3 ] ID 103 OF oFld:aDialogs[ 1 ] VALID if( ChkVaz( aVars[ 3 ] ), ( aButt[ 1 ]:Enable(), .T. ), ( aButt[ 1 ]:Disable(), .F. ) )  PICTURE "@!"
REDEFINE GET aGets[ 4 ] VAR aVars[ 4 ] ID 104 OF oFld:aDialogs[ 1 ] PICTURE "@!"
REDEFINE DBCOMBO aGets[ 5 ] VAR aVars[ 5 ] ALIAS "TIPP"  ITEMFIELD "CODT" LISTFIELD "NOME" ID 105 OF oFld:aDialogs[ 1 ] UPDATE
REDEFINE GET aGets[ 6 ] VAR aVars[ 6 ] ID 106 OF oFld:aDialogs[ 1 ] VALID ChkNCic( aVars[ 6 ], aGets[ 6 ] )
REDEFINE GET aGets[ 7 ] VAR aVars[ 7 ] ID 107 OF oFld:aDialogs[ 1 ]
REDEFINE DBCOMBO aGets[ 8 ] VAR aVars[ 8 ] ID 108 OF oFld:aDialogs[ 1 ] ALIAS "AREA"  ITEMFIELD "CODA" LISTFIELD "NOME" ON CHANGE SetScopeRota( aVars[ 8 ], aGets[ 54 ] )
REDEFINE GET aGets[ 9 ] VAR aVars[ 9 ] ID 109 OF oFld:aDialogs[ 1 ] PICTURE "@!"
........
REDEFINE DTPICKER aGets[ 21 ] VAR aVars[ 21 ] ID 121 OF oFld:aDialogs[ 1 ]
REDEFINE DBCOMBO aGets[ 22 ] VAR aVars[ 22 ] ID 122 OF oFld:aDialogs[ 1 ] ALIAS "TIPF"  ITEMFIELD "CODF" LISTFIELD "NOME"
REDEFINE GET aGets[ 23 ] VAR aVars[ 23 ] ID 123 OF oFld:aDialogs[ 1 ] PICTURE "99"

 


If nobody reported earlier it might be related to recent changes in COMBOBOX class or I´m missing something.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: DBCOMBO question

Postby Antonio Linares » Mon Jun 10, 2013 12:45 pm

André,

Thanks for the screenshots.

I have just tested FWH samples/Testdbc1.prg and seems to behave fine. Would you mind to build it and check if it fails too ?

buildh.bat testdbc1
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42092
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: DBCOMBO question

Postby ADutheil » Mon Jun 10, 2013 1:10 pm

In testdbc1 you are not retrieving/editing any data. The problem is that when I retreive data the actual code is shown and not the meaning of the code which I think is the purpose of DBCOMBO.
Selecting FARMACIA saves 03 which is correct, but loading 03 shows 03 and I think it should show FARMACIA.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: DBCOMBO question

Postby Antonio Linares » Mon Jun 10, 2013 9:08 pm

André,

If you add this method to Class TDbCombo:

Code: Select all  Expand view
METHOD Set( cItem ) CLASS TDBCombo

   local nAt := AScan( ::aItems, { | c | Upper( c ) == Upper( cItem ) } )
   
   if nAt != 0
      ::Select( nAt )
   else
      SetWindowText( ::hWnd, cItem )
   endif
   
return nil


then this modified testdcb.prg wors fine (selected items are preselected):

Code: Select all  Expand view
/*
Program : DBC1.PRG
Purpose : Test DBCombo
Notes   :
*/


#include "fivewin.ch"
#include "dbcombo.ch"


function main()
   local oDlg, oDBC1, oDBC2, cVar, oCust, cStateID:="CA", oBtn, cState:="  "
   local cDept:= "200", oStates, aItems, aList
   field NAME

   if file("states.dbf")
      use states
      index on upper(NAME) to temp
      database oStates
   else
      msgInfo("File states.dbf not found.")
   endif

   define dialog oDlg

   @ 10,30 dbcombo oDBC1 var cStateID of oDlg;
      alias oStates:cAlias;
      size 100,200 pixel;
      itemfield "CODE" ;
      listfield "NAME";
      update;

   aList:= {"Accounting","HR","Marketing","Production","Research","Shipping","Sales"}
   aItems:= {"100","200","400","300","600","500","700"}

   @ 30,30 DBCOMBO oDBC2 VAR cDept;
      items aItems;
      size 100,200 pixel;
      list aList;
      of oDlg;
      update


   @ 50, 50 button oBtn prompt "Selected";
      of oDlg pixel ;
      action msgInfo( "cStateId: " +cStateID +CRLF+"DeptNo: "+cDept,"Selected" );
      default

   activate dialog oDlg center;

   ferase("temp.ntx")

return nil

// EOF
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42092
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: DBCOMBO question

Postby Antonio Linares » Mon Jun 10, 2013 9:11 pm

I initialized the vars with cStateID:="CA" and cDept:= "200"

and got:

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42092
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: DBCOMBO question

Postby ADutheil » Mon Jun 10, 2013 9:30 pm

Tested and everything seems OK now. Thanks a lot.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: DBCOMBO question

Postby Horizon » Wed Jun 12, 2013 7:24 pm

Hi Antonio,

I have just download and tested the 13.05.

It gives the an error like below.

Code: Select all  Expand view
Application
===========
   Path and name: D:\PRG\CRM\Crm.exe (32 bits)
   Size: 3,834,368 bytes
   Compiler version: xHarbour build 1.2.2 Intl. (SimpLex) (Rev. 9719)
   FiveWin  Version: FWHX 13.05
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 6 mins 12 secs
   Error occurred at: 12/06/2013, 22:00:12
   Error description: Error BASE/1102  Argument error: UPPER
   Args:
     [   1] = N   2

Stack Calls
===========
   Called from:  => UPPER( 0 )
   Called from: .\source\classes\DBCOMBO.PRG => (b)TDBCOMBO:SET( 458 )
   Called from:  => ASCAN( 0 )
   Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:SET( 458 )
   Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:DEFAULT( 244 )
   Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:INITIATE( 276 )
   Called from:  => __OBJSENDMSG( 0 )
   Called from:  => HB_EXECFROMARRAY( 0 )
   Called from: .\source\function\HARBOUR.PRG => OSEND( 287 )


I have realized the new Set method. I have changed it and now my app. works now without error.

Can you please confirm it?

Code: Select all  Expand view
METHOD Set( cItem ) CLASS TDBCombo
   local nAt
   if ValType(cItem) = "C"
    nAt := AScan( ::aItems, { | c | Upper( c ) == Upper( cItem ) } )
   ELSE
    nAt := AScan( ::aItems, { | c |  c == cItem } )
   ENDIF
   
   if nAt != 0
      ::Select( nAt )
   else
      SetWindowText( ::hWnd, cItem )
   endif
   
return nil        
 
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: DBCOMBO question

Postby Antonio Linares » Wed Jun 12, 2013 8:06 pm

Hakan,

Your fix is fine, thanks :-)

I missed non-string values, my mistake, sorry. We were so focused on strings that paid no attention to other types
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42092
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 106 guests