Hi All,
I have a table…where I can’t opening reading and i can write close reading…and total usuage will be calculated based on closed reading from opening reading…
in the next record… based on the closed reading…it will be taken into account as opening reading…how to do this…
Opening reading is not updating…
how to do that? Its urgent please
Thanks
Have a nice day
kranthi
December 7, 2015, 12:06pm
2
Do you have some code to do that?
You can find the last record inserted (order by recid desc) and get the closed reading.
In modifield field of table,
I have written the code ?
this.TotalUsuage = this.CloseReading - this.OpeningReading;
this.OpeningReading = this.orig().CloseReading;
In Update ?
ttsbegin;
this.OpeningReading = this.orig().CloseReading;
ttscommit;
super();
In modifield field of table,
I have written the code ?
form lik this
date open reading close reading total usage
01/12/2015 0.0000 10.0000 10.0000
02/12/2015 10.0000 20.0000 10.0000
03/12/2015 20.0000 45.0000 25.0000
In modified field of that table…I have used this code
this.TotalUsuage = this.CloseReading - this.OpeningReading;
this.OpeningReading = this.orig().CloseReading;
In Update method also
ttsbegin;
this.OpeningReading = this.orig().CloseReading;
this.openingReading = this.closereading
ttscommit;
super();
the orig will give you the state of the buffer before it was update.
In your case it will not work as you are creating a new record and you need to get the openingReading from the last records close reading.