FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xbrowse best way to change browse cols realtime
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 09:30 AM

Hello,

I have a Xbrowse where I show this month with several fields related to this month.

Local nPeriod = 8 (August)

Xbrowse :

August
C1 C2 C3 C4

C1 = data T1_1 in database
C2 = data T1_2
C3 = data T1_3
....

Now when we become Sept. Parameter set (cPeriod = 9) The browse should show september data

_September__
C1 C2 C3 C4

C1 = data T9_1 in database
C2 = data T9_2
C3 = data T9_3
....

At this point, the data is all in 1 database : Id,Name,..., T1_1,T1_2,T1_3,T1_4,T2_1,....,T12_1,T12_2 until T12,4

What is the best approach for this way of showing Xbrowses ?
Invoicing software also has to change this views every year ?
Maybe a better system in data structure of dbf/oRs?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 10:39 AM
Marc,

I have a solution to show / refresh the xbrowse month-values on button-action.
As well I have to change the year if the selected month > month of date.
Is that the solution You are looking for ?



defined files :

Jan_16.dbf
Feb_16.dbf
...
Jan_17.dbf
Feb_17.dbf
...

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.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 10:59 AM

Uwe,

Yes, That is the solution.

You use a new dbf for each Month/year ?

I suppose
1 file = general data like, name, tel, adres... and ID

Year/Month files with

ID, and datacoloms for xbrowse.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 11:17 AM
Marc,
Yes the data of each month are included in a extra dbf because it is possible to select month of different years.

< cMName > is a var related to the month-dbf You want to open.

using only ONE browser with < cMName > = month on button-change

ALIAS cMName UPDATE

Code (fw): Select all Collapse
DBSELECTAREA(cMName)
DBSETORDER ( cMName )

REDEFINE XBROWSE oBrw1 ID 110 OF oFld:aDialogs[ 1 ] AUTOSORT  FASTEDIT ;
COLUMNS { "NACHNAME", "VORNAME", "KD_NR", "RTYP", "PFLSTUFE", ;
                        "KOST_RZH", "KOST_BEI", "KOST_PRI", ;
                        "KRK", "KRX", "LEER", ;
            "PFK1", "PFX1", "PFK2", "PFX2", "PFK3", "PFX3", "PFK4", "PFX4", "PFK5", "PFX5", "LEER", ;
                        "B2K", "B2X", "PBK", "B1K", "B1X", "PBX", "LEER", ;
                "VPK", "VPX",  "PRA", "PRI", "BERG", "LEER", "SUMME", "PKT_SUMME", "LEER", "RECH_DATUM"} ;  
ALIAS cMName UPDATE


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.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 12:11 PM

Also data like Name, vorname,rtyp, .... are in every single dbf.

How do you maintain the names then ? They should be on 1 place not ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 12:20 PM
Marc,

there is a customer-dbf with the customer names ( can change at any time ).
Writing bills, I add the names from the customer file to the month-dbf
That means the month-dbf*s are not equal and can include different names.

The way I'm adding data

On top the customer.dbf
on bottom the selected month-dbf

A new record adds the selected names from the customer-dbf
There is a relation on customer names
( the names are not visible in the month-dbf only the performances )



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.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 12:43 PM

Every Logic is interesting, so yes, do so.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 12:53 PM

Marc,

if You need more infos about the program-structure
I can explain.

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.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 01:19 PM

Uwe,

You put the names in the month dbf, only for purpose of browse like the top picture ? so that you dont have to make a relation ?
Otherwise it is not nessesary.

Xbrowse can't browse two dbf's in one xbrowse I believe, else we could browse partial the customer, and data in one browse.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 01:21 PM

Uwe,

I'm also interested in how you browse the changing month and day's (calender look) in the last browse.
This also in dynamic.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 01:26 PM
Marc,

have a look at the new picture for the logic.

I need a seperate customer.dbf because of changes ( adding / delete ).
The customers inside the month-dbf's are the same at the time, the month-dbf is created.

Showing the results, the customer.dbf ( only for creation to include the name in the month-dbf )
is not needed and the selected names are visible

I'm also interested in how you browse the changing month and day's (calender look) in the last browse.
This also in dynamic.


That was the most complicated part ! :(

I will try to extract this part.

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.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 01:42 PM

Uwe,

I see the logic.

Only, when browsing older data's, you could sometimes have changes in names. For that browse it probably does not matter.

I'm interested in the code of building the Xbrowse, where you show the dates/months, depending on the active month of selected button.
How the headers are created.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 01:55 PM
Marc,

I'm interested in the code of building the Xbrowse, where you show the dates/months, depending on the active month of selected button.
How the headers are created


There is still more :

Saturday, Sunday and other special days are detected and the columns have a different color.
As well the total days of a month is detected and the non needed columns are disabled.

There is a solution to jump after adding a value to the next cell without return.

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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 01:58 PM
What is the best approach for this way of showing Xbrowses ?

Please try this sample.
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   OpenData()
   BrowseData()

return nil

function BrowseData()

   local oDlg, oFont, oCbx, oBrw
   local nMonth   := 1
   local aMonths[ 12 ]
   local nOffSet

   AEval( aMonths, { |c,i| aMonths[ i ] := NtoCMonth( i ) } )
   nOffSet     := MARCV->( FIELDPOS( "T1_1" ) ) - 4

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE DIALOG oDlg SIZE 400,400 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 COMBOBOX oCbx VAR nMonth SIZE 200,400 PIXEL OF oDlg ;
      ITEMS aMonths ON CHANGE oBrw:Refresh()

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "MARCV" ;
      COLUMNS "ID", "Name", ;
         { || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet ) ) }, ;
         { || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet + 1 ) ) }, ;
         { || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet + 2 ) ) }, ;
         { || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet + 3 ) ) }  ;
      HEADERS nil, nil, "C1", "C2", "C3", "C4" ;
      PICTURES nil, nil, "9999", "9999", "9999", "9999" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

function OpenData()

   CreateData()

   USE MARCV NEW SHARED VIA "DBFCDX"

return nil

function CreateData()

   local aCols    := { { "ID",  "+", 4, 0 }, { "NAME", "C", 6, 0 } }
   local i, j, c, a

   for i := 1 to 12
      for j := 1 to 4
         c  := "T" + LTrim( Str( i ) ) + "_" + Str( j, 1 )
         AAdd( aCols, { c, "N", 4, 0 } )
      next
   next

   DBCREATE( "MARCV", aCols, "DBFCDX", .T., "DB" )

   for i := 1 to 10
      APPEND BLANK
      FIELD->NAME    := "Name" + StrZero( i, 2 )
      for j := 3 to FCOUNT()
         FieldPut( j, HB_RandomInt( 10,9999 ) )
      next
   next
   CLOSE DATA

return nil


Maybe a better system in data structure of dbf/oRs?


ID, Name, ..., MONTHNUM, C1, C2, C3, C4
Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse best way to change browse cols realtime
Posted: Tue Aug 01, 2017 03:04 PM

Mr. Rao,

Very interesting sample !! Works like wanted. Will study it some more.

Thanks.

Btw : Mr. Rao, do you have also commercial software in FWH ? Ex. Invoicing

Marc

Marc Venken

Using: FWH 23.08 with Harbour