Lazarus
Programming => Databases => Topic started by: Whillis on December 06, 2018, 02:31:02 am
-
As i said in another topic, im a beginner with databases and this is actually something to test myself into making a database, its like a system for a shop, ill choose a type of Monitor, Computer case and keyboard (one of each) to make it into a full Pc showing the total price.
I got a database connected to lazarus with workbench, so far i got three tables (Monitor, Computer case and Keyboard) each one with an id and a price, these three tables work into making another table (PC) that combines those 3 Id's, but now i want to also sum up the prices of the 3 components and make a total price in the PC table but i can't find how to code it out..
Ps. Im using Data controls (TDBGrids, TDBLLookupComboBoxes, etc) to show those tables data.
-
While you're making the combined "PC" table, you can also get each price and sum them up to make a total. Save it with the combined Id, if you want. Doesn't sound very difficult, where are you finding problems? (And, what problems?)
ETA: The data controls matter very little in this context. What is really important are the data sources.
-
The components' Id's (monitor,keyboard. case...) will be in the table PC, which creates an Id for this group of id's setting an order (something like: | pc_ID = M_id | C_id | K_id | ),
I didn't explained mysel very well but there's already 4 tables i made in workbench: Monitor/Computer case/Keyboard/PC, the issue is to make another column in the pc table with the total price of the 3 components (Monitor/C.Case/Keyboard), now i dont know how it could be done in lazarus or already make a column 'Total Price' for the PC table in workbench and just set a code for summing up the values.
The problem is i dont really know how it would be done, i thought of making a button but i have no idea of what to code inside of it to call a total price value and place it into a total price .
basically i dont know how to put it into coding.
-
Frankly speaking, this sounds like a very basic setup. There are lots of information on the wiki about databases, starting with the Database portal (http://wiki.freepascal.org/Portal:Databases) and the SQLdb Tutorial (http://wiki.freepascal.org/SQLdb_Tutorial0). You may want to read a little before starting to code. And google for a good SQL tutorial while you're at it ;)
-
How do you store the founded records (Monitor/C.Case/Keyboard) in your application?