Database saving implemented

Now saves history with details. Also possible to save new StockItems.
Decreasing database quantity on purchase somewhat works, but is
currently deactivated.