Israel Portillo Posted June 14, 2016 Posted June 14, 2016 Hi everybody. I have an issue I cant resolve... How to do a continuos showmodal. I explain it. In normal scene I have this behavior. procedure TValidaVentasForm.EtiquetasButtonClick(Sender: TObject); begin while true do begin // send the form.... CodigosBarrasForm.ShowModal; // And obtain some data of that... id:=CodigosBarrasForm.CodigoEdit.Text; // if id<>'' then // we obtained valid data DoSomeVeryInterestingWithTheData(id) else break; // <---- The end of the show // or I repeat again... end; // end; I run a showmodal form to obtain a data from it until this data is an empty string.... Yes, yes, I know your answer.... Callback functions.... Here is my unigui stage: procedure TValidaVentasForm.EtiquetasButtonClick(Sender: TObject); begin CodigoBarrasform.showModal(self.FormCodigoBarrasLectura); // <---- The below procedure as callback parameter end; procedure TValidaVentasForm.FormCodigoBarrasLectura(Sender: TComponent; AResult: Integer); // <---- The callback begin // In the below variable I put the result obtained CodigoBarrasForm in mainmodule to use here... if UniMainModule.TheIDObtainedFromCodigodeBarrasForm<>'' then begin DoSomeVeryInterestingWithTheData(UniMainModule.TheIDObtainedFromCodigodeBarrasForm); // How to relaunch the form again ? end; //else // Does not happend anything // // Here is the puzzle... Please help me... how to drive this... // // // if UniMainModule.TheIdObtainedFromCodigodeBarrasForm<>'' then // begin // DoSomeVeryInterestingWithTheData(UniMainModule.TheIdObtainedFromCodigodeBarrasForm); // // But How to repeat the showmodal() ? // How to do a working: // self.EtiquetasButtonClick(Self); // end; end How to launch again the codigoBarrasForm until the CodigosBarrasform.CodigoEdit text = '' ???? Any help is welcomed. Quote
Sherzod Posted June 15, 2016 Posted June 15, 2016 Hi, For now can you try this approach ?!: 1. Try to use a UniTimer: Enabled -> False; Interval -> 100; procedure TValidaVentasForm.UniTimer1Timer(Sender: TObject); begin (Sender as TUniTimer).Enabled := False; CodigoBarrasform.ShowModal(CodigoBarrasLectura); end; 2. CallBack fn: procedure TValidaVentasForm.CodigoBarrasLectura(Sender: TComponent; AResult: Integer); begin if UniMainModule.TheIdObtainedFromCodigodeBarrasForm<>'' then begin ... UniTimer1.Enabled := True; end; end; Best regards. Quote
Israel Portillo Posted June 16, 2016 Author Posted June 16, 2016 Very well I assumed that solution.... I will implent it. Thanks a lot. Quote
Israel Portillo Posted June 27, 2016 Author Posted June 27, 2016 Hi Delphi Developer. Can you help me again.... How to drive a callback to perfom an abort in a TableBeforeEdit ? procedure TFacturaRapidaForm.NcTableBeforeEdit(DataSet: TDataSet); begin if ncTable.fieldbyname('saldo').asFloat <= 0 then begin if (MessageDlg('Documento saldado.. ..'+#13+#10+'Desea editarlo?', mtConfirmation, [mbYes, mbNo], 0) = mrNo) then abort; end; // self.nAnterioPago:=nctable.fieldbyname('pago').AsFloat; end; Thanks for your help.... Quote
Sherzod Posted June 28, 2016 Posted June 28, 2016 Hi, Can you try this approach: ?! UniDBGrid1->ClientEvents->ExtEvents-> beforeedit fn: function beforeedit(editor, context, eOpts) { return confirm("Documento saldado.. ..\nDesea editarlo?"); } Best regards. Quote
Israel Portillo Posted June 28, 2016 Author Posted June 28, 2016 Sorry, its no clear for me The idea before edit is if "saldo" field is cero.. then ask for confirmation to edit or abort... And if there will be an edition then to put another field ("pago") in a temporal forms variable (this.nPagoAnterior) ... if ncTable.fieldbyname('saldo').asFloat <= 0 then begin if (MessageDlg('Documento saldado.. ..'+#13+#10+'Desea editarlo?', mtConfirmation, [mbYes, mbNo], 0) = mrNo) then abort; end; // self.nAnterioPago:=nctable.fieldbyname('pago').AsFloat; Not just to ask for to edit..... Sorry, this time I dont understand you approach.... Quote
Sherzod Posted June 28, 2016 Posted June 28, 2016 Can you try this?: 1. function beforeedit(editor, context, eOpts) { var indx = 1; // your saldo ColumnIndex if (this.getStore().getAt(this.uniRow).get(indx) <= 0) { return confirm("Documento saldado.. ..\nDesea editarlo?"); } } 2. procedure TFacturaRapidaForm.NcTableBeforeEdit(DataSet: TDataSet); begin self.nAnterioPago:=nctable.fieldbyname('pago').AsFloat; end; Quote
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.