Sales Invoice to mysql

Respected Seniors,

I am trying to develop Sales Invoice like this

I used ListView to store products and their amount like this

AIA is here
t_ListView_Crud (1).aia (5.5 KB)

This mysql table
AA

I want to ask
Am I going to right side to create sales invoice
Or should I use some other MIT APP components instead of ListView and TinDB?

If you think I am doing good then Please help me how to save data from ListView + TinyDB to Mysql table?

Regards

It looks like a price list.

Why do you want to have it in TinyDB and MySQL?

One way to do this is to save it to TinyDB and then copy the entire TinyDB to a web server as a file.

Sir it is not a price list,
When a customer goes to a shop to buy some products then shopekeeper generates a bill for him. I am trying to develop such system.

Every bill will be saved in database for further reports like sales journal, date wise sales, product wise sale, customer wise sales, monthly sales etc.

If I do not save current bill or all bills to database then how is it possible to create sale reports?

Regards

This does not sound like enough information for your database. Do products have a unit price? For example the reciept is for 2 banana's costing 50 each?
Are there taxes that should be on the receipt?
Maybe the name or the customer id needs to be saved?
And so on...

Yes you are right sir, I skipped following columns
1-Customer information
2-Product Qty
3-Product Rate

Actually I wanted to add above columns later, just wanted to know how to save ListIndex data to mysql table.

Anyway I have added all other columns as

and here is AIA
t_ListView_Crud (2).aia (6.9 KB)

Please help me how to save this data to mysql table.

Many Thanks in advance

Could you consider the possibility that I am not a sir?
It seems that you need to give more thought to what you want to achieve.
Probably you want your MySQL database on a server and you need to give it a lot more thought on what the tables will look like, such as a table with product information, a table with sales info etc.

Anyway, look here: App Inventor Tutorials and Examples: MySQL | Pura Vida Apps

I know well how to save data to mysql table but the question is how to post data from ListView.

It looks like your question is how to insert several rows into a table?

Taifun

Dear Taifun
You are right that I want to insert many rows in single query.
Actually my cash Memo is like this

I took this image from my Desktop software that I developed many years ago.
I am trying to develop same app in MIT APP Inventor.

But the problem is how to save all product rows data in mysql.

I used ListView to display all products and stored them in TinyDB but do not know how to send this data to mysql. I already have a table in phymyadin.

Here is AIA
t_ListView_Crud (2).aia (6.9 KB)

Please help

Do you know how to Insert a new row into a MySQL table?

Why do you use list pickers as data of record? Their formatting makes for nice presentation but needs to be stripped for storage.

Study if you can use related tables, here is an example with Sqlite:

1 Like

Here is code block for cash memo single product

and here are php codes

if ($button == "btn_sl_save")
{

$query = "INSERT INTO cashsalp (ddate,vou_no,vou_type,cr_amount,dr_amount,acc_code,acc_name,code2,acc_name2,driver,qty,rate,type)
VALUES('$datex','$txt_sl_vou_no','$vou_type','$txt_cr_amount','0','$txt_cr_code','$txt_cr_party','$txt_dr_code','$txt_dr_party','$driver','$txt_qty','$txt_rate','P')";

        if (mysqli_query($dbc, $query))
        {
            echo "Voucher saved successfully.";
        }
        else
        {
            echo "ERROR: Could not able to execute" . $query . " " . mysqli_error($dbc);
        }
    mysqli_close($dbc);
     exit();
};

I am saving single records in all modules but unable to save more than one products in same voucher.

Regards

Sir the example does show Cash Memo data like this

This software was developed by me for a Supper Store, the user clicks on any cell and update data then he clicks ADD button to save data in mysql. I used Grid Control and it is just like Excel sheet.

Please forgive me, does MIT APP Inventor not have any component or function to easily insert more than one products same time in mysql table?

Regards

It looks like your php script can insert only one record... to insert multiple records at the sane time see again ny previous answer for the sql syntax

On my webpage you can find an example php script, which is able to receive different sql statements

Taifun

Respected Taifun, with great honor I am very sorry to say that may I could not express my issue properly. No matter I try to describe again

Suppose I have this data
tt

In this case, a block like this will be used to send data to php file

and this php script will be used to save data into mysql table

 $query = "INSERT INTO cashsalp (ddate,vou_no,cr_amount,acc_name,acc_name2,qty,rate)
		VALUES ('$datex','$txt_sl_vou_no','$txt_cr_amount','$txt_dr_party','$txt_product','$txt_qty','$txt_rate')";

        if (mysqli_query($dbc, $query))
        {
           echo 'Data Saved';
        }
        else
        {
            echo "ERROR: Could not able to execute" . $query . " " . mysqli_error($dbc);
            exit();
        }

Now I repeat my question again

The above cash memo contains only one product as

APPLE

So for one product the above code block and php script work fine.

How to add second item in MIT APP Screen?
If my cash memo has FIVE products to sell then should I create 5 rows of textboxes?
Is there not any DYNAMIC extension or method to create textboxes according to cash memo items.

If yes then How to make blocks to to send data to php file?

Some seniors are saying I am not using command or script to save many records in same query. I know how to insert multiple records

https://www.w3schools.com/php/php_mysql_insert_multiple.asp

But can somebody guide me how to prepare many records in MIT APP to send to php file?

I hope I have cleared the issue now.

Regards

Maybe it would be easier to help you if you posted the MySQL Create Table statements for all your tables.

A good data model makes for simple code.

Yes there are, for example [F/OS] - Dynamic Components Extension (for every component) 2.2.2 - Extensions - Kodular Community

However to keep it simple let me recommend you to have only textboxes for one product and a save button, which adds a product into a list, you can display the list using the tableview extension

And later if all products have been added to the list, send all rows in one sql statement to the database

Taifun