Página 1 de 1

DBFBrowse nRecSel after Append

Publicado: Lun May 28, 2007 2:53 pm
por Oleg
Dear developers!
I try to append record into DBFBrowse with lAutoSave==.f. (see attached
sample). Now all is working except the following.
I have table with index on field->nomerpr. When I append record with with
field->nomerpr:=maximum_value, DBFBrowse sets cursor on new record after
append. But when I append record with with field->nomerpr:=not_maximum_value
(in the middle of values), DBFBrowse does not sets cursor on just appended
record. How can I avoid this? I always want to set cursor onto just appended
record.
Can you look at this? Just click 'Append' button, enter 120 into first
field, anything into second and press Enter.
Regards, Oleg.


Attached files test25.zip (2.5 KB)Â

DBFBrowse nRecSel after Append

Publicado: Lun May 28, 2007 5:27 pm
por ignacio
Oleg,
Just do the following:
METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
lCanceled := .t.
RETURN Nil
This way you are telling the class to do nothing after your manual append
operation.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=465ad0df@ozsrv2.ozlan.local...]465ad0df@ozsrv2.ozlan.local...[/email]
> Dear developers!
>
> I try to append record into DBFBrowse with lAutoSave==.f. (see attached
> sample). Now all is working except the following.
>
> I have table with index on field->nomerpr. When I append record with with
> field->nomerpr:=maximum_value, DBFBrowse sets cursor on new record after
> append. But when I append record with with
> field->nomerpr:=not_maximum_value
> (in the middle of values), DBFBrowse does not sets cursor on just appended
> record. How can I avoid this? I always want to set cursor onto just
> appended
> record.
>
> Can you look at this? Just click 'Append' button, enter 120 into first
> field, anything into second and press Enter.
>
> Regards, Oleg.
>
>
>
>
>
>

DBFBrowse nRecSel after Append

Publicado: Lun May 28, 2007 5:27 pm
por NoName
Oleg,
Just do the following:
METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
lCanceled := .t.
RETURN Nil
This way you are telling the class to do nothing after your manual append
operation.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=465ad0df@ozsrv2.ozlan.local...]465ad0df@ozsrv2.ozlan.local...[/email]
> Dear developers!
>
> I try to append record into DBFBrowse with lAutoSave==.f. (see attached
> sample). Now all is working except the following.
>
> I have table with index on field->nomerpr. When I append record with with
> field->nomerpr:=maximum_value, DBFBrowse sets cursor on new record after
> append. But when I append record with with
> field->nomerpr:=not_maximum_value
> (in the middle of values), DBFBrowse does not sets cursor on just appended
> record. How can I avoid this? I always want to set cursor onto just
> appended
> record.
>
> Can you look at this? Just click 'Append' button, enter 120 into first
> field, anything into second and press Enter.
>
> Regards, Oleg.
>
>
>
>
>
>

DBFBrowse nRecSel after Append

Publicado: Lun May 28, 2007 10:16 pm
por Oleg
Ignacio!
> Just do the following:
>
> METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
> lCanceled := .t.
> RETURN Nil
>
> This way you are telling the class to do nothing after your manual append
> operation.
Sorry, but it does not work in my sample.
After appending record with field->nomerpr:=not_maximum_value
(in the middle of values), DBFBrowse does not sets cursor on just appended
record. You can see it in my sample, if you click 'Append' button, then
enter 120 into first
field, anything into second field and press Enter.
Regards, Oleg.

DBFBrowse nRecSel after Append

Publicado: Lun May 28, 2007 10:16 pm
por Oleg
Ignacio!
> Just do the following:
>
> METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
> lCanceled := .t.
> RETURN Nil
>
> This way you are telling the class to do nothing after your manual append
> operation.
Sorry, but it does not work in my sample.
After appending record with field->nomerpr:=not_maximum_value
(in the middle of values), DBFBrowse does not sets cursor on just appended
record. You can see it in my sample, if you click 'Append' button, then
enter 120 into first
field, anything into second field and press Enter.
Regards, Oleg.

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 7:23 am
por Oleg
Ignacio!
I have found that all is working as I expect if i add the following code:
METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
if oSender:nEditMode==beAppend
skip -1
endif
// lCanceled:=.t.
RETURN Nil
But I think it is a hack, and I am not sure that it will be working in all
cases.
Can you analyze and tell me if described behaviour is a bug or not?
Regards, Oleg.

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 7:23 am
por Oleg
Ignacio!
I have found that all is working as I expect if i add the following code:
METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
if oSender:nEditMode==beAppend
skip -1
endif
// lCanceled:=.t.
RETURN Nil
But I think it is a hack, and I am not sure that it will be working in all
cases.
Can you analyze and tell me if described behaviour is a bug or not?
Regards, Oleg.

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 7:25 am
por Oleg
Ignacio!
I have found that all is working as I expect if i add the following code:
METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
if oSender:nEditMode==beAppend
skip -1
endif
// lCanceled:=.t.
RETURN Nil
But I think it is a hack (or workaround), and I am not sure that it will be
working in all
cases. Can you analyze and tell me if described behaviour is a bug or not?
Regards, Oleg.

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 7:25 am
por Oleg
Ignacio!
I have found that all is working as I expect if i add the following code:
METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
if oSender:nEditMode==beAppend
skip -1
endif
// lCanceled:=.t.
RETURN Nil
But I think it is a hack (or workaround), and I am not sure that it will be
working in all
cases. Can you analyze and tell me if described behaviour is a bug or not?
Regards, Oleg.

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 9:36 am
por ignacio
Oleg,
Here is working fine. Pleae try the attached project.
Regards
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=465b2aec@ozsrv2.ozlan.local...]465b2aec@ozsrv2.ozlan.local...[/email]
> Ignacio!
>
>> Just do the following:
>>
>> METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
>> lCanceled := .t.
>> RETURN Nil
>>
>> This way you are telling the class to do nothing after your manual append
>> operation.
>
> Sorry, but it does not work in my sample.
> After appending record with field->nomerpr:=not_maximum_value
> (in the middle of values), DBFBrowse does not sets cursor on just appended
> record. You can see it in my sample, if you click 'Append' button, then
> enter 120 into first
> field, anything into second field and press Enter.
>
> Regards, Oleg.
>
>


Attached files test25.zip (1.9 KB)Â

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 9:36 am
por NoName
Oleg,
Here is working fine. Pleae try the attached project.
Regards
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=465b2aec@ozsrv2.ozlan.local...]465b2aec@ozsrv2.ozlan.local...[/email]
> Ignacio!
>
>> Just do the following:
>>
>> METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
>> lCanceled := .t.
>> RETURN Nil
>>
>> This way you are telling the class to do nothing after your manual append
>> operation.
>
> Sorry, but it does not work in my sample.
> After appending record with field->nomerpr:=not_maximum_value
> (in the middle of values), DBFBrowse does not sets cursor on just appended
> record. You can see it in my sample, if you click 'Append' button, then
> enter 120 into first
> field, anything into second field and press Enter.
>
> Regards, Oleg.
>
>


Attached files test25.zip (1.9 KB)Â

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 9:45 am
por ignacio
Oleg,
Try to overload temporarily the method TDbfBrowse:CancelEdit() with the
following code:
CLASS TDbfBrowse FROM XDbfBrowse
METHOD CancelEdit( lAbort, nKey )
END CLASS
METHOD CancelEdit( lAbort, nKey ) CLASS TDbfBrowse
LOCAL oCol
LOCAL nEditMode := ::nEditMode
IF ! ::lEditMode
RETURN Nil
ENDIF
Super:CancelEdit( @lAbort, nKey, .F. )
IF ! lAbort .AND. ::lAutoSave
IF nEditMode >= beAPPEND
( ::cAlias )->( DbAppend() )
IF NetErr()
lAbort := .T.
ENDIF
ELSE
lAbort := !( ::cAlias )->( DbRLock() )
ENDIF
ENDIF
FOR EACH oCol IN ::aCols
WITH OBJECT oCol
IF :lEdited
IF !lAbort .AND. ::lAutoSave
( ::cAlias )->( FieldPut( :nField, :oGridEdit:Value ) )
ENDIF
:lEdited := .F.
ENDIF
END WITH
NEXT
IF ! lAbort .AND. ::lAutoSave
( ::cAlias )->( DbrUnlock() )
ENDIF
IF nEditMode = beAPPEND .AND. !lAbort
::nRowSel++
::nLen++
::OnChange( .T. )
ENDIF
::Redraw()
RETURN Nil
If it works correctly on your side we will include it on next release. Thank
you for your feedback and sorry for any inconvenience.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=465bb8f7@ozsrv2.ozlan.local...]465bb8f7@ozsrv2.ozlan.local...[/email]
> Ignacio!
>
> I have found that all is working as I expect if i add the following code:
>
> METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
> if oSender:nEditMode==beAppend
> skip -1
> endif
> // lCanceled:=.t.
> RETURN Nil
>
> But I think it is a hack, and I am not sure that it will be working in all
> cases.
> Can you analyze and tell me if described behaviour is a bug or not?
>
> Regards, Oleg.
>
>

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 9:45 am
por NoName
Oleg,
Try to overload temporarily the method TDbfBrowse:CancelEdit() with the
following code:
CLASS TDbfBrowse FROM XDbfBrowse
METHOD CancelEdit( lAbort, nKey )
END CLASS
METHOD CancelEdit( lAbort, nKey ) CLASS TDbfBrowse
LOCAL oCol
LOCAL nEditMode := ::nEditMode
IF ! ::lEditMode
RETURN Nil
ENDIF
Super:CancelEdit( @lAbort, nKey, .F. )
IF ! lAbort .AND. ::lAutoSave
IF nEditMode >= beAPPEND
( ::cAlias )->( DbAppend() )
IF NetErr()
lAbort := .T.
ENDIF
ELSE
lAbort := !( ::cAlias )->( DbRLock() )
ENDIF
ENDIF
FOR EACH oCol IN ::aCols
WITH OBJECT oCol
IF :lEdited
IF !lAbort .AND. ::lAutoSave
( ::cAlias )->( FieldPut( :nField, :oGridEdit:Value ) )
ENDIF
:lEdited := .F.
ENDIF
END WITH
NEXT
IF ! lAbort .AND. ::lAutoSave
( ::cAlias )->( DbrUnlock() )
ENDIF
IF nEditMode = beAPPEND .AND. !lAbort
::nRowSel++
::nLen++
::OnChange( .T. )
ENDIF
::Redraw()
RETURN Nil
If it works correctly on your side we will include it on next release. Thank
you for your feedback and sorry for any inconvenience.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=465bb8f7@ozsrv2.ozlan.local...]465bb8f7@ozsrv2.ozlan.local...[/email]
> Ignacio!
>
> I have found that all is working as I expect if i add the following code:
>
> METHOD DbfBrowse1PostEdit( oSender, lCanceled, nKey ) CLASS TForm1
> if oSender:nEditMode==beAppend
> skip -1
> endif
> // lCanceled:=.t.
> RETURN Nil
>
> But I think it is a hack, and I am not sure that it will be working in all
> cases.
> Can you analyze and tell me if described behaviour is a bug or not?
>
> Regards, Oleg.
>
>

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 11:03 am
por Oleg
Ignacio!
Thank you for your support.
I analyzed all my attempts and your proposals. My previous solution with
"Skip -1" was incomplete. The problem happens when I add some record and by
index order it must get into the middle of first DBFBrowse's screen. In this
case the current record is changing as the result of incorrect TDBFBrowse's
stabilization. You can see it if you debug TDBFBrowse:CancelEdit (appended
record must have small values in the first field - 4,5,6...).
Anyway, I was able to workaround this behaviour in attached sample. I do not
like it, but it works. Maybe you analyze it and suggest something better.
Sorry for not clear explanation, the English is not my native language.
Regards, Oleg


Attached files test25.zip (3.2 KB)Â

DBFBrowse nRecSel after Append

Publicado: Mar May 29, 2007 11:03 am
por Oleg
Ignacio!
Thank you for your support.
I analyzed all my attempts and your proposals. My previous solution with
"Skip -1" was incomplete. The problem happens when I add some record and by
index order it must get into the middle of first DBFBrowse's screen. In this
case the current record is changing as the result of incorrect TDBFBrowse's
stabilization. You can see it if you debug TDBFBrowse:CancelEdit (appended
record must have small values in the first field - 4,5,6...).
Anyway, I was able to workaround this behaviour in attached sample. I do not
like it, but it works. Maybe you analyze it and suggest something better.
Sorry for not clear explanation, the English is not my native language.
Regards, Oleg


Attached files test25.zip (3.2 KB)Â