d.bernaert Posted January 12, 2020 Share Posted January 12, 2020 Hello, due to the large structure of the application each form is responsable for his own data handling. So, I have the following problem. If I want to edit a record and the record is locked by another user I have a problem. The code is the following currently: In the browse form I have the following code to edit a record: if (BasicBrowse.Active) and (not BasicBrowse.FieldByName('Id').isNull) then begin With BasicAddFrm do begin if Init_basic_modification(BasicBrowse.FieldByName('Id').AsInteger) then ShowModal(CallBackInsertUpdateBasicTable) else Close; end; end; As you can see this calls a function Init_basic_modification with the id of the record. This function will return true if the record can ben edited and false if the record is locked. So when the record is locked I don't want to display the update screen. This is the code of the function: function TBasicAddFrm.Init_basic_modification(Id: longint): boolean; begin LblTitle.Caption := MsgModifyItem; UniMainModule.Result_dbAction := 0; BasicTables_Edit.Close; BasicTables_Edit.SQL.Clear; BasicTables_Edit.SQL.Add('Select * from basictables where id=' + IntToStr(Id)); BasicTables_Edit.Open; Try BasicTables_Edit.Edit; Result := True; Except Result := False; BasicTables_Edit.Cancel; BasicTables_Edit.Close; ShowToast(MsgRecordLocked); End; end; Is there a way to get that done? I've tried with adding Ext.get(sender.id).el.setVisible(false); to afterlayout to hide form initialy which works. How can I make it visible depending on the result of the function? I know I could place the dataset on a datamodule and check there if there is a lock on the record but due to the structure of the application (separation of concern) that is not really an option. Thx, Dominique Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.