In Memory database

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

In Memory database

Post by AndyGable »

Hi everyone,

I have in my windows app a list of items that are scanned and I can remove and add items so when the receipt is printed anything that was voided does not show

So I was thinking maybe to replicate this function in the Linux app I would use a in memory database

So my question is how to make a in memory database? Does anyone have any example code or a website that shows how to do this?

Thanks for any advice

Andy
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: In Memory database

Post by cogier »

Can you help us understand what you are trying to achieve so we can help you: -
I have in my windows app
- What is the name of this app?
...so when the receipt is printed...
- Is this a till receipt for a customer or...?
... list of items that are scanned...
- Barcodes, images. What is scanned?
... memory database...
- Do you mean that the item(s) will only exist while the computer is on, or am I missing something?
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: In Memory database

Post by AndyGable »

Hi Cogier,

Please find replays to your questions
- What is the name of this app?
My app is called NPoS Point of Sale
- Is this a till receipt for a customer or...?
This is a receipit that is printed for the customer
Barcodes, images. What is scanned?
The layout of the current in memory list is

LineNumber,Barcode,Description,Qty,UnitPirce,LinePrice,VAT

the idea is (on the windows version) when a Item is Deleted (voided) from the sale the Listbox that holds the item list would remove the item from the list (say they remove a bottle of water that is at line 4)
- Do you mean that the item(s) will only exist while the computer is on, or am I missing something?
Yes this in memory database is only in use while the PoS is active (everything else is stored on the Main Database server)

The idea is when a recipit is generated at the end of the sale the it would look like this


WELCOME TO THE STORE

VALUE ORANGE JUICE £0.35
------------------------------------------
TOTAL £0.35
CASH £0.40
CHANGE £0.05
------------------------------------------

and not Like this


WELCOME TO THE STORE

VALUE APPLE JUICE £0.50
VALUE ORANGE JUICE £0.35
**Next Item is voided**
VALUE APPLE JUICE -£0.50
------------------------------------------
TOTAL £0.35
CASH £0.40
CHANGE £0.05
------------------------------------------


This is the code I am using in my Windows Appliactions to create the List that is used for the Printed daya

Code: Select all

Public Class LineItem

    Private _itemType As String
    Private _itemMode As String

    Private _iD As Integer
    Private _itemBarcodeNumber As String

    Private _line1 As String
    Private _line2 As String
    Private _line3 As String
    Private _line4 As String
    Private _price As Decimal
    Private _qtySold As Integer
    Private _linePrice As Decimal
    Private _vATID As String

    Private _discountName As String
    Private _discountValue As Decimal

    Private _lineNumber As Integer

    Private _guranteeDetails As String

    Private _westernUnionSendingValue As Decimal
    Private _westernUnionFee As Decimal

    Private _TransactionId As Integer

    Private _SaleLocationNumber As String

    Public Property ItemType() As String
        Get
            Return _itemType
        End Get
        Set(ByVal value As String)
            _itemType = value
        End Set
    End Property

    Public Property ItemMode() As String
        Get
            Return _itemMode
        End Get
        Set(ByVal value As String)
            _itemMode = value
        End Set
    End Property

    Public Property ID() As Integer
        Get
            Return _iD
        End Get
        Set(ByVal value As Integer)
            _iD = value
        End Set
    End Property

    Public Property ItemBarcodeNumber() As String
        Get
            Return _itemBarcodeNumber
        End Get
        Set(ByVal value As String)
            _itemBarcodeNumber = value
        End Set
    End Property

    Public Property Line1() As String
        Get
            Return _line1
        End Get
        Set(ByVal value As String)
            _line1 = value
        End Set
    End Property

    Public Property Line2() As String
        Get
            Return _line2
        End Get
        Set(ByVal value As String)
            _line2 = value
        End Set
    End Property

    Public Property Line3() As String
        Get
            Return _line3
        End Get
        Set(ByVal value As String)
            _line3 = value
        End Set
    End Property

    Public Property Line4() As String
        Get
            Return _line4
        End Get
        Set(ByVal value As String)
            _line4 = value
        End Set
    End Property

    Public Property Price() As Decimal
        Get
            Return _price
        End Get
        Set(ByVal value As Decimal)
            _price = value
        End Set
    End Property

    Public Property LinePrice() As Decimal
        Get
            Return _linePrice
        End Get
        Set(ByVal value As Decimal)
            _linePrice = value
        End Set
    End Property

    Public Property VATID() As String
        Get
            Return _vATID
        End Get
        Set(ByVal value As String)
            _vATID = value
        End Set
    End Property

    Public Property DiscountName() As String
        Get
            Return _discountName
        End Get
        Set(ByVal value As String)
            _discountName = value
        End Set
    End Property

    Public Property DiscountValue() As Decimal
        Get
            Return _discountValue
        End Get
        Set(ByVal value As Decimal)
            _discountValue = value
        End Set
    End Property

    Public Property LineNumber() As Integer
        Get
            Return _lineNumber
        End Get
        Set(ByVal value As Integer)
            _lineNumber = value
        End Set
    End Property

    Public Property QtySold() As Decimal
        Get
            Return _qtySold
        End Get
        Set(ByVal value As Decimal)
            _qtySold = value
        End Set
    End Property

    Public Property GuranteeDetails() As String
        Get
            Return _guranteeDetails
        End Get
        Set(ByVal value As String)
            _guranteeDetails = value
        End Set
    End Property

    Public Property WesternUnionSendingValue() As Decimal
        Get
            Return _westernUnionSendingValue
        End Get
        Set(ByVal value As Decimal)
            _westernUnionSendingValue = value
        End Set
    End Property

    Public Property WesternUnionFee() As Decimal
        Get
            Return _westernUnionFee
        End Get
        Set(ByVal value As Decimal)
            _westernUnionFee = value
        End Set
    End Property

    Public Property TransactionIDNumber() As Integer
        Get
            Return _TransactionId
        End Get
        Set(ByVal value As Integer)
            _TransactionId = value
        End Set
    End Property

    Public Property SaleLocationNumber() As String
        Get
            Return _SaleLocationNumber
        End Get
        Set(ByVal value As String)
            _SaleLocationNumber = value
        End Set
    End Property

    Public Sub New( _
            ByVal aItemTypeLocal As String, _
            ByVal aItemID As Integer, _
            ByVal aItemBarcode As String, _
            ByVal aLine1_Description As String, _
            ByVal aLine2_Description As String, _
            ByVal aLine3_Description As String, _
            ByVal aLine4_Description As String, _
            ByVal aItemPrice As Decimal, _
            ByVal aLinePrice_Local As Decimal, _
            ByVal aItemVATCodeLocal As String, _
            ByVal aLocalLineNumber As Integer, _
            ByVal alocalQtySold As Integer, _
            ByVal alocalDiscountName As String, _
            ByVal aLocalDiscountValue As Integer, _
            ByVal aLocalGuranteeDetails As String, _
            ByVal aLocalWesternUnionSendingValue As Decimal, _
            ByVal aLocalWesternUnionSendingFee As Decimal, _
            ByVal aSaleLocationNumber As String)

        ItemType = aItemTypeLocal
        ItemMode = SaleMode
        ID = aItemID
        ItemBarcodeNumber = aItemBarcode
        Line1 = aLine1_Description
        Line2 = aLine2_Description
        Line3 = aLine3_Description
        Line4 = aLine4_Description
        Price = aItemPrice
        LinePrice = aLinePrice_Local
        VATID = aItemVATCodeLocal
        DiscountName = alocalDiscountName
        DiscountValue = aLocalDiscountValue
        LineNumber = aLocalLineNumber
        QtySold = alocalQtySold
        GuranteeDetails = aLocalGuranteeDetails

        WesternUnionSendingValue = aLocalWesternUnionSendingValue
        WesternUnionFee = aLocalWesternUnionSendingFee

        SaleLocationNumber = aSaleLocationNumber
    End Sub
End Class
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: In Memory database

Post by cogier »

I have started a program using the methods I am familiar with. I have not finished with the 'Receipt' yet. I just want to know that I am on the right track. There is a CSV file that contains the 'Database' which is loaded into arrays when the program is started. It is in the program's folder. This can be edited in Calc or even Gambas. I found that if you scan barcodes into Google you get straight to the product, so it was easy to copy a few items in the kitchen and create this file. The prices are just a wild guess, note that they are stored as pence not pounds, this is deliberate as there is less chance of rounding errors.

Image
POS_Tool-0.0.1.tar.gz
(13.19 KiB) Downloaded 188 times
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: In Memory database

Post by AndyGable »

cogier wrote: Saturday 26th June 2021 11:34am I have started a program using the methods I am familiar with. I have not finished with the 'Receipt' yet. I just want to know that I am on the right track. There is a CSV file that contains the 'Database' which is loaded into arrays when the program is started. It is in the program's folder. This can be edited in Calc or even Gambas. I found that if you scan barcodes into Google you get straight to the product, so it was easy to copy a few items in the kitchen and create this file. The prices are just a wild guess, note that they are stored as pence not pounds, this is deliberate as there is less chance of rounding errors.

Image

POS_Tool-0.0.1.tar.gz
I like how that is looking Cogier so I would say you are on the right track.

What I do with the receipt is once the sale is completed I use the temp file that holds the current sale data to generate the receipit.
Post Reply