Rotina p/ identificar quem esta usando a mesma tabela e bloq
Esta rotina tenho usado neste projeto de cheques. Essa rotina irá identifcar quem esta usando o banco de dados e o registro na rede bloqueando logo em seguida, possibilitando que outros usuarios aguardem a atualização dos dados para posteriormente terem acesso, espero ter ajudado alguem no forum
MODULO.TCHEQUES.IndexFieldNames := ´CHQ_NUMERO´;
if MODULO.TCHEQUES.Findkey( [Codigo] ) then
begin
if MessageDlg(´Registro já existente, deseja alterá-lo?´, mtConfirmation, [MbYes, mbNo], 0) = mrYes then
begin
try
MODULO.TCHEQUES.Edit;
except
on E: Exception do
begin
MessageBeep(0);
Str := E.Message;
if (Pos(´User:´, Str) > 0)
then
Str := Copy(Str,Pos(´User:´, Str)+5, Length(Str))
else
Str := ´Usuário desconhecido´;
FORMMENSAGEM.LabelUSUARIO.Caption := Str;
FORMMENSAGEM.SHOWMODAL;
DBEDITCONTACORRENTE.SETFOCUS;
end;
end;
end
MODULO.TCHEQUES.IndexFieldNames := ´CHQ_NUMERO´;
if MODULO.TCHEQUES.Findkey( [Codigo] ) then
begin
if MessageDlg(´Registro já existente, deseja alterá-lo?´, mtConfirmation, [MbYes, mbNo], 0) = mrYes then
begin
try
MODULO.TCHEQUES.Edit;
except
on E: Exception do
begin
MessageBeep(0);
Str := E.Message;
if (Pos(´User:´, Str) > 0)
then
Str := Copy(Str,Pos(´User:´, Str)+5, Length(Str))
else
Str := ´Usuário desconhecido´;
FORMMENSAGEM.LabelUSUARIO.Caption := Str;
FORMMENSAGEM.SHOWMODAL;
DBEDITCONTACORRENTE.SETFOCUS;
end;
end;
end
Amarildo
Curtidas 0