Jump to content

Drag & Drop


strate
 Share

Recommended Posts

In the script below I want to be able drag a printer name into the treeview above it. Then when its dropped on to a instance of "Printer Needs Selected!" the printer name is in the treeview. To get the treeview to state "Printer Needs Selected!" you must click on a label choice. I can do everything except get the drag & drop to work.

Any help would be greatly appreciated.

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>
#include <GuiTreeView.au3>
#include <Array.au3>
#Include <GuiList.au3>
#Include <File.au3>
#include <Date.au3>
#include <WindowsConstants.au3>


Global $INIFile = @ScriptDir & '\Label App.ini'
;~ Global $INIFile = 'G:\Packaging\Shared\Prod. Clerk Tools\Bulk Label App\Bulk Label App V2\Bulk.ini'
If Not FileExists($INIFile) Then
    MsgBox(4096,'Error','Unable to locate INI file. Program now closing.')
    Exit
EndIf

Global $LogFile = IniRead($INIFile,'Paths','Log','Error') & 'Label App User Log.txt'
Global $TempFile = @TempDir & '\Label App.txt'
Global $PrinterName = IniRead(IniRead($INIFile,'Paths','LabelView Label.ini File','ERROR'), 'Labelview', 'printer_name', '....') & ' on ' & IniRead(IniRead($INIFile,'Paths','LabelView Label.ini File','ERROR'), 'Labelview', 'port', '....')
_Log($LogFile,'Program Initializing - Printer name is '&$PrinterName)
Global $Kit_Weight, $Caution_Label
Local $OldSelectedLabelCount
Global Const $VK_NUMLOCK = 0x90
_Log($LogFile,'Program Initializing - Creating GUI')

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Labels", 882, 560, -1, -1)

Global $a_PartsRightEdge[3] = [100,230,-1]
Global $a_PartsText[3] = ["Ready...",'','']
$StatusBar1 = _GUICtrlStatusBarCreate ($Form1, $a_PartsRightEdge, $a_PartsText)

$Group1 = GUICtrlCreateGroup("Label Options", 16, 8, 201, 65)
GUICtrlSetColor(-1, 0x0000FF)
$KitSetup = GUICtrlCreateCheckbox("Kit Setup", 32, 26, 169, 20,$BS_PUSHLIKE)
$SingleLabel = GUICtrlCreateCheckbox("Single Label", 32, 45, 169, 20,$BS_PUSHLIKE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Label Data", 16, 88, 201, 358)
GUICtrlSetColor(-1, 0x0000FF)
$Labe20 = GUICtrlCreateLabel("Sales Order Number:", 24, 112, 113, 16)
$SalesOrder = GUICtrlCreateInput("", 24, 128, 37, 21,$ES_NUMBER)
GUICtrlSetLimit($SalesOrder,5)
$Label3 = GUICtrlCreateLabel("Customer Part Number:", 24, 160, 113, 16)
$CustomerPartNumber = GUICtrlCreateInput("", 24, 176, 145, 21,$ES_UPPERCASE)
GUICtrlSetTip(-1, "Must be the same as found in QAD.")
$Label1 = GUICtrlCreateLabel("Kit Number:", 64, 208, 59, 16)
$Label2 = GUICtrlCreateLabel("TRW", 24, 209, 40, 16)
GUICtrlSetFont(-1, 11, 400, 0, "TRWLogo")
GUICtrlSetColor(-1, 0xFF0000)
$KitNumber = GUICtrlCreateInput("", 24, 224, 113, 21,$ES_UPPERCASE)
$Label4 = GUICtrlCreateLabel("Description:", 24, 256, 60, 16)
$Description = GUICtrlCreateButton("Click to enter description.", 24, 272, 145, 20, 0)
GUICtrlSetCursor ($Description, 0)
GUICtrlSetTip(-1, "Description is selected from user list.")
$Label5 = GUICtrlCreateLabel("Due Date:", 24, 304, 53, 16)
$DueDate = GUICtrlCreateInput("", 24, 320, 49, 21,$ES_NUMBER)
GUICtrlSetLimit($DueDate, 6)
$Label6 = GUICtrlCreateLabel("Quantity Requested:", 24, 352, 101, 16)
$QtyRequested = GUICtrlCreateInput("", 24, 368, 97, 21,$ES_NUMBER)
$Label7 = GUICtrlCreateLabel("Quantity Per Pallet:", 24, 400, 94, 16)
$QtyPerPallet = GUICtrlCreateInput("", 24, 416, 97, 21,$ES_NUMBER)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;~ $Group3 = GUICtrlCreateGroup("Identification Labels", 240, 88, 201, 153)
;~ GUICtrlSetColor(-1, 0x0000FF)
;~ $Label8 = GUICtrlCreateLabel("Quantity on Label:", 256, 112, 90, 16)
;~ $IDQty = GUICtrlCreateInput("", 256, 128, 89, 21,$ES_NUMBER)
;~ $Label9 = GUICtrlCreateLabel("Number of labels with this quantity:", 256, 160, 167, 16)
;~ $IDQtyofLabels = GUICtrlCreateInput("", 256, 176, 89, 21,$ES_NUMBER)
;~ $IDAdd = GUICtrlCreateButton("Add", 256, 208, 89, 20, $BS_DEFPUSHBUTTON)
;~ GUICtrlCreateGroup("", -99, -99, 1, 1)
;~ GUICtrlSetCursor ($IDAdd, 0)
$IDTreeView     = GUICtrlCreateTreeView(664, 16, 201, 280, $TVS_NOSCROLL, $WS_EX_CLIENTEDGE)
$IDTreeView_0   = GUICtrlCreateTreeViewItem("Address Label", $IDTreeView)
$IDTreeView_1   = GUICtrlCreateTreeViewItem("", $IDTreeView_0)
$IDTreeView_2   = GUICtrlCreateTreeViewItem("Standard Label Data", $IDTreeView)
$IDTreeView_15  = GUICtrlCreateTreeViewItem("Sales Order", $IDTreeView_2)
$IDTreeView_16  = GUICtrlCreateTreeViewItem("", $IDTreeView_15)
$IDTreeView_5   = GUICtrlCreateTreeViewItem("Customer Part Number", $IDTreeView_2)
$IDTreeView_6   = GUICtrlCreateTreeViewItem("", $IDTreeView_5)
$IDTreeView_3   = GUICtrlCreateTreeViewItem("Kit Number", $IDTreeView_2)
$IDTreeView_4   = GUICtrlCreateTreeViewItem("", $IDTreeView_3)
$IDTreeView_7   = GUICtrlCreateTreeViewItem("Description", $IDTreeView_2)
$IDTreeView_8   = GUICtrlCreateTreeViewItem("", $IDTreeView_7)
$IDTreeView_9   = GUICtrlCreateTreeViewItem("Due Date", $IDTreeView_2)
$IDTreeView_10  = GUICtrlCreateTreeViewItem("", $IDTreeView_9)
$IDTreeView_11  = GUICtrlCreateTreeViewItem("Quantity Requested", $IDTreeView_2)
$IDTreeView_12  = GUICtrlCreateTreeViewItem("", $IDTreeView_11)
$IDTreeView_13  = GUICtrlCreateTreeViewItem("Quantity Per Pallet", $IDTreeView_2)
$IDTreeView_14  = GUICtrlCreateTreeViewItem("", $IDTreeView_13)
;~ $Group4 = GUICtrlCreateGroup("Address Labels", 240, 8, 201, 65)
;~ GUICtrlSetColor(-1, 0x0000FF)
;~ $GMAddressLabels = GUICtrlCreateCheckbox("GM Address Labels", 256, 26, 169, 20,$BS_PUSHLIKE)
;~ $NONGMAddressLabels = GUICtrlCreateCheckbox("Non-GM Address Labels", 256, 45, 169, 20,$BS_PUSHLIKE)
;~ GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 664, 308, 201, 123)
$LoadPrintJob = GUICtrlCreateButton("Load Print Job", 713, 445, 100, 20)
GUICtrlSetCursor ($LoadPrintJob, 0)
$Print = GUICtrlCreateButton("Print", 16, 464, 201, 25)
GUICtrlSetCursor ($Print, 0)
$Clear = GUICtrlCreateButton("Clear", 16, 500, 201, 25);, 0)
GUICtrlSetCursor ($Clear, 0)

#region ; Label Selection Controls
Dim $ADDRESS_SELECTION_GROUP_X      = 240
Dim $ADDRESS_SELECTION_GROUP_Y      = 10
Dim $ADDRESS_LABELS_GROUP           = GUICtrlCreateGroup("Address Labels", $ADDRESS_SELECTION_GROUP_X - 10, $ADDRESS_SELECTION_GROUP_Y, 165, 127)
Dim $ADDRESS_LIST                   = GUICtrlCreateList('', $ADDRESS_SELECTION_GROUP_X, $ADDRESS_SELECTION_GROUP_Y + 18, 145, 105,BitOR($WS_BORDER,$WS_VSCROLL,$LBS_DISABLENOSCROLL,$LBS_MULTIPLESEL))
GUICtrlSetData(-1,'GM Address Label|NON-GM Address Label','None')
Dim $PACKAGING_SELECTION_GROUP_X    = 240
Dim $PACKAGING_SELECTION_GROUP_Y    = 140
Dim $PACKAGING_LABELS_GROUP         = GUICtrlCreateGroup("Packaging Labels", $PACKAGING_SELECTION_GROUP_X - 10, $PACKAGING_SELECTION_GROUP_Y, 165, 127)
Dim $PACKAGING_LABELS_LIST          = GUICtrlCreateList('', $PACKAGING_SELECTION_GROUP_X, $PACKAGING_SELECTION_GROUP_Y + 18, 145, 105,BitOR($WS_BORDER,$WS_VSCROLL,$LBS_MULTIPLESEL,$LBS_DISABLENOSCROLL))
GUICtrlSetData(-1,'Unit Labels|Master Labels|GM Master','None')
Dim $MISC_SELECTION_GROUP_X         = 240
Dim $MISC_SELECTION_GROUP_Y         = 270
Dim $MISC_LABELS_GROUP              = GUICtrlCreateGroup("Misc. Labels", $MISC_SELECTION_GROUP_X - 10, $MISC_SELECTION_GROUP_Y, 165, 127)
Dim $MISC_LIST                      = GUICtrlCreateList('', $MISC_SELECTION_GROUP_X, $MISC_SELECTION_GROUP_Y + 18, 145, 105,BitOR($WS_BORDER,$WS_VSCROLL,$LBS_MULTIPLESEL,$LBS_DISABLENOSCROLL))
GUICtrlSetData(-1,'Audit Tag|4X6 Over Pack Label|5X3 Over Pack Label','None')
#endregion

;~ BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), 


;~ $PrinterTreeView = GUICtrlCreateTreeView(410, 16, 201, 280, $TVS_HASLINES, $WS_EX_CLIENTEDGE)
$PrinterTreeView = GUICtrlCreateTreeView(410, 16, 201, 280, BitOr($TVS_HASLINES,$TVS_SHOWSELALWAYS) , $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
$PrinterList = GUICtrlCreateList("",410,308,201,123)
GUICtrlSetData(-1,_Identify_Printers())
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlSetState(-1,$GUI_DISABLE)
_GUICtrlTreeViewExpand($IDTreeView)

#EndRegion ### END Koda GUI section ###

_Log($LogFile,'Program Initializing - GUI Created')

$DataInputs = _ArrayCreate($SalesOrder,$KitNumber,$CustomerPartNumber,$Description,$DueDate,$QtyRequested,$QtyPerPallet)

_SetDisplayData()
;~ _EnableAddressLabelOptions(0)
_EnableLabelData(0)
;~ _EnableIDLabelData(0)
;~ _EnableListData(0)
_EnableTreeViewData(0)

_Log($LogFile,'Program Initializing - GUI controls set to a "fresh" state.')

#region  ; Check INI to decide whether or not to run LabelView
If IniRead($INIFile,'Settings','Run LabelView','Error') = 1 Then
    If WinExists('Command File Monitor') <> 1 Then
        _Log($LogFile,'Program Initializing - Opening Labelview Command File Monitor.')
        _OpenLabelView()
        Do
            Sleep(25)
        Until WinExists('Command File Monitor') = 1
        _Log($LogFile,'Program Initializing - Command File Monitor is ready.')
    EndIf
EndIf
#endregion

GUISetState(@SW_SHOW)
_Log($LogFile,'Program Initializing - Painting GUI.')
;_GUICtrlStatusBarSetText ($StatusBar1,"GUI Opened",1)
$ProgressBar1 = _GUICtrlStatusBarCreateProgress ( $StatusBar1,1)
GUICtrlSetColor($ProgressBar1,39950)



$OldInput = ''

;~ If Not FileExists(@DesktopDir & "\Bulk Label App V2.lnk") Then
;~  FileCreateShortcut (@ScriptFullPath, @DesktopDir & "\Bulk Label App V2.lnk")
;~ EndIf
;~ If Not FileExists(@ProgramsDir & "\Bulk Label App V2.lnk") Then
;~  FileCreateShortcut (@ScriptFullPath, @ProgramsDir & "\Bulk Label App V2.lnk")
;~ EndIf

$Inputs = _ArrayCreate('Edit1','Edit2','Edit3','Button6','Edit4','Edit5','Edit6','Edit7')
While 1
    _LabelSelectionUpdate()
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $PrinterTreeView
            MsgBox(262144,'Debug line ~180','Selection:' & @lf & '$PrinterTreeView' & @lf & @lf & 'Return:' & @lf & $PrinterTreeView & @lf & @lf & '@Error:' & @lf & @Error) ;### Debug MSGBOX
            
        
        
;~      Case $GMAddressLabels
;~          If GUICtrlRead($GMAddressLabels) = 1 Then
;~              GUICtrlSetState($NONGMAddressLabels,$GUI_UNCHECKED)
;~              GUICtrlSetData($IDTreeView_1,'GM')
;~              _SetDisplayData()
;~              _EnableLabelData(1)
;~              _Log($LogFile,'User Action: GM address label style.')
;~          Else
;~              GUICtrlSetState($NONGMAddressLabels,$GUI_CHECKED)
;~              GUICtrlSetData($IDTreeView_1,'NON-GM')
;~              _SetDisplayData()
;~              _EnableLabelData(1)
;~              _Log($LogFile,'User Action: NON GM address label style.')
;~          EndIf
;~      Case $NONGMAddressLabels
;~          If GUICtrlRead($NONGMAddressLabels) = 1 Then
;~              GUICtrlSetState($GMAddressLabels,$GUI_UNCHECKED)
;~              GUICtrlSetData($IDTreeView_1,'NON-GM')
;~              _SetDisplayData()
;~              _EnableLabelData(1)
;~              _Log($LogFile,'User Action: NON GM address label style.')
;~          Else
;~              GUICtrlSetState($GMAddressLabels,$GUI_CHECKED)
;~              GUICtrlSetData($IDTreeView_1,'GM')
;~              _SetDisplayData()
;~              _EnableLabelData(1)
;~              _Log($LogFile,'User Action: GM address label style.')
;~          EndIf
        Case $KitSetup
            If GUICtrlRead($KitSetup) = 1 Then
                GUICtrlSetState($SingleLabel,$GUI_UNCHECKED)
                _SetDisplayData()
                _EnableLabelData(1)
                GUICtrlSetData ($ProgressBar1,1)
;~              _EnableAddressLabelOptions(1)
                _Log($LogFile,'User Action: Full kit setup style of production run.')
            Else
                GUICtrlSetState($SingleLabel,$GUI_CHECKED)
                _SetDisplayData()
                _EnableLabelData(1)
                GUICtrlSetData ($ProgressBar1,1)
;~              _EnableAddressLabelOptions(1)
                _Log($LogFile,'User Action: Bpkg/Brec style of production run.')
            EndIf
        Case $SingleLabel
            If GUICtrlRead($SingleLabel) = 1 Then
                GUICtrlSetState($KitSetup,$GUI_UNCHECKED)
                _SetDisplayData()
                _EnableLabelData(1)
                GUICtrlSetData ($ProgressBar1,1)
;~              _EnableAddressLabelOptions(1)
                _Log($LogFile,'User Action: Bpkg/Brec style of production run.')
            Else
                GUICtrlSetState($KitSetup,$GUI_CHECKED)
                _SetDisplayData()
                _EnableLabelData(1)
                GUICtrlSetData ($ProgressBar1,1)
;~              _EnableAddressLabelOptions(1)
                _Log($LogFile,'User Action: Full kit setup style of production run.')
            EndIf
;~      Case $IDAdd
;~          _Log($LogFile,'User Action: ID labels, "Add" button.')
;~          Local $QtyPerLabel = GUICtrlRead($IDQty)
;~          Local $QtyofLabels = GUICtrlRead($IDQtyofLabels)
;~          If $QtyPerLabel = '' Or $QtyofLabels = '' Then
;~              _Log($LogFile,'User Error: ID labels, data incomplete.')
;~              ContinueLoop
;~          EndIf
;~          _EnableListData(1)
;~          If $QtyofLabels > 1 Then
;~              _GUICtrlListAddItem($List1, $QtyofLabels & ' labels at a quantity of ' & $QtyPerLabel)
;~              _Log($LogFile,'Program Action: '& $QtyofLabels & ' labels at a quantity of ' & $QtyPerLabel & ' added to list.')
;~          Else
;~              _GUICtrlListAddItem($List1, $QtyofLabels & ' label at a quantity of ' & $QtyPerLabel)
;~              _Log($LogFile,'Program Action: '& $QtyofLabels & ' label at a quantity of ' & $QtyPerLabel & ' added to list.')
;~          EndIf
;~          GUICtrlSetData($IDQty,'')
;~          GUICtrlSetData($IDQtyofLabels,'')
;~          GUICtrlSetState($IDQty,$GUI_FOCUS)
;~      Case $IDRemove
;~          _Log($LogFile,'User Action: ID label Remove button')
;~          _Log($LogFile,'Program Action: Removed ' & _GUICtrlListGetText($List1,_GUICtrlListSelectedIndex($List1)) & ' from the list.')
;~          _GUICtrlListDeleteItem($List1, _GUICtrlListSelectedIndex($List1))
        Case $Description
            _Log($LogFile,'User Action: Description button')
            HotKeySet('{ENTER}')
            _Description()
            GUICtrlSetState($DueDate,$GUI_FOCUS)
        Case $Clear
            _Log($LogFile,'User Action: Clear clicked.')
;~          _EnableAddressLabelOptions(0)
            _EnableLabelData(0)
;~          _EnableListData(0)
            _EnableTreeViewData(0)
;~          _EnableIDLabelData(0)
            _ClearAllInputs()
            _SetDisplayData()
            GUICtrlSetData($IDTreeView_1,'')
;~          GUICtrlSetState($NONGMAddressLabels,$GUI_UNCHECKED)
;~          GUICtrlSetState($GMAddressLabels,$GUI_UNCHECKED)
;~          GUICtrlSetState($BpkgBrec,$GUI_UNCHECKED)
;~          GUICtrlSetState($BulkESD,$GUI_UNCHECKED)
            _Log($LogFile,'Program Action: GUI controls set to a "fresh" state.')
            ;_GUICtrlStatusBarSetText ($StatusBar1,"Controls Reset",1)
        Case $Print
            _Log($LogFile,'User Action: Print clicked.')
            _Print()
            _Log($LogFile,'Program State: Program side of print process completed')
            ;_GUICtrlStatusBarSetText ($StatusBar1,"Printing complete inside the application.",1)
        Case $GUI_EVENT_CLOSE;, $Close
            _Log($LogFile,'User Action: Either "X" or "Close" button clicked.')
            Exit
        
        Case $PrinterList
            $s_Printer = _GUICtrlListGetSelItemsText($PrinterList)
;~          $s_Printer[1]
            
            
            
    EndSwitch
;~  If GUICtrlRead($SalesOrder) <> '' And GUICtrlRead($KitNumber) <> '' And GUICtrlRead($CustomerPartNumber) <> '' And GUICtrlRead($Description) <> 'Click to enter description.' And GUICtrlRead($DueDate) <> '' And GUICtrlRead($QtyRequested) <> '' And GUICtrlRead($QtyPerPallet) <> '' And GUICtrlGetState($IDQty) = 144 Then
;~      _EnableIDLabelData(1)
;~      _Log($LogFile,'Program Action: ID label controls enabled.')
;~  EndIf

;~  $Inputs = _ArrayCreate('Edit1','Edit2','Edit3','Button6','Edit4','Edit5','Edit6','Edit7')
    $NewInput = ControlGetFocus('Label')
    If $NewInput <> $OldInput Then
        If _ArraySearch($Inputs, $NewInput) <> -1 Then
            _SetDisplayData()
            $OldInput = $NewInput
        EndIf
    EndIf
    
    If StringInStr(ControlGetFocus($Form1),'Edit') Then
        HotKeySet('{ENTER}','_CatchEnterThenTab')
    ElseIf ControlGetFocus($Form1)='Button6' Then
        HotKeySet('{ENTER}')
        _Description()
    Else
        HotKeySet('{ENTER}')
    EndIf
    If @HOUR < 14 Then
        _Log($LogFile,'Program Action: Time is less than 14, running.')
        Exit
    EndIf
    
    If WinActive('Labels') Then _SetNumLock()
    
WEnd

Func _SetDisplayData()
    $Display = _ArrayCreate($IDTreeView_0,$IDTreeView_15,$IDTreeView_2,$IDTreeView_3,$IDTreeView_5,$IDTreeView_7,$IDTreeView_9,$IDTreeView_11,$IDTreeView_13)
    For $i = 1 To UBound($Display)-1
        _GUICtrlTreeViewSetIcon($IDTreeView, $Display[$i],  "shell32.dll", 50)
    Next

;~  $DataInputs = _ArrayCreate($SalesOrder,$KitNumber,$CustomerPartNumber,$Description,$DueDate,$QtyRequested,$QtyPerPallet)
    $TreeItems = _ArrayCreate($IDTreeView_16,$IDTreeView_4,$IDTreeView_6,$IDTreeView_8,$IDTreeView_10,$IDTreeView_12,$IDTreeView_14)
    For $i = 0 To UBound($DataInputs)-1
        If GUICtrlRead($DataInputs[$i]) = '' Or GUICtrlRead($DataInputs[$i]) = 'Click to enter description.' Then
            GUICtrlSetData($TreeItems[$i],'')
            _GUICtrlTreeViewSetIcon($IDTreeView, $TreeItems[$i],  "shell32.dll", 131)
        Else
            GUICtrlSetData($TreeItems[$i],GUICtrlRead($DataInputs[$i]))
            _GUICtrlTreeViewSetIcon($IDTreeView, $TreeItems[$i],  "shell32.dll", 208)
        EndIf
    Next
EndFunc
;~ Func _EnableAddressLabelOptions($View) ; 1=yes 0=no
;~  If $View = 1 Then
;~      GUICtrlSetState($NONGMAddressLabels,$GUI_ENABLE)
;~      GUICtrlSetState($GMAddressLabels,$GUI_ENABLE)
;~      _Log($LogFile,'Program Action: Enabled address label options.')
;~  EndIf
;~  If $View = 0 Then
;~      GUICtrlSetState($NONGMAddressLabels,$GUI_DISABLE)
;~      GUICtrlSetState($GMAddressLabels,$GUI_DISABLE)
;~      _Log($LogFile,'Program Action: Disabled address label options.')
;~  EndIf
;~ EndFunc
Func _EnableLabelData($View) ; 1=yes 0=no
    If $View = 1 Then
        GUICtrlSetState($SalesOrder,$GUI_ENABLE)
        GUICtrlSetState($KitNumber,$GUI_ENABLE)
        GUICtrlSetState($CustomerPartNumber,$GUI_ENABLE)
        GUICtrlSetState($Description,$GUI_ENABLE)
        GUICtrlSetState($DueDate,$GUI_ENABLE)
        GUICtrlSetState($QtyRequested,$GUI_ENABLE)
        GUICtrlSetState($QtyPerPallet,$GUI_ENABLE)
        _EnableTreeViewData(1)
        GUICtrlSetState($SalesOrder,$GUI_FOCUS)
        _Log($LogFile,'Program Action: Enabled Label data controls.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,"Enabled data controls.",1)
    EndIf
    If $View = 0 Then
        GUICtrlSetState($SalesOrder,$GUI_DISABLE)
        GUICtrlSetState($KitNumber,$GUI_DISABLE)
        GUICtrlSetState($CustomerPartNumber,$GUI_DISABLE)
        GUICtrlSetState($Description,$GUI_DISABLE)
        GUICtrlSetState($DueDate,$GUI_DISABLE)
        GUICtrlSetState($QtyRequested,$GUI_DISABLE)
        GUICtrlSetState($QtyPerPallet,$GUI_DISABLE)
        _EnableTreeViewData(0)
        _Log($LogFile,'Program Action: Disabled Label data controls.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,"Disabled data controls.",1)
    EndIf
EndFunc
;~ Func _EnableIDLabelData($View) ; 1=yes 0=no
;~  If $View = 1 Then
;~      GUICtrlSetState($IDQty,$GUI_ENABLE)
;~      GUICtrlSetState($IDQtyofLabels,$GUI_ENABLE)
;~      GUICtrlSetState($IDAdd,$GUI_ENABLE)
;~      GUICtrlSetState($Print,$GUI_ENABLE)
;~      GUICtrlSetState($Clear,$GUI_ENABLE)
;~      GUICtrlSetState($IDRemove,$GUI_ENABLE)
;~  EndIf
;~  If $View = 0 Then
;~      GUICtrlSetState($IDQty,$GUI_DISABLE)
;~      GUICtrlSetState($IDQtyofLabels,$GUI_DISABLE)
;~      GUICtrlSetState($IDAdd,$GUI_DISABLE)
;~      GUICtrlSetState($Print,$GUI_DISABLE)
;~      GUICtrlSetState($Clear,$GUI_DISABLE)
;~      GUICtrlSetState($IDRemove,$GUI_DISABLE)
;~  EndIf
;~ EndFunc
;~ Func _EnableListData($View) ; 1=yes 0=no
;~  If $View = 1 Then
;~      GUICtrlSetState($List1,$GUI_ENABLE)
;~      _Log($LogFile,'Program Action: Enabled ID label list.')
;~  EndIf
;~  If $View = 0 Then
;~      GUICtrlSetState($List1,$GUI_DISABLE)
;~      _Log($LogFile,'Program Action: Disabled ID label list.')
;~  EndIf
;~ EndFunc
Func _EnableTreeViewData($View) ; 1=yes 0=no
    If $View = 1 Then
        GUICtrlSetState($IDTreeView,$GUI_ENABLE)
        _Log($LogFile,'Program Action: Enabled Label data visual.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,"Enabled data tree.",1)
    EndIf
    If $View = 0 Then
        GUICtrlSetState($IDTreeView,$GUI_DISABLE)
        _Log($LogFile,'Program Action: Disabled Label data visual.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,"Disabled data tree.",1)
    EndIf
EndFunc
Func _Description()
    _ListViewGUI('Descriptions on File:',IniRead($INIFile, 'Paths', 'Description File', 'Error'))
    GUICtrlSetState($DueDate,$GUI_FOCUS)
EndFunc   ;==>_Description
Func _ListViewGUI($GUIName,$ListFileName)
    Local $s_FilePath
    Local $a_Description
    Local $ListData
    
    #region ; Ensure the file exists, if so open it.
    If $ListFileName = 'Error' Then
        MsgBox(4096,'Alert','Unable to load path to the description file from "'&$INIFile&'" file.')
        _Log($LogFile,'Unable to load path to the description file from "'&$INIFile&'" file.')
    EndIf
    $File = FileOpen($ListFileName,0)   ; Check if file opened for reading OK
    If $file = -1 Then
        MsgBox(0, "Error", "Unable to locate description file.")
        Exit
    EndIf
    #endregion
    
    #region ; Create description list
    While 1
        $line = FileReadLine($File)
        If @error = -1 Then ExitLoop
        $line = StringMid($line,2,StringLen($line)-2)
        $ListData = $ListData & $line & '|'
    Wend
    FileClose($file)
    _Log($LogFile,'Program Action: Description list created.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,"Description list created.",1)
    #endregion
    
    $Desc = GuiCreate("Description", 210, 335,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    $Label__ListViewGUI     = GuiCtrlCreateLabel ($GUIName, 10, 10, 190, 20)
    $List__ListViewGUI      = GuiCtrlCreateList  ("", 10, 30, 190, 279)
    GUICtrlSetdata(-1,$ListData)
    $bOk__ListViewGUI       = GuiCtrlCreateButton("Ok"    , 10 , 305, 50, 20,$BS_DEFPUSHBUTTON )
    $bAdd__ListViewGUI      = GuiCtrlCreateButton("Add"   , 60 , 305, 50, 20)
    $bRemove__ListViewGUI   = GuiCtrlCreateButton("Remove", 110, 305, 50, 20)
    $bClose__ListViewGUI    = GuiCtrlCreateButton("Close" , 160, 305, 40, 20)
    GUICtrlSetState($List__ListViewGUI,$GUI_FOCUS)
    GuiSetState()
    WinSetOnTop($Desc,'',1)
    _Log($LogFile,'Program Action: Description GUI created.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,"Description GUI created.",1)
    While 1
        $msg = GuiGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE ; GUI Close
                _Log($LogFile,'User Action: Close "X" clicked.')
                WinSetOnTop("Description",'',0)
                GUIDelete()
                ExitLoop
            Case $msg = $bClose__ListViewGUI ;  Button Close
                _Log($LogFile,'User Action: Close button clicked.')
                WinSetOnTop("Description",'',0)
                GUIDelete()
                ExitLoop
            Case $msg = $bAdd__ListViewGUI ; Add Description
                _Log($LogFile,'User Action: "Add" button clicked.')
                WinSetOnTop("Description",'',0)
                While 1
                    $sDescription = InputBox('Description','Enter New Description:','','',200,130)
                    Select
                        Case @error = 1
                            _Log($LogFile,'User Action: "Cancel" button clicked.')
                            $sDescription = ''
                            ExitLoop
                        Case $sDescription = ''
                            _Log($LogFile,'User Action: "Continue" button clicked - Input field blank.')
                            ContinueLoop
                        Case @error = 0
                            $sDescription = StringUpper($sDescription)
                            FileWrite($ListFileName, '"' & $sDescription & '"' & @LF)
                            _Log($LogFile,'Program Action: '&$sDescription&' added to the description file')
                            ;_GUICtrlStatusBarSetText ($StatusBar1,$sDescription&' added to the description file.',1)
                            GUICtrlSetData($Description,$sDescription)
                            GUIDelete($Desc)
                            ExitLoop(2)
                    EndSelect
                WEnd
            Case $msg = $bOk__ListViewGUI ; Ok Selection
                _Log($LogFile,'User Action: "Ok" clicked')
                $sDescription = GUICtrlRead($List__ListViewGUI)
                If $sDescription = '' Then ContinueLoop
                WinSetOnTop("Description",'',0)
                GUIDelete($Desc)
                GUICtrlSetData($Description ,$sDescription)
                _Log($LogFile,'Program Action: '&$sDescription&' set on the description button.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,$sDescription&' set on the description button.',1)
                ExitLoop
            Case $msg = $bRemove__ListViewGUI ; Remove Selection
                _Log($LogFile,'User Action: "Remove" clicked')
                _FileReadToArray($ListFileName,$a_Description)
                $sDescription = GUICtrlRead($List__ListViewGUI)
                If $sDescription = '' Then ContinueLoop
                $i_index = _ArraySearch($a_Description,'"'&$sDescription&'"')
                _ArrayDelete($a_Description,$i_index)
                FileDelete($ListFileName)
                _FileWriteFromArray($ListFileName,$a_Description,1)
                _Log($LogFile,'Program Action: '&$sDescription&' removed from the description file.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,$sDescription&' removed from the description file.',1)
                WinSetOnTop("Description",'',0)
                MsgBox(4096,'Notice',$sDescription & ' removed from the list.')
                GUIDelete($Desc)
                ExitLoop
        EndSelect
    WEnd
EndFunc
Func _ClearAllInputs()
;~  $Inputs = _ArrayCreate($SalesOrder,$KitNumber,$CustomerPartNumber,$Description,$DueDate,$QtyRequested,$QtyPerPallet,$IDQty,$IDQtyofLabels)
    $Inputs = _ArrayCreate($SalesOrder,$KitNumber,$CustomerPartNumber,$Description,$DueDate,$QtyRequested,$QtyPerPallet)
    For $i = 0 To UBound($Inputs)-1
        If $i = 3 Then
            GUICtrlSetData($Inputs[$i],'Click to enter description.')
        Else
            GUICtrlSetData($Inputs[$i],'')
        EndIf
    Next
;~  GUICtrlSetData($List1,'')
EndFunc
Func _DataVerification()
    #region ; Sales Order Number
    Global $sSalesOrder = GUICtrlRead($SalesOrder)
    If $sSalesOrder = '' Then
        MsgBox(4096, 'Error', 'Sales order number is invalid.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(1)
        _Log($LogFile,'Program Action: Sales Order number is invalid, '&$sSalesOrder&'.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Sales Order number is invalid, '&$sSalesOrder,1)
        Return
    EndIf
    If StringLen($sSalesOrder) <> 5 Then
        MsgBox(4096, 'Error', 'Sales order number is not valid length.' & @CRLF & @CRLF & 'Must be five (5) digits in length.')
        SetError(1)
        _Log($LogFile,'Program Action: Sales Order number is invalid, '&$sSalesOrder&'.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Sales Order number is invalid, '&$sSalesOrder,1)
        Return
    EndIf
    If StringIsDigit($sSalesOrder) = 0 Then
        MsgBox(4096, 'Error', 'Sales order number is invalid.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(1)
        _Log($LogFile,'Program Action: Sales Order number is invalid, '&$sSalesOrder&'.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Sales Order number is invalid, '&$sSalesOrder,1)
        Return
    EndIf
    _Log($LogFile,'Program Action: Sales Order '&$sSalesOrder&' is okay.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Sales Order is valid, '&$sSalesOrder,1)
    #endregion

    #region ; Customer Part Number
    Global $sCustomerPartNumber = GUICtrlRead($CustomerPartNumber)
    If $sCustomerPartNumber = '' Then
        MsgBox(4096, 'Error', 'Customer part number is blank.')
        SetError(2)
        _Log($LogFile,'Program Action: Customer part number is blank.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Customer part number is blank.',1)
        Return
    EndIf
    _Log($LogFile,'Program Action: Customer part number '&$sCustomerPartNumber&' is okay.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Customer part number '&$sCustomerPartNumber&' is okay.',1)
    #endregion

    #region ; TRW Kit Number
    Global $sKitNumber = GUICtrlRead($KitNumber)
    If $sKitNumber = '' Then
        MsgBox(4096, 'Error', 'TRW kit number is blank.')
        SetError(3)
        _Log($LogFile,'Program Action: TRW kit number is blank.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'TRW kit number is blank.',1)
        Return
    EndIf

    If FileExists(IniRead($INIFile,'Paths','Process Sheets','Error') & '\' & $sKitNumber & '.xls') = 0 Then
        MsgBox(4096, 'Error', "Process sheet doesn't exist for this kit number." & @CRLF & @CRLF & 'Unable to print labels, see production clerk.')
        SetError(3)
        _Log($LogFile,'Program Action: No process sheet for TRW kit number '&$sKitNumber&'.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'No process sheet for TRW kit number '&$sKitNumber&'.',1)
        Return
    EndIf
    _Log($LogFile,'Program Action: TRW kit number '&$sKitNumber&' is okay.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'TRW kit number '&$sKitNumber&' is okay.',1)
    #endregion

    #region ; Description
    Global $sDescription = GUICtrlRead($Description)
    If $sDescription = 'Click to Choose Description' Then
        MsgBox(4096, 'Error', 'Description is incorrect.')
        SetError(4)
        _Log($LogFile,'Program Action: Description is incorrect.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Description is incorrect.',1)
        Return
    EndIf
    _Log($LogFile,'Program Action: Description '&$sDescription&' is okay.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Description '&$sDescription&' is okay.',1)
    #endregion

    #region ; Due Date
    Global $sDueDate = GUICtrlRead($DueDate)
    If $sDueDate = '' Then
        MsgBox(4096, 'Error', 'Due date is blank.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(5)
        _Log($LogFile,'Program Action: Date is blank.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Date is blank.',1)
        Return
    EndIf
    If StringLen($sDueDate) <> 6 Then
        MsgBox(4096, 'Error', 'Due date is not valid length.' & @CRLF & @CRLF & 'Must be six (6) digits in length.' & @CRLF & 'Example: 071307')
        SetError(5)
        _Log($LogFile,'Program Action: Date '&$sDueDate&' is invalid length.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Date '&$sDueDate&' is invalid length.',1)
        Return
    EndIf
    If StringIsDigit($sDueDate) = 0 Then
        MsgBox(4096, 'Error', 'Due date is invalid.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(5)
        _Log($LogFile,'Program Action: Date '&$sDueDate&' is bad format.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Date '&$sDueDate&' is bad format.',1)
        Return
    EndIf

    $MONTH = StringLeft($sDueDate, 2)
    $DAY = StringMid($sDueDate, 3, 2)
    $YEAR = '20' & StringRight($sDueDate, 2)

    If _DateIsValid($YEAR & "/" & $MONTH & "/" & $DAY) = 0 Then
        MsgBox(4096, 'Error', 'Due date is invalid.' & @CRLF & @CRLF & 'Either it is entered wrong, or' & @CRLF & 'the date is impossible.')
        SetError(5)
        _Log($LogFile,'Program Action: Date '&$sDueDate&' is not possible.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Date '&$sDueDate&' is not possible.',1)
        Return
    EndIf
    _Log($LogFile,'Program Action: Date '&$sDueDate&' is possible.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Date '&$sDueDate&' is possible.',1)
    #endregion

    #region ; Quantity Requested
    Global $sQtyRequested = GUICtrlRead($QtyRequested)
    If $sQtyRequested = '' Then
        MsgBox(4096, 'Error', 'Quantity requested is blank.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(6)
        _Log($LogFile,'Program Action: Quantity requested is blank.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity requested is blank.',1)
        Return
    EndIf
    If StringIsDigit($sQtyRequested) = 0 Then
        MsgBox(4096, 'Error', 'Quantity requested is invalid.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(6)
        _Log($LogFile,'Program Action: Quantity requested '&$sQtyRequested&' is bad.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity requested '&$sQtyRequested&' is bad.',1)
        Return
    EndIf
    _Log($LogFile,'Program Action: Quantity requested '&$sQtyRequested&' is okay.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity requested '&$sQtyRequested&' is okay.',1)
    #endregion

    #region ; Quantity Per Full Pallet
    Global $sQtyPerPallet = GUICtrlRead($QtyPerPallet)
    If $sQtyPerPallet = '' Then
        MsgBox(4096, 'Error', 'Quantity per full pallet is blank.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(7)
        _Log($LogFile,'Program Action: Quantity per full pallet is blank.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity per full pallet is blank.',1)
        Return
    EndIf
    If StringIsDigit($sQtyPerPallet) = 0 Then
        MsgBox(4096, 'Error', 'Quantity per full pallet is invalid.' & @CRLF & @CRLF & 'Only digit (0-9) characters.')
        SetError(7)
        _Log($LogFile,'Program Action: Quantity per full pallet '&$sQtyRequested&' is bad.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity per full pallet '&$sQtyRequested&' is bad.',1)
        Return
    EndIf
    _Log($LogFile,'Program Action: Quantity per full pallet ('&$sQtyRequested&') is okay.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity per full pallet ('&$sQtyRequested&') is okay.',1)
    #endregion
    SetError(0)
    _Log($LogFile,'Program Action: Data verified okay.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Data verified okay.',1)
EndFunc   ;==>_DataVerification
Func _Print()
    Local $sAddress
    Local $sType
    
    #region ; Verify valid data entry. If invalid data exists it will prompt the user.
    _Log($LogFile,'Program Action: Data verification started.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Data verification started.',1)
    _DataVerification()
    If @error <> 0 Then
        Select
            Case @error = 1
                GUICtrlSetState($SalesOrder, $GUI_ENABLE)
                GUICtrlSetState($SalesOrder, $GUI_FOCUS)
                _Log($LogFile,'Program Action: Sales Order input brought to focus.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,'Sales Order input brought to focus.',1)
                Return
            Case @error = 3
                GUICtrlSetState($KitNumber, $GUI_ENABLE)
                GUICtrlSetState($KitNumber, $GUI_FOCUS)
                _Log($LogFile,'Program Action: Kit number input brought to focus.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,'Kit number input brought to focus.',1)
                Return
            Case @error = 2
                GUICtrlSetState($CustomerPartNumber, $GUI_ENABLE)
                GUICtrlSetState($CustomerPartNumber, $GUI_FOCUS)
                _Log($LogFile,'Program Action: Customer part number input brought to focus.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,'Customer part number input brought to focus.',1)
                Return
            Case @error = 4
                GUICtrlSetState($Description, $GUI_ENABLE)
                GUICtrlSetState($Description, $GUI_FOCUS)
                _Log($LogFile,'Program Action: Description button brought to focus.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,'Description button brought to focus.',1)
                Return
            Case @error = 5
                GUICtrlSetState($DueDate, $GUI_ENABLE)
                GUICtrlSetState($DueDate, $GUI_FOCUS)
                _Log($LogFile,'Program Action: Due date input brought to focus.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,'Due date input brought to focus.',1)
                Return
            Case @error = 6
                GUICtrlSetState($QtyRequested, $GUI_ENABLE)
                GUICtrlSetState($QtyRequested, $GUI_FOCUS)
                _Log($LogFile,'Program Action: Quantity requested input brought to focus.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity requested input brought to focus.',1)
                Return
            Case @error = 7
                GUICtrlSetState($QtyPerPallet, $GUI_ENABLE)
                GUICtrlSetState($QtyPerPallet, $GUI_FOCUS)
                _Log($LogFile,'Program Action: Quantity per pallet input brought to focus.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,'Quantity per pallet input brought to focus.',1)
                Return
        EndSelect
    EndIf
    #endregion

    #region ; Define Full and Partial Pallets
    Global $FULL_PALLETS = Int($sQtyRequested / $sQtyPerPallet)
    Global $PARTIAL = $sQtyRequested - ($sQtyPerPallet * $FULL_PALLETS)
    _Log($LogFile,'Program Action: Full and partial pallet calculated.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Full and partial pallet calculated.',1)
    #endregion
    
    #region ; Captailize Alpha Data
    $sCustomerPartNumber = StringUpper($sCustomerPartNumber)
    $sKitNumber = StringUpper($sKitNumber)
    $sDescription = StringUpper($sDescription)
    _Log($LogFile,'Program Action: Alphanumeric data capatilized.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Alphanumeric data capatilized.',1)
    #endregion
    
    #region ; Check/Write Kit Data
    IniReadSection(IniRead($INIFile,'Paths','Finished Kit Data','Error'),$sKitNumber & ',' & $sCustomerPartNumber)
    If @error Then
        IniWrite(IniRead($INIFile,'Paths','Finished Kit Data','Error'),$sKitNumber & ',' & $sCustomerPartNumber,'Description',$sDescription)
        If GUICtrlRead($BpkgBrec) = 1 Then
            $sType = 'Bpkg/Brec'
            _Log($LogFile,'Program Action: Bpkg/Brec added as finished kit type.')
        Else
            $sType = 'Bulk/ESD'
            _Log($LogFile,'Program Action: Bulk/ESD added as finished kit type.')
        EndIf
        IniWrite(IniRead($INIFile,'Paths','Finished Kit Data','Error'),$sKitNumber & ',' & $sCustomerPartNumber,'Type',$sType)
        If GUICtrlRead($NONGMAddressLabels) = 1 Then
            $sAddress = 'NON GM'
            _Log($LogFile,'Program Action: NON GM added as finished kit address label style.')
        Else
            $sAddress = 'GM'
            _Log($LogFile,'Program Action: GM added as finished kit address label style.')
        EndIf
        IniWrite(IniRead($INIFile,'Paths','Finished Kit Data','Error'),$sKitNumber & ',' & $sCustomerPartNumber,'Address Label Style',$sAddress)
        IniWrite(IniRead($INIFile,'Paths','Finished Kit Data','Error'),$sKitNumber & ',' & $sCustomerPartNumber,'Date & Time Entered',_NowCalc())
        
    EndIf
    #endregion
    
    #region ; Write Pallet Data
    For $i = 1 To $FULL_PALLETS
        If GUICtrlRead($BpkgBrec) = 1 Then ; Audit Tag
            _AuditTag(IniRead($INIFile,'Paths','Barcoded Audit Tag','Error'),$sQtyPerPallet)
            _Log($LogFile,'Program Action: Barcoded audit tag print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'Barcoded audit tag print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet,1)
        Else
            _AuditTag(IniRead($INIFile,'Paths','Plain Audit Tag','Error'),$sQtyPerPallet)
            _Log($LogFile,'Program Action: Plain audit tag print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'Plain audit tag print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet,1)
        EndIf
        If GUICtrlRead($NONGMAddressLabels) = 1 Then ; Address Label
            _NonGMShippingLabel('1',IniRead($INIFile,'Paths','NON GM Address Label','Error'),$sQtyPerPallet)
            _Log($LogFile,'Program Action: NON GM address label print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'NON GM address label print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet,1)
            _DCXShipCodeLabel($sSalesOrder)
        Else
            _GMShippingLabels('4',$sQtyPerPallet)
            _Log($LogFile,'Program Action: GM address label print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'GM address label print job data added to temp file. Quantity on pallet: '&$sQtyPerPallet,1)
        EndIf
    Next
    
    If $PARTIAL <> 0 Then
        If GUICtrlRead($BpkgBrec) = 1 Then ; Audit Tag
            _AuditTag(IniRead($INIFile,'Paths','Barcoded Audit Tag','Error'),$PARTIAL)
            _Log($LogFile,'Program Action: Barcoded audit tag print job data added to temp file. Quantity on partial pallet: '&$PARTIAL)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'Barcoded audit tag print job data added to temp file. Quantity on partial pallet: '&$PARTIAL,1)
        Else
            _AuditTag(IniRead($INIFile,'Paths','Plain Audit Tag','Error'),$PARTIAL)
            _Log($LogFile,'Program Action: Plain audit tag print job data added to temp file. Quantity on partial pallet: '&$PARTIAL)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'Plain audit tag print job data added to temp file. Quantity on partial pallet: '&$PARTIAL,1)
        EndIf
        If GUICtrlRead($NONGMAddressLabels) = 1 Then
            _NonGMShippingLabel('1',IniRead($INIFile,'Paths','NON GM Address Label','Error'),$PARTIAL)
            _Log($LogFile,'Program Action: NON GM address label print job data added to temp file. Quantity on partial pallet: '&$PARTIAL)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'NON GM address label print job data added to temp file. Quantity on partial pallet: '&$PARTIAL,1)
            _DCXShipCodeLabel($sSalesOrder)
        Else
            _GMShippingLabels('4',$PARTIAL)
            _Log($LogFile,'Program Action: GM address label print job data added to temp file. Quantity on partial pallet: '&$PARTIAL)
            ;_GUICtrlStatusBarSetText ($StatusBar1,'GM address label print job data added to temp file. Quantity on partial pallet: '&$PARTIAL,1)
        EndIf
    EndIf
    
    #endregion
    #region ; Write ID Label Data
;~  For $i = 0 To _GUICtrlListCount($List1) -1
;~      $value = _GUICtrlListGetText($List1, $i)
;~      $value = StringSplit($value,' ')
;~      If GUICtrlRead($NONGMAddressLabels) = 1 Then ; ID Labels
;~          _NonGMShippingLabel($value[1],IniRead($INIFile,'Paths','NON GM Bulk ID Label','Error'),$value[UBound($value)-1])
;~          _Log($LogFile,'Program Action: NON GM ID label print job data added to temp file. Quantity on pallet: '&$value[UBound($value)-1] &' Number of labels: '&$value[1])
;~      Else
;~          _GMShippingLabels($value[1],$value[UBound($value)-1])
;~          _Log($LogFile,'Program Action: GM ID label print job data added to temp file. Quantity on pallet: '&$value[UBound($value)-1] &' Number of labels: '&$value[1])
;~      EndIf
;~  Next
    #endregion
    
    FileCopy($TempFile,IniRead(IniRead($INIFile,'Paths','LabelView Label.ini File','ERROR'), 'Command File', 'Monitor Dir', '....') &'\Bulk.cmd')
    _Log($LogFile,'Program Action: Temp file copied to '&IniRead(IniRead($INIFile,'Paths','LabelView Label.ini File','ERROR'), 'Command File', 'Monitor Dir', '....') &'\Bulk.cmd')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Temp file copied to '&IniRead(IniRead($INIFile,'Paths','LabelView Label.ini File','ERROR'), 'Command File', 'Monitor Dir', '....') &'\Bulk.cmd',1)
    
    FileDelete($TempFile)
    _Log($LogFile,'Program Action: Temp file deleted.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'Temp file deleted.',1)
    _ClearAllInputs()
    _Log($LogFile,'Program Action: All inputs cleared.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'All inputs cleared.',1)
    
    GUICtrlSetState($BpkgBrec,$GUI_UNCHECKED)
    GUICtrlSetState($BulkESD,$GUI_UNCHECKED)
    GUICtrlSetState($NONGMAddressLabels,$GUI_UNCHECKED)
    GUICtrlSetState($GMAddressLabels,$GUI_UNCHECKED)
    _SetDisplayData()
;~  _EnableAddressLabelOptions(0)
    _EnableLabelData(0)
;~  _EnableIDLabelData(0)
;~  _EnableListData(0)
    _EnableTreeViewData(0)
    _Log($LogFile,'Program Action: GUI controls set to a "fresh" state.')
    ;_GUICtrlStatusBarSetText ($StatusBar1,'GUI controls reset.',1)
EndFunc
Func _AuditTag($Label,$QOP)
    $Caution_Label = Caution_label($sKitNumber,$sCustomerPartNumber,$sSalesOrder,$QOP)
    FileWriteLine($TempFile, 'LABELNAME = "' & $Label & '"' & @CRLF & _
            'Printer = "' & $PrinterName & '"' & @CRLF & _
            'SO = "' & $sSalesOrder & '"' & @CRLF & _
            'Cust = "' & $sCustomerPartNumber & '"' & @CRLF & _
            'text16 = "' & $sKitNumber & '"' & @CRLF & _
            'Desc = "' & $sDescription & '"' & @CRLF & _
            'Due = "' & $sDueDate & '"' & @CRLF & _
            'qop = "' & $QOP & '"' & @CRLF & _
            'QTY = "' & $sQtyRequested & '"' & @CRLF & _
            'PER = "' & $sQtyPerPallet & '"' & @CRLF & _
            'Partial = "' & $PARTIAL & '"' & @CRLF & _
            'FP = "' & $FULL_PALLETS & '"' & @CRLF & _
            'Full_Weight = "' & $Kit_Weight * $QOP + 50 & '"' & @CRLF & _
            'Current_Weight = "' & $Kit_Weight * $QOP + 50 & '"' & @CRLF & _
            'Caution_Label = "' & $Caution_Label & '"' & @CRLF & _
            'LABELQUANTITY =1')
EndFunc   ;==>_AuditTag
Func _DCXShipCodeLabel($sSalesOrder)
    Local $Ship_Code_Number = IniRead(IniRead($INIFile,'Paths','DCX Ship Code File','Error'), 'Ship Codes', $sSalesOrder, 'Error')
    If $Ship_Code_Number <> 'Error' Then
        FileWriteLine($TempFile, 'LABELNAME = "' & IniRead($INIFile,'Paths','DCX Ship Code Label','Error') & '"' & @CRLF & _
                'Printer = "' & $PrinterName & '"' & @CRLF & _
                'Text16 = "' & $Ship_Code_Number & '"' & @CRLF & _
                'LABELQUANTITY =1')
        _Log($LogFile,'Program Action: DCX ship code label print job data added to temp file. Code: '&$Ship_Code_Number)
        ;_GUICtrlStatusBarSetText ($StatusBar1,'DCX Ship code label.',1)
    EndIf
EndFunc   ;==>_DCXShipCodeLabel
Func _NonGMShippingLabel($qty,$Label,$QOP)
    FileWriteLine($TempFile, 'LABELNAME = "' & $Label & '"' & @CRLF & _
            'Printer = "' & $PrinterName & '"' & @CRLF & _
            'Text19 = "' & $sSalesOrder & '"' & @CRLF & _
            'Part = "' & $sCustomerPartNumber & '"' & @CRLF & _
            'kit = "' & $sKitNumber & '"' & @CRLF & _
            'text14 = "' & $sDescription & '"' & @CRLF & _
            'QTY = "' & $QOP & '"' & @CRLF & _
            'LABELQUANTITY ='&$qty)
EndFunc   ;==>_NonGMShippingLabel
Func _GMShippingLabels($qty,$QOP)
    FileWriteLine($TempFile, 'LabelName = "' & IniRead($INIFile,'Paths','GM Address Label','Error') & '"' & @CRLF & _
            'Printer = "' & $PrinterName & '"' & @CRLF & _
            'SO = "' & $sSalesOrder & '"' & @CRLF & _
            'Part = "' & $sCustomerPartNumber & '"' & @CRLF & _
            'text40 = "' & $sKitNumber & '"' & @CRLF & _
            'text38 = "' & $sDescription & '"' & @CRLF & _
            'QTY = "' & $QOP & '"' & @CRLF & _
            'LABELQUANTITY = '&$qty)
EndFunc   ;==>_GMShippingLabels
Func Caution_label($sKitNumber,$sCustomerPartNumber,$sSalesOrder,$QOP)
    Local $Sales_Order_Customer = IniRead(IniRead($INIFile,'Paths','Finished Kit Data', "ERROR"),$sKitNumber & ',' & $sCustomerPartNumber, 'Heavy Load Label', "ERROR")
    $Kit_Weight = IniRead(IniRead($INIFile,'Paths','Finished Kit Data', "ERROR"),$sKitNumber&','&$sCustomerPartNumber, "Weight", "ERROR")
    If $Sales_Order_Customer = 'ERROR' Then
        _Log($LogFile,'Program Action: Opening heavy load label GUI.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Opening heavy load label GUI.',1)
        _HeavyLoadLabelGUI($sKitNumber,$sCustomerPartNumber,IniRead($INIFile,'Paths','Finished Kit Data', "ERROR"))
    EndIf
    If $Kit_Weight = 'ERROR' Then
        _Log($LogFile,'Program Action: Opening kit weight GUI.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,'Opening kit weight GUI.',1)
        _KitWeightGUI($sKitNumber,$sCustomerPartNumber,IniRead($INIFile,'Paths','Finished Kit Data', "ERROR"))
    EndIf
    If $Kit_Weight * $QOP + 50 >= 800 Then
        Select
            Case $Sales_Order_Customer = "FORD"
                $Caution_Label = "Ford Heavy.bmp"
                _Log($LogFile,'Program Action: '&$Caution_Label&' selected as heavy load image.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,$Caution_Label&' selected as heavy load image.',1)
                Return $Caution_Label
            Case Else
                $Caution_Label = "BonW Heavy.bmp"
                _Log($LogFile,'Program Action: '&$Caution_Label&' selected as heavy load image.')
                ;_GUICtrlStatusBarSetText ($StatusBar1,$Caution_Label&' selected as heavy load image.',1)
                Return $Caution_Label
        EndSelect
    Else
        $Caution_Label = "Nothing.bmp" ;Fake file
        _Log($LogFile,'Program Action: '&$Caution_Label&' selected as heavy load image.')
        ;_GUICtrlStatusBarSetText ($StatusBar1,$Caution_Label&' selected as heavy load image.',1)
        Return $Caution_Label
    EndIf
EndFunc   ;==>Caution_label
Func _CatchEnterThenTab()
    Send('{TAB}')
EndFunc
Func _OpenLabelView()
    $s_LabelViewExe = RegRead('HKEY_CLASSES_ROOT\Lblvw.Document\shell\open\command','')
    $s_LabelViewExe = StringSplit($s_LabelViewExe,' ')
    $LabelView_PID = Run($s_LabelViewExe[1] & " /cmdm " & IniRead(IniRead($INIFile,'Paths','LabelView Label.ini File','ERROR'), 'Command File', 'Monitor Dir', '....'))
    _Log($LogFile,'Program Initializing - Waiting on Command File Monitor to open.')
    WinWait('Command File Monitor')
    WinActivate($Form1)
    WinWaitActive($Form1)
EndFunc
Func _GetNumLock()
    Local $ret
    $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK)
    Return $ret[0]
EndFunc
Func _SetNumLock()
    If _GetNumLock() = 0 Then
        ConsoleWrite('@@ Debug(865) : _GetNumLock() = ' & _GetNumLock() & @lf & '>Error code: ' & @error & @lf) ;### Debug Console
        Do
            Send('{NUMLOCK}')
            Sleep(200)
        Until _GetNumLock() = 1
    EndIf
EndFunc
Func _LabelSelectionUpdate()
    Dim $a_ListBox[4]
    $a_ListBox[1] = $ADDRESS_LIST
    $a_ListBox[2] = $PACKAGING_LABELS_LIST
    $a_ListBox[3] = $MISC_LIST
    $SelectedLabelCount = 0
    For $i = 1 To 3
        $SelectedLabelCount += _GUICtrlListGetSelCount($a_ListBox[$i])
    Next
    If $SelectedLabelCount <> $OldSelectedLabelCount Then
        _GUICtrlTreeViewDeleteAllItems ( $PrinterTreeView )
        GUICtrlSetState($PrinterList,$GUI_DISABLE)
        GUICtrlSetData ( $PrinterList,'|'&_Identify_Printers())
        Dim $a_list
        Dim $PrinterTreeViewItem[1][1][1]
        For $i = 1 to 3
            $a_list = _GUICtrlListGetSelItemsText($a_ListBox[$i])
            ReDim $PrinterTreeViewItem[Ubound($PrinterTreeViewItem,1)+1][Ubound($PrinterTreeViewItem,2)+1][Ubound($PrinterTreeViewItem,3)+1]
            Select
                Case $i = 1
                    $PrinterTreeViewItem[1][1][1] = _GUICtrlTreeViewInsertItem($PrinterTreeView,'Address Labels')
                Case $i = 2
                    $PrinterTreeViewItem[2][1][1] = _GUICtrlTreeViewInsertItem($PrinterTreeView,'Packaging Labels')
                Case $i = 3
                    $PrinterTreeViewItem[3][1][1] = _GUICtrlTreeViewInsertItem($PrinterTreeView,'Misc. Labels')
            EndSelect
            For $ii = 1 To Ubound($a_list) -1
                ReDim $PrinterTreeViewItem[Ubound($PrinterTreeViewItem,1)][Ubound($PrinterTreeViewItem,2)+1][Ubound($PrinterTreeViewItem,3)]
                $PrinterTreeViewItem[Ubound($PrinterTreeViewItem,1)-1][Ubound($PrinterTreeViewItem,2)-1][Ubound($PrinterTreeViewItem,1)-1] = _GUICtrlTreeViewInsertItem($PrinterTreeView,$a_list[$ii],$PrinterTreeViewItem[$i][1][1])
                ReDim $PrinterTreeViewItem[Ubound($PrinterTreeViewItem,1)][Ubound($PrinterTreeViewItem,2)][Ubound($PrinterTreeViewItem,3)+1]
                $PrinterTreeViewItem[Ubound($PrinterTreeViewItem,1)-1][Ubound($PrinterTreeViewItem,2)-1][Ubound($PrinterTreeViewItem,1)-1] = _GUICtrlTreeViewInsertItem($PrinterTreeView,'Printer Needs Selected!',$PrinterTreeViewItem[Ubound($PrinterTreeViewItem,1)-1][Ubound($PrinterTreeViewItem,2)-1][Ubound($PrinterTreeViewItem,1)-1])
                _GUICtrlTreeViewExpand($PrinterTreeView)
                GUICtrlSetState($PrinterList,$GUI_ENABLE)
            Next
        Next
        $OldSelectedLabelCount = $SelectedLabelCount
    EndIf
EndFunc
 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;;;;;;;;;;;;;;;;;;;;;;;;                 09/25/07                 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _Identify_Printers()
    Local $key, $default, $i = 1, $list, $name
    If @OSTYPE = "WIN32_WINDOWS" Then ;for 95/98/Me
        $key = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers"
        $default = RegRead("HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers", "Default")
    Else;WIN_NT type   for NT/2000/XP/2003
        $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers"
        $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
        $default = StringLeft($default, StringInStr($default, ",") - 1);remove info after comma...
    EndIf
    
    ; ENUMERATE LOCAL PRINTERS
    While 1
        RegRead($key, "")
        If @error = 1 Then ExitLoop
        Local $name = RegEnumKey($key, $i)
        If @error Then ExitLoop
;~         Local $port = " on " & RegRead($key & "\" & $name, "Port")
;~         If StringReplace($name,",","\") = $default Then $port = ' * DEFAULT * ' & $port
;~         $list = $list & StringReplace($name,",","\") & $port & @CRLF
        $list = $list & StringReplace($name,",","\") & '|'
        $i = $i + 1
    WEnd
    
    If $list = "" Then $list = "No printers detected" & @CRLF
    Return $list
EndFunc   ;==>_Identify_Printers


#region ; Kit Weight INI
;~ $s_CustomerPartNumber = '04721820AE'
;~ $s_Kit = 136041
;~ $s_KitDataFile = 'C:\Testkitweight.ini'
;~ _KitWeightGUI($s_Kit,$s_CustomerPartNumber,$s_KitDataFile)

Func _KitWeightGUI($s_Kit,$s_CustomerPartNumber,$s_KitDataFile)
;~  #include <GUIConstants.au3>
;~  #include <Array.au3>
    Local $i_Weight
    Local $msg
    Local $Form1, $Label1, $Label2, $CtrlB_Continue ; GUI Controls
    
    #Region ### START Koda GUI section ### Form=
    $Kit_Setup = GUICreate("Kit Setup", 265, 128, -1, -1)
    $Label1 = GUICtrlCreateLabel("Kit "&$s_Kit&" is currently not on file.", 8, 8, 260, 17)
    $Label2 = GUICtrlCreateLabel("To create labels for this kit you must enter the weight of a finished kit. The weight should be on your process sheet already.", 8, 32, 245, 49)
    $CtrlI_Weight = GUICtrlCreateInput("", 8, 96, 49, 21)
    GUICtrlSetCursor ($CtrlI_Weight, 5)
    $CtrlB_Continue = GUICtrlCreateButton("Continue", 104, 96, 145, 23, $BS_DEFPUSHBUTTON)
    GUICtrlSetCursor ($CtrlB_Continue, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    WinSetOnTop($Kit_Setup,'',1)
    While 1
        Sleep(10)
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $CtrlB_Continue
                $i_Weight = GUICtrlRead($CtrlI_Weight)
                If StringIsDigit($i_Weight)Then
                    SetError(0)
                ElseIf StringRegExp($i_Weight,'[0123456789]*[.][0123456789]+') <> 0  Then
                    SetError(0)
                Else
                    SetError(1)
                EndIf
                If @error Then 
                    GUISetState(@SW_HIDE)
                    MsgBox(4096+48,'Error','Invalid format, only digits (0-9) are acceptable.')
                    GUICtrlSetData($CtrlI_Weight,'')
                    GUICtrlSetState($CtrlI_Weight,$GUI_FOCUS)
                    GUISetState(@SW_SHOW)
                    ContinueLoop
                Else
                    IniWrite($s_KitDataFile,$s_Kit&','&$s_CustomerPartNumber,'Weight',$i_Weight)
                    WinSetOnTop($Kit_Setup,'',0)
                    GUIDelete($Kit_Setup)
                    ExitLoop
                EndIf
        EndSwitch
    WEnd
    
EndFunc
#endregion
#region ; Customer Name - Sales Order Link INI
;~ #include <GUIConstants.au3>

;~ $s_CustomerPartNumber = '04721820AE'
;~ $s_Kit = 136041
;~ $s_KitDataFile = 'C:\Testkitdata.ini'

;~ _HeavyLoadLabelGUI($s_Kit,$s_CustomerPartNumber,$s_KitDataFile)

Func _HeavyLoadLabelGUI($s_Kit,$s_CustomerPartNumber,$s_KitDataFile)
    #Region ### START Koda GUI section ### Form=
    $Heavy_Load = GUICreate("Label Selection", 233, 388, -1, -1)
    $Label1 = GUICtrlCreateLabel("This sales order is currently not on file.", 16, 16, 183, 17)
    $Label2 = GUICtrlCreateLabel("Select the image below, that best suits the proper label, required for the customer.", 16, 40, 203, 33)
    $Pic1 = GUICtrlCreatePic("G:\Packaging\Labels\LVWIN70\PCX\Ford Heavy.bmp", 24, 88, 185, 137, BitOR($SS_NOTIFY,$WS_GROUP))
    GUICtrlSetCursor ($Pic1, 0)
    $Pic2 = GUICtrlCreatePic("G:\Packaging\Labels\LVWIN70\PCX\BonW Heavy.bmp", 24, 240, 185, 121, BitOR($SS_NOTIFY,$WS_GROUP))
    GUICtrlSetCursor ($Pic2, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    WinSetOnTop($Heavy_Load,'',1)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Pic1
                IniWrite($s_KitDataFile,$s_Kit&','&$s_CustomerPartNumber,'Heavy Load Label','Ford')
                ExitLoop
            Case $Pic2
                IniWrite($s_KitDataFile,$s_Kit&','&$s_CustomerPartNumber,'Heavy Load Label','Other')
                ExitLoop
        EndSwitch
    WEnd
    WinSetOnTop($Heavy_Load,'',0)
    GUIDelete($Heavy_Load)
EndFunc
#endregion
Func _Log($s_LogFile,$WhatToLog)
    Local $file = FileOpen($s_LogFile,1)
    FileWriteLine($file, _NowDate() & ' ' & _NowTime(5) & ' ' & $WhatToLog );& @CRLF)
    FileClose($file)
EndFunc
INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
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...