Topic: Help in tablegrid

Hello to all, I need help. I have a database with ,Last name, name and barcode . In my project in the first tablegrid1 is the whole database and in the second tablegrid2  there is only a column with the barcode. Knowing only the barcode how can i import the last name and name in the tablegri2 ? I try the left join but i faild. A little help please ?


https://i.postimg.cc/CLmr4180/1.jpg


Thank you in advance
Vassilis

Post's attachments

Attachment icon TestTablegrid.zip 334.57 kb, 295 downloads since 2019-05-29 

Re: Help in tablegrid

It's very strange question. Can you explain, what is your purpose?

Dmitry.

Re: Help in tablegrid

Yes. I will insert  a excel  file with the new option Import data. In this file there will be only one column with the Barcode. So when the barcode exist in the database how can it shows us the name and the lastname in the tablegrid2 ?
Suppose that you scan a barcode only to create a order for your business. How can you see  the name of the product according the barcode.

Re: Help in tablegrid

Hi everybody,
how i can i do subtraction of  the result of a Sum (Total) and the result of another Sum (total),
it's for a takings project.
Thank You smile

Re: Help in tablegrid

v_pozidis wrote:

Yes. I will insert  a excel  file with the new option Import data. In this file there will be only one column with the Barcode. So when the barcode exist in the database how can it shows us the name and the lastname in the tablegrid2 ?
Suppose that you scan a barcode only to create a order for your business. How can you see  the name of the product according the barcode.

procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
var
    i: integer;
    barcode: string;
    sLastName, sSurName: string;
begin
    for i := 0 to Form1.TableGrid2.RowCount-1 do
    begin
        barcode := SQLExecute('SELECT bb From "Order" WHERE id='+ IntToStr(Form1.TableGrid2.dbIndexToID(i)));
        if barcode <> '' then
        begin
            sLastName := SQLExecute('SELECT LastNAme FROM Stoixeia WHERE aa='+barcode);
            sSurName := SQLExecute('SELECT Sname FROM Stoixeia WHERE aa='+barcode);
            if sLastName <> '' then SQLExecute('UPDATE "Order" SET LastNameA = ''' + escape_special_characters(sLastName) + ''' WHERE id='+IntToStr(Form1.TableGrid2.dbIndexToID(i)));
            if sSurName <> '' then SQLExecute('UPDATE "Order" SET SNameA = ''' + escape_special_characters(sSurName) + ''' WHERE id='+IntToStr(Form1.TableGrid2.dbIndexToID(i)));
        end;
    end;
    Form1.TableGrid2.dbUpdate;
end;
Dmitry.

Re: Help in tablegrid

Joyce Solo wrote:

Hi everybody,
how i can i do subtraction of  the result of a Sum (Total) and the result of another Sum (total),
it's for a takings project.
Thank You smile

Please create a new topic for your question and explain your question in more details.

Dmitry.

Re: Help in tablegrid

Thank you Dmitry. I thought I could do that using the left join.

Re: Help in tablegrid

Another way to create caluclated field in the table "Order"

(SELECT Stoixeia.LastNAme FROM Stoixeia WHERE Stoixeia.aa = "Order".bb LIMIT 1)
(SELECT Stoixeia.Sname FROM Stoixeia WHERE Stoixeia.aa = "Order".bb LIMIT 1)
Dmitry.