It was my long term query, what event should be used with AutoCalculation. I tried with ColumValid event, but was not successful. Then I tried with LostFocus event of Grid (
Here is the code for those who are interested.
Code: Select all
// called from ColumnValid event
Static Function CalcAmt()
local i, c, mIctr, mQty, mRate, mRateper, mAmt
if !(lAddmode .or. lEditmode)
return nil
endif
i := this.CellRowIndex
if i < 1
return nil
endif
c := this.CellColIndex
mIctr := if(c=1, this.CellValue, frmSale.grdSaledtl.cell(i, 1))
if c = 1 .and. mIctr > 0
frmSale.grdSaledtl.Cell(i, 2) := aProd[mIctr, 3]
frmSale.grdSaledtl.Cell(i, 7) := aProd[mIctr, 4]
frmSale.grdSaledtl.Cell(i, 8) := aProd[mIctr, 5]
frmSale.grdSaledtl.Cell(i, 9) := aProd[mIctr, 6]
endif
mQty := if(c=6, this.CellValue, frmSale.grdSaledtl.Cell(i, 6))
mRate := if(c=7, this.CellValue, frmSale.grdSaledtl.Cell(i, 7))
if c = 8
this.CellValue := if(this.CellValue <= 0, 1, this.CellValue)
endif
mRatePer:= if(c=8, this.CellValue, frmSale.grdSaledtl.Cell(i, 8))
mAmt := mQty * mRate / if(mRatePer = 0, 1, mRatePer)
if mAmt <> frmSale.grdSaledtl.Cell(i, 10)
frmSale.grdSaledtl.Cell(i, 10) := mAmt
CalcTotAmt()
endif
return nilSudip