Skip to content

Complicated Usage

Alex Billson edited this page May 3, 2016 · 2 revisions

The contents of this page are not necessary functions of SalesC but may be needed to edit the less accessible aspects of SalesC

##Structure of salesc.db dbstructure

The image above shows the structure of the salesc.db database, as you can see it really only comprises of three tables:

  • Sales : Holds all the items of a sale, links them together with a sale_group
  • Payments : Each payment is linked to a sale_group, holds data like amount and payment type
  • Products : The foundation of retail, product details are held in the product table

This level of simplicity is all there for a reason, SalesC designed around the idea that the most basic form of a POS system revolves around these three elements. It is ideal for the sake of the program's functionality that any expansion for SalesC is based on one of these three elements and that the associated functions are updated to include these expansions. This is not to say that adding a value for a table is hard, in fact it's as easy as modifying the db_create method to include more fields. The challenge however comes when modifying the code of SalesC to include this new piece of data and so this is made easier by the clearly defined database structure of the program.

##Change auto-iteration of sale_id autoiteratevalue

Changing the value of the constant auto_increment in mainwindow.c will change how products are added to the database. By default (as mentioned in installation) the value of auto_increment is 0 which means that sales require a unique, explicitly set, sale_id. If this is changed to 1, new products will automatically be assigned an ID. There are a few complications to this however:

  • This can only be done with the source code variant of SalesC at the moment
  • The make command must be run afterwards to update the details
  • The salesc.db file must be deleted after the change has been made, this will result in a loss of all data relating to SalesC

##Using the SQLite Database System SalesC uses SQLite as it's storage system, if you know basic SQL this means that you are able to query the salesc.db file as well modify the structure of the database. Whilst you can download SQLite in multiple forms here you can also download the cross-platform, open source tool SQLite Browser. The tool is a GUI based application which allows for easy modification of tables, inserting/deleting of entries and SQL queries; it was the tool which I used throughout the development of SalesC. Consult the various queries and statements in salesbase.c if you want to learn more about how the program connects with the database. For example, the db_create function:

dbinit