xbrowse edit dbcombo

xbrowse edit dbcombo

Postby brewster » Tue Mar 03, 2015 7:03 am

Hello,
I am trying to get a dbcombo functional in this xbrowse sample by Mr. Nages

The oRec:drvr displays fine ,but without any functional dbcombo.

Don't know if I've chosen the proper form of dbcombo or have the syntax correct.

Any help appreciated.

Bruce


Code: Select all  Expand view
  Local oTruc, oBrw, oDlg, oRec

   // path_seg defined static above  
   
   oTruc := TDataBase():New()
   
   oTruc := TDataBase():Open( , cPath_seg + 'TRUC' )


   DEFINE DIALOG oDlg FROM 10, 25 TO 35, 100    TITLE " Tdatabase Test"
   
   @ 12,10 XBROWSE oBrw SIZE -10,-30  PIXEL OF oDlg ;
     FIELDS oTruc:TAG  , oTruc:Que_dte, oTruc:Shp_dte, oTruc:org  , oTruc:DrpA ,;
              oTruc:DrpB , oTruc:DrpC  ,  oTruc:Drvr   , oTruc:Qty1 , oTruc:Desc1,;
              oTruc:Qty2  ,  oTruc:Desc2  , oTruc:Trip_num,oTruc:Notes ;            
     HEADERS "Tag","Que Date","Ship Date", "Orgin", "A", "B", "C", "DR",;
               "Qty1","Desc1","Qty2","Desc2", "Trip #", "Notes" ;            
     FIELDSIZES 30  , 60       , 60        ,  45,     45,  45,  45, 40,;
                30, 50, 30, 50, 45, 160 ;
     OBJECT oTruc ;
     AUTOSORT ;
     CELL LINES NOBORDER
     
   WITH OBJECT oBrw
    :bEdit         := { |oRec| CustEditDlg( oRec ) } // reconfigures edit()  
    :CreateFromCode()   // seems to need this to make xbrowse display
   END
   
   @ 170,10 BUTTON "Add" SIZE 40,12 PIXEL OF oDlg ;
      ACTION ( oRec := TDataRow():New( oTruc, nil, .t. ), oRec:Edit(), oBrw:Refresh(), oBrw:SetFocus() )
   
   @ 170,60 BUTTON "Edit" SIZE 40,12 PIXEL OF oDlg ;
      ACTION ( oRec := TDataRow():New( oTruc ), oRec:Edit(), oBrw:Refresh(), oBrw:SetFocus() )
     
   ACTIVATE DIALOG oDlg
   
   oTruc:close()

return nil
//---------------------------------------//
// downloaded 02/09/15 FW
// 09/08/13 cust edit dialog nages - Xbrow, add, edit, modify, delete
static function CustEditDlg( oRec )

   local oDlg, oFont, oGrp
   local oDrv, oDbc2  
   
   oDrv := TDataBase():New()
   oDrv := TDataBase():Open( , cPath_seg + 'T_drv' )
   
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 618,382 PIXEL FONT oFont TITLE "EDIT MILL"

   @ 0, 4 GROUP oGrp TO 168, 305 OF oDlg PIXEL

   @ 12, 10 SAY "Tag:"       OF oDlg SIZE 15, 8 PIXEL
   @ 10, 44 GET oRec:Tag     OF oDlg SIZE 105, 12 PIXEL UPDATE
   @ 26, 10 SAY "Que Dte:"   OF oDlg SIZE 15, 8 PIXEL
   @ 24, 44 GET oRec:Que_dte OF oDlg SIZE 105, 12 PIXEL UPDATE
   @ 40, 10 SAY "Shp_dte:"   OF oDlg SIZE 21, 8 PIXEL
   @ 38, 44 GET oRec:shp_dte OF oDlg SIZE 155, 12 PIXEL UPDATE
   @ 54, 10 SAY "Org:"       OF oDlg SIZE 13, 8 PIXEL
   @ 52, 44 GET oRec:org     OF oDlg SIZE 155, 12 PIXEL UPDATE
   @ 68, 10 SAY "Drp A:"     OF oDlg SIZE 19, 8 PIXEL
   @ 66, 44 GET oRec:DrpA    OF oDlg SIZE 15, 12 PIXEL UPDATE
   @ 82, 10 SAY "Drp B:"     OF oDlg SIZE 12, 8 PIXEL
   @ 80, 44 GET oRec:DrpB    OF oDlg SIZE 55, 12 PIXEL UPDATE
   @ 96, 10 SAY "Drp C:"     OF oDlg SIZE 29, 8 PIXEL
   @ 94, 44 GET oRec:DrpC    OF oDlg SIZE 44, 12 PIXEL UPDATE
   @ 124, 10 SAY "Drvr:"     OF  oDlg SIZE 15, 8 PIXEL
   //@ 122, 44 GET  oRec:Drvr OF oDlg SIZE 12, 12 PIXEL UPDATE PICTURE  "99"
   @ 146, 40 dbcombo oDBC2 var oRec:Drvr of oDlg;
      alias oDrv:cAlias;
      size 75,250 pixel;
      itemfield "DRVR" ;
      listfield "TNAME";
      update  
   @ 138, 10 SAY "Qty 1:"    OF oDlg SIZE 21, 8 PIXEL
   @ 136, 44 GET oRec:Qty1   OF oDlg SIZE 40, 12 PIXEL UPDATE PICTURE  "999999.99"
   @ 152, 10 SAY "Desc 1:"   OF oDlg SIZE 21, 8 PIXEL
   @ 150, 44 GET oRec:Desc1  OF oDlg SIZE 255, 12 PIXEL UPDATE
   @ 172, 175 BUTTON "&Undo" OF oDlg SIZE 42, 14 PIXEL WHEN oRec:Modified() ACTION ( oRec:UnDo(), oDlg:Update() )
   @ 172, 219 BUTTON "&Save" OF oDlg SIZE 42, 14 PIXEL WHEN oRec:Modified() ACTION ( oRec:Save(), oDlg:Update() )
   @ 172, 263 BUTTON "&Close" OF oDlg SIZE 42, 14 PIXEL CANCEL ACTION ;
      ( If( oRec:Modified() .and. MsgYesNo( "Save Changes ?" ), oRec:Save(), nil ), oDlg:End() )

   AEval( oDlg:aControls, { |o| If( o:ClassName == "TGET", o:bValid := { || oDlg:AEvalWhen(), .t. }, nil ) } )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oDrv:close()
   
return nil
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am

Re: xbrowse edit dbcombo

Postby nageswaragunupudi » Tue Mar 03, 2015 9:08 am

Please indicate version of FWH you are using
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse edit dbcombo

Postby brewster » Tue Mar 03, 2015 1:27 pm

FWH 14.11
Harbour 3.2.0dev ( r1406271520 )
bcc582

Bruce
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am

Re: xbrowse edit dbcombo

Postby nageswaragunupudi » Wed Mar 04, 2015 3:32 pm

1) Please substitute this
Code: Select all  Expand view
    FIELDS oTruc:TAG  , oTruc:Que_dte, oTruc:Shp_dte, oTruc:org  , oTruc:DrpA ,;
              oTruc:DrpB , oTruc:DrpC  ,  oTruc:Drvr   , oTruc:Qty1 , oTruc:Desc1,;
              oTruc:Qty2  ,  oTruc:Desc2  , oTruc:Trip_num,oTruc:Notes ;            
 

with
Code: Select all  Expand view
    COLUMNS "TAG", "Que_dte", "Shp_dte", "org", "DrpA", "DrpB", "DrpC", "Drvr", "Qty1", "Desc1", ;
        "Qty2", "Desc2", "Trip_num","Notes" ;            
 

and try.

2) Please never use FIELDS clause. Please use COLUMNS clause only always.

Please let me know if you still have problems.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse edit dbcombo

Postby brewster » Wed Mar 04, 2015 6:11 pm

Mr. Nages,

I made the changes as suggested ( fields to columns ), but that hasn't had any effect on the dbcombo displaying properly in the CustEditDlg function.

Bruce
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am

Re: xbrowse edit dbcombo

Postby nageswaragunupudi » Wed Mar 04, 2015 6:19 pm

I shall prepare and post a very similar sample for you. Please wait
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse edit dbcombo

Postby nageswaragunupudi » Sun Mar 08, 2015 10:22 am

I do not have your DBFs. But customer.dbf and states.dbf in \fwh\samples folder are very similar to your example

I prepared the sample using these two DBFs. If your FWH installation path is different, please change the path in the program
Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

function XbrAddEdit()

   local oCust, oStates
   local aStates
   local oWnd, oBar, oBrw, oFont


   RddSetDefault( "DBFCDX" )
   SET DELETED ON

   oStates  := TDataBase():Open( nil, "c:\\fwh\\samples\\states.dbf" )
   aStates  := ( oStates:nArea )->( FW_DbfToArray() )
   oStates:Close()

   oCust    := TDataBase():Open( nil, "c:\\fwh\\samples\\customer.dbf" )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )
   DEFINE BUTTONBAR oBar OF oWnd SIZE 90,32 2007
   DEFINE BUTTON OF oBar PROMPT "Add"     CENTER ACTION oBrw:EditSource( .t. )
   DEFINE BUTTON OF oBar PROMPT "Edit"    CENTER ACTION oBrw:EditSource()
   DEFINE BUTTON OF oBar PROMPT "Delete"  CENTER ACTION oBrw:Delete()

   @ 0,0 XBROWSE oBrw OF oWnd DATASOURCE oCust ;
      COLUMNS "FIRST","LAST","STREET","CITY","STATE","ZIP","HIREDATE","MARRIED","AGE","SALARY","NOTES" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :SetChecks()
      :nEditTypes    := EDIT_GET
      :bEdit         := { |oRec| EditDlg( oRec ) }

      WITH OBJECT oBrw:oCol( "STATE" )
         :nEditType     := EDIT_LISTBOX
         :aEditListTxt  := aStates
      END
      :brclicked := { || EditDlg() }
      //
      :CreateFromCode()
   END

   oWnd:oClient      := oBrw

   ACTIVATE WINDOW oWnd MAXIMIZED
   RELEASE FONT oFont
   oCust:Close()

return nil

static function EditDlg( oRec )


   local oDlg, oGrp, oBtn, oStates
   local lSave := .f.

   oStates  := TDataBase():Open( , "STATES" )

   DEFINE DIALOG oDlg SIZE 820,380 PIXEL FONT oRec:oBrw:oFont ;
      TITLE If( oRec:RecNo == 0, "ADD ", "EDIT " ) + "CUSTOMER"

   @ 0, 4 GROUP oGrp TO 168, 405 OF oDlg PIXEL


   @ 12, 10 SAY "First:" OF oDlg SIZE 15, 8 PIXEL
   @ 10, 44 GET oRec:First    OF oDlg SIZE 105, 12 PIXEL UPDATE

   @ 26, 10 SAY "Last:" OF oDlg SIZE 15, 8 PIXEL
   @ 24, 44 GET oRec:Last     OF oDlg SIZE 105, 12 PIXEL  UPDATE

   @ 40, 10 SAY "Street:" OF oDlg SIZE 21, 8 PIXEL
   @ 38, 44 GET oRec:Street   OF oDlg SIZE 155, 12 PIXEL UPDATE

   @ 54, 10 SAY "City:" OF oDlg SIZE 13, 8 PIXEL
   @ 52, 44 GET oRec:City     OF oDlg SIZE 155, 12 PIXEL UPDATE

   @ 68, 10 SAY "State:" OF oDlg SIZE 19, 8 PIXEL
   @ 66, 44 DBCOMBO oRec:State SIZE 100,100 PIXEL OF oDlg UPDATE ;
      ALIAS oStates:cAlias ITEMFIELD "CODE" LISTFIELD "NAME"

   @ 82, 10 SAY "Zip:" OF oDlg SIZE 12, 8 PIXEL
   @ 80, 44 GET oRec:Zip      OF oDlg SIZE 55, 12 PIXEL  UPDATE

   @ 96, 10 SAY "Hiredate:" OF oDlg SIZE 29, 8 PIXEL
   @ 94, 44 GET oRec:Hiredate OF oDlg SIZE 44, 12 PIXEL

   @ 108, 44 CHECKBOX oRec:Married  PROMPT "&Married:" OF oDlg SIZE 43, 12 PIXEL  UPDATE

   @ 124, 10 SAY "Age:" OF oDlg SIZE 15, 8 PIXEL
   @ 122, 44 GET oRec:Age      OF oDlg SIZE 12, 12 PIXEL PICTURE  "99"

   @ 138, 10 SAY "Salary:" OF oDlg SIZE 21, 8 PIXEL
   @ 136, 44 GET oRec:Salary   OF oDlg SIZE 40, 12 PIXEL PICTURE  "999,999.99"  UPDATE

   @ 152, 10 SAY "Notes:" OF oDlg SIZE 21, 8 PIXEL
   @ 150, 44 GET oRec:Notes    OF oDlg SIZE 355, 12 PIXEL  UPDATE

   @ 172, 275 BUTTON oBtn PROMPT "&Undo" OF oDlg SIZE 42, 14 PIXEL ;
         WHEN oRec:Modified() ;
         ACTION ( oRec:Undo(), oDlg:Update() )

   @ 172, 319 BUTTON oBtn PROMPT "&Save" OF oDlg SIZE 42, 14 PIXEL ;
         WHEN oRec:Modified() ;
         ACTION (oDlg:End(), lSave := .T.)
   @ 172, 363 BUTTON oBtn PROMPT "&Cancel" OF oDlg SIZE 42, 14 PIXEL   CANCEL ACTION (oDlg:End())

   ACTIVATE DIALOG oDlg CENTERED

   if lSave
      oRec:Save()
      oRec:oBrw:SetFocus()
   endif

   oStates:Close()

return nil

 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse edit dbcombo

Postby ukoenig » Sun Mar 08, 2015 10:27 pm

Mr. Rao,

thank You very much.
Your sample is great and very useful for my new project.

best regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xbrowse edit dbcombo

Postby ukoenig » Mon Mar 09, 2015 6:02 pm

Mr. Rao,

adding some logic for practical uses to Your sample :

I explain

There is a CUSTOMER.dbf and PRODUCTS.dbf ( instead of STATE.dbf )
CUSTOMER.dbf includes 4 new fields
PRODUCT
VALUE
QUANTUM
AMOUNT


1.) The user selects a product with the combo
2.) Selecting a product, the price from PRODUCTS is added to column CUSTOMER-VALUE from the combo-selection
3.) The user defines the QUANTUM
4.) The field AMOUNT is calculated VALUE * QUANTUM = AMOUNT
5.) TOTAL of column AMOUNT on FOOTER

that makes it VERY useful and saves a lot of input-time !!!

maybe there is any sample :?: , otherwise I have to carry on testing.

Image

best regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xbrowse edit dbcombo

Postby brewster » Mon Mar 16, 2015 12:54 pm

Mr. Nages,

The dbcombo sample code you supplied, compiles and runs fine.
I will implement it in my code and persue.
-------

Using Tdatabase() is new to me and the burning question is, what setup is needed
to use your example in a multiuser environment. ( lShared, lBuffer ? ).
Is there a sample somewhere, I could reference ?

Gratefully,
Bruce S.
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am

Re: xbrowse edit dbcombo

Postby nageswaragunupudi » Mon Mar 16, 2015 1:11 pm

brewster wrote:Mr. Nages,

The dbcombo sample code you supplied, compiles and runs fine.
I will implement it in my code and persue.
-------

Using Tdatabase() is new to me and the burning question is, what setup is needed
to use your example in a multiuser environment. ( lShared, lBuffer ? ).
Is there a sample somewhere, I could reference ?

Gratefully,
Bruce S.

TDatabase by default is set for multiuser use and is buffered.
I suggest you do not do anything. Just use it.

You can work directly with RDD too. The above sample code works directly with RDD also.
Why do u want to use TDataBase?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse edit dbcombo

Postby brewster » Tue Mar 17, 2015 6:46 am

Mr. Nages,

>>>Why do u want to use TDataBase?

Your original posted sample used Tdatabase and I thought I'd try and become familiar with it.

I am relatively new to FWH.
I have converted all(most) of my Clipper programs to FWH and want to make them all into multiuser applications.
I'm familiar with record /file locking the old way, but knew the next step was to take advantage of ADO, ADS, SQL, etc. of which I know nothing about.

Also, using ADO examples in the forum, I have built working applications.

The wrestling with above samples helps me to begin to even ask valid questions.
I'd like to stay with .dbfs and apply something with a decent learning curve.

The vaque question is, which one do I choose ?

Recently, Jeff Barnes and others threads have provided food for thought.


Regards,
Bruce S.
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 47 guests