Exempt certain xBrowse rows from MakeTotals()

Exempt certain xBrowse rows from MakeTotals()

Postby Rick Lipkin » Thu Aug 13, 2015 1:49 pm

To All - Rao

I am trying to reproduce a grid that I can insert rows that have subtotal amounts that will not be calculated in MakeTotals(). Is there a way to exempt a row so it will not be calculated ? .. see attached .. Direct and Indirect ..

or .. only select certain rows to be calculated with MakeTotals ?

Rick Lipkin
Image
Image
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Exempt certain xBrowse rows from MakeTotals()

Postby reinaldocrespo » Fri Aug 14, 2015 7:10 pm

Hey Rick;

Have you checked the bSumCondition property of the xBrwColumn class?

I think this should work:
Code: Select all  Expand view  RUN
oCol:bSumCondition := { |n,o| <condition> }


Where <Condition> could be o:oBrw:....
Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Exempt certain xBrowse rows from MakeTotals()

Postby Rick Lipkin » Fri Aug 14, 2015 8:19 pm

Reinaldo

Yes .. for some reason it does not work .. it may have something to do with the array .. I have to zero it out on init and for some reason I can not color rows nor exempt any rows

I sent Rao a private e-mail and he originally suggested your solution .. this code fails to exempt a specific row nor color the rows ..

Rick Lipkin

Code: Select all  Expand view  RUN

// project plan ---------------------------

              REDEFINE xBROWSE oLbx3  ;
              ARRAY aPlan             ;
              HEADERS "Budget"+CRLF+"Item",         ;
                      "Origional"+CRLF+"Budget",    ;
                      "Budget"+CRLF+"Revision",     ;
                      "Current"+CRLF+"Budget",      ;
                      "Origional"+CRLF+"Contract",  ;
                      "Contract"+CRLF+"Revisions",  ;
                      "Current"+CRLF+"Committed",   ;
                      "Pending"+CRLF+"Proposals",   ;
                      "Potential"+CRLF+"Exposures", ;
                      "Potential"+CRLF+"Costs",     ;
                      "Potential"+CRLF+"Project Costs" ;
              COLSIZES 185,73,73,73,73,73,73,73,73,73,73 ; // 11
              PICTURE "","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99" ;
              ID 174 of oCust     ;
              AUTOCOLS CELL LINES

              oLbx3:lHScroll := .t.  // turn on horiz scroll bar

              oLbx3:aCols[12]:Hide() // hide last column used for row color

              oCol:bSumCondition  := { |nValue, oCol| oCol:oLbx3:aRow[ 12 ] <> '2'  }

              oLbx3:nStretchCol  := 1
              oLbx3:lFooter  := .t.
              oCol           := oLbx3:aCols[ 1 ]
              oCol:bFooter   := { || Ltrim( Str( oLbx3:KeyNo() ) ) + " / " + LTrim( Str( oLbx3:KeyCount() ) ) }
              oLbx3:bChange  := { || oCol:RefreshFooter() }

              oLbx3:nFooterTypes    := AGGR_SUM
              oLbx3:MakeTotals()

              oLbx3:lRecordSelector := .f.

            *  msginfo( olbx3:aCols[12] )
              oLbx3:bClrStd := {|| { CLR_BLACK,;
              if( len(aPlan) = 0,CLR_WHITE,;
              if( oLbx3:aCols[12] = '1', RGB(179,203,204), CLR_WHITE )) } }

 
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Exempt certain xBrowse rows from MakeTotals()

Postby reinaldocrespo » Fri Aug 14, 2015 9:55 pm

Hey Rick!

Call me crazy, just a quick look at your code i think this won't work;

Code: Select all  Expand view  RUN
oCol:bSumCondition  := { |nValue, oCol| oCol:oLbx3:aRow[ 12 ] <> '2'  }


Instead it should be:
Code: Select all  Expand view  RUN
oCol:bSumCondition  := { |nValue, oCol| oCol:oBrw:Potential:Value() <> '2'  }


Or
Code: Select all  Expand view  RUN
oCol:bSumCondition  := { |nValue, oCol| oLbx3:aArrayData[ oLbx3:nArrayAt, 12 ] <> '2'  


no?
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Exempt certain xBrowse rows from MakeTotals()

Postby reinaldocrespo » Fri Aug 14, 2015 9:59 pm

Rick;

BTW- I forgot to mention your screenshots are just beautiful. Some people are just born artistic. So much data. So well organized. Nice job.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Exempt certain xBrowse rows from MakeTotals()

Postby Rick Lipkin » Sat Aug 15, 2015 4:31 pm

Reinaldo

Thank you for your kind complements .. I will have a chance to test your suggestions Monday morning.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Exempt certain xBrowse rows from MakeTotals()

Postby Rick Lipkin » Mon Aug 17, 2015 8:14 pm

To All

I have put together sample code with its self contained data. What I am trying to do :

1) exempt rows from MakeTotals() that have array [12] value of "2" or "4"
2) be able to color rows also based on the value of array[12]

Double click on the Owner, then double click on the project to see the cost disbursement.

You will see in my code where I am struggling with this.

Any Help would be appreciated!
Rick Lipkin

Filechk.Rc
Code: Select all  Expand view  RUN

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"

FILECHK DIALOG 26, 35, 277, 63
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
FONT 8, "Microsoft Sans Serif"
{
 CONTROL "", 120, "STATIC", SS_NOPREFIX | WS_GROUP, 21, 23, 224, 10
}
 


Projbrow.Rc
Code: Select all  Expand view  RUN

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"




//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
PROJBROW DIALOG 12, 11, 671, 347
STYLE DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
FONT 6, "MS Sans Serif"
{
    CONTROL         "Add", 129, "TBtnBmp", 0x50010020, 3, 167, 22, 21, 0x00000000
    CONTROL         "Edit", 130, "TBtnBmp", 0x50010020, 3, 192, 22, 21, 0x00000000
    CONTROL         "View", 131, "TBtnBmp", 0x50010020, 3, 218, 22, 21, 0x00000000
    CONTROL         "Del", 132, "TBtnBmp", 0x50010020, 3, 242, 22, 21, 0x00000000
    CONTROL         "Add", 124, "TBtnBmp", 0x50010020, 250, 15, 22, 21, 0x00000000
    CONTROL         "Edit", 125, "TBtnBmp", 0x50010020, 250, 40, 22, 21, 0x00000000
    CONTROL         "View", 126, "TBtnBmp", 0x50010020, 250, 66, 22, 21, 0x00000000
    CONTROL         "Del", 127, "TBtnBmp", 0x50010020, 250, 90, 22, 21, 0x00000000
    CONTROL         "Project Plan", 174, "TXBrowse", 0x50A10000, 30, 160, 640, 185, 0x00000000
    CONTROL         "Project Info", 173, "TXBrowse", 0x50A10000, 275, 15, 315, 140, 0x00000000
    CONTROL         "Close", 128, "TBtnBmp", 0x50010020, 606, 15, 57, 21, 0x00000000
    CONTROL         "Del", 123, "TBtnBmp", 0x50010020, 3, 91, 22, 21, 0x00000000
    CONTROL         "View", 122, "TBtnBmp", 0x50010020, 3, 66, 22, 21, 0x00000000
    CONTROL         "Edit", 121, "TBtnBmp", 0x50010020, 3, 41, 22, 21, 0x00000000
    CONTROL         "Add", 120, "TBtnBmp", 0x50010020, 3, 16, 22, 21, 0x00000000
    CONTROL         "Customer Info", 172, "TXBrowse", 0x50A10000, 30, 15, 205, 140, 0x00000000
    LTEXT           "Owner Name", 143, 36, 5, 45, 9, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
    LTEXT           "( double click the Owner to load detail )", 145, 90, 5, 140, 9, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
    LTEXT           "Project Info", 148, 280, 4, 75, 9, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
    LTEXT           "( double click the project line view detail )", 144, 367, 5, 180, 9, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
}
 


Code: Select all  Expand view  RUN

// ProjBrow.prg

#INCLUDE "FIVEWIN.CH"
#include "xbrowse.ch"

*STATIC oWndFind

//------------------------
Func _ProjBrow( cMode,oWndMain )

Local oDlg,lOk1,cSay,oSay,cDefa
Local nYear,cFile,nStart


SET DELETED on
SET CENTURY on
SET 3DLOOK on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

// where .exe started from is default directory //

cFILE  := GetModuleFileName( GetInstance() )
nSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,nSTART-1)


SET DEFA to ( cDEFA )

REQUEST DBFCDX
REQUEST DBFFPT
rddsetdefault( "
DBFCDX" )

If empty( cMode )
   cMode := "
V"
Endif

LightGreyGrad()

lOK1   := .F.

DEFINE DIALOG oDlg RESOURCE "
FILECHK"       ;
       TITLE "
Please be patient"

       cSAY :=  "
Opening Tables"
       REDEFINE SAY oSay var cSay ID 120 of oDLG UPDATE

       oDLG:bStart := { || lOK1 := _OpenUm0( oDLG,oSAY,@cSAY ) }

ACTIVATE DIALOG oDLG CENTERED

oSay := NIL
cSay := NIL

IF lOK1 = .F.
   Close Databases
   RETURN(NIL)
ENDIF
           // cMode
_ProjBrow1( "
A")

CLose Databases

Return(.t.)

//----------------
Static Func _OpenUm0( oDlg, oSay,cSay )

Local cSql,oErr,dbf_stru,cDefa

cDefa := set(7)

If .not. file( cDefa+"
\Owner.Dbf" )

   Dbf_Stru := {}
   Aadd( dbf_stru, { "
Owner_Num", "N", 5, 0 } )
   Aadd( dbf_stru, { "
Owner",     "C", 50,0 } )

   dbCreate( cDefa+"
\Owner.Dbf", dbf_Stru )

   Select 1
   Use ( cDefa+"
\Owner.dbf")  via "DBFCDX" EXCL
   Append Blank
   a->Owner_Num := 44
   a->Owner     := "
Bamberg School District 1"

   CLose Databases

ENdif

If .not. file( cDefa+"
\Project.Dbf" )

   Dbf_Stru := {}
   Aadd( dbf_stru, { "
Owner_Num", "N", 5, 0 } )
   Aadd( dbf_stru, { "
Project",   "C", 55,0 } )
   Aadd( dbf_stru, { "
ProjectNum","N", 5, 0 } )
   Aadd( dbf_stru, { "
ProjMgr",   "C", 20,0 } )
   Aadd( dbf_stru, { "
Status",    "C", 1,0  } )

   dbCreate( cDefa+"
\Project.Dbf", dbf_Stru )

   Select 1
   Use ( cDefa+"
\Project.dbf")  via "DBFCDX" EXCL
   Index on Owner_Num tag Owner_Num

   Append Blank
   a->Owner_Num  := 44
   a->Project    := "
Bamberg Middle and Bamberg High School Renovations"
   a->ProjectNum := 307
   a->ProjMgr    := "
Dale Collier"
   a->Status     := "
1"

   CLose Databases

ENdif

cSay := "
Opening Ownwer Table"
oSay:ReFresh()
SysReFresh()

Select 1
Use ( cDefa+"
\Owner.dbf")  via "DBFCDX" EXCL
Go Top

cSay := "
Opening Projects Table"
oSay:ReFresh()
SysReFresh()

Select 2
Use ( cDefa+"
\Project.dbf")  via "DBFCDX" EXCL
Set Order to Tag Owner_num

GoTo 0

oDlg:End()

Return(.t.)

//-------------------------------
FUNC _ProjBrow1( cMODE )

Local oCust,oLbx1,oLbx2,oLbx3

LOCAL SAYING,cDEFA,cSql,oErr,oRsSys
Local oFontB
LOCAL oIco,oCol,oCol1,cName,xTitle
LOCAL aPlan


Local lOk // valid close

Local oBUTT1                                // main buttons
Local oBUTT2,oBUTT3,oBUTT4,oBUTT5           // owner buttons
Local oButt6,oButt7,oButt8,oButt9           // project buttons
Local oButt10,oButt11,oButt12,oButt13       // plan butrtons

aPlan := {}

oFontB   := TFont():New("
Ms Sans Serif",,-6,.F.,.T. ,,,,.F. )
lOk      := .f.
aPlan    := {}
aColumns := {}


AAdd( aPlan, { space(12),;
               0.00,;
               0.00,;
               0.00,;
               0.00,;
               0.00,;
               0.00,;
               0.00,;
               0.00,;
               0.00,;
               0.00,;
                  0} )

LightGreyGrad()
xTITLE := "
Project Management Information"

DEFINE DIALOG oCust RESOURCE "
PROJBROW" ;
       Title xTitle

       REDEFINE SAY oSay1 ID 143 OF oCust UPDATE   // owner name
       oSay1:SetFont( oFontB )

       REDEFINE SAY oSay2 ID 145 OF oCust UPDATE   // double click owner
       oSay2:SetFont( oFontB )

       REDEFINE SAY oSay3 ID 148 OF oCust UPDATE   // project info
       oSay3:SetFont( oFontB )

       REDEFINE SAY oSay4 ID 144 OF oCust UPDATE   // double click
       oSay4:SetFont( oFontB )

       // Owner Browse -------------------------------------------

       REDEFINE xBROWSE oLBX1           ;
                ALIAS "
OWNER"           ;
                COLUMNS "
OWNER"         ;
                COLSIZES 284            ;
              HEADERS "
Owner or Client" ;
              ID 172 of oCust  ;
              AUTOCOLS LINES CELL

              oLbx1:lFooter   := .t.
              oCol            := oLbx1:aCols[ 1 ]
              oCol:bFooter    := { || Ltrim( Str( oLbx1:KeyNo() ) ) + "
/ " + LTrim( Str( oLbx1:KeyCount() ) ) }
              oLbx1:bChange   := { || oCol:RefreshFooter() }

              oLbx1:lRecordSelector := .f.
              _BrowColor( oLbx1 )


              oLbx1:bLDblClick := { |nRow,nCol | _ProjSlct( oButt2,oButt3,oButt4,;
                                                           oButt5,oLbx2,oLbx3,@aPlan)}



              // owner buttons -------------------------------------------------------------------------------------

              REDEFINE BTNBMP oButt2 ID 120 of oCust       ;    // add
              PROMPT "
Add" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt3 ID 121 of oCust       ;    // edit
              PROMPT "
Edit" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt4 ID 122 of oCust       ;    // view
              PROMPT "
View" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt5 ID 123 of oCust       ;    // del
              PROMPT "
Del"  CENTER 2007;
              ACTION ( NIL )


              // projects ---------------------------------------------------------------------

              REDEFINE xBROWSE oLBX2       ;
                 ALIAS "
PROJECT"           ;
                 COLUMNS "
PROJECT",        ;
                         "
PROJMGR",        ;
                         "
STATUS"          ;
              COLSIZES 260,75,74           ;
              HEADERS "
Project",           ;
                      "
Project Mgr",       ;
                      "
Status"             ;
              ID 173 of oCust  ;
              AUTOCOLS LINES CELL

              oLbx2:lFooter  := .t.
              oCol           := oLbx2:aCols[ 1 ]
              oCol:bFooter   := { || Ltrim( Str( oLbx2:KeyNo() ) ) + "
/ " + LTrim( Str( oLbx2:KeyCount() ) ) }
              oLbx2:bChange  := { || oCol:RefreshFooter() }

              oLbx2:lRecordSelector := .f.
              _BrowColor( oLbx2 )

              oLbx2:bLDblClick := { |nRow,nCol | _BuildPlan( oLbx3, @aPlan ),oLbx3:MakeTotals(),oLbx3:ReFresh(),oLbx3:SetFocus() }


              // project buttons -------------------------------------------------------------------------------------

              REDEFINE BTNBMP oButt6 ID 124 of oCust       ;    // add
              PROMPT "
Add" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt7 ID 125 of oCust       ;    // edit
              PROMPT "
Edit" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt8 ID 126 of oCust       ;    // view
              PROMPT "
View" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt9 ID 127 of oCust       ;    // del
              PROMPT "
Del"  CENTER 2007;
              ACTION ( NIL )


              // project plan ---------------------------

              REDEFINE xBROWSE oLbx3  ;
              ARRAY aPlan             ;
              HEADERS "
Budget"+CRLF+"Item",         ;
                      "
Origional"+CRLF+"Budget",    ;
                      "
Budget"+CRLF+"Revision",     ;
                      "
Current"+CRLF+"Budget",      ;
                      "
Origional"+CRLF+"Contract",  ;
                      "
Contract"+CRLF+"Revisions",  ;
                      "
Current"+CRLF+"Committed",   ;
                      "
Pending"+CRLF+"Proposals",   ;
                      "
Potential"+CRLF+"Exposures", ;
                      "
Potential"+CRLF+"Costs",     ;
                      "
Potential"+CRLF+"Project Costs" ;
              COLSIZES 185,73,73,73,73,73,73,73,73,73,73 ; // 11
              PICTURE "
","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99" ;
              ID 174 of oCust     ;
              AUTOCOLS CELL LINES

              oLbx3:lHScroll := .t.  // turn on horiz scroll bar

              oLbx3:aCols[12]:Hide() // hide last column used for row color

            *  oCol:bSumCondition  := { |nValue, oCol| oCol:oLbx3:aRow[ 12 ] <> '2'  }
            *  oCol:bSumCondition  := { |nValue, oCol| oLbx3:aArrayData[ oLbx3:nArrayAt, 12 ] <> '2' }
              oCol:bSumCondition  := { |nValue, oCol| oCol:oLbx3:Potential:Value() <> '2'  }

              oLbx3:nStretchCol  := 1
              oLbx3:lFooter  := .t.
              oCol           := oLbx3:aCols[ 1 ]
              oCol:bFooter   := { || Ltrim( Str( oLbx3:KeyNo() ) ) + "
/ " + LTrim( Str( oLbx3:KeyCount() ) ) }
              oLbx3:bChange  := { || oCol:RefreshFooter() }

              oLbx3:nFooterTypes    := AGGR_SUM
              oLbx3:MakeTotals()

              oLbx3:lRecordSelector := .f.

            *  msginfo( olbx3:aCols[12] )
            *  oLbx3:bClrStd := {|| { CLR_BLACK,;
            *  if( len(aPlan) = 0,CLR_WHITE,;
            *  if( oLbx3:aCols[12] = '1', RGB(179,203,204), CLR_WHITE )) } }


            *  msginfo( olbx3:aCols[12] )
            *  oLbx3:bClrStd := {|| { CLR_BLACK,;
            *  if( Len(aPlan) = 0,CLR_WHITE,;
            *  if( oLbx3:aCols[12] = '2', RGB(179,203,204), CLR_WHITE )) } }


            *  For i = 1 to LEN( oLbx3:aCols )
            *      oCol := oLbx3:aCols[ i ]
            *      oLbx3:aCols[ i ]:bClrStd := ChangeColor( oLbx3, i, oCol )
            *  Next



           *   _BrowColor( oLbx3 )

               // plan buttons -------------------------------------------------------------------------------------

              REDEFINE BTNBMP oButt10 ID 129 of oCust       ;    // add
              PROMPT "
Add" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt11 ID 130 of oCust       ;    // edit
              PROMPT "
Edit" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt12 ID 131 of oCust       ;    // view
              PROMPT "
View" CENTER 2007;
              ACTION ( NIL )

              REDEFINE BTNBMP oButt13 ID 132 of oCust       ;    // del
              PROMPT "
Del"  CENTER 2007;
              ACTION ( NIL )



              // main buttons -------------------------------------------------------------------------------------

              REDEFINE BTNBMP oButt1 ID 128 of oCust       ;    // Close and Save
              RESOURCE "
CANCEL", "DCANCEL", "DCANCEL" ;
              PROMPT "
Close" LEFT 2007;
              ACTION (  oCust:END(), dbCloseAll() )



ACTIVATE DIALOG oCust ;
         ON INIT ( oCust:Move(0,0),Asize( aPlan,0 ),oLbx3:ReFresh() ) ;
         VALID(!GETKEYSTATE( 27 ))


RETURN( NIL )

//--------------------------
Static Func _ReSizeUm( oCust,oWndChild,oLbx1 )

oCust:SetSize( oWndChild:nWidth, oWndChild:nHeight, .t. ) // frame and dialog link

// dialog controls
oCust:bResized = { | nSizeType, nWidth, nHeight | ResizeControls( nSizeType, nWidth, nHeight, oCust )  }

Return(nil)

//-------------------------
Static Func ResizeControls( nSizeType, nWidth, nHeight, oCust )


*xbrowse(oCust:aControls)
                                                            // 185
if nSizeType = 0 //SIZE_MAXIMIZED         //125              //60
   oCust:aControls[ 15  ]:SetSize( nWidth - 60, nHeight - 300 ) //txbrowse
endif

Return(nil)

//---------------------------
Static Func ChangeColor( oLbx3,i,oCol ) //

Local nColumn,nRow,cText

msginfo( i )
cText := oLbx3:aCols[ i ]:Value
msginfo( cText )

If i = 12
   msginfo(oLbx3:aCols[ i ]:Value )
Else
  Return {||  { CLR_BLACK, CLR_WHITE } }
ENdif


*Return {|| { ColorCell( oLbxA:aCols[ i ]:Value ), ColorCell( oLbxA:aCols[ i ]:Value ) } }
Return {||  { CLR_BLACK, ColorCell( oLbx3:aCols[ i ]:Value, oCol ) } }

//-------------------
Static Func ColorCell( cText,oCol )

LOCAL cColor,nLen,nColor
Local oBrw

msginfo( cText )
nColor := RGB(255, 255, 128)

Return(nCOlor)

oBrw := oCol:oBrw

If empty(cText) .or. cText = "
 "
   nColor := GetSysColor( 5 )
   Return(nColor)
Endif

cText := alltrim( cText )

// get the last byte
// cColor can only be 1-9

nLen   := len( cText )
cColor := substr(cText,nLen,1)

DO CASE
CASE cColor = "
1"  // yellow
     nColor := RGB(255, 255, 128)
CASE cColor = "
7"  // light Blue
     nColor := RGB(172,206,215)
CASE cColor = "
9"  // sand
     nColor := RGB(221,218,185)

*Msginfo( oBrw:nArrayAt )
*msginfo( oCol:nArrayCol )

*FillRect( hDC, { 100, 0, 150, 641 }, oBrCyan:hBrush )
*SysWait(2)

CASE cColor = "
8" // maroon
     nColor := RGB(171,129,151)
CASE cColor = "
5" // Red
     nColor := RGB(240, 0, 0)
CASE cColor = "
6" // light green
     nColor := RGB(210,235,216)
CASE cColor = "
3" // blue
     nColor := RGB(0,100,200)
CASE cColor = "
4" // orange
     nColor := RGB(255,172,89)
CASE cColor = "
2" // Red
     nColor := RGB(240, 0, 0)
OTHERWISE
     nColor := GetSysColor( 5 )
ENDCASE

RETURN( nColor )




//----------------------------
Static Func _BuildPlan( oLbx3, aPlan )

Local oDlg,cSay,oSay,lOk1,i,oCol

DEFINE DIALOG oDlg                                            ;
       FROM 5, 8 to 10, 75                                    ;
       TITLE "
Building Plan Information ...... Please be patient"  ;
       STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME )

       cSAY :=  "
Building Plan "

       @ 1,13 SAY oSAY VAR cSAY of oDLG //COLOR "
N/W"

       oDLG:bStart := { || _BuildUM( oDLG, @oSAY, @cSAY,@aPlan,oLbx3 )}

ACTIVATE DIALOG oDLG CENTERED

*For i = 1 to LEN( oLbx3:aCols )
*    oCol := oLbx3:aCols[ i ]
*    oLbx3:aCols[ i ]:bClrStd := ChangeColor( oLbx3, i, oCol )
*Next

*oLbx3:ReFresh()


oLbx3:MakeTotals()
oLbx3:ReFresh()
oLbx3:SetFocus()

Return(nil)

//---------------------------
Static Func _BuildUm(oDlg,oSay,cSay,aPlan,oLbx3 )

Local oRsBitem,oRsBrev,cSql,oErr,nProj,nTCurBud,cBRNumber,nTAmtOC,nAmtR,nCurrent
Local cBINumber
Local oRsCitem,nAmtC
Local aBitem,cBCat,cCostCat,cCat,i,cBudItem

Local oCol,cProj
Local oRsCopr, cCINumber,nAmtCr


nProj    := b->ProjectNum

nTCurBud := 0.00      // total current budget counter
nTAmtOC  := 0.00      // total origional contract counter
nAmtR    := 0.00      // budget revision item
nCurrent := 0.00      // current budget item
nAmtC    := 0.00      // origional contract item
nAmtCr   := 0.00      // contract rev


aBitem   := {}

// resize the array
Asize( aPlan,0 )



// create the Bitem list and sort accordingly

AAdd( aBitem, { "
Asbestos Abatment                  ", "307.21", "1", 0.00 } )
AAdd( aBitem, { "
B-E High School HVAC Controls      ", "307.20", "1", 0.00 } )
AAdd( aBitem, { "
B-E High School School Renovations ", "307.19", "1", 7000000.00 } )
AAdd( aBitem, { "
B-E Middle School Renovations      ", "307.10", "1", 3000000.00 } )
AAdd( aBitem, { "
Campus Communications              ", "306.6",  "1", 0.00 } )
AAdd( aBitem, { "
DHEC Required BEMS Asbestos Cleanup", "307.22", "1", 0.00 } )
AAdd( aBitem, { "
End of Line                        ", "307.17", "1", 0.00 } )
AAdd( aBitem, { "
Impact Fees                        ", "307.13", "1", 0.00 } )
AAdd( aBitem, { "
Infrastructure                     ", "307.16", "1", 0.00 } )
AAdd( aBitem, { "
Moving Costs                       ", "307.14", "1", 0.00 } )
AAdd( aBitem, { "
Owner Controlled C-Funds           ", "307.12", "1", 75000.00 } )
AAdd( aBitem, { "
Security Survellance               ", "307.18", "1", 0.00 } )
AAdd( aBitem, { "
Advertising                        ", "307.1",  "3", 50000.00 } )
AAdd( aBitem, { "
Architect Fee                      ", "307.2",  "3", 775000.00 } )
AAdd( aBitem, { "
CM Fee                             ", "307.3",  "3", 211434.00 } )
AAdd( aBitem, { "
FF and E                           ", "307.15", "3", 250000.00 } )
AAdd( aBitem, { "
Geotechnical Testing               ", "307.5",  "3", 0.00 } )
AAdd( aBitem, { "
IBC Chapter 1 and 17 Inspections   ", "307.4",  "3", 0.00 } )
AAdd( aBitem, { "
Legal Counsulting                  ", "307.7",  "3", 0.00 } )
AAdd( aBitem, { "
Printing                           ", "307.8",  "3", 0.00 } )
AAdd( aBitem, { "
Survey                             ", "307.9",  "3", 0.00 } )
AAdd( aBitem, { "
Contingency                        ", "307.11", "7", 425016.00 } )


cProj := ltrim(str(nProj))

// add direct and indirect blank records
AAdd( aBitem, { "
Direct Cost SubTotal",   cProj+".998", "2", 0.10 } )
AAdd( aBitem, { "
Indirect Cost Subtotal", cProj+".999", "4", 0.00 } )

nTCurBud := 0.00
nTAmtRev := 0.00

aSort( aBitem,,, {|x,y| (x[3] + x[1]) < (y[3] + y[1]) } )

*xbrowse(aBitem )


*xbrowse( aBitem )

For i = 1 to len(aBitem)

    cBudItem  := upper(aBitem[i][1])       // budget item
    cCat      := aBitem[i][3]              // catagory
    cBINumber := aBitem [i][2]             // valtype C
    If empty(cBINumber)
       cBINumber := "
999999999999999"
    Endif

    nAmtr := 0.00
    nAmtc := 0.00
    nCurrent := 0.00

    AAdd( aPlan, { aBitem[i][1], ;    // budget item description
                   aBitem[i][4] ,;    // Origional Budget
                    nAmtR,;           // Budget Revision
                    nCurrent,;        // current budget
                    nAmtC,;           // origional contract
                    0.00,;            // contract revisions
                    0.00,;            // current committed
                    0.00,;            // pending proposals
                    0.00,;            // potential exposures
                    0.00,;            // potential costs
                    0.00,;            // potential proj costs
                    aBitem[i][3] })   // 1 = direct cost,     // used to color row
                                      // 2 = indirect cost,
                                      // 3 = unk
                                      // 4 = cont

Next


oDlg:ENd()

*For i = 1 to LEN( oLbx3:aCols )
*    oCol := oLbx3:aCols[ i ]
*    oLbx3:aCols[ i ]:bClrStd := ChangeColor( oLbx3, i, oCol )
*Next

*oLbx3:ReFresh()

Return(.t.)

//------------------------------
Static Func _ProjSlct( oButt2,oButt3,oButt4,;
                       oButt5,oLbx2,oLbx3,aPlan)

Local nOwner_Number,Saying,cOwner


Select 1
If Eof()
   Saying := "
Sorry .. you can not view a Project unless you have an Owner First"
   MsgInfo( Saying )
   Return(.f.)
Endif


// resize the array
Asize( aPlan,0 )
oLbx3:ReFresh()
oLbx3:MakeTotals()



cOwner := a->Owner
If empty(cOwner)
   cOwner := "
Unknown"
Endif

cOwner := alltrim( cOwner )
select 1
nOwner_Number := a->Owner_Num

If empty(nOwner_number)
   nOwner_Number := 0

   Saying := "
Sorry .. no Projects Exist for Owner           "+chr(10)
   Saying += "
"+chr(10)
   Saying += cOwner

   Msginfo( Saying )

   Select 2
   GoTo 0

   oLbx2:ReFresh()
   Return(.f.)

ENdif

Select 2
Set Order to Tag Owner_num
Seek nOwner_Number

If .not. Found()
   Select 2
   GoTo 0
ENdif

oLbx2:ReFresh()

Return(.t.)

//------------------
Static Func LightGreyGrad()

SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )

Return(nil)


//----------------------
Static Func _BrowColor( oLbx )
                               // foreground      // background
local aGradBarSelFocus := {{1, RGB(0,128,255) , RGB(0,128,255) }}   // in focus
local aGradBarSel      := {{1, RGB(255,255,255), RGB(192,192,192)  }}   // not in focus   192

WITH OBJECT oLbx
      :bClrSel       := {|| { CLR_BLACK, aGradBarSel } }  // not in focus
      :bClrSelFocus  := {|| { CLR_WHITE, aGradBarSelFocus } }     // in focus
END

Return(nil)

// end ProjBrow
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Exempt certain xBrowse rows from MakeTotals()

Postby reinaldocrespo » Mon Aug 17, 2015 9:46 pm

In case this helps others this is the code that fixes the problem. Basically the problem here was that the 12th column is a char and Rick was comparing against a number therefore the returning value after evaluating bSumCond was always .t.. Here's the complete code for olbx3 xbrowse. Notice I added a header name for the 12th column and simply did a VAL() on that column to determine if it is considered on the column total or not:

Code: Select all  Expand view  RUN
             REDEFINE xBROWSE oLbx3  ;
              ARRAY aPlan             ;
              HEADERS "Budget"+CRLF+"Item",         ;
                      "Origional"+CRLF+"Budget",    ;
                      "Budget"+CRLF+"Revision",     ;
                      "Current"+CRLF+"Budget",      ;
                      "Origional"+CRLF+"Contract",  ;
                      "Contract"+CRLF+"Revisions",  ;
                      "Current"+CRLF+"Committed",   ;
                      "Pending"+CRLF+"Proposals",   ;
                      "Potential"+CRLF+"Exposures", ;
                      "Potential"+CRLF+"Costs",     ;
                      "Potential"+CRLF+"Project Costs", "hidden" ;
              COLSIZES 185,73,73,73,73,73,73,73,73,73,73 ; // 11
              PICTURE "","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99" ;
              ID 174 of oCust     ;
              AUTOCOLS CELL LINES FOOTERS

              oLbx3:lHScroll := .t.  // turn on horiz scroll bar
              oLbx3:hidden:Hide() // hide last column used for row color

              oLbx3:nStretchCol  := 1
              oCol           := oLbx3:aCols[ 1 ]
              oCol:bFooter   := { || Ltrim( Str( oLbx3:KeyNo() ) ) + " / " + LTrim( Str( oLbx3:KeyCount() ) ) }

              oLbx3:nFooterTypes    := AGGR_SUM
              oLbx3:aCols[ 2 ]:bSumCondition := { |n,o| VAL( IfNil( oLbx3:Hidden:Value(), "") ) > 4 }


              oLbx3:lRecordSelector := .f.
 


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Exempt certain xBrowse rows from MakeTotals()

Postby Rick Lipkin » Wed Aug 19, 2015 6:34 pm

To All

Inspired by Reinaldo's suggestions .. here is the final snipit of code that works for both the exemption from MakeTotals() and to color each Row .. notice, the key to the row color was to color each cell rather than by row .. as Reinaldo pointed out, if you Hide() a column, the row color will not work.

Rick Lipkin
Code: Select all  Expand view  RUN

// project plan ---------------------------

              REDEFINE xBROWSE oLbx3  ;
              ARRAY aPlan             ;
              HEADERS "Budget"+CRLF+"Item",         ;
                      "Origional"+CRLF+"Budget",    ;
                      "Budget"+CRLF+"Revision",     ;
                      "Current"+CRLF+"Budget",      ;
                      "Origional"+CRLF+"Contract",  ;
                      "Contract"+CRLF+"Revisions",  ;
                      "Current"+CRLF+"Committed",   ;
                      "Pending"+CRLF+"Proposals",   ;
                      "Potential"+CRLF+"Exposures", ;
                      "Potential"+CRLF+"Costs",     ;
                      "Potential"+CRLF+"Project Costs", "hidden" ;
              COLSIZES 185,73,73,73,73,73,73,73,73,73,73 ; // 11
              PICTURE "","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99" ;
              ID 174 of oCust     ;
              AUTOCOLS CELL LINES FOOTERS

              oLbx3:lHScroll := .t.  // turn on horiz scroll bar
              oLbx3:hidden:Hide()    // hide last column used for row color

              oLbx3:nStretchCol  := 1
              oCol           := oLbx3:aCols[ 1 ]
              oCol:bFooter   := { || Ltrim( Str( oLbx3:KeyNo() ) ) + " / " + LTrim( Str( oLbx3:KeyCount() ) ) }

              // maketotals

              oLbx3:nFooterTypes    := AGGR_SUM
              For i = 1 to LEN( oLbx3:aCols )
                  oLbx3:aCols[ i ]:bSumCondition := { || !( IfNil( oLbx3:Hidden:Value(), "" ) $ [24] ) }  // exemption
              Next

              // color columns not lines

              For i = 1 to LEN( oLbx3:aCols )
                 DO Case
                 Case i = 1
                      oLbx3:aCols[ 1 ]:bClrStd := { || iif( olbx3:Hidden:Value() $ [24], { CLR_BLACK, Rgb(217,254,131) }, { CLR_HBLUE, Rgb(238,238,238) }) }
                 Case i = 8 .or. i = 9 .or. i = 10 .or. i = 11
                      oLbx3:aCols[ i ]:bClrStd := { || iif( olbx3:Hidden:Value() $ [24], { CLR_BLACK, Rgb(217,254,131) }, { CLR_BLACK, Rgb(238,238,238) }) }
                 OtherWise
                      oLbx3:aCols[ i ]:bClrStd := { || iif( olbx3:Hidden:Value() $ [24], { CLR_BLACK, Rgb(217,254,131) }, { CLR_BLACK, CLR_WHITE }) }
                 ENdCase
              Next

              oLbx3:lRecordSelector := .f.
 

Image
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

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