edit browse

edit browse

Postby hag » Sat Jul 19, 2008 11:37 pm

I have a browse that i want to edit numbers in a column. I would like to start the edit process by using any number key or the enter key then have the the edit move down to the next line item.

I tried the number key as follows:

oBrw:bKeyChar := {| nKey, nRow,nCol | if(nKey= 55, editCell(oBrw,nRow,nCol),"") }

Then I get an error message:

Path and name: F:\FWH\cashflow\gl2.exe (32 bits)
Size: 1,361,408 bytes
Time from start: 0 hours 0 mins 7 secs
Error occurred at: 07/19/08, 16:30:22
Error description: Error BASE/1004 Message not found: TXBROWSE:NATCOL
Args:
[ 1] = O Object

Stack Calls
===========
Called from: => __ERRRT_SBASE(0)
Called from: => TXBROWSE:ERROR(170)
Called from: source\rtl\tobject.prg => (b)HBOBJECT(105)
Called from: => TXBROWSE:MSGNOTFOUND(0)
Called from: => TXBROWSE:NATCOL(164)
Called from: .\source\function\EDITCELL.PRG => EDITCELL(0)
Called from: gl2.prg => (b)COMPAREPL(647)
Called from: => TXBROWSE:KEYCHAR(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: => TXBROWSE:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(0)
Called from: => DIALOGBOX(0)
Called from: => TDIALOG:ACTIVATE(0)
Called from: gl2.prg => COMPAREPL(745)
Called from: gl2.prg => CALLIT(89)

The enter key works fine however it doesn't move to the next line.

Can someone tell me how to do this.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby nageswaragunupudi » Sun Jul 20, 2008 5:21 am

You are using TXBrowse. You are using oBrw:nAtCol in your function EditCell, but there is no data / method with the name nAtCol in TXBrowse. You need to correct your function editCell
Regards

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

Postby hag » Sun Jul 20, 2008 5:46 am

thanks you for the response.

You wrote:

You are using TXBrowse. You are using oBrw:nAtCol in your function EditCell, but there is no data / method with the name nAtCol in TXBrowse. You need to correct your function editCell

Editcell is not my function it comes from:
Called from: .\source\function\EDITCELL.PRG => EDITCELL(0)

Correct the function to what?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby nageswaragunupudi » Sun Jul 20, 2008 5:48 am

Editcell function is not for xbrowse.

Actually if you are using xbrowse, you do not have to write any code for editing. Its very simple. Please compile and try the following code. This example browses and edits the TOTAL column of SALES.DBF in the fwh samples folder. Just as you wanted, if the user is on TOTAL column, any key will invoke edit and after the edit the cursor goes down the next row,
Code: Select all  Expand view  RUN
#include 'fivewin.ch'
#include 'xbrowse.ch'


function Main()

   local oDlg, oBrw, oCol, b

   USE \FWH\SAMPLES\SALES NEW SHARED

   DEFINE DIALOG oDlg SIZE 540,440 PIXEL

   @ 10,10 XBROWSE oBrw ;
      SIZE 250,200 PIXEL ;
      OF oDlg ;
      ALIAS 'SALES' ;
      AUTOCOLS ;
      FASTEDIT ;
      LINES CELL

   WITH OBJECT oBrw:oCol( 'Total' )

      b              := :bOnPostEdit
      :nEditType     := EDIT_GET
      :bOnPostEdit   := { |o,x,n| Eval( b,o,x,n ), o:oBrw:GoDown() }

   END

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil


After you compile and run the above code independantly, you can adopt the same method in your code.
Regards

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

Postby hag » Sun Jul 20, 2008 7:10 am

The fastedit works great.
I added the following code to my browse. (i'm using a resource for the browse):

after redefining the xbrowse

Code:

WITH OBJECT oBrw:oCol( 'act1' )

b := :bOnPostEdit
:nEditType := EDIT_GET
:bOnPostEdit := { |o,x,n| Eval( b,o,x,n ), o:oBrw:GoDown() }

END


I get the following error message "No exported method: BONPOSTEDIT"
Almost there. Any suggestions will be great.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby nageswaragunupudi » Sun Jul 20, 2008 7:17 am

Please post the command you are using to create xbrowse, i.e., REDEFINE XBROWSE command fully.
Regards

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

Postby hag » Sun Jul 20, 2008 7:26 am

Here it is

REDEFINE xBROWSE oBrw ID 101 OF oDlg1 cell lines fastedit autocols //COLOR CLR_RED,CLR_HGRAY

WITH OBJECT oBrw:oCol( gl->act1 )

b := :bOnPostEdit
:nEditType := EDIT_GET

:OnPostEdit := { |o,x,n| Eval( o,x,n ), o:oBrw:GoDown() }

END
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby nageswaragunupudi » Sun Jul 20, 2008 7:29 am

Please change

WITH OBJECT oBrw:oCol( gl->act1 )

as

WITH OBJECT oBrw:oCol( "act1" )

Syntax:
oBrw:oCol( <cHeader> ) --> Column object having the header <cheader> ( case insensitive ).

Also

REDEFINE xBROWSE oBrw ID 101 OF oDlg1 cell lines fastedit autocols ;
ALIAS "<youraliasname>"

ALIAS clause is a must.
Regards

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

Postby hag » Sun Jul 20, 2008 7:39 am

Changed as follows:
WITH OBJECT oBrw:oCol("Actual")

the error still occurs not when I'm editing but when I go into the browse. The browse never appears.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby nageswaragunupudi » Sun Jul 20, 2008 7:41 am

Can you please post your code ? Entire function till activating the dialog
Regards

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

Postby hag » Sun Jul 20, 2008 7:55 am

I sent the entire prg: A lot of code. Been working well in 16 bit but need to move it for a more up to date appearance.

Take a look at the program at www.cashplan.com. Download a copy and give it a ride.

there are 2 editable fields in the browse..."Title" and "Actual"

Thanks so much for all of your efforts.

Its very late here in Los Angeles and I need to get some sleep. Post any help you can provide and I'll check it out in the AM.

Thanks again.

[code]

// GL2.PRG COMPARATIVE PROFIT AND LOSS
// 950718

#include "fivewin.ch"
#include "xbrowse.ch"
#include "report.ch"

#DEFINE LOGPIXELX 88

/* virtual memory
changed GrabSales()
*/

memvar nfp
memvar ecflag,ecnum,ecalpha
memvar oWnd1
memvar invreturn
memvar myear,mcompname
memvar goforward
memvar ofont7

field account,title,ty13

static cMovit
static oBrw, month[12]

static n2040 := 0
static n2500 := 0
static n3353 := 0

static lNeedreset := .t.
static lamount := .F.


// use by percent columns

static nsPlanMonth
static nsActMonth
static nsPlanYTD
static nsActYTD

static bAct,fbact,act1
static bTy,fbty,cty,cact

static cMonth, nMonth
static nFilterType := 0
static bDiff,fbdiff
static mbs := 0

static lVar := .f.
static cAlias

memvar gld, gln

function callit()

/*
commented out invreturn
index files carry,carry1
expcf
*/



public nfp := .f.
public gld := "gl.d47"
public gln := "gl.n47"
public oWnd1
public hWnd

DEFINE WINDOW OWND1 FROM 1, 5 TO 20, 80

set resources to "global.dll"


use (gld) alias gl new
index on account to (gln)
index on cr8Spec() to jake //decendng pl

* index on cr8Specialntx() to carry //alpha
* index on cr8Spec2() to carry1 //decending cf

set index to (gln),jake //,carry,carry1
gl->(dbsetorder(1))


use cfglob.d47 alias cfglob new

comparepl()

return nil


function comparepl()
local bSeek := {|| gl->(dbseek('1000')) }
local nOldArea := select()
local oBrow1, b, oCol
local oCombined := {}
local oDbf
local bWhile
local lNocost := .F.
local getlist := {}
local oDlg, oGet, oDlg1
local mhelp := 1 // := 205
local aRect[4]
local oBtn1
local oBtn2
local oBtn3,oBtn4
local oSay1
local oSay2,oSay3
local xMonth
local small_font //:= 0
local hDc
local aMonth := {}
local oCbx
local setOrder := gl->(dbsetorder())
local oldFilter := gl->(dbsetfilter())
local nIndex := 0
local oBmp1
local nValid := 1



cMovit := SPACE(4)

small_font := getdevicecaps(getdc(hDc),88) //== 96
releasedc(hDc)

select gl

// FIX SALES IF TRANSFERRED NEGATIVE

gl->(dbseek("1000"))
if gl->act1 < 0
gl->act1 := gl->act1*-1
endif
if gl->act2 < 0
gl->act2 := gl->act2*-1
endif
if gl->act3 < 0
gl->act3 := gl->act3*-1
endif
if gl->act4 < 0
gl->act4 := gl->act4*-1
endif
if gl->act5 < 0
gl->act5 := gl->act5*-1
endif
if gl->act6 < 0
gl->act6 := gl->act6*-1
endif
if gl->act7 < 0
gl->act7 := gl->act7*-1
endif
if gl->act8 < 0
gl->act8 := gl->act8*-1
endif
if gl->act9 < 0
gl->act9 := gl->act9*-1
endif
if gl->act10 < 0
gl->act10 := gl->act10*-1
endif
if gl->act11 < 0
gl->act11 := gl->act11*-1
endif
if gl->act12 < 0
gl->act12 := gl->act12*-1
endif


//stopkeybs()

mbs := 0

goforward := .t.

gl->(dbseek("2019"))
mbs := ty13 +mbs
gl->(dbseek("2021"))
mbs := ty13 +mbs
gl->(dbseek("2030"))
mbs := ty13 +mbs

gl->(dbgotop())

if goforward == .f.
gl->(dbsetorder(1))
gl->(dbgotop())
return nil
endif

nMonth := 1
cMonth := 0

month[1] := cfglob->mo1
month[2] := cfglob->mo2
month[3] := cfglob->mo3
month[4] := cfglob->mo4
month[5] := cfglob->mo5
month[6] := cfglob->mo6
month[7] := cfglob->mo7
month[8] := cfglob->mo8
month[9] := cfglob->mo9
month[10] := cfglob->mo10
month[11] := cfglob->mo11
month[12] := cfglob->mo12


select gl
set filter to
go top


set order to 1

//GiveUserDefined(1)
elimimlines(1)

// 32 bit

* if invreturn == .T.
* msgStop("Your inventory turnover rate is not correct therefore reports will not be available. Please return to cost of goods sold and correct this condition! ")
* return nil
* endif

gl->(dbseek("1000"))
if gl->dif12 == 2

MsgStop("Your beginning balances are not in balance. Therefore reports are not available until the beginning balances have been balanced.";
, "Beginning Balance Sheet Out Of Balance " )
return nil
endif

gl->(dbseek("1000"))
if gl->ty13=0

msgStop("There are no sales indicated therefore reports are not available.")
return nil
endif

gl->(dbseek("9001"))
mYear := gl->a13

aMonth := amonth(.t.)

DEFINE FONT oFont7 NAME "Ms Sans Serif" SIZE 0,-12
DEFINE DIALOG oDlg RESOURCE "cmpmonth" OF oWnd1 helpid mhelp font ofont7

//REDEFINE GET oGet VAR nMonth ID 104 of oDlg PICTURE "99" update valid range()

REDEFINE COMBOBOX oCBX VAR xMonth ITEMS aMonth ;
ID 104 OF oDlg on change(nMonth := ascan(aMonth,xMonth))

REDEFINE BUTTON ID 4001 of oDlg ACTION odlg:End()

ACTIVATE DIALOG oDlg centered

cursorwait()

cMonth := month[nMonth]

nFilterType := SalesTreat()

if nFilterType <= 5

gl->(dbseek("2001"))
gl->ty13 := .0001

* gl->(dbseek("2040"))
* gl->ty13 := .0001
*
* gl->(dbseek("2041"))
* gl->ty13 := .0001

gl->(dbseek("2050"))
gl->ty13 := .0001

endif

gl->(dbseek("2004"))
do while .NOT. EOF()
if gl->act1 +;
gl->act2 +;
gl->act3 +;
gl->act4 +;
gl->act5 +;
gl->act6 +;
gl->act7 +;
gl->act8 +;
gl->act9 +;
gl->act10 +;
gl->act11 +;
gl->act12 <> 0 .and. gl->ty13 <= 0 // 1/16/01 add Less than <
// to accept negative numbers

gl->ty13 := .001
endif
skip
enddo


gl->(dbseek("3800"))
gl->ty1 := 0
gl->ty2 := 0
gl->ty3 := 0
gl->ty4 := 0
gl->ty5 := 0
gl->ty6 := 0
gl->ty7 := 0
gl->ty8 := 0
gl->ty9 := 0
gl->ty10 := 0
gl->ty11 := 0
gl->ty12 := 0
gl->ty13 := 0

gl->act1 := 0
gl->act2 := 0
gl->act3 := 0
gl->act4 := 0
gl->act5 := 0
gl->act6 := 0
gl->act7 := 0
gl->act8 := 0
gl->act9 := 0
gl->act10 := 0
gl->act11 := 0
gl->act12 := 0

gl->(dbgotop())


select gl


do case
case nFilterType == 1 // ONE LINE COST OF GOODS SOLD

gl->(dbseek("2040"))
gl->title := "Cost of sales"

if nfp == .T.
gl->title := "Total program costs"
endif

gl->(dbseek("1000"))
if gl->title == "Collections "
gl->title := "Sales"
endif

if nfp == .T.
gl->title := "Revenue"
endif

set filter to .Not. Ty13 = 0 .And.;
gl->account # '0900' .and. ;
gl->account # '0125' .and. ;
gl->account # '0150' .and. ;
gl->account # '0175' .and. ;
gl->account # '2039' .and. ;
gl->account # '2044' .and. ;
gl->account # '3601' .and. ;
gl->account # '5610' .and. ;
gl->account # '2053' .and. ;
gl->account # '2054' .and. ;
gl->account # '2514' .and. ;
gl->account # '2515' .and. ;
gl->account # '2632' .and. ;
gl->account # '2634' .and. ;
gl->account # '2733' .and. ;
gl->account # '2734' .and. ;
gl->account # '2833' .and. ;
gl->account # '2834' .and. ;
gl->account # '2933' .and. ;
gl->account # '2934' .and. ;
gl->account # '2998' .and. ;
gl->account # '2999' .and. ;
gl->account # '3355' .and. ;
gl->account # '3356' .and. ;
gl->account # '3485' .and. ;
gl->account # '3487' .and. ;
! (gl->account >= '2004' .and. gl->account <= '2008') .and. ;
! (gl->account >= '2010' .and. gl->account <= '2038') .and. ;
! (gl->account >= '6000')

case nFilterType == 2 // MATERIAL, LABOR, OVERHEAD & FIXED COSTS


gl->(dbseek("2040"))
gl->title := "Cost of sales"

if nfp == .T.
gl->title := "Total program costs"
endif

gl->(dbseek("1000"))
if gl->title == "Collections "
gl->title := "Sales"
endif

if nfp == .T.
gl->title := "Revenue"
endif

set filter to .Not. Ty13 = 0 .And.;
gl->account # '0900' .and. ;
gl->account # '0125' .and. ;
gl->account # '0150' .and. ;
gl->account # '0175' .and. ;
gl->account # '2044' .and. ;
gl->account # '5610' .and. ;
gl->account # '3601' .and. ;
gl->account # '2053' .and. ;
gl->account # '2054' .and. ;
gl->account # '2514' .and. ;
gl->account # '2515' .and. ;
gl->account # '2632' .and. ;
gl->account # '2634' .and. ;
gl->account # '2733' .and. ;
gl->account # '2734' .and. ;
gl->account # '2833' .and. ;
gl->account # '2834' .and. ;
gl->account # '2933' .and. ;
gl->account # '2934' .and. ;
gl->account # '2998' .and. ;
gl->account # '2999' .and. ;
gl->account # '3355' .and. ;
gl->account # '3356' .and. ;
gl->account # '3485' .and. ;
gl->account # '3487' .and. ;
! (gl->account >= '2004' .and. gl->account <= '2008') .and. ;
! (gl->account >= '2022' .and. gl->account <= '2029') .AND. ;
! (gl->account >= '2031' .and. gl->account <= '2038') .AND. ;
! (gl->account >= '6000')

case nFilterType == 3 // DETAIL COST OF GOODS SOLD

//SET BACK TO NO DISPLAY

gl->(dbseek("2024"))
do while gl->account <= "2038"
if gl->ty13 == 0
gl->ty13 := .0001
endif
gl->(dbskip())
enddo

gl->(dbseek("2040"))
gl->title := "Cost of sales"
if nfp == .T.
gl->title := "Total program costs"
endif


gl->(dbseek("1000"))
if gl->title == "Collections "
gl->title := "Sales"
endif

if nfp == .T.
gl->title := "Revenue"
endif


set filter to .Not. gl->ty13 = 0 .And.;
gl->account # '0900' .and. ;
gl->account # '0125' .and. ;
gl->account # '0150' .and. ;
gl->account # '0175' .and. ;
gl->account # '2019' .and. ;
gl->account # '2021' .and. ;
gl->account # '2030' .AND. ;
gl->account # '2044' .and. ;
gl->account # '3601' .AND. ;
gl->account # '5610' .and. ;
gl->account # '2053' .and. ;
gl->account # '2054' .and. ;
gl->account # '2514' .and. ;
gl->account # '2515' .and. ;
gl->account # '2632' .and. ;
gl->account # '2634' .and. ;
gl->account # '2733' .and. ;
gl->account # '2734' .and. ;
gl->account # '2833' .and. ;
gl->account # '2834' .and. ;
gl->account # '2933' .and. ;
gl->account # '2934' .and. ;
gl->account # '2998' .and. ;
gl->account # '2999' .and. ;
gl->account # '3355' .and. ;
gl->account # '3356' .and. ;
gl->account # '3485' .and. ;
gl->account # '3487' .and. ;
! (gl->account >= '2004' .and. gl->account <= '2008') .and. ;
! (gl->account >= '6000')

case nFilterType == 5 // % COMPLETE

gl->(dbseek("2040"))
gl->title := "Job costs"

gl->(dbseek("1000"))
if gl->title == "Collections "
gl->title := "Revenues"
endif


set filter to .Not. gl->ty13 = 0 .And.;
gl->account # '0100' .and. ;
gl->account # '0125' .and. ;
gl->account # '0150' .and. ;
gl->account # '0175' .and. ;
gl->account # '2044' .and. ;
gl->account # '3601' .and. ;
gl->account # '5610' .and. ;
gl->account # '2053' .and. ;
gl->account # '2054' .and. ;
gl->account # '2514' .and. ;
gl->account # '2515' .and. ;
gl->account # '2632' .and. ;
gl->account # '2634' .and. ;
gl->account # '2733' .and. ;
gl->account # '2734' .and. ;
gl->account # '2833' .and. ;
gl->account # '2834' .and. ;
gl->account # '2933' .and. ;
gl->account # '2934' .and. ;
gl->account # '2998' .and. ;
gl->account # '2999' .and. ;
gl->account # '3355' .and. ;
gl->account # '3356' .and. ;
gl->account # '3485' .and. ;
gl->account # '3487' .and. ;
! (gl->account >= '2010' .and. gl->account <= '2038') .and. ;
! (gl->account >= '6000')
endcase

gl->(dbgotop())

// CONVERT THIS YEAR (TY) FIELD NAME TO A CODE BLOCK
cty := 'ty'+ ltrim(str(nMonth))
bTy := &("{|| gl->" + cTy +"}")


// convert Actual Year (ACT) field name to a code block
cAct := 'act'+ ltrim(str(nMonth))
bAct := &("{|| gl->" + cAct +"}")

// DIFFERENCES. . .
bDiff := &("{|| gl->" + cTy + " - gl->" + cAct +"}")

grabSales(bSeek)

SubTotal()
grabSales(bSeek)

act1 := {|| cAct}

// NEW 6/26/99 .. ADDED SO AS TO CALCULATE IF DATA IMPORTED

subtotal(1)
subtotal(2)
subtotal(3)
subtotal(4)
subtotal(5)
//subtotal(6)
subtotal(7)
subtotal(8)
subtotal(9)
subtotal(10)
subtotal(11)

* expcf->(dbseek("z Total"))
* if expcf->usepercomp == .T. // FLAGS USING PERCENT COMPLETE
* select gl
* subtotal(6)
* endif

// new departments 1-5
// set order to 3

removeDash(.t.)

nIndex := openit()

gl->(dbsetorder(nIndex))

DEFINE FONT oFont7 NAME "Ms Sans Serif" SIZE 0,-12
DEFINE DIALOG oDlg1 RESOURCE "cmpbrowse" of oWnd1 font ofont7
REDEFINE xBROWSE oBrw ID 101 OF oDlg1 cell lines fastedit autocols //COLOR CLR_RED,CLR_HGRAY

WITH OBJECT oBrw:oCol( "Title" )

b := :bOnPostEdit
:nEditType := EDIT_GET

:OnPostEdit := { |o,x,n| Eval( o,x,n ), o:oBrw:GoDown() }

END


getcoors(ownd1:nTop,ownd1:nLeft,ownd1:nBottom,ownd1:nRight)


if oWnd1:nRight >= 1020 //.AND. oWnd1:nRight <= 1032)

oDlg1:bResized := ;
{|| aRect := GetWndRect(oDlg1:hWnd), ;
oBrw:Move( 14,18,arect[ 4 ]-arect[ 2 ] - 27, ;
aRect[3]-aRect[1]-142,.t.);
,oSay1:move(arect[3] -aRect[1]- 124,30 ,,,.t.); //105
,oSay2:move(arect[3] -aRect[1]- 124,200 ,,,.t.); //104
,oSay3:move(arect[3] -aRect[1]- 124,600 ,,,.t.); //107
,oBmp1:move(arect[3] -aRect[1]- 124,750 ,,,.t.); //106
,oBtn2:move(arect[3] -aRect[1]- 100,30 ,,,.t.); //14
,oBtn3:move(arect[3] -aRect[1]- 100,230 ,,,.t.); //4002
,oBtn1:move(arect[3] -aRect[1]- 100,430 ,,,.t.); //4002
,oBrw:refresh() } //103

// oBrw:Move( 14,18,arect[ 4 ]-arect[ 2 ] - 27, ;
// aRect[3]-aRect[1]-115,.t.);

endif

// 796

if (oWnd1:nRight > 600 .AND. oWnd1:nRight < 1020)
oDlg1:bResized := ;
{|| aRect := GetWndRect(oDlg1:hWnd), ;
oBrw:Move( 14,18,arect[ 4 ]-arect[ 2 ] - 27, ;
aRect[3]-aRect[1]-115,.t.);
,oSay1:move(arect[3] -aRect[1]- 91,30 ,,,.t.); //105
,oSay2:move(arect[3] -aRect[1]- 91,200 ,,,.t.); //104
,oSay3:move(arect[3] -aRect[1]- 91,600 ,,,.t.); //107
,oBmp1:move(arect[3] -aRect[1]- 91,750 ,,,.t.); //106
,oBtn2:move(arect[3] -aRect[1]- 61,30 ,,,.t.); //14
,oBtn3:move(arect[3] -aRect[1]- 61,230 ,,,.t.); //4002
,oBtn1:move(arect[3] -aRect[1]- 61,430 ,,,.t.); //4002
,oBrw:refresh() } //103
endif

* oBrw:lMChange := .t. // disable mousemove
oBrw:nFreeze := 2 // freeze first column

* oBrw:nAdjColumn := 1 // expand this column to flush table right
* oBrw:nClrForeHead := CLR_WHITE
* oBrw:nClrBackHead := CLR_BLUE
* oBrw:nClrBackFocus := CLR_YELLOW //RGB(22,245,84)
* oBrw:nClrForeFocus := CLR_BLACK
* oBrw:lNoHScroll := .f. // don't use that pesky horiz scroll bar
* oBrw:lNoGrayBar := .f.
*

// oBrw:bLDblClick := {| nRow, nCol | picard(oBrw, nRow, nCol,0 )}

//oBrw:bKeyChar := {| nKey, nRow,nCol | if(nKey= 55, editCell(oBrw,nRow,nCol),"") }

//oBrw:fastedit := .T.

* oBrw:bRClicked := {| nRow,nCol | buildx(oBrw, nRow, nCol, odlg,1),oBrw:refresh(),oBrw:setfocus()}

ADD COLUMN TO oBrw;
DATA FIELDBLOCK (("title"),Select("gl")) ;
SIZE 165 LEFT HEADER "Title";
EDITABLE;
COLOR If( gl->title == Repli("-",30),CLR_WHITE,), {|| CLR_WHITE }

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 30), ;
if(gl->title == repli('=', 30), repli(' ', 30), ;
if(gl->title == repli(' ', 30), repli(' ', 30), ;
trans( eval(bTy), '999,999,999') ))) };
SIZE 100 RIGHT HEADER "Plan" +" "+cMonth

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 5), ;
if(gl->title == repli('=', 30), repli(' ', 5), ;
if(gl->title == repli(' ', 30), repli(' ', 5), ;
trans( 100* (eval(bTy)/nsPlanMonth), '@Z 999.9')) )) };
SIZE 50 RIGHT HEADER " %"

ADD COLUMN TO oBrw;
SIZE 100 RIGHT PICTURE "999,999,999" ; //"rb/rb", "w+/rb"
DATA FIELDWBLOCK (eval(act1),Select("gl")) ;
HEADER "Actual"+" "+cMonth ;
COLOR CLR_WHITE, CLR_CYAN EDITABLE

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 5), ;
if(gl->title == repli('=', 30), repli(' ', 5), ;
if(gl->title == repli(' ', 30), repli(' ', 5), ;
trans( 100*(eval(bAct)/nsActMonth), '@Z 999.9')) )) };
SIZE 50 RIGHT HEADER " %"

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 11), ;
if(gl->title == repli('=', 30), repli(' ', 11), ;
if(gl->title == repli(' ', 30), repli(' ', 11), ;
trans( fixsign(bdiff), '999,999,999') ))) };
SIZE 100 RIGHT HEADER "Diff."+" "+cMonth

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 11), ;
if(gl->title == repli('=', 30), repli(' ', 11), ;
if(gl->title == repli(' ', 30), repli(' ', 11), ;
trans( PostYTD(), '999,999,999')) )) };
SIZE 100 RIGHT HEADER "Plan YTD"

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 5), ;
if(gl->title == repli('=', 30), repli(' ', 5), ;
if(gl->title == repli(' ', 30), repli(' ', 5), ;
trans( 100*(PostYTD()/nsPlanYTD), '@Z 999.9') ))) };
SIZE 50 RIGHT HEADER " %"

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 11), ;
if(gl->title == repli('=', 30), repli(' ', 11), ;
if(gl->title == repli(' ', 30), repli(' ', 11), ;
trans( PostActual(oBrw), '999,999,999') ))) };
SIZE 100 RIGHT HEADER "Actual YTD"

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 5), ;
if(gl->title == repli('=', 30), repli(' ', 5), ;
if(gl->title == repli(' ', 30), repli(' ', 5), ;
trans( 100 * (PostActual(oBrw)/nsActYTD), '@Z 999.9')) )) };
SIZE 50 RIGHT HEADER " %"

ADD COLUMN TO oBrw;
DATA {|| if(gl->title == repli('-', 30), repli(' ', 11), ;
if(gl->title == repli('=', 30), repli(' ', 11), ;
if(gl->title == repli(' ', 30), repli(' ', 11), ;
trans( nFixSign(PostYTD() - PostActual(oBrw) ), '999,999,999') ))) };
SIZE 100 RIGHT HEADER "Diff YTD"

REDEFINE say oSay1 ID 105 OF ODLG1
REDEFINE say oSay2 ID 104 OF ODLG1
REDEFINE say oSay3 ID 107 OF ODLG1

REDEFINE BTNBMP oBmp1 ID 106 OF ODLG1 file "TESTBMP2.BMP"

REDEFINE BUTTON oBtn1 ID 4002 OF ODLG1 ;
ACTION(buildx(oBrw, " ", " ", odlg,2),ODLG1:END())

REDEFINE BUTTON oBtn2 ID 9 OF ODLG1 ;
ACTION clearact()

REDEFINE BUTTON oBtn3 ID 8 OF ODLG1 ;
ACTION(removeDash(.f.),prnpalcmp(1,3,.f.,nIndex),removeDash(.t.))

oBmp1:ctooltip:= " To add a <user defined> expense to any expense department "+CRLF+;
" right click on the department's total line and a <user defined> "+CRLF+;
" expense will be added to the department selected."

if small_font <= 96 .OR. oWnd1:nRight >= 1020
activate dialog oDlg1 centered on init(odlg1:maximize(),oBrw:setfocus())
else
activate dialog oDlg1 centered on init(oBrw:setfocus())
endif



removeDash(.f.)

gl->(dbsetorder(setOrder))
gl->(dbsetfilter(oldFilter))


return nil //


static function range()

cursorWait()

if nMonth > 12
msgStop("You are out of range the month should be 1 to 12. ")
return .F.
endif

return .T.


function AcctCatagory()
local nCatagory := 0

if val(gl->account) >= 2004 .and. val(gl->account) <= 2008
nCatagory := 6

return nCatagory

elseif val(gl->account) >= 1500 .and. val(gl->account) <= 2041
nCatagory := 1

return nCatagory

elseif val(gl->account) >= 2055 .and. val(gl->account) <= 2500
nCatagory := 2
elseif val(gl->account) >= 3000 .and. val(gl->account) <= 3353
nCatagory := 3
elseif val(gl->account) >= 3360 .and. val(gl->account) <= 3480
nCatagory := 4
elseif val(gl->account) >= 3491 .and. val(gl->account) <= 3544
nCatagory := 5
elseif val(gl->account) >= 2520 .and. val(gl->account) <= 2625
nCatagory := 7
elseif val(gl->account) >= 2635 .and. val(gl->account) <= 2720
nCatagory := 8
elseif val(gl->account) >= 2735 .and. val(gl->account) <= 2820
nCatagory := 9
elseif val(gl->account) >= 2835 .and. val(gl->account) <= 2920
nCatagory := 10
elseif val(gl->account) >= 2935 .and. val(gl->account) <= 2996
nCatagory := 11

elseif gl->account == '3805' .or. ;
gl->account == '3801' .or. ;
gl->account == '3815' .or. ;
gl->account == '3802' .or. ;
gl->account == '3808' .or. ;
gl->account == '3810' .or. ;
gl->account == '4000' .or. ;
gl->account == '4030'

nCatagory := 12

endif

return nCatagory


function PostYTD()
local nValue := 0
local oldOrder := gl->(indexord())

gl->(dbsetorder(1))

do case
case nMonth == 1
nValue := GL->TY1

case nMonth == 2
nValue := GL->TY1 + GL->TY2

case nMonth == 3
nValue := GL->TY1 + GL->TY2 + GL->TY3

case nMonth == 4
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4

case nMonth == 5
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5

case nMonth == 6
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5 + GL->TY6

case nMonth == 7
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5 + GL->TY6 +;
GL->TY7

case nMonth == 8
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5 + GL->TY6 +;
GL->TY7 + GL->TY8

case nMonth == 9
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5 + GL->TY6 +;
GL->TY7 + GL->TY8 + GL->TY9

case nMonth == 10
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5 + GL->TY6 +;
GL->TY7 + GL->TY8 + GL->TY9 + GL->TY10

case nMonth == 11
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5 + GL->TY6 +;
GL->TY7 + GL->TY8 + GL->TY9 + GL->TY10 + GL->TY11

case nMonth == 12
nValue := GL->TY1 + GL->TY2 + GL->TY3 + GL->TY4 + GL->TY5 + GL->TY6 +;
GL->TY7 + GL->TY8 + GL->TY9 + GL->TY10 + GL->TY11 + GL->TY12
endcase

subtotal(1)

gl->(dbsetorder(oldOrder))

return nValue

// end PostYTD()


function PostActual(oBrw)
local nValue := 0
local oldOrder := gl->(indexord())

gl->(dbsetorder(1))

do case
case nMonth == 1
nValue := GL->act1

case nMonth == 2
nValue := GL->act1 + GL->act2

case nMonth == 3
nValue := GL->act1 + GL->act2 + GL->act3

case nMonth == 4
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4

case nMonth == 5
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5

case nMonth == 6
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5 + GL->act6

case nMonth == 7
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5 + GL->act6 +;
GL->act7

case nMonth == 8
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5 + GL->act6 +;
GL->act7 + GL->act8

case nMonth == 9
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5 + GL->act6 +;
GL->act7 + GL->act8 + GL->act9

case nMonth == 10
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5 + GL->act6 +;
GL->act7 + GL->act8 + GL->act9 + GL->act10

case nMonth == 11
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5 + GL->act6 +;
GL->act7 + GL->act8 + GL->act9 + GL->act10 + GL->act11

case nMonth == 12
nValue := GL->act1 + GL->act2 + GL->act3 + GL->act4 + GL->act5 + GL->act6 +;
GL->act7 + GL->act8 + GL->act9 + GL->act10 + GL->act11 + GL->act12
endcase

//subTotal(1)

gl->(dbsetorder(oldOrder))

return nValue
// end PostActual()


//function SubTotal(object, nBegin)

function SubTotal(nBegin)
local nOldPos := gl->(recno())
local cAct := 'act'+ ltrim(str(nMonth))
local bAct := &("{|| gl->" + cAct +"}")
local dAct := &("{|| gl->" + cAct +"}")
local nSub := 0
local nCatagory
local nSub1 := 0
local cStartAt
local cStopat
local cAccount
local cAcct := gl->account
local n2041 := 0 // gross profit
local n3600 := 0 // total of all expenses
local n3800 := 0 // net amt
local n4020 := 0 // net before taxes
local n4500 := 0 // net income/loss
local n1000 := 0 // sales
local n3805 := 0 // interest income
local n3802 := 0 // interest cash balance
local n3808 := 0 // interest/owner
local n3810 := 0 // sale of assets
local n4000 := 0 // other income
local n4030 := 0 // income tax
local n4040 := 0 // draws in P&L
local n3480 := 0 // dept 3
local n3544 := 0 // dept 4
local n2625 := 0 // New dept 1
local n2720 := 0 // New dept 2
local n2820 := 0 // New dept 3
local n2920 := 0 // New dept 4
local n2996 := 0 // New dept 5
local n3996 := 0 // other income
local n3998 := 0 // other income
local n3801 := 0 // gain sale asset
local n3815 := 0 // bonus

local mAct1 := 0
local mAct2 := 0
local mAct3 := 0
local mAct4 := 0
local mAct5 := 0
local mAct6 := 0
local mAct7 := 0
local mAct8 := 0
local mAct9 := 0
local mAct10 := 0
local mAct11 := 0
local mAct12 := 0
local nDontDo := 1
local nGross := 0
local nDisc := 0
local nNetSale := 0
local nGet := 0
local nWhatIsIt := 0
local oldOrder := gl->(indexord())


cursorWait()

// cMovit: this var value comes from picard()
// fix sales using gross and the disc.

nGet := whatField()

select gl
set filter to
gl->(dbsetorder(1))

if gl->account == "1000"
gl->(dbseek("1000"))
nWhatIsIt := gl->(fieldget(nGet))


gl->(dbseek("0900"))
if gl->ty13 <> 0

if gl->act1 <= 1
gl->act1 := .0001
endif
if gl->act2 <= 1
gl->act2 := .0001
endif
if gl->act3 <= 1
gl->act3 := .0001
endif
if gl->act4 <= 1
gl->act4 := .0001
endif
if gl->act5 <= 1
gl->act5 := .0001
endif
if gl->act6 <= 1
gl->act6 := .0001
endif
if gl->act7 <= 1
gl->act7 := .0001
endif
if gl->act8 <= 1
gl->act8 := .0001
endif
if gl->act9 <= 1
gl->act9 := .0001
endif
if gl->act10 <= 1
gl->act10 := .0001
endif
if gl->act11 <= 1
gl->act11 := .0001
endif
if gl->act12 <= 1
gl->act12 := .0001
endif

gl->(dbseek("0950"))
if gl->act1 <= 1
gl->act1 := .0001
endif
if gl->act2 <= 1
gl->act2 := .0001
endif
if gl->act3 <= 1
gl->act3 := .0001
endif
if gl->act4 <= 1
gl->act4 := .0001
endif
if gl->act5 <= 1
gl->act5 := .0001
endif
if gl->act6 <= 1
gl->act6 := .0001
endif
if gl->act7 <= 1
gl->act7 := .0001
endif
if gl->act8 <= 1
gl->act8 := .0001
endif
if gl->act9 <= 1
gl->act9 := .0001
endif
if gl->act10 <= 1
gl->act10 := .0001
endif
if gl->act11 <= 1
gl->act11 := .0001
endif
if gl->act12 <= 1
gl->act12 := .0001
endif

gl->(dbseek("0900"))
nGross := fieldget(nGet)

gl->(dbseek("0950"))
nDisc := fieldget(nGet)
else
gl->(dbseek("0900"))
gl->act1 := 0
gl->act2 := 0
gl->act3 := 0
gl->act4 := 0
gl->act5 := 0
gl->act6 := 0
gl->act7 := 0
gl->act8 := 0
gl->act9 := 0
gl->act10 := 0
gl->act11 := 0
gl->act12 := 0

gl->(dbseek("0950"))
gl->act1 := 0
gl->act2 := 0
gl->act3 := 0
gl->act4 := 0
gl->act5 := 0
gl->act6 := 0
gl->act7 := 0
gl->act8 := 0
gl->act9 := 0
gl->act10 := 0
gl->act11 := 0
gl->act12 := 0


endif


gl->(dbseek("1000"))
if gl->act1 <= 1
gl->act1 := .0001
endif
if gl->act2 <= 1
gl->act2 := .0001
endif
if gl->act3 <= 1
gl->act3 := .0001
endif
if gl->act4 <= 1
gl->act4 := .0001
endif
if gl->act5 <= 1
gl->act5 := .0001
endif
if gl->act6 <= 1
gl->act6 := .0001
endif
if gl->act7 <= 1
gl->act7 := .0001
endif
if gl->act8 <= 1
gl->act8 := .0001
endif
if gl->act9 <= 1
gl->act9 := .0001
endif
if gl->act10 <= 1
gl->act10 := .0001
endif
if gl->act11 <= 1
gl->act11 := .0001
endif
if gl->act12 <= 1
gl->act12 := .0001
endif

cAccount := "1000"
nSub1 := nGross-nDisc

if EMPTY(cMovIt)
cMovit := "1000"
endif

if nSub1 <> nsActMOnth .AND. !EMPTY(nsActMonth) .AND. val(cMovit) < 1000
nSub := nSub1
else

if nSub == 0
gl->(dbseek("1000"))
nSub := nWhatIsIT
if nSub == 0
nSub := .0001
endif
endif
endif

if gl->(dbseek(cAccount))
fieldput(fieldpos(cAct),nSub)
endif

endif

if nBegin == nil
nCatagory := AcctCatagory() // ret 4
else
nCatagory := nBegin
endif


if nCatagory == 1 // cost of goods sold

cStartAt := '1500'
cStopat := '2038'
cAccount := '2040'

select gl
set filter to

gl->(dbseek("1500"))
do while gl->account <= '2038'
if gl->ty13 > 1
nDontDo := 2
exit
endif
gl->(dbskip())
enddo

if nDontDo == 1
cStartAt := '2040'
cStopat := '2040'
cAccount := '2040'
endif

elseif nCatagory == 2 // dept 1
cStartAt := '2055'
cStopat := '2490'
cAccount := '2500'

elseif nCatagory == 3 // dept 2
cStartAt := '3000'
cStopat := '3351'
cAccount := '3353'

elseif nCatagory == 4 // dept 3
cStartAt := '3360'
cStopat := '3460'
cAccount := '3480'

elseif nCatagory == 5 // dept 4
cStartAt := '3491'
cStopat := '3542'
cAccount := '3544'

elseif nCatagory == 6 // % complete
cStartAt := '2004'
cStopat := '2008'
cAccount := '2040'

elseif nCatagory == 7 // New Dept 1
cStartAt := '2520'
cStopat := '2615'
cAccount := '2625'

elseif nCatagory == 8 // New Dept 2
cStartAt := '2635'
cStopat := '2709'
cAccount := '2720'

elseif nCatagory == 9 // New Dept 3
cStartAt := '2735'
cStopat := '2809'
cAccount := '2820'

elseif nCatagory == 10 // New Dept 4
cStartAt := '2835'
cStopat := '2908'
cAccount := '2920'

elseif nCatagory == 11 // New Dept 5
cStartAt := '2935'
cStopat := '2994'
cAccount := '2996'

elseif nCatagory == 12 // DON'T DO ANYTHING YET

endif


if nCatagory == 1 .or. nCatagory == 2 .or. nCatagory == 3;
.or. nCatagory == 4 .or. nCatagory == 5 .or. nCatagory == 6;
.or. nCatagory == 7 .or. nCatagory == 8 .or. nCatagory == 9;
.or. nCatagory == 10 .or. nCatagory == 11

nSub := 0

if gl->(dbseek(cStartAt))
do while gl->account <= cStopAt .and. ! gl->(eof())
nsub += eval(bact)
gl->(dbskip())
enddo

if gl->(dbseek(cAccount))
fieldput(fieldpos(cAct),nSub)
endif

endif
endif


if nCatagory == 1 // cost of goods sold
n2040 := nSub
elseif nCatagory == 2 // selling expense
n2500 := nsub
elseif nCatagory == 3 // G and A
n3353 := nSub
elseif nCatagory == 4 // G and A
n3480 := nSub
elseif nCatagory == 5 // G and A
n3544 := nSub
elseif nCatagory == 6 // cost of goods sold
n2040 := nSub
elseif nCatagory == 7 // New Dept 1
n2625 := nSub
elseif nCatagory == 8 // New Dept 2
n2720 := nSub
elseif nCatagory == 9 // New Dept 3
n2820 := nSub
elseif nCatagory == 10 // New Dept 4
n2920 := nSub
elseif nCatagory == 11 // New Dept 5
n2996 := nSub
endif

if nFilterType == 1 // one liner - sales
if gl->(dbseek('2040'))
n2040 := eval(bAct)
endif
endif

// FETCH VALUES
// FUTURE: BUILD AND ARRAY AND than DO A FOR/NEXT

if gl->(dbseek('1000')) // SALES
n1000 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('2040')) // cost of goods sold
if nCatagory == 1 // cost of goods sold
fieldput(fieldpos(cAct),n2040 )
else

n2040 := fieldget(fieldpos(cAct))

endif

endif


if gl->(dbseek('2041')) // GROSS PROFIT
n2041 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('2500')) // TOTAL SELLING EXPENSES
n2500 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3353')) // TOTAL GA EXPENSES
n3353 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3480')) // TOTAL SELLING EXPENSES
n3480 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3544')) // TOTAL SELLING EXPENSES
n3544 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3805')) // INTEREST INCOME
n3805 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3802')) // INTEREST INCOME CASH BALANCE
n3802 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3801')) // INTEREST INCOME CASH BALANCE
n3801 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3815')) // INTEREST INCOME CASH BALANCE
n3815 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3808')) // INTEREST/OWNER
n3808 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3810')) // SALE OF ASSETS
n3810 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('4000')) // OTHER INCOME
n4000 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('3996')) // OTHER INCOME
n3996 := fieldget(fieldpos(cAct))
endif
if gl->(dbseek('3998')) // OTHER INCOME
n3998 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('4020')) // NET BEFORE TAX
n4020 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('4030')) // INCOME TAX
n4030 := fieldget(fieldpos(cAct))
endif
if gl->(dbseek('4040')) // INCOME TAX
n4040 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('2625')) // New Dept 1
n2625 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('2720')) // New Dept 2
n2720 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('2820')) // New Dept 3
n2820 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('2920')) // New Dept 4
n2920 := fieldget(fieldpos(cAct))
endif

if gl->(dbseek('2996')) // New Dept 5
n2996 := fieldget(fieldpos(cAct))
endif


* n2041 := n1000 - n2040 // gross profit
* n3600 := n2500 + n3353 // total of all expenses
* n3800 := n2041 - n3600 // net amt
* n4020 := n3800 + n3805 + n3802 +n3808 + n3810 + n4000 +n3801-n3815 // net before taxes
* N4500 := N4020 - N4030 // NET INCOME/LOSS

// UPDATE FIELDS

if gl->(dbseek('2041')) // GROSS PROFIT
n2041 := n1000 - n2040
fieldput(fieldpos(cAct), n2041 )
endif

if gl->(dbseek('3600')) // TOTAL OF ALL EXPENSES
n3600 := n2500 + n3353 + n3480 + n3544 +n2625+n2720+n2820+n2920+n2996
fieldput(fieldpos(cAct), n3600 )
endif

if gl->(dbseek('3800')) // NET AMT
//fieldput(fieldpos(cAct), n2041 - n3600)

gl->(dbseek("3800"))
gl->ty1 := 0
gl->ty2 := 0
gl->ty3 := 0
gl->ty4 := 0
gl->ty5 := 0
gl->ty6 := 0
gl->ty7 := 0
gl->ty8 := 0
gl->ty9 := 0
gl->ty10 := 0
gl->ty11 := 0
gl->ty12 := 0
gl->ty13 := 0
gl->act1 := 0
gl->act2 := 0
gl->act3 := 0
gl->act4 := 0
gl->act5 := 0
gl->act6 := 0
gl->act7 := 0
gl->act8 := 0
gl->act9 := 0
gl->act10 := 0
gl->act11 := 0
gl->act12 := 0


gl->(dbseek('2041'))
n2041 := fieldget(fieldpos(cTy))

gl->(dbseek('3600'))
n3600 := fieldget(fieldpos(cTy))

* gl->(dbseek('3800')) // NET AMT
* n3800 := fieldput(fieldpos(cTy), n2041 - n3600)


// PUT VALUE TO ORIGINAL

gl->(dbseek('2041'))
n2041 := fieldget(fieldpos(cAct))
gl->(dbseek('3600'))
n3600 := fieldget(fieldpos(cAct))

* gl->(dbseek('3800')) // NET AMT
* fieldput(fieldpos(cAct), n2041 - n3600)

endif

if gl->(dbseek('4020')) // NET BEFORE TAXES
fieldput(fieldpos(cAct),n2041 - n3600 + n3801 - n3815 + n3802 + n3805 + n3808 + n3810 + n4000+ n3996+ n3998 )
endif

if gl->(dbseek('4500')) // NET INCOME/LOSS
endif
fieldput(fieldpos(cAct), n2041 - n3600 + n3801 - n3815+ n3802 + n3805 + n3808 + n3810 + n3996+ n3998+ n4000 - n4030-n4040)

nCalc()

fixthefilter()
gl->(dbsetorder(oldOrder))
gl->(dbgoto(nOldPos))

return nil
// end function SubTotal()


static function SkipDB(nSkipRequest, bWhileCond)
local nActSkip := 0

if nSkipRequest == 0
dbskip(0)
elseif nSkipRequest > 0 .and. !eof()
// keep skipping until number of skips requested is satisfied
do while nActSkip < nSkipRequest
dbskip(1)
// Evaluate condition to each record
if !eval( bWhileCond ) .or. eof()
dbskip(-1)
exit
endif
nActSkip++
enddo

elseif nSkipRequest < 0
do while nActSkip > nSkipRequest
dbskip(-1)
// This check is important! BOF bangs do not
// sit on phantom record. Rather the top record
// is evaluated, and may meet the condition
if bof()
exit
endif

// Evaluate condition to each record
if !eval(bWhileCond)
dbskip(1)
exit
endif
nActSkip--
enddo
endif

return nActSkip
// end function SkipDB()

/* CONVERT SOME ACCOUNT DIFFERENCES TO NEGATIVE NUMBERS
*/
function FixSign(block)
local nValue := eval(block)

if gl->account == '3805' .or. ;
gl->account == '3801' .or. ;
gl->account == '3815' .or. ;
gl->account == '3802' .or. ;
gl->account == '3810' .or. ;
gl->account == '2041' .or. ;
gl->account == '3800' .or. ;
gl->account == '4020' .or. ;
gl->account == '4500' .or. ;
gl->account == '4000' .or. ;
gl->account == '1000'

nValue := nValue * -1
endif

return nValue

function nFixSign(nValue)

if gl->account == '3805' .or. ;
gl->account == '3801' .or. ;
gl->account == '3815' .or. ;
gl->account == '3802' .or. ;
gl->account == '3810' .or. ;
gl->account == '4000' .or. ;
gl->account == '2041' .or. ;
gl->account == '3800' .or. ;
gl->account == '4020' .or. ;
gl->account == '4500' .or. ;
gl->account == '1000'

nValue := nValue * -1
endif

return nValue

// end GL2.PRG


function isCostofSales()
local retval := .f.

//gl->(dbseek('2010'))

gl->(dbseek('1500'))
do while gl->account < '2039'

if gl->ty13 # 0 ;
.or. gl->act1 > 0 ;
.or. gl->act2 > 0 ;
.or. gl->act3 > 0 ;
.or. gl->act4 > 0 ;
.or. gl->act5 > 0 ;
.or. gl->act6 > 0 ;
.or. gl->act7 > 0 ;
.or. gl->act8 > 0 ;
.or. gl->act9 > 0 ;
.or. gl->act10 > 0 ;
.or. gl->act11 > 0 ;
.or. gl->act12 > 0

retval := .T.
exit
endif

gl->(dbskip())
enddo

return retval


function GrabSales(bSeek)
local nOldPos := gl->(recno())
local oldOrder := indexord()


gl->(dbsetorder(1))
gl->(dbseek("1000"))

do while .T.

if nMonth == 1
if gl->act1 == 0
gl->act1 := .001
endif

nsPlanYTD := gl->ty1
nsActYTD := gl->act1
nsPlanMonth := gl->ty1
nsActMonth := gl->act1
exit
endif
if nMonth == 2
if gl->act2 == 0
gl->act2 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2
nsActYTD := gl->act1+gl->act2
nsPlanMonth := gl->ty2
nsActMonth := gl->act2
exit
endif
if nMonth == 3
if gl->act3 == 0
gl->act3 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3
nsActYTD := gl->act1+gl->act2+gl->act3
nsPlanMonth := gl->ty3
nsActMonth := gl->act3
exit
endif
if nMonth == 4
if gl->act4 == 0
gl->act4 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4
nsPlanMonth := gl->ty4
nsActMonth := gl->act4
exit
endif
if nMonth == 5
if gl->act5 == 0
gl->act5 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5
nsPlanMonth := gl->ty5
nsActMonth := gl->act5
exit
endif
if nMonth == 6
if gl->act6 == 0
gl->act6 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5+gl->ty6
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5+gl->act6
nsPlanMonth := gl->ty6
nsActMonth := gl->act6
exit
endif
if nMonth == 7
if gl->act7 == 0
gl->act7 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5+gl->ty6+gl->ty7
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5+gl->act6+gl->act7


nsPlanMonth := gl->ty7
nsActMonth := gl->act7
exit
endif
if nMonth == 8
if gl->act8 == 0
gl->act8 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5+gl->ty6+gl->ty7+gl->ty8
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5+gl->act6+gl->act7+gl->act8

nsPlanMonth := gl->ty8
nsActMonth := gl->act8
exit
endif
if nMonth == 9
if gl->act9 == 0
gl->act9 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5+gl->ty6+gl->ty7+gl->ty8+gl->ty9
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5+gl->act6+gl->act7+gl->act8+gl->act9
nsPlanMonth := gl->ty9
nsActMonth := gl->act9
exit
endif
if nMonth == 10
if gl->act10 == 0
gl->act10 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5+gl->ty6+gl->ty7+gl->ty8+gl->ty9+gl->ty10
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5+gl->act6+gl->act7+gl->act8+gl->act9+gl->act10
nsPlanMonth := gl->ty10
nsActMonth := gl->act10
exit
endif
if nMonth == 11
if gl->act11 == 0
gl->act11 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5+gl->ty6+gl->ty7+gl->ty8+gl->ty9+gl->ty10+gl->ty11
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5+gl->act6+gl->act7+gl->act8+gl->act9+gl->act10+gl->act11
nsPlanMonth := gl->ty11
nsActMonth := gl->act11
exit
endif
if nMonth == 12
if gl->act12 == 0
gl->act12 := .001
endif
nsPlanYTD := gl->ty1+gl->ty2+gl->ty3+gl->ty4+gl->ty5+gl->ty6+gl->ty7+gl->ty8+gl->ty9+gl->ty10+gl->ty11+gl->ty12
nsActYTD := gl->act1+gl->act2+gl->act3+gl->act4+gl->act5+gl->act6+gl->act7+gl->act8+gl->act9+gl->act10+gl->act11+gl->act12
nsPlanMonth := gl->ty12
nsActMonth := gl->act12
exit
endif

enddo


gl->(dbsetorder(OldOrder))
gl->(dbgoto(nOldPos))

return nil


function SalesTreat()
local nSalesType := 0
lamount := .F.

* expcf->(dbseek("z Total"))
* if expcf->usepercomp == .T. // FLAGS USING PERCENT COMPLETE
* nSalesType := 5 // % COMPLETE
* return nSalesType
* endif

// 2002

if cfglob->costmeth == 1
if cfglob->costopt == 1
nSalesType := 1 // ONE LINE COST OF GOODS SOLD
endif
if cfglob->costopt == 2
nSalesType := 2 // MLO
endif
elseif cfglob->costmeth == 2
nSalesType := 2 // MLO
elseif cfglob->costmeth == 3
nSalesType := 3 // DETAIL
elseif cfglob->costmeth == 4
nSalesType := 1 // ONE LINE COST OF GOODS SOLD
elseif cfglob->costmeth == 5
nSalesType := 5 // % COMPLETE
endif

if nSalesType == 0
nSalesType := 1
endif

return nSalesType

/* IS THERE A VALUE IN ANY FIELD TY13 FOR A RANGE OF ACCOUNTS?
*/

function prnpalcmp(mquick,mvar,lFilter,nIndex)

local oReport, oFont1, oFont2, oPrn, oPen1
local mforecast := ""
local mfooter := ""
local mbrket1
local mbrket2
local mbrket3
local mlen := 0
local newName
local oldOrder := gl->(indexord())

if nfp == .T.
NewNAme := "Statement Of Activities"
else
NewNAme := "Profit And Loss"
endif

set filter to
gl->(dbsetorder(1))

gl->(dbseek("4500"))
if gl->ty1 <= -10000000
mlen := 1
elseif gl->ty2 <= -10000000
mlen := 1
elseif gl->ty3 <= -10000000
mlen := 1
elseif gl->ty4 <= -10000000
mlen := 1
elseif gl->ty5 <= -10000000
mlen := 1
elseif gl->ty6 <= -10000000
mlen := 1
elseif gl->ty7 <= -10000000
mlen := 1
elseif gl->ty8 <= -10000000
mlen := 1
elseif gl->ty9 <= -10000000
mlen := 1
elseif gl->ty10 <= -10000000
mlen := 1
elseif gl->ty11 <= -10000000
mlen := 1
elseif gl->ty12 <= -10000000
mlen := 1
endif

if mlen == 1
mbrket1 := "999,999,999"
mbrket2 := " 99,999,999"
mbrket3 := " 999.99"

else
mbrket1 := "@) 999,999,999"
mbrket2 := "@) 99,999,999"
mbrket3 := "@) 999.99"
endif

anote->(dbseek("4500"))
mfooter := rtrim(anote->edit)

mforecast := company->prtname
mforecast := rtrim(mforecast)

gl->(dbgotop())

elimimlines(1)

gl->(dbgotop())

newFilter()
//gl->(dbsetorder(nIndex))

if company->alpha == 3
gl->(dbsetorder(3))
endif

if company->alpha == 2 //.AND. mvar == 1
gl->(dbsetorder(2))
endif


define font oFont1 name "Arial" size 4,7
define font oFont2 name "Arial" size 8,12 BOLD

define pen oPen1 width 1

gl->(dbgotop())

PRINT oPrn NAME "SET_LANDSCAPE"
prnlandscape()
ENDPRINT

if mvar == 3
if msgYesNo("Do you wish to view a print preview?")
REPORT oReport;
TITLE rtrim(mcompname),;
+NewName+" "+ mForecast+"/"+"Actual "+" "+str(mYear,4,0) CENTERED;
FONT oFont1,;
oFont2;
PEN oPen1;
HEADER "Date: "+dtoc(date())+" Time: "+time()+spac
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby hag » Sun Jul 20, 2008 7:29 pm

I've done every thing possible but onPostEdit doesn't seem to work at all in a browse from resources.


All I'm trying to do is after editing the cell have the program automatically move to the next cell below.

Works in a brows from code but not from a browse from resources.

HELP
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby hag » Sun Jul 20, 2008 11:58 pm

Came up with my own userdefined function and it is not pretty but works.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: D.Fernandez and 89 guests