How to update 2 tables by filling up one form only?

  1. I am developing a inventory management system.

  2. My system comprises of the following tables (attributes):-
    (i) Product (ProductID, Product_description)
    (ii) Location (Location)
    (iii) Transaction (DateTime, ProductID, Qty_change, Location)
    (iv) Available locations (ProductID, Location, Available_qty)

  3. The system has a Transaction_form, which allows users to fill in how many pieces of inventory he wishes to move in or move out, and to which location he will be moving. After filling up this form, the system will create a row in the โ€œTransactionโ€ table. However, i want the system to update also the โ€œAvailable locationsโ€ table too!

  4. Therefore, if the user inputs that 10pcs of product โ€œAโ€ is taken away from location โ€œ1L1Aโ€. The system should search in the table โ€œAvailable locationโ€ if there is a row containing โ€œ1L1Aโ€ in location and product โ€œAโ€ in product ID. If there is, the โ€œAvailable qtyโ€ of that row should minus 10pcs. Alternatively, the system should create a new row in the table โ€œAvailable locationโ€ recording that available qty of product โ€œAโ€ in location โ€œ1L1Aโ€ is โ€œ-10โ€.

  5. Creating the table โ€œAvailable locationโ€ is essential because I want to create a virtual column (related available locations) in โ€œproductโ€ table. Such that when i click the product_detail page, the user can see the available location where he can find that particular product.

I would be so grateful if anyone could advise me how to solve this problem. Many thxxx

0 0 84
0 REPLIES 0
Top Labels in this Space