BoonPek Posted June 18, 2010 Share Posted June 18, 2010 (edited) Hello, I've just finished making my Till Receipt Generator for my ICT class. It was meant to be done on Microsoft Excel and using macros, but my teacher wants me to do it in my own way. Please evaluate it, and add stuff to it if you want to. Thanks. Credits go to Malkey and stampy for assisting me in the early stages. Code: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <File.au3> Global $Barcodes, $Barcode0, $Barcode1, $Barcode2, $Barcode3, $Barcode4, $Barcode5, $Barcode6, $Barcode7, $Barcode8, $Barcode9 Global $Status0, $Status1, $Status2, $Status3, $Status4, $Status5, $Status6, $Status7, $Status8, $Status9, $Status Global $ItemCost0, $ItemCost1, $ItemCost2, $ItemCost3, $ItemCost4, $ItemCost5, $ItemCost6, $ItemCost7, $ItemCost8, $ItemCost9 Global $Cost0, $Cost1, $Cost2, $Cost3, $Cost4, $Cost5, $Cost6, $Cost7, $Cost8, $Cost9 Global $Item0, $Item1, $Item2, $Item3, $Item4, $Item5, $Item6, $Item7, $Item8, $Item9 Global $Qty0, $Qty1, $Qty2, $Qty3, $Qty4, $Qty5, $Qty6, $Qty7, $Qty8, $Qty9, $StaffNames, $StaffList Global $Price0, $Price1, $Price2, $Price3, $Price4, $Price5, $Price6, $Price7, $Price8, $Price9, $StoreNames, $StoreName, $StaffNames Global $Total, $Total0, $Total1, $Total2, $Total3, $Total4, $Total5, $Total6, $Total7, $Total8, $Total9, $TotalAmount Global $QtyItem = "|1|2|3|4|5|6|7|8|9|10", $CashAmount, $ChangeAmount, $TotalAmt, $Change, $Cash, $Timer Global $ItemName0, $ItemName1, $ItemName2, $ItemName3, $ItemName4, $ItemName5, $ItemName6, $ItemName7, $ItemName8, $ItemName9 Global $QtyState0, $QtyState1, $QtyState2, $QtyState3, $QtyState4, $QtyState5, $QtyState6, $QtyState7, $QtyState8, $QtyState9 Global $ClearBtn, $PrintBtn, $Spaces, $StarLine, $Stars, $MainGUI, $msg, $msg1, $SetData, $ClrData Global $Name0, $Name1, $Name2, $Name3, $Name4, $Name5, $Name6, $Name7, $Name8, $Name9 Global $Money0, $Money1, $Money2, $Money3, $Money4, $Money5, $Money6, $Money7, $Money8, $Money9 Global $StaffData0, $StaffData1, $StaffData2, $Staff, $Staff0, $Staff1, $Staff2, $Store $MainGUI = GUICreate("Reciept Generator", 400, 600, -1, -1) $StoreName = IniRead("Database.ini", "General", "StoreName", "") $StoreNames = GUICtrlCreateLabel($StoreName, 0, 10, 400, 20, $SS_CENTER) GUICtrlSetFont(-1, 12, 600, 4, "Calibri") GUICtrlCreateGroup("", 10, 40, 380, 45) GUICtrlCreateLabel("Staff Name:", 15, 55, 130, 20) $StaffList = IniRead("Database.ini", "General", "StaffNames", "") $StaffNames = GUICtrlCreateCombo("", 200, 55, 180, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($StaffNames, $StaffList) GUICtrlCreateGroup("", 10, 85, 380, 50) GUICtrlCreateLabel("Date:", 15, 95, 130, 15) GUICtrlCreateLabel("Time:", 15, 115, 130, 15) $Date = GUICtrlCreateLabel("", 200, 95, 130, 15) $Time = GUICtrlCreateLabel("", 200, 115, 130, 15) #Region Barcode GUICtrlCreateLabel("Barcode No.", 10, 150, 75, 15) $Barcodes = IniRead("Database.ini", "General", "Barcodes", "") $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) $Barcode5 = GUICtrlCreateCombo("", 10, 320, 75, 20, $CBS_DROPDOWNLIST) $Barcode6 = GUICtrlCreateCombo("", 10, 350, 75, 20, $CBS_DROPDOWNLIST) $Barcode7 = GUICtrlCreateCombo("", 10, 380, 75, 20, $CBS_DROPDOWNLIST) $Barcode8 = GUICtrlCreateCombo("", 10, 410, 75, 20, $CBS_DROPDOWNLIST) $Barcode9 = GUICtrlCreateCombo("", 10, 440, 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) $Item5 = GUICtrlCreateLabel("", 100, 322, 100, 15) $Item6 = GUICtrlCreateLabel("", 100, 352, 100, 15) $Item7 = GUICtrlCreateLabel("", 100, 382, 100, 15) $Item8 = GUICtrlCreateLabel("", 100, 412, 100, 15) $Item9 = GUICtrlCreateLabel("", 100, 442, 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) $Cost5 = GUICtrlCreateLabel("", 210, 320, 50, 15) $Cost6 = GUICtrlCreateLabel("", 210, 350, 50, 15) $Cost7 = GUICtrlCreateLabel("", 210, 380, 50, 15) $Cost8 = GUICtrlCreateLabel("", 210, 410, 50, 15) $Cost9 = GUICtrlCreateLabel("", 210, 440, 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) $Qty5 = GUICtrlCreateCombo("", 270, 320, 40, 20, $CBS_DROPDOWNLIST) $Qty6 = GUICtrlCreateCombo("", 270, 350, 40, 20, $CBS_DROPDOWNLIST) $Qty7 = GUICtrlCreateCombo("", 270, 380, 40, 20, $CBS_DROPDOWNLIST) $Qty8 = GUICtrlCreateCombo("", 270, 410, 40, 20, $CBS_DROPDOWNLIST) $Qty9 = GUICtrlCreateCombo("", 270, 440, 40, 20, $CBS_DROPDOWNLIST) #EndRegion Quantity #Region Price GUICtrlCreateLabel("Price", 320, 150, 60, 15) $Price0 = GUICtrlCreateLabel("", 320, 170, 60, 15) $Price1 = GUICtrlCreateLabel("", 320, 200, 60, 15) $Price2 = GUICtrlCreateLabel("", 320, 230, 60, 15) $Price3 = GUICtrlCreateLabel("", 320, 260, 60, 15) $Price4 = GUICtrlCreateLabel("", 320, 290, 60, 15) $Price5 = GUICtrlCreateLabel("", 320, 320, 60, 15) $Price6 = GUICtrlCreateLabel("", 320, 350, 60, 15) $Price7 = GUICtrlCreateLabel("", 320, 380, 60, 15) $Price8 = GUICtrlCreateLabel("", 320, 410, 60, 15) $Price9 = GUICtrlCreateLabel("", 320, 440, 60, 15) #EndRegion Price #Region Total GUICtrlCreateLabel("Total:", 270, 480, 40, 15) $TotalAmount = GUICtrlCreateLabel("", 320, 480, 60, 15) GUICtrlCreateLabel("Cash:", 270, 510, 40, 15) GUICtrlCreateLabel("$", 320, 510, 7, 15) $CashAmount = GUICtrlCreateInput("", 330, 510, 50, 20, $ES_NUMBER) GUICtrlCreateLabel("Change:", 270, 530, 40, 15) $ChangeAmount = GUICtrlCreateLabel("", 320, 530, 60, 15) #EndRegion Total $ClearBtn = GUICtrlCreateButton("Clear All", 40, 565, 100, 25) $PrintBtn = GUICtrlCreateButton("Print", 150, 565, 100, 25) $SetBtn = GUICtrlCreateButton("Set Data", 260, 565, 100, 25) ClearAll() GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() Switch $msg Case $Barcode0, $Qty0 $Status0 = GUICtrlRead($Barcode0) $QtyState0 = GUICtrlRead($Qty0) $ItemCost0 = IniRead("Database.ini", "Costs", $Status0, "") $ItemName0 = IniRead("Database.ini", "Items", $Status0, "") GUICtrlSetData($Item0, $ItemName0) GUICtrlSetData($Cost0, "$" & $ItemCost0) If $Status0 = "" Then $Total0 = "" GUICtrlSetData($Qty0, "", "") GUICtrlSetData($Price0, "") GUICtrlSetData($Cost0, "") Else If $QtyState0 = "" Then $QtyState0 = 1 $Total0 = $ItemCost0 GUICtrlSetData($Qty0, $QtyItem, "1") GUICtrlSetData($Price0, "$" & $ItemCost0) Else $Total0 = $QtyState0 * $ItemCost0 GUICtrlSetData($Qty0, $QtyItem, $QtyState0) GUICtrlSetData($Price0, "$" & $Total0) EndIf EndIf TotalCount() Case $Barcode1, $Qty1 $Status1 = GUICtrlRead($Barcode1) $QtyState1 = GUICtrlRead($Qty1) $ItemCost1 = IniRead("Database.ini", "Costs", $Status1, "") $ItemName1 = IniRead("Database.ini", "Items", $Status1, "") GUICtrlSetData($Item1, $ItemName1) GUICtrlSetData($Cost1, "$" & $ItemCost1) If $Status1 = "" Then $Total1 = "" GUICtrlSetData($Qty1, "", "") GUICtrlSetData($Price1, "") GUICtrlSetData($Cost1, "") Else If $QtyState1 = "" Then $QtyState1 = 1 $Total1 = $ItemCost1 GUICtrlSetData($Qty1, $QtyItem, "1") GUICtrlSetData($Price1, "$" & $ItemCost1) Else $Total1 = $QtyState1 * $ItemCost1 GUICtrlSetData($Qty1, $QtyItem, $QtyState1) GUICtrlSetData($Price1, "$" & $Total1) EndIf EndIf TotalCount() Case $Barcode2, $Qty2 $Status2 = GUICtrlRead($Barcode2) $QtyState2 = GUICtrlRead($Qty2) $ItemCost2 = IniRead("Database.ini", "Costs", $Status2, "") $ItemName2 = IniRead("Database.ini", "Items", $Status2, "") GUICtrlSetData($Item2, $ItemName2) GUICtrlSetData($Cost2, "$" & $ItemCost2) If $Status2 = "" Then $Total2 = "" GUICtrlSetData($Qty2, "", "") GUICtrlSetData($Price2, "") GUICtrlSetData($Cost2, "") Else If $QtyState2 = "" Then $QtyState2 = 1 $Total2 = $ItemCost2 GUICtrlSetData($Qty2, $QtyItem, "1") GUICtrlSetData($Price2, "$" & $ItemCost2) Else $Total2 = $QtyState2 * $ItemCost2 GUICtrlSetData($Qty2, $QtyItem, $QtyState2) GUICtrlSetData($Price2, "$" & $Total2) EndIf EndIf TotalCount() Case $Barcode3, $Qty3 $Status3 = GUICtrlRead($Barcode3) $QtyState3 = GUICtrlRead($Qty3) $ItemCost3 = IniRead("Database.ini", "Costs", $Status3, "") $ItemName3 = IniRead("Database.ini", "Items", $Status3, "") GUICtrlSetData($Item3, $ItemName3) GUICtrlSetData($Cost3, "$" & $ItemCost3) If $Status3 = "" Then $Total3 = "" GUICtrlSetData($Qty3, "", "") GUICtrlSetData($Price3, "") GUICtrlSetData($Cost3, "") Else If $QtyState3 = "" Then $QtyState3 = 1 $Total3 = $ItemCost3 GUICtrlSetData($Qty3, $QtyItem, "1") GUICtrlSetData($Price3, "$" & $ItemCost3) Else $Total3 = $QtyState3 * $ItemCost3 GUICtrlSetData($Qty3, $QtyItem, $QtyState3) GUICtrlSetData($Price3, "$" & $Total3) EndIf EndIf TotalCount() Case $Barcode4, $Qty4 $Status4 = GUICtrlRead($Barcode4) $QtyState4 = GUICtrlRead($Qty4) $ItemCost4 = IniRead("Database.ini", "Costs", $Status4, "") $ItemName4 = IniRead("Database.ini", "Items", $Status4, "") GUICtrlSetData($Item4, $ItemName4) GUICtrlSetData($Cost4, "$" & $ItemCost4) If $Status4 = "" Then $Total4 = "" GUICtrlSetData($Qty4, "", "") GUICtrlSetData($Price4, "") GUICtrlSetData($Cost4, "") Else If $QtyState4 = "" Then $QtyState4 = 1 $Total4 = $ItemCost4 GUICtrlSetData($Qty4, $QtyItem, "1") GUICtrlSetData($Price4, "$" & $ItemCost4) Else $Total4 = $QtyState4 * $ItemCost4 GUICtrlSetData($Qty4, $QtyItem, $QtyState4) GUICtrlSetData($Price4, "$" & $Total4) EndIf EndIf TotalCount() Case $Barcode5, $Qty5 $Status5 = GUICtrlRead($Barcode5) $QtyState5 = GUICtrlRead($Qty5) $ItemCost5 = IniRead("Database.ini", "Costs", $Status5, "") $ItemName5 = IniRead("Database.ini", "Items", $Status5, "") GUICtrlSetData($Item5, $ItemName5) GUICtrlSetData($Cost5, "$" & $ItemCost5) If $Status5 = "" Then $Total5 = "" GUICtrlSetData($Qty5, "", "") GUICtrlSetData($Price5, "") GUICtrlSetData($Cost5, "") Else If $QtyState5 = "" Then $QtyState5 = 1 $Total5 = $ItemCost5 GUICtrlSetData($Qty5, $QtyItem, "1") GUICtrlSetData($Price5, "$" & $ItemCost5) Else $Total5 = $QtyState5 * $ItemCost5 GUICtrlSetData($Qty5, $QtyItem, $QtyState5) GUICtrlSetData($Price5, "$" & $Total5) EndIf EndIf TotalCount() Case $Barcode6, $Qty6 $Status6 = GUICtrlRead($Barcode6) $QtyState6 = GUICtrlRead($Qty6) $ItemCost6 = IniRead("Database.ini", "Costs", $Status6, "") $ItemName6 = IniRead("Database.ini", "Items", $Status6, "") GUICtrlSetData($Item6, $ItemName6) GUICtrlSetData($Cost6, "$" & $ItemCost6) If $Status6 = "" Then $Total6 = "" GUICtrlSetData($Qty6, "", "") GUICtrlSetData($Price6, "") GUICtrlSetData($Cost6, "") Else If $QtyState6 = "" Then $QtyState6 = 1 $Total6 = $ItemCost6 GUICtrlSetData($Qty6, $QtyItem, "1") GUICtrlSetData($Price6, "$" & $ItemCost6) Else $Total6 = $QtyState6 * $ItemCost6 GUICtrlSetData($Qty6, $QtyItem, $QtyState6) GUICtrlSetData($Price6, "$" & $Total6) EndIf EndIf TotalCount() Case $Barcode7, $Qty7 $Status7 = GUICtrlRead($Barcode7) $QtyState7 = GUICtrlRead($Qty7) $ItemCost7 = IniRead("Database.ini", "Costs", $Status7, "") $ItemName7 = IniRead("Database.ini", "Items", $Status7, "") GUICtrlSetData($Item7, $ItemName7) GUICtrlSetData($Cost7, "$" & $ItemCost7) If $Status7 = "" Then $Total7 = "" GUICtrlSetData($Qty7, "", "") GUICtrlSetData($Price7, "") GUICtrlSetData($Cost7, "") Else If $QtyState7 = "" Then $QtyState7 = 1 $Total7 = $ItemCost7 GUICtrlSetData($Qty7, $QtyItem, "1") GUICtrlSetData($Price7, "$" & $ItemCost7) Else $Total7 = $QtyState7 * $ItemCost7 GUICtrlSetData($Qty7, $QtyItem, $QtyState7) GUICtrlSetData($Price7, "$" & $Total7) EndIf EndIf TotalCount() Case $Barcode8, $Qty8 $Status8 = GUICtrlRead($Barcode8) $QtyState8 = GUICtrlRead($Qty8) $ItemCost8 = IniRead("Database.ini", "Costs", $Status8, "") $ItemName8 = IniRead("Database.ini", "Items", $Status8, "") GUICtrlSetData($Item8, $ItemName8) GUICtrlSetData($Cost8, "$" & $ItemCost8) If $Status8 = "" Then $Total8 = "" GUICtrlSetData($Qty8, "", "") GUICtrlSetData($Price8, "") GUICtrlSetData($Cost8, "") Else If $QtyState8 = "" Then $QtyState8 = 1 $Total8 = $ItemCost8 GUICtrlSetData($Qty8, $QtyItem, "1") GUICtrlSetData($Price8, "$" & $ItemCost8) Else $Total8 = $QtyState8 * $ItemCost8 GUICtrlSetData($Qty8, $QtyItem, $QtyState8) GUICtrlSetData($Price8, "$" & $Total8) EndIf EndIf TotalCount() Case $Barcode9, $Qty9 $Status9 = GUICtrlRead($Barcode9) $QtyState9 = GUICtrlRead($Qty9) $ItemCost9 = IniRead("Database.ini", "Costs", $Status9, "") $ItemName9 = IniRead("Database.ini", "Items", $Status9, "") GUICtrlSetData($Item9, $ItemName9) GUICtrlSetData($Cost9, "$" & $ItemCost9) If $Status9 = "" Then $Total9 = "" GUICtrlSetData($Qty9, "", "") GUICtrlSetData($Price9, "") GUICtrlSetData($Cost9, "") Else If $QtyState9 = "" Then $QtyState9 = 1 $Total9 = $ItemCost9 GUICtrlSetData($Qty9, $QtyItem, "1") GUICtrlSetData($Price9, "$" & $ItemCost9) Else $Total9 = $QtyState9 * $ItemCost9 GUICtrlSetData($Qty9, $QtyItem, $QtyState9) GUICtrlSetData($Price9, "$" & $Total9) EndIf EndIf TotalCount() Case $CashAmount $Cash = GUICtrlRead($CashAmount) TotalCount() Case $ClearBtn ClearAll() Case $PrintBtn Print() Case $SetBtn SETDATA() EndSwitch SetTime() Until $msg = $GUI_EVENT_CLOSE Func TotalCount() $Total = $Total0 + $Total1 + $Total2 + $Total3 + $Total4 + $Total5 + $Total6 + $Total7 + $Total8 + $Total9 $Change = $Cash - $Total GUICtrlSetData($TotalAmount, "$" & $Total) If $Cash <> "" Then GUICtrlSetData($ChangeAmount, "$" & $Change) EndIf EndFunc ;==>TotalCount Func SetTime() $Timed = TimerDiff($Timer) If $Timed > 250 Then GUICtrlSetData($Time, @HOUR & ":" & @MIN & ":" & @SEC) GUICtrlSetData($Date, @MDAY & "/" & @MON & "/" & @YEAR) $Timer = TimerInit() EndIf EndFunc ;==>SetTime Func ClearAll() $Total = "" GUICtrlSetData($Barcode0, $Barcodes) GUICtrlSetData($Barcode1, $Barcodes) GUICtrlSetData($Barcode2, $Barcodes) GUICtrlSetData($Barcode3, $Barcodes) GUICtrlSetData($Barcode4, $Barcodes) GUICtrlSetData($Barcode5, $Barcodes) GUICtrlSetData($Barcode6, $Barcodes) GUICtrlSetData($Barcode7, $Barcodes) GUICtrlSetData($Barcode8, $Barcodes) GUICtrlSetData($Barcode9, $Barcodes) GUICtrlSetData($Item0, "") GUICtrlSetData($Item1, "") GUICtrlSetData($Item2, "") GUICtrlSetData($Item3, "") GUICtrlSetData($Item4, "") GUICtrlSetData($Item5, "") GUICtrlSetData($Item6, "") GUICtrlSetData($Item7, "") GUICtrlSetData($Item8, "") GUICtrlSetData($Item9, "") GUICtrlSetData($Cost0, "") GUICtrlSetData($Cost1, "") GUICtrlSetData($Cost2, "") GUICtrlSetData($Cost3, "") GUICtrlSetData($Cost4, "") GUICtrlSetData($Cost5, "") GUICtrlSetData($Cost6, "") GUICtrlSetData($Cost7, "") GUICtrlSetData($Cost8, "") GUICtrlSetData($Cost9, "") GUICtrlSetData($Qty0, "") GUICtrlSetData($Qty1, "") GUICtrlSetData($Qty2, "") GUICtrlSetData($Qty3, "") GUICtrlSetData($Qty4, "") GUICtrlSetData($Qty5, "") GUICtrlSetData($Qty6, "") GUICtrlSetData($Qty7, "") GUICtrlSetData($Qty8, "") GUICtrlSetData($Qty9, "") GUICtrlSetData($Price0, "") GUICtrlSetData($Price1, "") GUICtrlSetData($Price2, "") GUICtrlSetData($Price3, "") GUICtrlSetData($Price4, "") GUICtrlSetData($Price5, "") GUICtrlSetData($Price6, "") GUICtrlSetData($Price7, "") GUICtrlSetData($Price8, "") GUICtrlSetData($Price9, "") GUICtrlSetData($TotalAmount, "") GUICtrlSetData($CashAmount, "") GUICtrlSetData($ChangeAmount, "") EndFunc ;==>ClearAll Func Print() If $Total = "" Then MsgBox(16, "Error", "You do not have any data in your reciept") Else If $Change < 0 Then MsgBox(16, "Error", "You need at least $" & $Total & " to pay for the Items.") GUICtrlSetData($CashAmount, "") Else If GUICtrlRead($StaffNames) = "" Then MsgBox(16, "Error", "Please select your name from the list above.") Else $File = FileOpen("Print.txt", 2) $Spaces = "" $Spaces = StringRight(" ", (36 - (StringLen($StoreName) + 4)) / 2) $Stars = StringTrimRight("************************************", (36 - (StringLen($StoreName) + 4))) $StarLine = $Spaces & $Stars & $Spaces $StoreNameD = $Spaces & "* " & GuiCtrlRead($StoreName) & " *" & $Spaces FileWrite($File, $StarLine & @CRLF) FileWrite($File, $StoreNameD & @CRLF) FileWrite($File, $StarLine & @CRLF) FileWrite($File, @CRLF) FileWrite($File, "Staff Name: " & GUICtrlRead($StaffNames) & @CRLF) FileWrite($File, "Date: " & GUICtrlRead($Date) & @CRLF) FileWrite($File, "Time: " & GUICtrlRead($Time) & @CRLF) FileWrite($File, @CRLF) FileWrite($File, "------------------------------------" & @CRLF) FileWrite($File, "Item Name Cost Qty. Price" & @CRLF) FileWrite($File, "------------------------------------" & @CRLF) If $Status0 <> "" Then If StringLen($ItemName0) > 16 Then $ItemName0 = StringTrimRight($ItemName0, StringLen($ItemName0) - 13) & "..." EndIf FileWrite($File, $ItemName0) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName0))) FileWrite($File, "$" & $ItemCost0) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost0))) FileWrite($File, $QtyState0) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState0))) FileWrite($File, "$" & $Total0 & @CRLF) EndIf If $Status1 <> "" Then If StringLen($ItemName1) > 16 Then $ItemName1 = StringTrimRight($ItemName1, StringLen($ItemName1) - 13) & "..." EndIf FileWrite($File, $ItemName1) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName1))) FileWrite($File, "$" & $ItemCost1) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost1))) FileWrite($File, $QtyState1) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState1))) FileWrite($File, "$" & $Total1 & @CRLF) EndIf If $Status2 <> "" Then If StringLen($ItemName2) > 16 Then $ItemName2 = StringTrimRight($ItemName2, StringLen($ItemName2) - 13) & "..." EndIf FileWrite($File, $ItemName2) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName2))) FileWrite($File, "$" & $ItemCost2) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost2))) FileWrite($File, $QtyState2) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState2))) FileWrite($File, "$" & $Total2 & @CRLF) EndIf If $Status3 <> "" Then If StringLen($ItemName3) > 16 Then $ItemName3 = StringTrimRight($ItemName3, StringLen($ItemName3) - 13) & "..." EndIf FileWrite($File, $ItemName3) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName3))) FileWrite($File, "$" & $ItemCost3) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost3))) FileWrite($File, $QtyState3) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState3))) FileWrite($File, "$" & $Total3 & @CRLF) EndIf If $Status4 <> "" Then If StringLen($ItemName4) > 16 Then $ItemName4 = StringTrimRight($ItemName4, StringLen($ItemName4) - 13) & "..." EndIf FileWrite($File, $ItemName4) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName4))) FileWrite($File, "$" & $ItemCost4) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost4))) FileWrite($File, $QtyState4) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState4))) FileWrite($File, "$" & $Total4 & @CRLF) EndIf If $Status5 <> "" Then If StringLen($ItemName5) > 16 Then $ItemName5 = StringTrimRight($ItemName5, StringLen($ItemName5) - 13) & "..." EndIf FileWrite($File, $ItemName5) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName5))) FileWrite($File, "$" & $ItemCost5) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost5))) FileWrite($File, $QtyState5) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState5))) FileWrite($File, "$" & $Total5 & @CRLF) EndIf If $Status6 <> "" Then If StringLen($ItemName6) > 16 Then $ItemName6 = StringTrimRight($ItemName6, StringLen($ItemName6) - 13) & "..." EndIf FileWrite($File, $ItemName6) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName6))) FileWrite($File, "$" & $ItemCost6) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost6))) FileWrite($File, $QtyState6) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState6))) FileWrite($File, "$" & $Total6 & @CRLF) EndIf If $Status7 <> "" Then If StringLen($ItemName7) > 16 Then $ItemName7 = StringTrimRight($ItemName7, StringLen($ItemName7) - 13) & "..." EndIf FileWrite($File, $ItemName7) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName7))) FileWrite($File, "$" & $ItemCost7) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost7))) FileWrite($File, $QtyState7) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState7))) FileWrite($File, "$" & $Total7 & @CRLF) EndIf If $Status8 <> "" Then If StringLen($ItemName8) > 16 Then $ItemName8 = StringTrimRight($ItemName8, StringLen($ItemName8) - 13) & "..." EndIf FileWrite($File, $ItemName8) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName8))) FileWrite($File, "$" & $ItemCost8) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost8))) FileWrite($File, $QtyState8) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState8))) FileWrite($File, "$" & $Total8 & @CRLF) EndIf If $Status9 <> "" Then If StringLen($ItemName9) > 16 Then $ItemName9 = StringTrimRight($ItemName9, StringLen($ItemName9) - 13) & "..." EndIf FileWrite($File, $ItemName9) FileWrite($File, StringTrimLeft(" ", StringLen($ItemName9))) FileWrite($File, "$" & $ItemCost9) FileWrite($File, StringTrimLeft(" ", StringLen($ItemCost9))) FileWrite($File, $QtyState9) FileWrite($File, StringTrimLeft(" ", StringLen($QtyState9))) FileWrite($File, "$" & $Total9 & @CRLF) EndIf FileWrite($File, "------------------------------------" & @CRLF) FileWrite($File, @CRLF) FileWrite($File, "Total: $" & $Total & @CRLF) FileWrite($File, "Cash: $" & $Cash & @CRLF) FileWrite($File, @CRLF) FileWrite($File, "Change: $" & $Change & @CRLF) FileClose($File) _FilePrint("Print.txt") Sleep(100) FileDelete("Print.txt") EndIf EndIf EndIf EndFunc ;==>Print Func SETDATA() GUICreate("Set Data", 290, 500, -1, -1) GUICtrlCreateGroup("", 5, 0, 280, 340) GUICtrlCreateLabel("Barcode", 10, 10, 50, 15) GUICtrlCreateLabel("00000001", 10, 40, 50, 15) GUICtrlCreateLabel("00000002", 10, 70, 50, 15) GUICtrlCreateLabel("00000003", 10, 100, 50, 15) GUICtrlCreateLabel("00000004", 10, 130, 50, 15) GUICtrlCreateLabel("00000005", 10, 160, 50, 15) GUICtrlCreateLabel("00000006", 10, 190, 50, 15) GUICtrlCreateLabel("00000007", 10, 220, 50, 15) GUICtrlCreateLabel("00000008", 10, 250, 50, 15) GUICtrlCreateLabel("00000009", 10, 280, 50, 15) GUICtrlCreateLabel("00000010", 10, 310, 50, 15) GUICtrlCreateLabel("Name", 70, 10, 100, 15) $Name0 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000001", ""), 70, 40, 100, 20) GUICtrlSetLimit(-1, 16) $Name1 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000002", ""), 70, 70, 100, 20) GUICtrlSetLimit(-1, 16) $Name2 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000003", ""), 70, 100, 100, 20) GUICtrlSetLimit(-1, 16) $Name3 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000004", ""), 70, 130, 100, 20) GUICtrlSetLimit(-1, 16) $Name4 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000005", ""), 70, 160, 100, 20) GUICtrlSetLimit(-1, 16) $Name5 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000006", ""), 70, 190, 100, 20) GUICtrlSetLimit(-1, 16) $Name6 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000007", ""), 70, 220, 100, 20) GUICtrlSetLimit(-1, 16) $Name7 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000008", ""), 70, 250, 100, 20) GUICtrlSetLimit(-1, 16) $Name8 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000009", ""), 70, 280, 100, 20) GUICtrlSetLimit(-1, 16) $Name9 = GUICtrlCreateInput(IniRead("Database.ini", "Items", "00000010", ""), 70, 310, 100, 20) GUICtrlSetLimit(-1, 16) GUICtrlCreateLabel("Cost", 180, 10, 50, 15) $Money0 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000001", ""), 180, 40, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money1 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000002", ""), 180, 70, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money2 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000003", ""), 180, 100, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money3 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000004", ""), 180, 130, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money4 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000005", ""), 180, 160, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money5 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000006", ""), 180, 190, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money6 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000007", ""), 180, 220, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money7 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000008", ""), 180, 250, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money8 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000009", ""), 180, 280, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) $Money9 = GUICtrlCreateInput(IniRead("Database.ini", "Costs", "00000010", ""), 180, 310, 100, 20, $ES_NUMBER) GUICtrlSetLimit(-1, 4) GUICtrlCreateLabel("Store Name", 10, 350, 60, 15) $Store = GUICtrlCreateInput(IniRead("Database.ini", "General", "StoreName", ""), 80, 350, 200, 20) GUICtrlSetLimit(-1, 32) GUICtrlCreateLabel("Staff Names", 10, 380, 60, 15) $Staff = StringSplit(IniRead("Database.ini", "General", "StaffNames", ""), "|") $Staff0 = GUICtrlCreateInput($Staff[1], 80, 380, 200, 20) GUICtrlSetLimit(-1, 15) $Staff1 = GUICtrlCreateInput($Staff[2], 80, 410, 200, 20) GUICtrlSetLimit(-1, 15) $Staff2 = GUICtrlCreateInput($Staff[3], 80, 440, 200, 20) GUICtrlSetLimit(-1, 15) $SetData = GUICtrlCreateButton("Save Data", 20, 470, 120, 25) $ClrData = GUICtrlCreateButton("Clear Data", 150, 470, 120, 25) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) Do $msg1 = GUIGetMsg() Switch $msg1 Case $SetData SaveSettings() Case $ClrData ClearSettings() EndSwitch Until $msg1 = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>SETDATA Func SaveSettings() If GUICtrlRead($Name0) <> "" Then If GUICtrlRead($Money0) <> "" Then IniWrite("Database.ini", "Items", "00000001", GUICtrlRead($Name0)) IniWrite("Database.ini", "Costs", "00000001", GUICtrlRead($Money0)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000001""", 0) EndIf Else If GUICtrlRead($Money0) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000001""", 0) EndIf EndIf If GUICtrlRead($Name1) <> "" Then If GUICtrlRead($Money1) <> "" Then IniWrite("Database.ini", "Items", "00000002", GUICtrlRead($Name1)) IniWrite("Database.ini", "Costs", "00000002", GUICtrlRead($Money1)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000002""", 0) EndIf Else If GUICtrlRead($Money1) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000002""", 0) EndIf EndIf If GUICtrlRead($Name2) <> "" Then If GUICtrlRead($Money2) <> "" Then IniWrite("Database.ini", "Items", "00000003", GUICtrlRead($Name2)) IniWrite("Database.ini", "Costs", "00000003", GUICtrlRead($Money2)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000003""", 0) EndIf Else If GUICtrlRead($Money2) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000003""", 0) EndIf EndIf If GUICtrlRead($Name3) <> "" Then If GUICtrlRead($Money3) <> "" Then IniWrite("Database.ini", "Items", "00000004", GUICtrlRead($Name3)) IniWrite("Database.ini", "Costs", "00000004", GUICtrlRead($Money3)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000004""", 0) EndIf Else If GUICtrlRead($Money3) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000004""", 0) EndIf EndIf If GUICtrlRead($Name4) <> "" Then If GUICtrlRead($Money4) <> "" Then IniWrite("Database.ini", "Items", "00000005", GUICtrlRead($Name4)) IniWrite("Database.ini", "Costs", "00000005", GUICtrlRead($Money4)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000005""", 0) EndIf Else If GUICtrlRead($Money4) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000005""", 0) EndIf EndIf If GUICtrlRead($Name5) <> "" Then If GUICtrlRead($Money5) <> "" Then IniWrite("Database.ini", "Items", "00000006", GUICtrlRead($Name5)) IniWrite("Database.ini", "Costs", "00000006", GUICtrlRead($Money5)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000006""", 0) EndIf Else If GUICtrlRead($Money5) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000006""", 0) EndIf EndIf If GUICtrlRead($Name6) <> "" Then If GUICtrlRead($Money6) <> "" Then IniWrite("Database.ini", "Items", "00000007", GUICtrlRead($Name6)) IniWrite("Database.ini", "Costs", "00000007", GUICtrlRead($Money6)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000007""", 0) EndIf Else If GUICtrlRead($Money6) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000007""", 0) EndIf EndIf If GUICtrlRead($Name7) <> "" Then If GUICtrlRead($Money7) <> "" Then IniWrite("Database.ini", "Items", "00000008", GUICtrlRead($Name7)) IniWrite("Database.ini", "Costs", "00000008", GUICtrlRead($Money7)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000008""", 0) EndIf Else If GUICtrlRead($Money7) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000008""", 0) EndIf EndIf If GUICtrlRead($Name8) <> "" Then If GUICtrlRead($Money8) <> "" Then IniWrite("Database.ini", "Items", "00000009", GUICtrlRead($Name8)) IniWrite("Database.ini", "Costs", "00000009", GUICtrlRead($Money8)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000009""", 0) EndIf Else If GUICtrlRead($Money8) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000009""", 0) EndIf EndIf If GUICtrlRead($Name9) <> "" Then If GUICtrlRead($Money9) <> "" Then IniWrite("Database.ini", "Items", "00000010", GUICtrlRead($Name9)) IniWrite("Database.ini", "Costs", "00000010", GUICtrlRead($Money9)) Else MsgBox(16, "Error", "Please enter the cost of your Item in Barcode ""00000010""", 0) EndIf Else If GUICtrlRead($Money9) <> "" Then MsgBox(16, "Error", "Please enter the name of your Item in Barcode ""00000010""", 0) EndIf EndIf If GUICtrlRead($Store) <> "" Then IniWrite("Database.ini", "General", "StoreName", GUICtrlRead($Store)) GUICtrlSetData($StoreNames, GUICtrlRead($Store)) Else MsgBox(16, "Error", "Please enter the name of your Store.", 0) EndIf If GUICtrlRead($Staff0) <> "" Or GUICtrlRead($Staff1) <> "" Or GUICtrlRead($Staff2) <> "" Then If GUICtrlRead($Staff0) = "" Then $StaffData0 = "" Else $StaffData0 = GUICtrlRead($Staff0) EndIf If GUICtrlRead($Staff1) = "" Then $StaffData1 = "" Else If $StaffData0 = "" Then $StaffData1 = GUICtrlRead($Staff1) & "|" Else If GUICtrlRead($Staff2) = "" Then $StaffData1 = "|" & GUICtrlRead($Staff1) Else $StaffData1 = "|" & GUICtrlRead($Staff1) & "|" EndIf EndIf If GUICtrlRead($Staff2) = "" Then $StaffData2 = "" Else $StaffData2 = GUICtrlRead($Staff2) EndIf IniWrite("Database.ini", "General", "StaffNames", $StaffData0 & $StaffData1 & $StaffData2) GuiCtrlSetData($StaffNames, "") GuiCtrlSetData($StaffNames, $StaffData0 & $StaffData1 & $StaffData2) EndIf EndIf EndFunc ;==>SaveSettings Func ClearSettings() EndFunc ;==>ClearSettings Database.ini: [General] Barcodes=||00000001|00000002|00000003|00000004|00000005|00000006|00000007|00000001|00000009|00000010 StaffNames=Administrator|Staff 1|Staff 2 StoreName=The Shop Name [Items] 00000001=Item 1 00000002=Item 2 00000003=Item 3 00000004=Item 4 00000005=Item 5 00000007=Item 6 00000006=Item 7 00000008=Item 8 00000009=Item 9 00000010=Item 10 [Costs] 00000001=200 00000002=100 00000003=400 00000004=1600 00000005=800 00000007=9999 00000006=9999 00000008=9999 00000009=9999 00000010=9999 Edited June 18, 2010 by BoonPek Link to comment Share on other sites More sharing options...
IchBistTod Posted July 2, 2010 Share Posted July 2, 2010 date properly formatted. its DD/MM/YYYY it should be MM/DD/YYYY [center][/center][center]=][u][/u][/center][center][/center] Link to comment Share on other sites More sharing options...
Kiesp Posted July 2, 2010 Share Posted July 2, 2010 date properly formatted.its DD/MM/YYYY it should be MM/DD/YYYYDepends on who's reading. For me it looks normal Anyways, the name of the Store is not showed correctly on the receipt for me Look at attachmentReceipt.pdf http://www.autoitscript.com/forum/index.php?showtopic=69911 <-- Best hacker ever :D Link to comment Share on other sites More sharing options...
storme Posted July 2, 2010 Share Posted July 2, 2010 date properly formatted.its DD/MM/YYYY it should be MM/DD/YYYYActualy DD/MM/YYYY is correct for where I'm sitting. Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
James Posted July 2, 2010 Share Posted July 2, 2010 date properly formatted.its DD/MM/YYYY it should be MM/DD/YYYYMy god you are an ignorant idiot.Date formats change based on the country. A better idea would be to get the local date format for the registry and build it off of that.James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now