Jump to content

Till Reciept Model


Recommended Posts

Hello,

I have been set a task for making a till receipt model for my ICT work. I got it to read from an INI database and display the values, but I can't seem to be able to make the Item Names refresh when the barcode values are changed.

Can someone tell me how to change the Item Names when I change the Barcode instead of refreshing all the time?

The Program:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ComboConstants.au3>

Global $Barcode0, $Barcode1, $Barcode2, $Barcode3, $Barcode4
Global $Status0, $Status1, $Status2, $Status3, $Status4
Global $ItemName0, $ItemName1, $ItemName2, $ItemName3, $ItemName4
Global $ItemCost0, $ItemCost1, $ItemCost2, $ItemCost3, $ItemCost4

$Typeness = 1 

GUICreate(" Reciept Generator", 400, 600, -1, -1)

$StoreNames = GUICtrlCreateLabel("The Computer Store", 0, 10, 300, 20, $SS_CENTER)
GuiCtrlSetFont( -1, 12, 600, 4, "Calibri")

#Region Barcode

GuiCtrlCreateLabel("Barcode No.", 10, 150, 75, 15)

$Barcode0 = GuiCtrlCreateCombo("", 10, 170, 75, 20, $CBS_DROPDOWNLIST)
$Barcode1 = GuiCtrlCreateCombo("", 10, 200, 75, 20, $CBS_DROPDOWNLIST)
$Barcode2 = GuiCtrlCreateCombo("", 10, 230, 75, 20, $CBS_DROPDOWNLIST)
$Barcode3 = GuiCtrlCreateCombo("", 10, 260, 75, 20, $CBS_DROPDOWNLIST)
$Barcode4 = GuiCtrlCreateCombo("", 10, 290, 75, 20, $CBS_DROPDOWNLIST)

#EndRegion Barcode

#Region Item Name

GuiCtrlCreateLabel("Item Name", 100, 150, 100, 15)

$Item0 = GUICtrlCreateLabel("", 100, 172, 100, 15)
$Item1 = GUICtrlCreateLabel("", 100, 202, 100, 15)
$Item2 = GUICtrlCreateLabel("", 100, 232, 100, 15)
$Item3 = GUICtrlCreateLabel("", 100, 262, 100, 15)
$Item4 = GUICtrlCreateLabel("", 100, 292, 100, 15)

#EndRegion Item Name

#Region Cost

GUICtrlCreateLabel("Cost", 210, 150, 50, 15)

$Cost0 = GUICtrlCreateLabel("", 210, 170, 50, 15)
$Cost1 = GUICtrlCreateLabel("", 210, 200, 50, 15)
$Cost2 = GUICtrlCreateLabel("", 210, 230, 50, 15)
$Cost3 = GUICtrlCreateLabel("", 210, 260, 50, 15)
$Cost4 = GUICtrlCreateLabel("", 210, 290, 50, 15)

#EndRegion Cost

#Region Quantity

GuiCtrlCreateLabel("Qty.", 270, 150, 25, 15)

$Qty0 = GuiCtrlCreateCombo("", 270, 170, 40, 20, $CBS_DROPDOWNLIST)
$Qty1 = GuiCtrlCreateCombo("", 270, 200, 40, 20, $CBS_DROPDOWNLIST)
$Qty2 = GuiCtrlCreateCombo("", 270, 230, 40, 20, $CBS_DROPDOWNLIST)
$Qty3 = GuiCtrlCreateCombo("", 270, 260, 40, 20, $CBS_DROPDOWNLIST)
$Qty4 = GuiCtrlCreateCombo("", 270, 290, 40, 20, $CBS_DROPDOWNLIST)

#EndRegion Quantity

#Region Price

GUICtrlCreateLabel("Price", 320, 150, 50, 15)

$Price0 = GUICtrlCreateLabel("", 320, 170, 50, 15)
$Price1 = GUICtrlCreateLabel("", 320, 200, 50, 15)
$Price2 = GUICtrlCreateLabel("", 320, 230, 50, 15)
$Price3 = GUICtrlCreateLabel("", 320, 260, 50, 15)
$Price4 = GUICtrlCreateLabel("", 320, 290, 50, 15)

#EndRegion Price

GUISetState(@SW_SHOW)

GetCodes()

Do
    $msg = GUIGetMsg()
    ManageAll()
Until $msg = $GUI_EVENT_CLOSE

Func ReadCode($Type)
    If $Type = 0 Then
        $Status0 = GuiCtrlRead($Barcode0)
        $ItemName0 = IniRead("Database.ini", "Items", $Status0, "")
        $ItemCost0 = IniRead("Database.ini", "Costs", $Status0, "")
        GuiCtrlSetData($Item0, $ItemName0)
        GuiCtrlSetData($Cost0, $ItemCost0)
    ElseIf $Type = 1 Then
        $Status1 = GuiCtrlRead($Barcode1)
        $ItemName1 = IniRead("Database.ini", "Items", $Status1, "")
        $ItemCost1 = IniRead("Database.ini", "Costs", $Status1, "")
        GuiCtrlSetData($Item1, $ItemName1)
        GuiCtrlSetData($Cost1, $ItemCost1)
    ElseIf $Type = 2 Then
        $Status2 = GuiCtrlRead($Barcode2)
        $ItemName2 = IniRead("Database.ini", "Items", $Status2, "")
        $ItemCost2 = IniRead("Database.ini", "Costs", $Status2, "")
        GuiCtrlSetData($Item2, $ItemName2)
        GuiCtrlSetData($Cost2, $ItemCost2)
    ElseIf $Type = 3 Then
        $Status3 = GuiCtrlRead($Barcode3)
        $ItemName3 = IniRead("Database.ini", "Items", $Status2, "")
        $ItemCost3 = IniRead("Database.ini", "Costs", $Status2, "")
        GuiCtrlSetData($Item3, $ItemName3)
        GuiCtrlSetData($Cost3, $ItemCost3)
    ElseIf $Type = 4 Then
        $Status4 = GuiCtrlRead($Barcode4)
        $ItemName4 = IniRead("Database.ini", "Items", $Status2, "")
        $ItemCost4 = IniRead("Database.ini", "Costs", $Status2, "")
        GuiCtrlSetData($Item4, $ItemName4)
        GuiCtrlSetData($Cost4, $ItemCost4)
    EndIf
EndFunc

Func GetCodes()
    $Barcodes = IniRead("Database.ini", "General", "Barcodes", "")
    GuiCtrlSetData($Barcode0, $Barcodes)
    GuiCtrlSetData($Barcode1, $Barcodes)
    GuiCtrlSetData($Barcode2, $Barcodes)
    GuiCtrlSetData($Barcode3, $Barcodes)
    GuiCtrlSetData($Barcode4, $Barcodes)
EndFunc

Func ManageAll()
    If $Status0 <> GuiCtrlRead($Barcode0) Then
        GuiCtrlSetData($Item0, $Status 0)
        ;ReadCode(0)
    ElseIf $Status1 <> GuiCtrlRead($Barcode1) Then
        GuiCtrlSetData($Item0, $Status 1)
        ;ReadCode(1)
    ElseIf $Status2 <> GuiCtrlRead($Barcode2) Then
        GuiCtrlSetData($Item0, $Status 2)
        ;ReadCode(2)
    ElseIf $Status3 <> GuiCtrlRead($Barcode3) Then
        GuiCtrlSetData($Item0, $Status 3)
        ;ReadCode(3)
    ElseIf $Status4 <> GuiCtrlRead($Barcode4) Then
        GuiCtrlSetData($Item0, $Status 4)
        ;ReadCode(4)
    EndIf
EndFunc

Database:

[General]
Barcodes=||00000001|00000002|00000003|00000004|00000005
StaffNames=||Administrator
StoreName=Something
[Items]
00000001=Item 1
00000002=Item 2
00000003=Item 3
00000004=Item 4
00000005=Item 5
[Costs]
00000001=$100.00
00000002=$200.00
00000003=$400.00
00000004=$800.00
00000005=$1600.00
Link to comment
Share on other sites

You can simply read the msg from the combo itself to know it's been triggered.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ComboConstants.au3>

Global $Barcode0, $Barcode1, $Barcode2, $Barcode3, $Barcode4
Global $Status0, $Status1, $Status2, $Status3, $Status4, $Status
Global $ItemName0, $ItemName1, $ItemName2, $ItemName3, $ItemName4
Global $ItemCost0, $ItemCost1, $ItemCost2, $ItemCost3, $ItemCost4

$Typeness = 1

GUICreate(" Reciept Generator", 400, 600, -1, -1)

$StoreNames = GUICtrlCreateLabel("The Computer Store", 0, 10, 300, 20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 600, 4, "Calibri")

#Region Barcode

GUICtrlCreateLabel("Barcode No.", 10, 150, 75, 15)

$Barcode0 = GUICtrlCreateCombo("", 10, 170, 75, 20, $CBS_DROPDOWNLIST)
$Barcode1 = GUICtrlCreateCombo("", 10, 200, 75, 20, $CBS_DROPDOWNLIST)
$Barcode2 = GUICtrlCreateCombo("", 10, 230, 75, 20, $CBS_DROPDOWNLIST)
$Barcode3 = GUICtrlCreateCombo("", 10, 260, 75, 20, $CBS_DROPDOWNLIST)
$Barcode4 = GUICtrlCreateCombo("", 10, 290, 75, 20, $CBS_DROPDOWNLIST)

#EndRegion Barcode

#Region Item Name

GUICtrlCreateLabel("Item Name", 100, 150, 100, 15)

$Item0 = GUICtrlCreateLabel("", 100, 172, 100, 15)
$Item1 = GUICtrlCreateLabel("", 100, 202, 100, 15)
$Item2 = GUICtrlCreateLabel("", 100, 232, 100, 15)
$Item3 = GUICtrlCreateLabel("", 100, 262, 100, 15)
$Item4 = GUICtrlCreateLabel("", 100, 292, 100, 15)

#EndRegion Item Name

#Region Cost

GUICtrlCreateLabel("Cost", 210, 150, 50, 15)

$Cost0 = GUICtrlCreateLabel("", 210, 170, 50, 15)
$Cost1 = GUICtrlCreateLabel("", 210, 200, 50, 15)
$Cost2 = GUICtrlCreateLabel("", 210, 230, 50, 15)
$Cost3 = GUICtrlCreateLabel("", 210, 260, 50, 15)
$Cost4 = GUICtrlCreateLabel("", 210, 290, 50, 15)

#EndRegion Cost

#Region Quantity

GUICtrlCreateLabel("Qty.", 270, 150, 25, 15)

$Qty0 = GUICtrlCreateCombo("", 270, 170, 40, 20, $CBS_DROPDOWNLIST)
$Qty1 = GUICtrlCreateCombo("", 270, 200, 40, 20, $CBS_DROPDOWNLIST)
$Qty2 = GUICtrlCreateCombo("", 270, 230, 40, 20, $CBS_DROPDOWNLIST)
$Qty3 = GUICtrlCreateCombo("", 270, 260, 40, 20, $CBS_DROPDOWNLIST)
$Qty4 = GUICtrlCreateCombo("", 270, 290, 40, 20, $CBS_DROPDOWNLIST)

#EndRegion Quantity

#Region Price

GUICtrlCreateLabel("Price", 320, 150, 50, 15)

$Price0 = GUICtrlCreateLabel("", 320, 170, 50, 15)
$Price1 = GUICtrlCreateLabel("", 320, 200, 50, 15)
$Price2 = GUICtrlCreateLabel("", 320, 230, 50, 15)
$Price3 = GUICtrlCreateLabel("", 320, 260, 50, 15)
$Price4 = GUICtrlCreateLabel("", 320, 290, 50, 15)

#EndRegion Price

GUISetState(@SW_SHOW)

GetCodes()

Do
    $msg = GUIGetMsg()
    ManageAll($msg)
Until $msg = $GUI_EVENT_CLOSE

Func ReadCode($Type)
    If $Type = 0 Then
        $Status0 = GUICtrlRead($Barcode0)
        $ItemName0 = IniRead("Database.ini", "Items", $Status0, "")
        $ItemCost0 = IniRead("Database.ini", "Costs", $Status0, "")
        GUICtrlSetData($Item0, $ItemName0)
        GUICtrlSetData($Cost0, $ItemCost0)
    ElseIf $Type = 1 Then
        $Status1 = GUICtrlRead($Barcode1)
        $ItemName1 = IniRead("Database.ini", "Items", $Status1, "")
        $ItemCost1 = IniRead("Database.ini", "Costs", $Status1, "")
        GUICtrlSetData($Item1, $ItemName1)
        GUICtrlSetData($Cost1, $ItemCost1)
    ElseIf $Type = 2 Then
        $Status2 = GUICtrlRead($Barcode2)
        $ItemName2 = IniRead("Database.ini", "Items", $Status2, "")
        $ItemCost2 = IniRead("Database.ini", "Costs", $Status2, "")
        GUICtrlSetData($Item2, $ItemName2)
        GUICtrlSetData($Cost2, $ItemCost2)
    ElseIf $Type = 3 Then
        $Status3 = GUICtrlRead($Barcode3)
        $ItemName3 = IniRead("Database.ini", "Items", $Status2, "")
        $ItemCost3 = IniRead("Database.ini", "Costs", $Status2, "")
        GUICtrlSetData($Item3, $ItemName3)
        GUICtrlSetData($Cost3, $ItemCost3)
    ElseIf $Type = 4 Then
        $Status4 = GUICtrlRead($Barcode4)
        $ItemName4 = IniRead("Database.ini", "Items", $Status2, "")
        $ItemCost4 = IniRead("Database.ini", "Costs", $Status2, "")
        GUICtrlSetData($Item4, $ItemName4)
        GUICtrlSetData($Cost4, $ItemCost4)
    EndIf
EndFunc   ;==>ReadCode

Func GetCodes()
    $Barcodes = IniRead("Database.ini", "General", "Barcodes", "")
    GUICtrlSetData($Barcode0, $Barcodes)
    GUICtrlSetData($Barcode1, $Barcodes)
    GUICtrlSetData($Barcode2, $Barcodes)
    GUICtrlSetData($Barcode3, $Barcodes)
    GUICtrlSetData($Barcode4, $Barcodes)
EndFunc   ;==>GetCodes

Func ManageAll($msg)

    Select
        Case $msg = $Barcode0
            GUICtrlSetData($Item0, IniRead('Database.ini', 'Items', GUICtrlRead($Barcode0), ''))
        Case $msg = $Barcode1
            GUICtrlSetData($Item1, IniRead('Database.ini', 'Items', GUICtrlRead($Barcode1), ''))
        Case $msg = $Barcode2
            GUICtrlSetData($Item2, IniRead('Database.ini', 'Items', GUICtrlRead($Barcode2), ''))
        Case $msg = $Barcode3
            GUICtrlSetData($Item3, IniRead('Database.ini', 'Items', GUICtrlRead($Barcode3), ''))
        Case $msg = $Barcode4
            GUICtrlSetData($Item4, IniRead('Database.ini', 'Items', GUICtrlRead($Barcode4), ''))
    EndSelect

EndFunc   ;==>ManageAll
Link to comment
Share on other sites

It is "i" before "e" except after "c".

Spell it "receipt".

Hope this helps.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ComboConstants.au3>

Local $Barcodes, $Barcode0, $Barcode1, $Barcode2, $Barcode3, $Barcode4
Local $Status0, $Status1, $Status2, $Status3, $Status4, $Status
Local $ItemCost0, $ItemCost1, $ItemCost2, $ItemCost3, $ItemCost4
Local $Cost0, $Cost1, $Cost2, $Cost3, $Cost4, $Item0, $Item1, $Item2, $Item3, $Item4
Local $Qty0, $Qty1, $Qty2, $Qty3, $Qty4
Local $Price0, $Price1, $Price2, $Price3, $Price4, $StoreNames, $msg
Local $QtyItem = "2|3|4|5|6|7|8|9|10|11|12", $Typeness = 1

GUICreate(" Reciept Generator", 400, 600, -1, -1)

$StoreNames = GUICtrlCreateLabel("The Computer Store", 0, 10, 300, 20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 600, 4, "Calibri")

#region Barcode

GUICtrlCreateLabel("Barcode No.", 10, 150, 75, 15)
$Barcodes = IniRead("Database.ini", "General", "Barcodes", "")
$Barcode0 = GUICtrlCreateCombo("", 10, 170, 75, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($Barcode0, $Barcodes)
$Barcode1 = GUICtrlCreateCombo("", 10, 200, 75, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($Barcode1, $Barcodes)
$Barcode2 = GUICtrlCreateCombo("", 10, 230, 75, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($Barcode2, $Barcodes)
$Barcode3 = GUICtrlCreateCombo("", 10, 260, 75, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($Barcode3, $Barcodes)
$Barcode4 = GUICtrlCreateCombo("", 10, 290, 75, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($Barcode4, $Barcodes)

#endregion Barcode

#region Item Name

GUICtrlCreateLabel("Item Name", 100, 150, 100, 15)

$Item0 = GUICtrlCreateLabel("", 100, 172, 100, 15)
$Item1 = GUICtrlCreateLabel("", 100, 202, 100, 15)
$Item2 = GUICtrlCreateLabel("", 100, 232, 100, 15)
$Item3 = GUICtrlCreateLabel("", 100, 262, 100, 15)
$Item4 = GUICtrlCreateLabel("", 100, 292, 100, 15)

#endregion Item Name

#region Cost

GUICtrlCreateLabel("Cost", 210, 150, 50, 15)

$Cost0 = GUICtrlCreateLabel("", 210, 170, 50, 15)
$Cost1 = GUICtrlCreateLabel("", 210, 200, 50, 15)
$Cost2 = GUICtrlCreateLabel("", 210, 230, 50, 15)
$Cost3 = GUICtrlCreateLabel("", 210, 260, 50, 15)
$Cost4 = GUICtrlCreateLabel("", 210, 290, 50, 15)

#endregion Cost

#region Quantity

GUICtrlCreateLabel("Qty.", 270, 150, 25, 15)

$Qty0 = GUICtrlCreateCombo("1", 270, 170, 40, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $QtyItem)
$Qty1 = GUICtrlCreateCombo("1", 270, 200, 40, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $QtyItem)
$Qty2 = GUICtrlCreateCombo("1", 270, 230, 40, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $QtyItem)
$Qty3 = GUICtrlCreateCombo("1", 270, 260, 40, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $QtyItem)
$Qty4 = GUICtrlCreateCombo("1", 270, 290, 40, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $QtyItem)

#endregion Quantity

#region Price

GUICtrlCreateLabel("Price", 320, 150, 50, 15)

$Price0 = GUICtrlCreateLabel("", 320, 170, 50, 15)
$Price1 = GUICtrlCreateLabel("", 320, 200, 50, 15)
$Price2 = GUICtrlCreateLabel("", 320, 230, 50, 15)
$Price3 = GUICtrlCreateLabel("", 320, 260, 50, 15)
$Price4 = GUICtrlCreateLabel("", 320, 290, 50, 15)

#endregion Price

GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    Switch $msg
    Case $Barcode0, $Qty0
    $Status0 = GUICtrlRead($Barcode0)
    $ItemCost0 = IniRead("Database.ini", "Costs", $Status0, "")
    GUICtrlSetData($Item0, IniRead("Database.ini", "Items", $Status0, ""))
    GUICtrlSetData($Cost0, $ItemCost0)
    GUICtrlSetData($Price0, "$" & GUICtrlRead($Qty0) * StringTrimLeft($ItemCost0, 1))

    Case $Barcode1, $Qty1
    $Status1 = GUICtrlRead($Barcode1)
    $ItemCost1 = IniRead("Database.ini", "Costs", $Status1, "")
    GUICtrlSetData($Item1, IniRead("Database.ini", "Items", $Status1, ""))
    GUICtrlSetData($Cost1, $ItemCost1)
    GUICtrlSetData($Price1, "$" & GUICtrlRead($Qty1) * StringTrimLeft($ItemCost1, 1))

    Case $Barcode2, $Qty2
    $Status2 = GUICtrlRead($Barcode2)
    $ItemCost2 = IniRead("Database.ini", "Costs", $Status2, "")
    GUICtrlSetData($Item2, IniRead("Database.ini", "Items", $Status2, ""))
    GUICtrlSetData($Cost2, $ItemCost2)
    GUICtrlSetData($Price2, "$" & GUICtrlRead($Qty2) * StringTrimLeft($ItemCost2, 1))

    Case $Barcode3, $Qty3
    $Status3 = GUICtrlRead($Barcode3)
    $ItemCost3 = IniRead("Database.ini", "Costs", $Status3, "")
    GUICtrlSetData($Item3, IniRead("Database.ini", "Items", $Status3, ""))
    GUICtrlSetData($Cost3, $ItemCost3)
    GUICtrlSetData($Price3, "$" & GUICtrlRead($Qty3) * StringTrimLeft($ItemCost3, 1))

    Case $Barcode4, $Qty4
    $Status4 = GUICtrlRead($Barcode4)
    $ItemCost4 = IniRead("Database.ini", "Costs", $Status4, "")
    GUICtrlSetData($Item4, IniRead("Database.ini", "Items", $Status4, ""))
    GUICtrlSetData($Cost4, $ItemCost4)
    GUICtrlSetData($Price4, "$" & GUICtrlRead($Qty4) * StringTrimLeft($ItemCost4, 1))

    EndSwitch
Until $msg = $GUI_EVENT_CLOSE
Edited by Malkey
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...