Sign in to follow this  
Followers 0
llewxam

can't force listbox to not sort

6 posts in this topic

Without posting huge code with proprietary info (SQL database IP address and login info) I can not post an example of this, but I have 2 listboxes, each displays information on special orders for a inventory/ordering system I am doing for my company. One box shows orders that are on time, the other shows orders that are overdue. Our special order numbers are done by location and an incremented number, so the third order from York is "YK3", the 50th from Harrisburg is "DS50" etc. We have 4 locations. I would like the oldest orders to be placed highest so have coded in a quick check on the special order using _DateDiff, and have tried using _GUICtrlListBox_InsertString($SPOList, $rowSPONumber), _GUICtrlListBox_InsertString($SPOList, $rowSPONumber, -1), and _GUICtrlListBox_AddString($SPOList, $rowSPONumber) and do NOT have $LBS_SORT on the listboxes, yet each time I try it out the listboxes are sorted as

DS1

DS6

LM4

YK8

etc

In a previous script I put "$LBS_SORT = 0x0001" after my includes and that did the trick, but now won't, saying $LBS_SORT was already set as a Const. I do not have ListBoxConstants.au3 as an include, do have GUIListBox.au3 but it doesn't set $LBS_SORT. Oh, and also tried Opt("$LBS_SORT"=0x00000001) to no avail. I'm really running out of ideas on what to do to make the dang listboxes stop sorting, any other things I should try??

Again sorry I can't post the current code, I guess I COULD but would have to yank the SQL login info, in which case the code might not be much good to anyone. If requested I will do that though, nothing else in the code is "top secret" :(

Thanks for any suggestions!

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Knew I was forgetting to mention something :(

I already have it using BitOR($WS_VSCROLL, $LBS_NOTIFY)

Current includes are:

#include <EditConstants.au3>

#include <array.au3>

#include <_sql.au3>

#include <Inet.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <GuiListBox.au3>

#include <StaticConstants.au3>

Including ListBoxConstants or not makes no difference.

Added $WS_BORDER for grins though I can see what that does, but wanted to do it so I could say I tried, still sorts. hehe, they are persistant!! :)

Thanks

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What the heck, here it is with the login and a few other little details cut out:

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;~      AutoIt Version: 3.3.4.0
;~      Author        : Ian Maxwell

#include <EditConstants.au3>
#include <array.au3>
#include <_sql.au3>
#include <Inet.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <StaticConstants.au3>


Local $serverAddress = ""  ;IP address of database goes here
Local $serverUserName = "sa"  ;the standard default
Local $serverPassword = ""  ;set as needed

_SQL_RegisterErrorHandler();register the error handler to prevent hard crash on COM error

$oADODB = _SQL_Startup()
If $oADODB = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())

If _sql_Connect(-1, $serverAddress, "name", $serverUserName, $serverPassword) = $SQL_ERROR Then  ;change "name"
    MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
    _SQL_Close()
    Exit
EndIf

$PublicIP = _GetIP()
$IP = StringSplit($PublicIP, ".")
If $IP[1] = 000 And $IP[2] = 000 And $IP[3] = 000 Then  ;change "000" to proper IP octets
    TCPStartup()
    $serverAddress = TCPNameToIP("database")
EndIf

Local $hCombo, $nowShowingNew, $nowShowingOld
Local $row, $rowData, $rowSPONumber, $rowCustomerID, $rowDescription, $rowWebsite, $rowNotes, $rowDateTime, $rowDateTimeVerbose, $rowEmployee, $rowQuantity, $rowCost, $rowTotal, $rowDeposit, $rowStatus, $SPOForUpdating, $rowWhere
$overdueDays = 7

$SPOListWidth = 175
$SPOGUI = GUICreate("SPO Manager (Beta 7) 3/24/2010", 520, 450)
GUICtrlCreateLabel("On Time SPOs:", 5, 5, 75, 15)
GUICtrlSetBkColor(-1, "0x00ff00")
$onTimeSPOShow = GUICtrlCreateLabel("", 85, 5, 50, 15)
$SPOList = GUICtrlCreateList("", 5, 20, $SPOListWidth, 235, BitOR($WS_VSCROLL, $LBS_NOTIFY))
GUICtrlCreateLabel("Overdue SPOs:", 5, 250, 75, 15)
GUICtrlSetBkColor(-1, "0xff0000")
GUICtrlSetColor(-1, "0xffffff")
$overdueSPOShow = GUICtrlCreateLabel("", 85, 250, 85, 15)
$overdueSPOList = GUICtrlCreateList("", 5, 265, $SPOListWidth, 150, BitOR($WS_VSCROLL, $LBS_NOTIFY))
GUICtrlCreateLabel("Description:", $SPOListWidth + 10, 5, $SPOListWidth, 15)
$descriptionShow = GUICtrlCreateEdit("", $SPOListWidth + 10, 20, 515 - $SPOListWidth - 10, 60, BitOR($ES_READONLY, $WS_VSCROLL))
GUICtrlSetBkColor(-1, "0xffffff")
GUICtrlCreateLabel("Customer Name:", $SPOListWidth + 10, 100, 80, 15)
$customerNameShow = GUICtrlCreateLabel("", $SPOListWidth + 95, 100, 225, 15, BitOR($SS_CENTER, $ES_READONLY))
GUICtrlSetBkColor(-1, "0xffffff")
GUICtrlCreateLabel("Notes:", $SPOListWidth + 10, 140, $SPOListWidth, 15)
$notesShow = GUICtrlCreateEdit("", $SPOListWidth + 10, 155, 515 - $SPOListWidth - 10, 80, BitOR($ES_READONLY, $WS_VSCROLL))
GUICtrlSetBkColor(-1, "0xffffff")
GUICtrlCreateLabel("Date Ordered:", $SPOListWidth + 10, 250, 70, 15)
$dateTimeShow = GUICtrlCreateLabel("", $SPOListWidth + 85, 250, 65, 15, BitOR($SS_CENTER, $ES_READONLY))
GUICtrlSetBkColor(-1, "0xffffff")
GUICtrlCreateLabel("Quantity:", $SPOListWidth + 200, 250, 45, 15)
$quantityShow = GUICtrlCreateLabel("", $SPOListWidth + 250, 250, 70, 15, BitOR($SS_CENTER, $ES_READONLY))
GUICtrlSetBkColor(-1, "0xffffff")
GUICtrlCreateLabel("Ordered In:", $SPOListWidth + 10, 275, 60, 15)
$whereShow = GUICtrlCreateLabel("", $SPOListWidth + 70, 275, 80, 15, BitOR($SS_CENTER, $ES_READONLY))
GUICtrlSetBkColor(-1, "0xffffff")
GUICtrlCreateLabel("Ordered By:", $SPOListWidth + 185, 275, 60, 15)
$whoShow = GUICtrlCreateLabel("", $SPOListWidth + 250, 275, 70, 15, BitOR($SS_CENTER, $ES_READONLY))
GUICtrlSetBkColor(-1, "0xffffff")
GUICtrlCreateLabel("Days Old:", $SPOListWidth + 10, 305, 50, 15)
$daysOldShow = GUICtrlCreateLabel("", $SPOListWidth + 65, 305, 85, 15, BitOR($SS_CENTER, $ES_READONLY))
GUICtrlSetBkColor(-1, "0xffffff")
$setAsArrived = GUICtrlCreateButton("Set As Arrived", $SPOListWidth + 243, 395, 80, 20)
$showSPOButton = GUICtrlCreateButton("Show SPO", $SPOListWidth + 243, 370, 80, 20)
$editSPO = GUICtrlCreateButton("Edit SPO", $SPOListWidth + 243, 345, 80, 20)
$searchBox = GUICtrlCreateInput("", 5, 420, 90, 20)
$searchButton = GUICtrlCreateButton("Search", 100, 420, 80, 20)
$showAllButton = GUICtrlCreateButton("Show All", $SPOListWidth + 243, 420, 80, 20)
GUICtrlCreateLabel("Include Customer Name and", $SPOListWidth + 27, 408, 180, 20)
$searchWithName = GUICtrlCreateCheckbox("Business Name/Contact in Search", $SPOListWidth + 10, 420, 180, 20)
GUISetState(@SW_SHOW, $SPOGUI)
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
;~ Sleep(4000)
;~ Exit

_UpdateSplit() ;updates $split array with SQL data
_FillItems() ;populates $items list

Do

    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $setAsArrived Then
        $getDateTime = GUICtrlRead($dateTimeShow)
        If $getDateTime <> "" Then
            _SetAsArrived()
            $msg = ""
        Else
            MsgBox(48, "ERROR", "You have not yet selected an item!")
        EndIf
    EndIf
    If $msg = $showSPOButton Then
        $getDateTime = GUICtrlRead($dateTimeShow)
        If $getDateTime <> "" Then
            ShellExecute("http://site.com/vieworder.php?ordernum=" & $rowSPONumber)  ;change site
        Else
            MsgBox(48, "ERROR", "You have not yet selected an item!")
        EndIf
    EndIf
    If $msg = $editSPO Then
        $getDateTime = GUICtrlRead($dateTimeShow)
        If $getDateTime <> "" Then
            _EditSPO()
            $msg = ""
        Else
            MsgBox(48, "ERROR", "You have not yet selected an item!")
        EndIf
    EndIf
    If $msg = $searchButton Then
        _Search()
        $msg = ""
    EndIf
    If $msg = $showAllButton Then
        _UpdateSplit() ;updates $split array with SQL data
        _FillItems() ;populates $items list     GUIDelete($Add)
        $msg = ""
    EndIf

Until 1 = 2


Func _UpdateSplit()

    GUICtrlSetData($SPOList, "")
    GUICtrlSetData($overdueSPOList, "")
    GUICtrlSetData($descriptionShow, "")
    GUICtrlSetData($notesShow, "")
    GUICtrlSetData($quantityShow, "")
    GUICtrlSetData($dateTimeShow, "")
    GUICtrlSetData($onTimeSPOShow, "")
    GUICtrlSetData($overdueSPOShow, "")
    GUICtrlSetData($whereShow, "")
    GUICtrlSetData($whoShow, "")
    GUICtrlSetData($customerNameShow, "")
    GUICtrlSetData($searchBox, "")
    GUICtrlSetData($daysOldShow, "")
    GUICtrlSetBkColor($daysOldShow, "0xffffff")
    GUICtrlSetState($searchWithName, $GUI_UNCHECKED)
    SplashTextOn("Updating", "Retrieving outstanding SPO info, please be patient", 500, 40, -1, -1)
    Local $fullSQL = ""
    If _Sql_GetTableAsString(-1, "SELECT * FROM SpecialOrder WHERE Status='1';", $fullSQL) = $SQL_OK Then
    Else
        MsgBox(0 + 16 + 262144, "SQL Error", _SQL_GetErrMsg())
    EndIf
    $row = StringSplit(StringTrimRight($fullSQL, 1), Chr(3))
    SplashOff()

EndFunc   ;==>_UpdateSplit


Func _FillItems()

    SplashTextOn("Sorting", "Sorting SPO info, please be patient", 500, 40, -1, -1)
    GUICtrlSetData($SPOList, "")
    GUICtrlSetData($overdueSPOList, "")
    GUICtrlSetData($onTimeSPOShow, "")
    GUICtrlSetData($overdueSPOShow, "")
    _GUICtrlListBox_BeginUpdate($SPOList)
    _GUICtrlListBox_BeginUpdate($overdueSPOList)
    $listOnTimeSPO = 0
    $listOverdueSPO = 0
    For $a = 1 To $row[0]
        $rowData = $row[$a]
        _BreakRow()
        $SPOOrderDate = StringMid($rowDateTime, 7, 4) & "/" & StringMid($rowDateTime, 1, 2) & "/" & StringMid($rowDateTime, 4, 2) & " 00:00:00"
        $howOld = _DateDiff('D', $SPOOrderDate, _NowCalc())
        If $howOld <= $overdueDays Then
;~          GUICtrlSetData($SPOList, $rowSPONumber)
            For $b = $overdueDays To 0 Step -1
                If $howOld == $b Then _GUICtrlListBox_InsertString($SPOList, $rowSPONumber, -1)  ;experiment to sort by age
            Next
            $listOnTimeSPO += 1
        EndIf
        If _DateDiff('D', $SPOOrderDate, _NowCalc()) > $overdueDays Then
            GUICtrlSetData($overdueSPOList, $rowSPONumber)
            $listOverdueSPO += 1
        EndIf
    Next
    _GUICtrlListBox_EndUpdate($SPOList)
    _GUICtrlListBox_EndUpdate($overdueSPOList)
    GUICtrlSetData($onTimeSPOShow, $listOnTimeSPO)
    GUICtrlSetData($overdueSPOShow, $listOverdueSPO)
    SplashOff()

EndFunc   ;==>_FillItems


Func _FillTheBoxes()

    GUICtrlSetData($descriptionShow, $rowDescription)
    GUICtrlSetData($notesShow, $rowNotes)
    GUICtrlSetData($dateTimeShow, $rowDateTime)
    GUICtrlSetData($quantityShow, $rowQuantity)
    GUICtrlSetData($whereShow, $rowWhere)
    GUICtrlSetData($whoShow, $rowEmployee)
    $SPOOrderDate = StringMid($rowDateTime, 7, 4) & "/" & StringMid($rowDateTime, 1, 2) & "/" & StringMid($rowDateTime, 4, 2) & " 00:00:00"
    $howOld = _DateDiff('D', $SPOOrderDate, _NowCalc())
    GUICtrlSetData($daysOldShow, $howOld)

    If $howOld <= $overdueDays Then
        GUICtrlSetBkColor($daysOldShow, "0x00ff00")
        GUICtrlSetColor($daysOldShow, "0x000000")
    EndIf
    If $howOld > $overdueDays Then
        GUICtrlSetBkColor($daysOldShow, "0xff0000")
        GUICtrlSetColor($daysOldShow, "0xffffff")
    EndIf

    Do
        Local $fullSQL = ""
        If _Sql_GetTableAsString(-1, "SELECT * FROM Customer WHERE CustomerID='" & $rowCustomerID & "';", $fullSQL) = $SQL_OK Then
        Else
            GUICtrlSetData($customerNameShow, "")

            Local $fullBusSQL = ""
            If _Sql_GetTableAsString(-1, "SELECT * FROM Business WHERE CustomerID='" & $rowCustomerID & "';", $fullBusSQL) = $SQL_OK Then
            Else
                MsgBox(0 + 16 + 262144, "SQL Error", _SQL_GetErrMsg())
            EndIf
            $busRaw = StringSplit(StringTrimRight($fullBusSQL, 1), Chr(3))
            $bus = StringSplit($busRaw[1], Chr(2))
            $businessName = $bus[2]
            $contactName = $bus[3]
            GUICtrlSetData($customerNameShow, StringStripWS($businessName & " - " & $contactName, 1))
            ExitLoop
        EndIf

        $custRaw = StringSplit(StringTrimRight($fullSQL, 1), Chr(3))
        If $custRaw[1] <> "" Then
            $cust = StringSplit($custRaw[1], Chr(2))
            $custFirstName = $cust[2]
            $custLastName = $cust[3]
            GUICtrlSetData($customerNameShow, StringStripWS($custFirstName & " " & $custLastName, 1))
        EndIf
    Until 1 = 1

EndFunc   ;==>_FillTheBoxes


Func _BreakRow()

    $field = StringSplit($rowData, Chr(2))
    $rowSPONumber = $field[1]
    $rowCustomerID = $field[2]
    $rowDescription = $field[3]
    $rowWebsite = $field[4]
    $rowNotes = $field[5]
    $rowDateTimeVerbose = $field[6]
    $rowDateTime = StringMid($field[6], 5, 2) & "/" & StringMid($field[6], 7, 2) & "/" & StringMid($field[6], 1, 4)
    $rowEmployee = $field[7]
    $rowQuantity = $field[8]
    $rowCost = $field[9]
    $rowTotal = $field[10]
    $rowDeposit = $field[11]
    $rowStatus = $field[12]

    If StringInStr($rowSPONumber, "SPOC") <> 0 Or StringInStr($rowSPONumber, "CAR") <> 0 Then $rowWhere = "Carlisle"
    If StringInStr($rowSPONumber, "SPODS") <> 0 Or StringInStr($rowSPONumber, "HBG") <> 0 Then $rowWhere = "Harrisburg"
    If StringInStr($rowSPONumber, "SPOLM") <> 0 Or StringInStr($rowSPONumber, "LEM") <> 0 Then $rowWhere = "Lemoyne"
    If StringInStr($rowSPONumber, "SPOYK") <> 0 Or StringInStr($rowSPONumber, "YRK") <> 0 Then $rowWhere = "York"


;~  If $field[12] == 1 Then $rowStatus = "Not yet recieved"
;~  If $field[12] == 2 Then $rowStatus = "recieved and notified"
;~  If $field[12] == 3 Then $rowStatus = "picked up"

EndFunc   ;==>_BreakRow


Func _SetAsArrived()

    $yesOrNo = MsgBox(4, "Are You Sure?", "Are you sure you want to set " & $rowSPONumber & " as arrived?")
    If $yesOrNo = 6 Then
        _SQL_RegisterErrorHandler();register the error handler to prevent hard crash on COM error
        $oADODB = _SQL_Startup()
        If $oADODB = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
        If _sql_Connect(-1, $serverAddress, "name", $serverUserName, $serverPassword) = $SQL_ERROR Then  ;change "name"
            MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
            _SQL_Close()
            Exit
        EndIf
        If _SQL_Execute(-1, "UPDATE SpecialOrder SET Status='" & 2 & "' WHERE SPONum='" & $rowSPONumber & "'") = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
        $count = 1
        _UpdateSplit() ;updates $split array with SQL data
        _FillItems() ;populates $items list
    EndIf

EndFunc   ;==>_SetAsArrived


Func _EditSPO()

    $editGUI = GUICreate("Edit SPO", 480, 285)
    GUICtrlCreateLabel("Description:", 10, 5, 85, 15)
    $editGUIDescriptionShow = GUICtrlCreateEdit("", 10, 20, 460, 60, $WS_VSCROLL)
    GUICtrlSetBkColor(-1, "0xffffff")
    GUICtrlCreateLabel("Notes:", 10, 100, 85, 15)
    $editGUINotesShow = GUICtrlCreateEdit("", 10, 115, 460, 80, $WS_VSCROLL)
    GUICtrlSetBkColor(-1, "0xffffff")
    GUICtrlCreateLabel("Quantity:", 10, 215, 45, 15)
    $editGUIQuantityShow = GUICtrlCreateInput("", 60, 215, 70, 20)
    GUICtrlSetBkColor(-1, "0xffffff")
    GUICtrlCreateLabel("Price:", 240, 215, 45, 15)
    $editGUIPriceShow = GUICtrlCreateInput("", 290, 215, 70, 20)
    GUICtrlSetBkColor(-1, "0xffffff")
    $submitButton = GUICtrlCreateButton("Submit Change", 10, 255, 80, 20)
    GUISetState(@SW_SHOW, $editGUI)

    GUICtrlSetData($editGUIDescriptionShow, $rowDescription)
    GUICtrlSetData($editGUINotesShow, $rowNotes)
    GUICtrlSetData($editGUIQuantityShow, $rowQuantity)
    GUICtrlSetData($editGUIPriceShow, $rowCost)

    Do

        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            GUIDelete($editGUI)
            ExitLoop
        EndIf
        If $msg = $submitButton Then
            $editDescriptionIn = GUICtrlRead($editGUIDescriptionShow)
            $editNotesIn = GUICtrlRead($editGUINotesShow)
            $editQuantityIn = GUICtrlRead($editGUIQuantityShow)
            $editCostIn = GUICtrlRead($editGUIPriceShow)
            $editTaxIn = Round((Number($editQuantityIn) * Number($editCostIn) * .06), 2)
            $editTotalIn = Round((Number($editQuantityIn) * Number($editCostIn) + Number($editTaxIn)), 2)
            If _SQL_Execute(-1, "UPDATE SpecialOrder SET ItemDescription='" & $editDescriptionIn & "',Notes='" & $editNotesIn & "',Quantity='" & $editQuantityIn & "',Cost='" & $editCostIn & "',Tax='" & $editTaxIn & "' ,Total='" & $editTotalIn & "' WHERE SPONum='" & $rowSPONumber & "';") = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
            GUIDelete($editGUI)
            _UpdateSplit() ;updates $split array with SQL data
            _FillItems() ;populates $items list     GUIDelete($Add)
            ExitLoop
        EndIf

    Until 1 = 2

EndFunc   ;==>_EditSPO


Func _Search()

    $searchTerm = StringStripWS(GUICtrlRead($searchBox), 8)
    If $searchTerm = "" Then
        MsgBox(48, "ERROR", "No search terms have been entered!")
    Else
        GUICtrlSetData($SPOList, "")
        GUICtrlSetData($overdueSPOList, "")
        GUICtrlSetData($onTimeSPOShow, "")
        GUICtrlSetData($overdueSPOShow, "")
        GUICtrlSetData($descriptionShow, "")
        GUICtrlSetData($notesShow, "")
        GUICtrlSetData($quantityShow, "")
        GUICtrlSetData($dateTimeShow, "")
        GUICtrlSetData($whereShow, "")
        GUICtrlSetData($whoShow, "")
        GUICtrlSetData($customerNameShow, "")
        GUICtrlSetData($searchBox, "")
        GUICtrlSetData($daysOldShow, "")
        GUICtrlSetState($searchWithName, $GUI_UNCHECKED)

        _GUICtrlListBox_BeginUpdate($SPOList)
        _GUICtrlListBox_BeginUpdate($overdueSPOList)
        $listOnTimeSPO = 0
        $listOverdueSPO = 0
        SplashTextOn("Sorting", "Sorting SPO info, please be patient", 500, 40, -1, -1)

        For $a = 1 To $row[0]
            $searchName = ""
            $rowData = $row[$a]
            _BreakRow()

            If GUICtrlRead($searchWithName) = $GUI_CHECKED Then
                Do
                    Local $fullSQL = ""
                    If _Sql_GetTableAsString(-1, "SELECT * FROM Customer WHERE CustomerID='" & $rowCustomerID & "';", $fullSQL) = $SQL_OK Then
                    Else

                        Local $fullBusSQL = ""
                        If _Sql_GetTableAsString(-1, "SELECT * FROM Business WHERE CustomerID='" & $rowCustomerID & "';", $fullBusSQL) = $SQL_OK Then
                        Else
                            MsgBox(0 + 16 + 262144, "SQL Error", _SQL_GetErrMsg())
                        EndIf
                        $busRaw = StringSplit(StringTrimRight($fullBusSQL, 1), Chr(3))
                        $bus = StringSplit($busRaw[1], Chr(2))
                        $businessName = $bus[2]
                        $contactName = $bus[3]
                        $searchName = $businessName & $contactName
                        ExitLoop
                    EndIf

                    $custRaw = StringSplit(StringTrimRight($fullSQL, 1), Chr(3))
                    If $custRaw[1] <> "" Then
                        $cust = StringSplit($custRaw[1], Chr(2))
                        $custFirstName = $cust[2]
                        $custLastName = $cust[3]
                        $searchName = $custFirstName & $custLastName
;~                  GUICtrlSetData($customerNameShow, StringStripWS($custFirstName & " " & $custLastName, 1))
                    EndIf
                Until 1 = 1
            EndIf

            If StringInStr(StringStripWS($row[$a] & $searchName, 8), $searchTerm) <> 0 Then
                $rowData = $row[$a]
                _BreakRow()
                $SPOOrderDate = StringMid($rowDateTime, 7, 4) & "/" & StringMid($rowDateTime, 1, 2) & "/" & StringMid($rowDateTime, 4, 2) & " 00:00:00"
                If _DateDiff('D', $SPOOrderDate, _NowCalc()) <= $overdueDays Then
                    GUICtrlSetData($SPOList, $rowSPONumber)
                    $listOnTimeSPO += 1
                EndIf
                If _DateDiff('D', $SPOOrderDate, _NowCalc()) > $overdueDays Then
                    GUICtrlSetData($overdueSPOList, $rowSPONumber)
                    $listOverdueSPO += 1
                EndIf
            EndIf
        Next
        SplashOff()
        _GUICtrlListBox_EndUpdate($SPOList)
        _GUICtrlListBox_EndUpdate($overdueSPOList)
        GUICtrlSetData($onTimeSPOShow, $listOnTimeSPO)
        GUICtrlSetData($overdueSPOShow, $listOverdueSPO)
        GUICtrlSetData($descriptionShow, "")
        GUICtrlSetData($notesShow, "")
        GUICtrlSetData($quantityShow, "")
        GUICtrlSetData($dateTimeShow, "")
        GUICtrlSetData($whereShow, "")
        GUICtrlSetData($whoShow, "")
        GUICtrlSetData($customerNameShow, "")
        GUICtrlSetData($searchBox, "")
        GUICtrlSetData($daysOldShow, "")
        GUICtrlSetBkColor($daysOldShow, "0xffffff")
        GUICtrlSetState($searchWithName, $GUI_UNCHECKED)
    EndIf

EndFunc   ;==>_Search


Func _SPOList_DoubleClick()
    $sListItem = GUICtrlRead($SPOList) ; double clicked listbox item string
    For $a = 1 To $row[0]
        $rowData = $row[$a]
        _BreakRow()
        If $sListItem == $rowSPONumber Then
            _FillTheBoxes()
            ExitLoop
        EndIf
    Next
EndFunc   ;==>_SPOList_DoubleClick


Func _OverdueSPOList_DoubleClick()
    $sListItem = GUICtrlRead($overdueSPOList) ; double clicked listbox item string
    For $a = 1 To $row[0]
        $rowData = $row[$a]
        _BreakRow()
        If $sListItem == $rowSPONumber Then
            _FillTheBoxes()
            ExitLoop
        EndIf
    Next
EndFunc   ;==>_OverdueSPOList_DoubleClick


Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16) ; HiWord
    Local $nID = BitAND($wParam, 0xFFFF) ; LoWord
    Local Const $LBN_DBLCLK = 2

    Switch $nID
        Case $SPOList
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    _SPOList_DoubleClick()
            EndSwitch
        Case $overdueSPOList
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    _OverdueSPOList_DoubleClick()
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

Maybe this will shed some light on things. The _sql.au3 UDF is available here somewhere, I modified that slightly to keep it from including the column names from being included in the return string.

Posted Image

This is what it looks like, just to show. And no, we don't actually have 800+ outstanding orders!! :) It is a new database, we just haven't flagged anything since last December as arrived yet :(

Thanks

Ian

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Maybe this will shed some light on things.

Mmm, other than that the listdata is not sorted when using your settings with the list-help example code.

So its not your initial create list settings.

The _sql.au3 UDF is available here somewhere.

You wish ... Your problem, you find it, and link it. :)

How do you know that your list is sorting?

I mean, that the data the list displays is in a sorted order, don't mean the list itself is sorting is. It might be entered that way.

Think you need to take a closer look at your problem, and make sure its the list thats doing the sorting.

LOL, I attached the modified _sql.au3

I took your point and added a messagebox to the sorting I was doing using _DateDiff, looks like I wasn't thinking right when I did that and it turns out to be useless the way I am doing it now. :( Should have tested that earlier I guess, was chasing the wrong problem. So I need to change how I am looking for the days since ordered, then presumably all should be well.

Thanks for helping me chase my own tail!! :) hahaha! It's too late, time for bed!!

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
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
Sign in to follow this  
Followers 0