How to prevent user from locking a field

How to prevent user from locking a field

Post by Werkin » Sat, 05 Jul 2003 03:54:02



On a table frame on my form I have a field on the right most column designed
for users to left click on and then slide the mouse down over as many
records as they wish to select.  The field is logical.  As they slide the
mouse down the color of the field changes and the value is turned to False.
I then use this field to setGenFilter the table when the user clicks a
button.

My question is how can I prevent users from locking a record when they click
on the field.

Here is the code I am using so far:

In the built in action method of the field:
;--------------------------------------------------------------
method action(var eventInfo ActionEvent)
id = eventInfo.id()
if id = DataLockRecord then
 disableDefault
endif
if self.value = True then
 Self.Color = Blue
else
 Self.color = Gray
endif
endMethod
;----------------------------------------------------
In the built in mouseDown method of the field:
;------------------------------------------------------
method mouseDown(var eventInfo MouseEvent)
moveto(self)
if select.recordStatus("Locked") then
 select.unlockRecord()
endIf
if self.value = False then
   self.value = True
else
   self.value = False
endif
endMethod
;------------------------------------------------
In the built in mouseEnter method of the field:
;------------------------------------------------
method mouseEnter(var eventInfo MouseEvent)
var
 TopLeft,
 BotRight Point
endVar
disabledefault
if eventInfo.isLeftDown() then
 moveto(self)
   if select.recordStatus("Locked") then
    select.unlockRecord()
   endIf
 if self.value = False then
    self.value = True
 else
    self.value = False
 endif
   self.action(MoveScrollDown)
else
endif
endMethod

Thanks for your help in advance!

-Bruce

 
 
 

How to prevent user from locking a field

Post by Steven Gree » Sat, 05 Jul 2003 05:24:47



> My question is how can I prevent users from locking a record when they click
> on the field.

the simplest way would be to not let them do this is Edit Mode.. clicking on a
field doesn't lock the record.. clicking on a field *in Edit Mode* locks the
record..

--

Steve Green - Diamond Software Group, Inc - Waldorf Maryland USA
Corel CTech Paradox - http://www.diamondsg.com - Support/Downloads/Links
---------------------------------------------------------------------------------

Do you need a Sanity Check? http://www.diamondsg.com/sanity.htm
Upgrade/Downgrade versions? http://www.diamondsg.com/upgrade.htm
-------------------------------------------------------------------------

 
 
 

How to prevent user from locking a field

Post by Werkin » Sat, 05 Jul 2003 05:15:12


Quote:> the simplest way would be to not let them do this is Edit Mode.. clicking
on a
> field doesn't lock the record.. clicking on a field *in Edit Mode* locks
the
> record..

Thanks for the reply. Yes, that would be the easiest way to do it, keep the
user from entering edit mode, but I need to change the value of the field
from true to false as the user passes their cursor over the field.  The form
has to be in edit mode to do this I think?

I wonder if there is some way to filter the table based on the color, alone,
of the field object? Then I would not need to change the value of the field
and I could avoid edit mode.

-Bruce

 
 
 

How to prevent user from locking a field

Post by Tony McGuir » Sat, 05 Jul 2003 06:21:37


You could use a tcursor in the background, keeping it open and in edit mode.

The form would NOT have to be in edit mode to do this.

--
--
Tony

"I woke up and was able to get myself out of bed.
Being that fortunate, what's to complain about?"
_____________

 
 
 

How to prevent user from locking a field

Post by Liz » Sat, 05 Jul 2003 07:40:05


Rather than keeping them from locking it, why not unlock it the
instant the change is done.  Also, you can't lock a field, only a
record.

Liz


> On a table frame on my form I have a field on the right most column designed
> for users to left click on and then slide the mouse down over as many
> records as they wish to select.  The field is logical.  As they slide the
> mouse down the color of the field changes and the value is turned to False.
> I then use this field to setGenFilter the table when the user clicks a
> button.

> My question is how can I prevent users from locking a record when they click
> on the field.

> Here is the code I am using so far:

> In the built in action method of the field:
> ;--------------------------------------------------------------
> method action(var eventInfo ActionEvent)
> id = eventInfo.id()
> if id = DataLockRecord then
>  disableDefault
> endif
> if self.value = True then
>  Self.Color = Blue
> else
>  Self.color = Gray
> endif
> endMethod
> ;----------------------------------------------------
> In the built in mouseDown method of the field:
> ;------------------------------------------------------
> method mouseDown(var eventInfo MouseEvent)
> moveto(self)
> if select.recordStatus("Locked") then
>  select.unlockRecord()
> endIf
> if self.value = False then
>    self.value = True
> else
>    self.value = False
> endif
> endMethod
> ;------------------------------------------------
> In the built in mouseEnter method of the field:
> ;------------------------------------------------
> method mouseEnter(var eventInfo MouseEvent)
> var
>  TopLeft,
>  BotRight Point
> endVar
> disabledefault
> if eventInfo.isLeftDown() then
>  moveto(self)
>    if select.recordStatus("Locked") then
>     select.unlockRecord()
>    endIf
>  if self.value = False then
>     self.value = True
>  else
>     self.value = False
>  endif
>    self.action(MoveScrollDown)
> else
> endif
> endMethod

> Thanks for your help in advance!

> -Bruce

 
 
 

1. Prevent other user from locking a row (rowlock?)

Rene,

Consider the following. You have a user who calls up a row, so you decide to
lock the row. However, before the user has had a chance to edit and save,
the user's boss comes by and invites him/her to lunch. Your user, being
ambitious, of course decides that lunch with the boss is much more important
than completing the edit at hand, and goes off -- without saving the row or
closing the application.

Do you really want the row to be locked for the duration of the 2-hour
lunch, not to mention the hour following lunch when your user is
sharing/gloating to his/her colleagues about having had lunch with the boss?

Perhaps all you really need (and this of course is for you to decide) is to
ensure that if the user does change the data, that the data being changed is
the data that was originally retrieved. BTW, this technique has a name: it's
called "optimistic locking".

If this better suits your needs, then you might consider using a timestamp
column in your table. A timestamp (contrary to its name) is NOT a date/time
(that's a datetime data type). Rather a timestamp column is a number that is
guaranteed by SQL Server to be unique within the database. You assign a
timestamp column to a table, and every time that the row is updated the
value of the timestamp column changes.

So to use it, when your application retrieves data from the table it also
retrieves the current value of the timestamp. When your user decided to
change the data, your UPDATE includes:

WHERE <timestamp> = <value_previously_retrieved>

If the row has not been updated since it was retrieved for your user, the
UPDATE succeeds.
If the row has been changed, the UPDATE fails, and you can notify the user
of that fact.


2. ToolTipText ? confirm VFP 5 vs VFP 6

3. Prevent user from printing record fields

4. MD-Oracle Financials Developer,G/L,O/E,A/R,A/P,F/A

5. Preventing exclusive table lock with UPDATE

6. Oracle SQL*Net failing for multiple IP addresses

7. Preventing application lock?

8. ActiveX Document DLL

9. How do I prevent TABLE LOCKS in VIEWS?

10. How to Prevent locks on tempdb ?

11. How to prevent a table lock with UPDATE

12. prevent table lock when using BCP?

13. Preventing Table Lock Escalation