tMemDataset
Publicado: Vie Sep 08, 2006 4:10 pm
Hola, quisiera una recomendacion, estoy programando un sistema de sueldos y
uso un TBBrowse asociado con un tMemDataSet el tema es al actualizar el
codigo de concepto o la cantidad el sistema deberia recorrer el tMemDataSet
y recalcular todos los conceptos ya que puedo estar modificando las horas
extras y esa modificacion me afecta la jubilacion.
Cuando modifico alguno de estos datos pongo un variable en .T. y en el
evento onUpdate del tMemDataSet hago el recalculo, el tema es que cuando
recorro el tMemDataSet por cada registro siempre me devuelve el valor del
registro donde estoy parado yo creo que cuando el tMemDataSet esta en modo
de edicion pasa esto pero no se como solucionarlo en este sistema.
Si alguien me indica como solucionarlo se lo agradecere o si tiene otra
propuesta distinta la tomare desde ya muchas gracias.
Aqui abajo estan los metodos de actualizacion del codigo, el onUpdate del
tMemDataSet y la funcion que recalcula todo.
//---------------------------------------------------------- --------------------
METHOD DBBrowseColumn1PostEdit( oSender, Value, lCanceled, nKey ) CLASS
tLiquidacionHaberes
local nCantidad, nForm, cTipoCol
if ::aHaberes:lOpen .and. !lCanceled
::aHaberes:Codigo :=Value
::aHaberes:Descripcion:=DataFieldSql('ConceptosSue','Descrip cion','CodigoCon',Value,'')
nCantidad:=::aHaberes:Cantidad
nForm :=::oHab:CalcConcepto(::aHaberes:Codigo,@nCantidad,@cTipoCol )
::aHaberes:Cantidad:=nCantidad
::lRecalc:=.T.
endif
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD aHaberesUpdate( oSender ) CLASS tLiquidacionHaberes
local lUpd:=.F.
if ::lRecalc
::lRecalc:=.F.
::oHab:Recalcula()
::tHaberes:Value :=::oHab:TT_Haberes
::tDescuento:Value :=::oHab:TT_Descuentos
::tAsigFam:Value :=::oHab:TT_Asig_Fam
::tRetenciones:Value :=::oHab:TT_Retenciones
::tNoRemunera:Value :=::oHab:TT_No_Remunera
::tAportes:Value :=::oHab:TT_Aportes
::tACobrar:Value :=::oHab:TT_ACobrar
endif
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD Recalcula() CLASS LiquidacionEmpleado
local nRec:=::oHaberes:recno(), j, nForm, nCantidad, cTipoCol, cTipo, cAux
private TOT_HABERES, TOT_ASIG_FAM, TOT_NO_REMUNERA
private TOT_RETENCIONES, TOT_DESCUENTOS, TOT_APORTES, TOT_ACOBRAR
::oHaberes:lUpdLinked:=.F.
M->TOT_HABERES :=0
M->TOT_ASIG_FAM :=0
M->TOT_NO_REMUNERA:=0
M->TOT_RETENCIONES:=0
M->TOT_DESCUENTOS :=0
M->TOT_APORTES :=0
M->TOT_ACOBRAR :=0
::oHaberes:gotop()
while !::oHaberes:eof()
nCantidad:=::oHaberes:Cantidad
cTipoCol :=' '
nForm
:=::CalcConcepto(::oHaberes:Codigo,@nCantidad,@cTipoCol,@cTi po)
::oHaberes:Edit()
::oHaberes:Cantidad:=nCantidad
if cTipoCol=='I'
::oHaberes:Ingreso:=nForm
::oHaberes:Egreso :=0
else
::oHaberes:Ingreso:=0
::oHaberes:Egreso :=nForm
endif
::oHaberes:UpDate()
do case
case cTipo=='HAB'
M->TOT_HABERES +=nForm
case cTipo=='NRE'
M->TOT_NO_REMUNERA+=nForm
case cTipo=='FAM'
M->TOT_ASIG_FAM +=nForm
case cTipo=='APO'
M->TOT_APORTES +=nForm
case cTipo=='DES'
M->TOT_DESCUENTOS +=nForm
case cTipo=='RET'
M->TOT_RETENCIONES+=nForm
endcase
::oHaberes:skip(1)
enddo
::oHaberes:goto(nRec)
::oHaberes:lUpdLinked:=.T.
M->TOT_ACOBRAR :=M->TOT_HABERES+M->TOT_ASIG_FAM+M->TOT_NO_REMUNERA -
;
M->TOT_RETENCIONES-M->TOT_DESCUENTOS
::TT_HABERES :=M->TOT_HABERES
::TT_ASIG_FAM :=M->TOT_ASIG_FAM
::TT_NO_REMUNERA:=M->TOT_NO_REMUNERA
::TT_RETENCIONES :=M->TOT_RETENCIONES
::TT_DESCUENTOS :=M->TOT_DESCUENTOS
::TT_APORTES :=M->TOT_APORTES
::TT_ACOBRAR :=M->TOT_ACOBRAR
RETURN Nil
//---------------------------------------------------------- --------------------
uso un TBBrowse asociado con un tMemDataSet el tema es al actualizar el
codigo de concepto o la cantidad el sistema deberia recorrer el tMemDataSet
y recalcular todos los conceptos ya que puedo estar modificando las horas
extras y esa modificacion me afecta la jubilacion.
Cuando modifico alguno de estos datos pongo un variable en .T. y en el
evento onUpdate del tMemDataSet hago el recalculo, el tema es que cuando
recorro el tMemDataSet por cada registro siempre me devuelve el valor del
registro donde estoy parado yo creo que cuando el tMemDataSet esta en modo
de edicion pasa esto pero no se como solucionarlo en este sistema.
Si alguien me indica como solucionarlo se lo agradecere o si tiene otra
propuesta distinta la tomare desde ya muchas gracias.
Aqui abajo estan los metodos de actualizacion del codigo, el onUpdate del
tMemDataSet y la funcion que recalcula todo.
//---------------------------------------------------------- --------------------
METHOD DBBrowseColumn1PostEdit( oSender, Value, lCanceled, nKey ) CLASS
tLiquidacionHaberes
local nCantidad, nForm, cTipoCol
if ::aHaberes:lOpen .and. !lCanceled
::aHaberes:Codigo :=Value
::aHaberes:Descripcion:=DataFieldSql('ConceptosSue','Descrip cion','CodigoCon',Value,'')
nCantidad:=::aHaberes:Cantidad
nForm :=::oHab:CalcConcepto(::aHaberes:Codigo,@nCantidad,@cTipoCol )
::aHaberes:Cantidad:=nCantidad
::lRecalc:=.T.
endif
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD aHaberesUpdate( oSender ) CLASS tLiquidacionHaberes
local lUpd:=.F.
if ::lRecalc
::lRecalc:=.F.
::oHab:Recalcula()
::tHaberes:Value :=::oHab:TT_Haberes
::tDescuento:Value :=::oHab:TT_Descuentos
::tAsigFam:Value :=::oHab:TT_Asig_Fam
::tRetenciones:Value :=::oHab:TT_Retenciones
::tNoRemunera:Value :=::oHab:TT_No_Remunera
::tAportes:Value :=::oHab:TT_Aportes
::tACobrar:Value :=::oHab:TT_ACobrar
endif
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD Recalcula() CLASS LiquidacionEmpleado
local nRec:=::oHaberes:recno(), j, nForm, nCantidad, cTipoCol, cTipo, cAux
private TOT_HABERES, TOT_ASIG_FAM, TOT_NO_REMUNERA
private TOT_RETENCIONES, TOT_DESCUENTOS, TOT_APORTES, TOT_ACOBRAR
::oHaberes:lUpdLinked:=.F.
M->TOT_HABERES :=0
M->TOT_ASIG_FAM :=0
M->TOT_NO_REMUNERA:=0
M->TOT_RETENCIONES:=0
M->TOT_DESCUENTOS :=0
M->TOT_APORTES :=0
M->TOT_ACOBRAR :=0
::oHaberes:gotop()
while !::oHaberes:eof()
nCantidad:=::oHaberes:Cantidad
cTipoCol :=' '
nForm
:=::CalcConcepto(::oHaberes:Codigo,@nCantidad,@cTipoCol,@cTi po)
::oHaberes:Edit()
::oHaberes:Cantidad:=nCantidad
if cTipoCol=='I'
::oHaberes:Ingreso:=nForm
::oHaberes:Egreso :=0
else
::oHaberes:Ingreso:=0
::oHaberes:Egreso :=nForm
endif
::oHaberes:UpDate()
do case
case cTipo=='HAB'
M->TOT_HABERES +=nForm
case cTipo=='NRE'
M->TOT_NO_REMUNERA+=nForm
case cTipo=='FAM'
M->TOT_ASIG_FAM +=nForm
case cTipo=='APO'
M->TOT_APORTES +=nForm
case cTipo=='DES'
M->TOT_DESCUENTOS +=nForm
case cTipo=='RET'
M->TOT_RETENCIONES+=nForm
endcase
::oHaberes:skip(1)
enddo
::oHaberes:goto(nRec)
::oHaberes:lUpdLinked:=.T.
M->TOT_ACOBRAR :=M->TOT_HABERES+M->TOT_ASIG_FAM+M->TOT_NO_REMUNERA -
;
M->TOT_RETENCIONES-M->TOT_DESCUENTOS
::TT_HABERES :=M->TOT_HABERES
::TT_ASIG_FAM :=M->TOT_ASIG_FAM
::TT_NO_REMUNERA:=M->TOT_NO_REMUNERA
::TT_RETENCIONES :=M->TOT_RETENCIONES
::TT_DESCUENTOS :=M->TOT_DESCUENTOS
::TT_APORTES :=M->TOT_APORTES
::TT_ACOBRAR :=M->TOT_ACOBRAR
RETURN Nil
//---------------------------------------------------------- --------------------