Topic: Insert text into a report depending on your choice

Hi everyone,
I pulled out an old project of mine that was completed with the much-needed help of derek and domebil a few years ago. I've made some changes and I've hit a dead end with the inventory print.
Starting from the first form "frmPrincipale" you can see that there is an "Inventario" button, inventory in English. This opens a form that allows you to choose seasons and filters the results based on the selected season, no total inventory choices.
In the print report I would like to put the name of the season next to the writing "INVENTARIO", INVENTARIO "INVERNO", INVENTARIO "PRIMAVERA" etc. according to the choice made. I've made several attempts but I can't bring this change to term.
Thanks and greetings to all.

Post's attachments

Attachment icon Moon.zip 602.02 kb, 73 downloads since 2023-08-19 

Re: Insert text into a report depending on your choice

Hi Fabio

Post's attachments

Attachment icon Inventario.fr3 11.83 kb, 74 downloads since 2023-08-19 

3 (edited by reteinformatica 2023-08-19 23:01:45)

Re: Insert text into a report depending on your choice

Hi sparrows,
thanks a lot for the report. Could you kindly tell me what did you do please? Because apart from adding an empty memo I didn't understand how this memo should be configured. Then I noticed a small problem: if I don't choose any season, i.e. it gives me the total inventory of all seasons, it still writes me "Primavera". If, on the other hand, I select a season that does not have any articles, then it does not write anything next to the "Inventario" item
Thank you very much.

Re: Insert text into a report depending on your choice

In FastScript, next to INVENTARIO, a Memo9 text field is created.
An OnAfterPrint event has been created for MasterData1.
In the FastScript script for the event, we write a command.

   memo9.text := <Report."Stagione.Stagione">;

Yes, everything else is as you described, and here you need to think about how to solve it.

Re: Insert text into a report depending on your choice

Something like this

Post's attachments

Attachment icon Inventario.fr3 11.61 kb, 76 downloads since 2023-08-20 

6 (edited by reteinformatica 2023-08-20 10:26:42)

Re: Insert text into a report depending on your choice

Hi sparrows,
Thanks for the hint, that was something I didn't know.
I've tried various attempts, including the ones below but I just can't find the solution.

procedure MasterData1OnAfterPrint(Sender: TfrxComponent);
begin
  // if <"Stagione.Stagione.value"> = 0 then memo9.text := '' else
     if <"frmInventario.combobox1.index"> = 0 then memo9.text := '' else                                                                                                                                          
       memo9.text := <Report."Stagione.Stagione">;
end;

begin

end.

EDIT:
Ah OK. While I was writing you posted the change report, I hadn't noticed. So beyond that I didn't write the code well, my approach was also wrong.

Re: Insert text into a report depending on your choice

But one thing is still not clear to me: I have seen that with this modification there is no longer any code in the events of "MasterData1". In memo9 there is no longer any reference to the variation of "combobox1" except only if it is different from empty. So how does he choose the right season?

Re: Insert text into a report depending on your choice

It is easier for us to work with this variable than with the results (set) that are passed by the SQL query to FastScript .
The set is processed record by record sequentially in "MasterData1" or manually in a script.
The ComboBox1 variable is passed from the program itself when you select a season.
We only analyze this variable. If it is empty, then output 'ALL SEASONS'; if not empty, then the variable itself.

[IIF(<ComboBox1><>'',<ComboBox1>,'All seasons')]

One remark, you will already change the text ALL SEASONS for yourself.

9 (edited by reteinformatica 2023-08-20 10:55:09)

Re: Insert text into a report depending on your choice

Well, I get it. Thank you very much for the corrections and especially for the explanations. I decided to leave "All Seasons" because it is also a term used in Italian. Thanks again.

Re: Insert text into a report depending on your choice

Hi everyone, I'm here again. I always come up with new ideas but I can not develop, damn!
We always talk about this project.
I just realized that by creating a receipt (frmscontrinidetails) the project as it is also allows you to enter the quantity of an item even if the availability is lower. That is, I can put 3 pieces of an article even if I have 2.
This has a negative impact on the inventory because it inserts the article with equal quantity, in the case of the example, -1 and consequently subtracts the cost of the article.
If a user inserts that item by mistake or on purpose in the receipt, then in the inventory the cost is subtracted and therefore the inventory is untruthful.
How could I do to prevent entering quantities of a product that are lower than availability or at least not being notified of what is being done?
I've tried various ways including this creepy thing I post at the bottom but besides being crap it tells me that "function OnSQLException" already exists.
Thank you all.


function OnSQLException(Sender: TObject; Msg: string; SQL: string): boolean;
begin
  if Sender = frmScontrinidetail.button1 then
    begin
      if articoli.quantia < 0 then  
    begin      
      result := True; //*** blocca il messaggio originale di MVD ***
      MessageBox('ATTENZIONE stai inserendo una quantià inferiore alla disponibilità','', MB_ICONWARNING + 0); //*** messaggio personalizzato ***
    end;
end;

Re: Insert text into a report depending on your choice

I don't quite understand your bookkeeping. Sorry.
But the procedure should be as follows.
Create an OnClick event on button1.
In the event, create a check for the number of available articles (SQL query or an additional field on the form)
and the entered quantity value in Edit1.
If the number entered is greater than the remainder, do not allow writing.

12 (edited by reteinformatica 2023-08-20 21:31:52)

Re: Insert text into a report depending on your choice

Sorry Sparrow, I can't always convey what I think I probably expressed myself badly.
I'll try to make you understand with an example.
In the warehouse I loaded ten pieces of an item which I paid ten for each piece.
I make a receipt and put in eleven pieces, so one more than what I have in stock. The project doesn't stop me from putting in eleven pieces even though I only have ten pieces in my warehouse.
Going to make the inventory and being that I have finished all the pieces, in the general inventory I should have, at least for that item, a value equal to zero.
Instead, in the general value which also includes other items, it subtracts the value of that piece from the total.
Let's assume the general value of the entire inventory is one hundred, so it becomes ninety and it's not real because it should be one hundred.
I would like to try to do something that prevents me from adding more pieces of an item than I have in stock or at least warns me that I am exceeding the quantity I actually have.

Re: Insert text into a report depending on your choice

Ciao Fabio, prova così
if elencopro.Edit4.value  < 0 then elencopro.Button1.enabled:= False;
    if elencopro.Edit4.value  > 1 then elencopro.Button1.enabled:= true;

Domebil

Re: Insert text into a report depending on your choice

Ciao Domenico, "elencopro" esattamente a quale identificatore corrisponderebbe?

Re: Insert text into a report depending on your choice

dammi 10 minuti che ti mando un progetto con lo script completo

Domebil

16 (edited by domebil 2023-08-21 08:03:04)

Re: Insert text into a report depending on your choice

questo è un vecchio progetto rifatto

Post's attachments

Attachment icon GestArticoli.rar 725.83 kb, 72 downloads since 2023-08-21 

Domebil

Re: Insert text into a report depending on your choice

Good job

18 (edited by reteinformatica 2023-08-21 09:31:11)

Re: Insert text into a report depending on your choice

Grazie Domenico, ora lo guardo e cerco di capirci qualcosa. Poi vi faccio sapere. Per il momento ti posso dire che la grafica mi piace molto.
Thanks to you too sparrow.

Re: Insert text into a report depending on your choice

Grazie mille fabio! se qualcosa non ti è chiara siamo qui

Domebil

Re: Insert text into a report depending on your choice

Hi Fabio,
A couple of suggestions in addition to the advice you have already received about not saving a record if there is not enough stock.
In Option 1, you can show the available stock in the combobox (Product X  (100) etc etc).  You can also filter out those products where there is no stock so they do not even appear in the combobox.
In Option 2, when you select a product in the combobox, the available stock is shown as a text hint in the field where you enter the quantity.
As I said, it won't prevent the user from entering an incorrect quantity but at least it gives extra information about the available stock.
Derek.

Post's attachments

Attachment icon stock out.zip 980.74 kb, 69 downloads since 2023-08-21 

Re: Insert text into a report depending on your choice

domebil wrote:

Grazie mille fabio! se qualcosa non ti è chiara siamo qui

Ciao Domenico, il tuo programma funziona come volevo e su questo non avevo dubbi, la grafica come ho detto è stupenda e lo riconfermo anzi sono un po' invidioso perchè oltre a bloccarmi spesso sul codice non riesco a fare cose belle così.
Sto cercando di capire il funzionamento e penso di esserci arrivato, ora proverò ad applicare quello che ho capito sul mio.
Non l'ho ancora fatto perchè, provando il tuo programma, ho trovato un problema che da ore mi assilla, in quanto non riesco a capirne la motivazione e quando non capisco qualcosa non trovo pace finchè non l'ho capita.
Cliccando su "Elenco articoli" della finestra principale mi da questo errore ""20.0" is not a valid integer value. Script position, 957:7" e mi va alla riga "incriminata". Guardo e riguardo ma mi pare tutto corretto. Allora commento questa riga, rilancio il programma e non si avvia evidenziandomi una riga nella zona dei colori. Commento la riga e mi evidenzia la linea successiva. Nuovo commento ed errore nella linea successiva. Finchè non ne commento 3-4 e alla fine parte. Però non ho capito niente sul perchè questi errori.

Re: Insert text into a report depending on your choice

derek wrote:

Hi Fabio,
A couple of suggestions in addition to the advice you have already received about not saving a record if there is not enough stock.
In Option 1, you can show the available stock in the combobox (Product X  (100) etc etc).  You can also filter out those products where there is no stock so they do not even appear in the combobox.
In Option 2, when you select a product in the combobox, the available stock is shown as a text hint in the field where you enter the quantity.
As I said, it won't prevent the user from entering an incorrect quantity but at least it gives extra information about the available stock.
Derek.

Thank you so much tireless derek smile Check it out now.

Re: Insert text into a report depending on your choice

ciao Fabio il mio non da questo errore, rimetti il progetto con l'errore cosi riesco a vedere che è successo

Domebil

24 (edited by sparrow 2023-08-21 17:25:46)

Re: Insert text into a report depending on your choice

An error can occur if the Quantita field of the frmInserimentoArticolo form is incorrectly specified
or not specified (empty) when colorizing a table.
Several solutions:
set default value
do validation of the entered value in the Edit field,
modify the calculated field to return 0 instead of empty.


p.s. Fabio in this case, commenting one line will not help in finding the error. You need to comment out 957 - 960.
These lines contain the condition check.

Re: Insert text into a report depending on your choice

domebil wrote:

ciao Fabio il mio non da questo errore, rimetti il progetto con l'errore cosi riesco a vedere che è successo

Ciao Domenico,
ho riscaricato il programma e non da l'errore. Poi ho inserito un articolo e a questo punto da l'errore che ti dicevo.
Carico il progetto con l'articolo inserito nel database. All'interno c'è anche uno screen shot.

Post's attachments

Attachment icon GestArticoli.zip 795.04 kb, 52 downloads since 2023-08-21