Jump to content

Recommended Posts

Posted

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.

Posted

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.

  • 2 weeks later...
Posted
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....

Posted

Hi,

 

Can you try this approach: ?!

 

UniDBGrid1->ClientEvents->ExtEvents-> beforeedit fn:

function beforeedit(editor, context, eOpts) 
{
    return confirm("Documento saldado.. ..\nDesea editarlo?");
}

Best regards.

Posted

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....
Posted

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;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...