Jump to content

To Capture TAB name (CLOSED)


Recommended Posts

Hi all, I am back again with my UI.

I have written an UI where everytime I click on the tab, I need to capture the tab name so I can refresh certain data using that.

My only problem is how can I capture a tab click event?

I can't use the

case $msg=tabname
code as the tab names and even their number is not a constant. I make the tab list using all files present in a folder, every time i start the GUI.

If anyone wants the whole code, its here;

You can just search for the word "TAB" and you will be taken to the relevant area.

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.1.1 (beta)
    Author:         Rishav Sharan
    
    Script Function:
    GUI to create simple import test cases
    
#ce ----------------------------------------------------------------------------


;~ Includes
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GuiDateTimePicker.au3>
#include <GuiTab.au3>
#include <Array.au3>
#include <File.au3>



;~ GUI Backend data file. This is the temp ini file which saves all the data till a specific new file is created.
; This is to save the data in case of system failure.
; If we added the data directly to the grid, in case of accidental closure or power failure, the data will be lost.
$ProfilesINI = @ScriptDir & "\Profiles\NEW PROFILE.ini"




; GUI
$MainGUI = GUICreate("Optima Rate Import Test Case Creator", 1100, 900, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
GUISetIcon(@SystemDir & "\mspaint.exe", 0)
GUISetBkColor(0xFFFFFF)

$x1 = 10
$y1 = 10
GUICtrlCreateGroup("Please set the Path parameters", $x1, $y1, 920, 230)


; DETAILS FIELDS
$TCName_label = GUICtrlCreateLabel("Test Case Name", $x1 + 10, $y1 + 20, 90, 15)
$TCName_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 20, 170, 20, $ES_UPPERCASE)

$TCPassNo_label = GUICtrlCreateLabel("Pass Number", $x1 + 320, $y1 + 20, 90, 15)
$TCPassNo_field = GUICtrlCreateInput("1", $x1 + 420, $y1 + 20, 170, 20, $ES_NUMBER)

$CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 630, $y1 + 20, 90, 15)
$CarrierName_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 20, 170, 20, $ES_UPPERCASE)

$TestType_label = GUICtrlCreateLabel("Test Type", $x1 + 10, $y1 + 50, 90, 15)
$TestType_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($TestType_field, "Import Carrier Rates|Edit Carrier Rates|Run SQL File|Run Win Batch File", "Import Carrier Rates")

$AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x1 + 320, $y1 + 50, 90, 15)
$AdditionalDetails_field = GUICtrlCreateCombo("", $x1 + 420, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($AdditionalDetails_field, "Edit Entry|Delete Entry|Clear All", "Edit Entry")

$TNS_label = GUICtrlCreateLabel("TNS Name", $x1 + 630, $y1 + 50, 90, 15)
$TNS_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 50, 170, 20)


; CHECKBOX
$AutoExpire_Chkbox = GUICtrlCreateCheckbox("Automatically Expire Previously Priced Destinations", $x1 + 10, $y1 + 80, 250, 20)


; DATES
$IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
$IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
$IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
_GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

$DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
$DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
$DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
_GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")


; DETAILS FIELDS
$Destnination_label = GUICtrlCreateLabel("Destination Name", $x1 + 10, $y1 + 110, 90, 15)
$Destnination_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 110, 170, 20)

$DialCode_label = GUICtrlCreateLabel("Dial Code", $x1 + 320, $y1 + 110, 90, 15)
$DialCode_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 110, 170, 20, $ES_NUMBER)

$UidPass_label = GUICtrlCreateLabel("User Id/Password", $x1 + 630, $y1 + 110, 90, 15)
$UidPass_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 110, 170, 20)


; DETAILS FIELDS
$Rate_label = GUICtrlCreateLabel("Rate", $x1 + 10, $y1 + 140, 90, 15)
$Rate_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 140, 170, 20, $ES_NUMBER)


;~ CHECKBOXED DATE
$tDate = 0

$EffDate_label = GUICtrlCreateLabel("Use Effective Date", $x1 + 320, $y1 + 140, 90, 20)
$EffDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
$EffDate_handle = GUICtrlGetHandle($EffDate_datefield)
_GUICtrlDTP_SetFormat($EffDate_handle, "ddd, dd/MMM/yy")
_GUICtrlDTP_SetSystemTimeEx($EffDate_handle, $tDate, True)

$ExpDate_label = GUICtrlCreateLabel("Use Expiry Date", $x1 + 630, $y1 + 140, 90, 20)
$ExpDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
$ExpDate_handle = GUICtrlGetHandle($ExpDate_datefield)
_GUICtrlDTP_SetFormat($ExpDate_handle, "ddd, dd/MMM/yy")
_GUICtrlDTP_SetSystemTimeEx($ExpDate_handle, $tDate, True)



;~ $DatafileLocation_value = IniRead($ProfilesINI, "Paths", "$DatafileLocation", "Field Missing")
$RSDeffFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 170, 90, 15)
$RSDeffFileLocation_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 170, 670, 20)
$RSDeffFileLocation_button = GUICtrlCreateButton("Browse", $x1 + 830, $y1 + 170, 50, 20)

$RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 10, $y1 + 200, 90, 15)
$RefDeffFileLocation_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 200, 670, 20)
$RefDeffFileLocation_button = GUICtrlCreateButton("Browse", $x1 + 830, $y1 + 200, 50, 20)


; BUTTONS
$SaveBatch_button = GUICtrlCreateButton("Save to Grid", $x1 + 930, $y1, 150, 25)
$AddSeparator_button = GUICtrlCreateButton("Add Separator", $x1 + 930, $y1 + 30, 150, 25)
$AddAnal_button = GUICtrlCreateButton("Add Analysis Stage", $x1 + 930, $y1 + 60, 150, 25)
$RemFromGrid_button = GUICtrlCreateButton("Remove from Grid", $x1 + 930, $y1 + 90, 150, 25)
$MoveUp_button = GUICtrlCreateButton("Move up Item", $x1 + 930, $y1 + 120, 150, 25)
$MoveDown_button = GUICtrlCreateButton("Move Down Item", $x1 + 930, $y1 + 150, 150, 25)
$GridToFile_button = GUICtrlCreateButton("Save Grid to file", $x1 + 930, $y1 + 180, 150, 25)
$RunBatch_button = GUICtrlCreateButton("Run Batch", $x1 + 930, $y1 + 210, 150, 25, $BS_DEFPUSHBUTTON)


; TC SUITE TABS
$Tab_TCSuite = _GUICtrlTab_Create($MainGUI, 0, 255, 1100)



_GUICtrlTab_InsertItem($Tab_TCSuite, 0, "NEW PROFILE")

; GET ALL INI FILES IN THE PROFILES FOLDER IN AN ARRAY
$IniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)

; ADD TABS TO TAB BAR BASED OFF ON THE $IniFileList_array DATA
If @error = 0 Then
    For $d = 1 To $IniFileList_array[0]
        _GUICtrlTab_InsertItem($Tab_TCSuite, $d, $IniFileList_array[$d])
    Next
EndIf


; LIST VIEW
$BatchList = GUICtrlCreateListView("", 0, 280, 1100, 620, BitOR(-1, $LVS_NOSORTHEADER, $WS_VSCROLL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
$BatchList_handle = GUICtrlGetHandle($BatchList)
$Grid_serial_col = _GUICtrlListView_AddColumn($BatchList, "Serial No.")
$Grid_sequence_col = _GUICtrlListView_AddColumn($BatchList, "Sequence")
$Grid_Timestamp_col = _GUICtrlListView_AddColumn($BatchList, "Timestamp", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Status_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Status", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_OverallResult_col = _GUICtrlListView_AddColumn($BatchList, "Overall Result", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TCName_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Name", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_PassNo_col = _GUICtrlListView_AddColumn($BatchList, "Pass No.", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Carrier_col = _GUICtrlListView_AddColumn($BatchList, "Carrier Name", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TestType_col = _GUICtrlListView_AddColumn($BatchList, "Test Type", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Details_col = _GUICtrlListView_AddColumn($BatchList, "Details", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_TNS_col = _GUICtrlListView_AddColumn($BatchList, "TNS", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_AutoExpire_col = _GUICtrlListView_AddColumn($BatchList, "Autoexpire", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_IncrDate_col = _GUICtrlListView_AddColumn($BatchList, "Increase Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DecrDate_col = _GUICtrlListView_AddColumn($BatchList, "Decrease Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_DestName_col = _GUICtrlListView_AddColumn($BatchList, "Destination", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DialCode_col = _GUICtrlListView_AddColumn($BatchList, "Dial Code", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_UidPass_col = _GUICtrlListView_AddColumn($BatchList, "UserId/Password", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_Rate_col = _GUICtrlListView_AddColumn($BatchList, "Rate", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_EffectievDate_col = _GUICtrlListView_AddColumn($BatchList, "Effective Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_ExpiryDate_col = _GUICtrlListView_AddColumn($BatchList, "Expiry Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_RSFile_col = _GUICtrlListView_AddColumn($BatchList, "Template File", $LVSCW_AUTOSIZE)
$Grid_RefFile_col = _GUICtrlListView_AddColumn($BatchList, "Reference File", $LVSCW_AUTOSIZE)




; DISABLE ALL CARRIER RATES FIELDS CURRENTLY
GUICtrlSetState($AdditionalDetails_field, $GUI_DISABLE)
GUICtrlSetState($TNS_field, $GUI_DISABLE)
GUICtrlSetState($Destnination_field, $GUI_DISABLE)
GUICtrlSetState($DialCode_field, $GUI_DISABLE)
GUICtrlSetState($UidPass_field, $GUI_DISABLE)
GUICtrlSetState($Rate_field, $GUI_DISABLE)
GUICtrlSetState($EffDate_datefield, $GUI_DISABLE)
GUICtrlSetState($ExpDate_datefield, $GUI_DISABLE)

; DISABLE ALL EXTRA BUTTONS CURRENTLY
GUICtrlSetState($AddAnal_button, $GUI_DISABLE)
GUICtrlSetState($RunBatch_button, $GUI_DISABLE)
GUICtrlSetState($GridToFile_button, $GUI_DISABLE)



; GUI MESSAGE LOOP
GUISetState()

_RefreshGridData()




; Capture and execute all button clicks
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $RSDeffFileLocation_button
            $var = FileSaveDialog("Choose the DB Datafiles Folder", @WorkingDir, "Text files (*.ini;*.txt)")
            GUICtrlSetData($RSDeffFileLocation_field, $var)
        Case $msg = $RefDeffFileLocation_button
            $var = FileSaveDialog("Choose the DB Datafiles Folder", @WorkingDir, "Text files (*.ini;*.txt)")
            GUICtrlSetData($RefDeffFileLocation_field, $var)
        Case $msg = $GUI_EVENT_CLOSE
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            GUIDelete()
            Exit
        Case $msg = $SaveBatch_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = ""
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "Queued"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Case Name", $TCName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = ControlGetText("Optima Rate Import Test Case Creator", "Pass Number", $TCPassNo_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = ControlGetText("Optima Rate Import Test Case Creator", "Carrier Name", $CarrierName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Additional Details", $AdditionalDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $TNS_data = ControlGetText("Optima Rate Import Test Case Creator", "TNS Name", $TNS_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TNS", $TNS_data)

            $AutoExpire_data = ControlCommand("Optima Rate Import Test Case Creator", "Automatically Expire Previously Priced Destinations", $AutoExpire_Chkbox, "IsChecked", "")
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)

            $IncrDate_data = GUICtrlRead($IncrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = GUICtrlRead($DecrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = ControlGetText("Optima Rate Import Test Case Creator", "Destination Nam", $Destnination_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $DialCode_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = ControlGetText("Optima Rate Import Test Case Creator", "User Id/Password", $UidPass_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $Rate_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = GUICtrlRead($EffDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = GUICtrlRead($ExpDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $RSDeffFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Import File", $RSDeffFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $RSDeffFileLocation_data)

            $RefDeffFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Reference File", $RefDeffFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()

        Case $msg = $RemFromGrid_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            If $SelectedRow > 1 Then
                $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
                $Ini_Section_delete = $Grid_listdata_sections[$SelectedRow]
                IniDelete($ProfilesINI, $Ini_Section_delete)
                For $c = $Grid_listdata_sections[$SelectedRow] To $Grid_listdata_sections[0]
                    IniRenameSection($ProfilesINI, $Grid_listdata_sections[$c], $Grid_listdata_sections[$c] - 1)
                Next
            EndIf
            _RefreshGridData()


        Case $msg = $MoveUp_button
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow > 1 Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Above_section = $Grid_listdata_sections[$SelectedRow - 1]

                $temp = 9999999
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Above_section, $Grid_listdata_sections[$SelectedRow])
                IniRenameSection($ProfilesINI, $temp, $Grid_listdata_sections[$SelectedRow - 1])
            EndIf

            _RefreshGridData()

        Case $msg = $MoveDown_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow < $Grid_listdata_sections[0] Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Below_section = $Grid_listdata_sections[$SelectedRow + 1]

                MsgBox(0, $Selected_section, $Below_section)
                $temp = "xxx"
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Below_section, $Selected_section)
                IniRenameSection($ProfilesINI, $temp, $Below_section)
            EndIf

            _RefreshGridData()

        Case $msg = $AddSeparator_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $TNS_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TNS", $TNS_data)

            $AutoExpire_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)

            $IncrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $RSDeffFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $RSDeffFileLocation_data)

            $RefDeffFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()





    EndSelect
WEnd



Func _RefreshGridData()
    $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
    If @error Then
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
    ElseIf $Grid_listdata_sections[0] > 0 Then
        _GUICtrlListView_BeginUpdate($BatchList_handle)
        _GUICtrlListView_DeleteAllItems($BatchList_handle)

        For $a = 1 To $Grid_listdata_sections[0]

;~          _ArrayDisplay($Grid_listdata_sections)
            _ArraySort($Grid_listdata_sections, 0, 1)
;~          _ArrayDisplay($Grid_listdata_sections)
            $Grid_All_listdata = IniReadSection($ProfilesINI, $Grid_listdata_sections[$a])
            If Not @error Then
                If $Grid_All_listdata[0][0] > 0 Then
                    _GUICtrlListView_AddItem($BatchList_handle, $a)
                    _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_listdata_sections[$a], 1)
                    For $b = 2 To $Grid_All_listdata[0][0]
                        _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_All_listdata[$b][1], $b + 1)
                    Next
                EndIf
            EndIf
        Next
        For $a = 0 To _GUICtrlListView_GetColumnCount($BatchList_handle)
            _GUICtrlListView_SetColumnWidth($BatchList_handle, $a, $LVSCW_AUTOSIZE_USEHEADER)
        Next
        _GUICtrlListView_EndUpdate($BatchList_handle)
    EndIf
EndFunc   ;==>_RefreshGridData

What I am planning to do here is to get the tab name everytime the tab is clicked. based on the tab name I can get the name of the ini file that I need and I can refresh the grid with the chosen ini file data.

so basically i now have a tabbed flex grid where a collection of ini files is acting as a primitive database. I suppose there can a much better approach, but the current one suffices for my level of expertise, or lack thereof.

thanks and regards

Rishav

Edited by Rishav
Link to comment
Share on other sites

so uhh... any ideas? >_<

i did come across this example from someone in the forum (sorry forgot the thread i found this in)

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Global $main_GUI,$ok_button,$cancel_button

;This window has 2 ok/enable-buttons
$main_GUI       = GUICreate("TAB in TAB",260,250,-1,-1)
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$Enable_button  = GUICtrlCreateCheckbox("Disable Tab 2",150,220,100,20)

; Create the first child window that is implemented into the main GUI
$child1         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$child_tab      = GUICtrlCreateTab(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("A")
$child12tab     = GUICtrlCreateTabItem("B")
GUICtrlCreateTabItem("")

GUISetState()

; Create the second child window that is implemented into the main GUI
$child2         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$listview2      = GUICtrlCreateListView("Col1|Col2",10,10,210,150,-1,$WS_EX_CLIENTEDGE)
GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2)
GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2)

; Switch back the main GUI and create the tabs
GUISwitch($main_GUI)
$main_tab       = GUICtrlCreateTab(10,10,240,200)
$child1tab      = GUICtrlCreateTabItem("Tab 1")
$child2tab      = GUICtrlCreateTabItem("Tab 2")
GUICtrlCreateTabItem("")

GUISetState()



$HideShow = $GUI_HIDE + $GUI_SHOW
$tab2state = true

GUIRegisterMsg($WM_NOTIFY,"WM_Notify_Events")

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Enable_button
            $tab2state = GUICtrlRead($Enable_button) = $GUI_UNCHECKED
            If $tab2state Then
              GUISetState(@SW_ENABLE,$child2)
          Else
               GUISetState(@SW_DISABLE ,$child2)
              EndIf
                  
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
                  GUISetState(@SW_HIDE,$child2)
                  GUISetState(@SW_SHOW,$child1)
          
                Case 1
                  GUISetState(@SW_HIDE,$child1)
                  GUISetState(@SW_SHOW,$child2)
            EndSwitch
    EndSwitch
WEnd



Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
   ;#forceref $hWndGUI, $MsgID
    Local $tagNMHDR, $event
    Local Const $NM_RETURN = $NM_FIRST - 4
    Local Const $NM_RCLICK = -5
    Local Const $TCN_FIRST = -550
    Local Const $TCN_SELCHANGING = $TCN_FIRST-2
    Local $toTab
    Local $Debugit = True

    Switch $wParam
        Case $Main_Tab       
            $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
            If @error Then Return
            $event = DllStructGetData($tagNMHDR, 3)
            Switch $event
                Case $TCN_SELCHANGING
                    $Event_Code = $event
                    $toTab = DllStructGetData($tagNMHDR, 2)
                    If $DebugIt Then ConsoleWrite("-->$TCN_SELCHANGING to " & $toTab & @LF)
            EndSwitch
        EndSwitch   
$tagNMHDR = 0
EndFunc;==>WM_Notify_Events

then i tried marrying my Ui to it and the bastardized result still refuses to work. :(

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.1.1 (beta)
    Author:         Rishav Sharan
    
    Script Function:
    GUI to create simple import test cases
    
#ce ----------------------------------------------------------------------------


;~ Includes
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GuiDateTimePicker.au3>
#include <GuiTab.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiTab.au3>


;~ GUI Backend data file. This is the temp ini file which saves all the data till a specific new file is created.
; This is to save the data in case of system failure.
; If we added the data directly to the grid, in case of accidental closure or power failure, the data will be lost.
$ProfilesINI = @ScriptDir & "\Profiles\NEW PROFILE.ini"




; GUI
$MainGUI = GUICreate("Optima Rate Import Test Case Creator", 1100, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP))
GUISetIcon(@SystemDir & "\mspaint.exe", 0)
GUISetBkColor(0xFFFFFF)

$x1 = 10
$y1 = 10
GUICtrlCreateGroup("Please set the Path parameters", $x1, $y1, 920, 230)


; DETAILS FIELDS
$TCName_label = GUICtrlCreateLabel("Test Case Name", $x1 + 10, $y1 + 20, 90, 15)
$TCName_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 20, 170, 20, $ES_UPPERCASE)

$TCPassNo_label = GUICtrlCreateLabel("Pass Number", $x1 + 320, $y1 + 20, 90, 15)
$TCPassNo_field = GUICtrlCreateInput("1", $x1 + 420, $y1 + 20, 170, 20, $ES_NUMBER)

$CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 630, $y1 + 20, 90, 15)
$CarrierName_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 20, 170, 20, $ES_UPPERCASE)

$TestType_label = GUICtrlCreateLabel("Test Type", $x1 + 10, $y1 + 50, 90, 15)
$TestType_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($TestType_field, "Import Rates to Pending|Import Rates to Active|Edit Carrier Rates|Run SQL File|Run Win Batch File", "Import Rates to Pending")

$AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x1 + 320, $y1 + 50, 90, 15)
$AdditionalDetails_field = GUICtrlCreateCombo("", $x1 + 420, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($AdditionalDetails_field, "Edit Entry|Delete Entry|Clear All", "Edit Entry")

$TNS_label = GUICtrlCreateLabel("TNS Name", $x1 + 630, $y1 + 50, 90, 15)
$TNS_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 50, 170, 20)


; CHECKBOX
$AutoExpire_Chkbox = GUICtrlCreateCheckbox("Automatically Expire Previously Priced Destinations", $x1 + 10, $y1 + 80, 250, 20)


; DATES
$IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
$IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
$IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
_GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

$DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
$DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
$DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
_GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")


; DETAILS FIELDS
$Destnination_label = GUICtrlCreateLabel("Destination Name", $x1 + 10, $y1 + 110, 90, 15)
$Destnination_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 110, 170, 20)

$DialCode_label = GUICtrlCreateLabel("Dial Code", $x1 + 320, $y1 + 110, 90, 15)
$DialCode_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 110, 170, 20, $ES_NUMBER)

$UidPass_label = GUICtrlCreateLabel("User Id/Password", $x1 + 630, $y1 + 110, 90, 15)
$UidPass_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 110, 170, 20)


; DETAILS FIELDS
$Rate_label = GUICtrlCreateLabel("Rate", $x1 + 10, $y1 + 140, 90, 15)
$Rate_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 140, 170, 20, $ES_NUMBER)


;~ CHECKBOXED DATE
$tDate = 0

$EffDate_label = GUICtrlCreateLabel("Use Effective Date", $x1 + 320, $y1 + 140, 90, 20)
$EffDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
$EffDate_handle = GUICtrlGetHandle($EffDate_datefield)
_GUICtrlDTP_SetFormat($EffDate_handle, "ddd, dd/MMM/yy")
_GUICtrlDTP_SetSystemTimeEx($EffDate_handle, $tDate, True)

$ExpDate_label = GUICtrlCreateLabel("Use Expiry Date", $x1 + 630, $y1 + 140, 90, 20)
$ExpDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
$ExpDate_handle = GUICtrlGetHandle($ExpDate_datefield)
_GUICtrlDTP_SetFormat($ExpDate_handle, "ddd, dd/MMM/yy")
_GUICtrlDTP_SetSystemTimeEx($ExpDate_handle, $tDate, True)



;~ $DatafileLocation_value = IniRead($ProfilesINI, "Paths", "$DatafileLocation", "Field Missing")
$RSDeffFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 170, 90, 15)
$RSDeffFileLocation_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 170, 670, 20)
$RSDeffFileLocation_button = GUICtrlCreateButton("Browse", $x1 + 830, $y1 + 170, 50, 20)

$RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 10, $y1 + 200, 90, 15)
$RefDeffFileLocation_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 200, 670, 20)
$RefDeffFileLocation_button = GUICtrlCreateButton("Browse", $x1 + 830, $y1 + 200, 50, 20)


; BUTTONS
$SaveBatch_button = GUICtrlCreateButton("Save to Grid", $x1 + 930, $y1, 150, 25)
$AddSeparator_button = GUICtrlCreateButton("Add Separator", $x1 + 930, $y1 + 30, 150, 25)
$AddAnal_button = GUICtrlCreateButton("Add Analysis Stage", $x1 + 930, $y1 + 60, 150, 25)
$RemFromGrid_button = GUICtrlCreateButton("Remove from Grid", $x1 + 930, $y1 + 90, 150, 25)
$MoveUp_button = GUICtrlCreateButton("Move up Item", $x1 + 930, $y1 + 120, 150, 25)
$MoveDown_button = GUICtrlCreateButton("Move Down Item", $x1 + 930, $y1 + 150, 150, 25)
$GridToFile_button = GUICtrlCreateButton("Save Grid to file", $x1 + 930, $y1 + 180, 150, 25)
$RunBatch_button = GUICtrlCreateButton("Run Batch", $x1 + 930, $y1 + 210, 150, 25, $BS_DEFPUSHBUTTON)


; TC SUITE TABS
$Tab_TCSuite = _GUICtrlTab_Create($MainGUI, 0, 255, 1100,650)
$Tab_TCSuite_handle = GUICtrlGetHandle($Tab_TCSuite)


_GUICtrlTab_InsertItem($Tab_TCSuite, 0, "NEW PROFILE")

; GET ALL INI FILES IN THE PROFILES FOLDER IN AN ARRAY
$IniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)

; ADD TABS TO TAB BAR BASED OFF ON THE $IniFileList_array DATA
If @error = 0 Then
    For $d = 1 To $IniFileList_array[0]
        If $IniFileList_array[$d] <> "NEW PROFILE.ini" Then
            _GUICtrlTab_InsertItem($Tab_TCSuite, $d, $IniFileList_array[$d])
        EndIf
    Next
EndIf


; SET GRID TO THE SELECTD INI FILE, NEEDS WORK
;~ $SelectedTab_index=_GUICtrlTab_GetCurSel($Tab_TCSuite_handle)
;~ $SelectedTab_name=_GUICtrlTab_GetItemText($Tab_TCSuite_handle, $SelectedTab_index)
;~ $ProfilesINI = @ScriptDir & "\Profiles\" & $SelectedTab_name
;~ _RefreshGridData()


; LIST VIEW
$BatchList = GUICtrlCreateListView("", 5, 280, 1090, 620, BitOR(-1, $LVS_NOSORTHEADER, $WS_VSCROLL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
$BatchList_handle = GUICtrlGetHandle($BatchList)
$Grid_serial_col = _GUICtrlListView_AddColumn($BatchList, "Serial No.")
$Grid_sequence_col = _GUICtrlListView_AddColumn($BatchList, "Sequence")
$Grid_Timestamp_col = _GUICtrlListView_AddColumn($BatchList, "Timestamp", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Status_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Status", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_OverallResult_col = _GUICtrlListView_AddColumn($BatchList, "Overall Result", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TCName_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Name", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_PassNo_col = _GUICtrlListView_AddColumn($BatchList, "Pass No.", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Carrier_col = _GUICtrlListView_AddColumn($BatchList, "Carrier Name", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TestType_col = _GUICtrlListView_AddColumn($BatchList, "Test Type", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Details_col = _GUICtrlListView_AddColumn($BatchList, "Details", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_TNS_col = _GUICtrlListView_AddColumn($BatchList, "TNS", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_AutoExpire_col = _GUICtrlListView_AddColumn($BatchList, "Autoexpire", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_IncrDate_col = _GUICtrlListView_AddColumn($BatchList, "Increase Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DecrDate_col = _GUICtrlListView_AddColumn($BatchList, "Decrease Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_DestName_col = _GUICtrlListView_AddColumn($BatchList, "Destination", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DialCode_col = _GUICtrlListView_AddColumn($BatchList, "Dial Code", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_UidPass_col = _GUICtrlListView_AddColumn($BatchList, "UserId/Password", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_Rate_col = _GUICtrlListView_AddColumn($BatchList, "Rate", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_EffectievDate_col = _GUICtrlListView_AddColumn($BatchList, "Effective Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_ExpiryDate_col = _GUICtrlListView_AddColumn($BatchList, "Expiry Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_RSFile_col = _GUICtrlListView_AddColumn($BatchList, "Template File", $LVSCW_AUTOSIZE)
$Grid_RefFile_col = _GUICtrlListView_AddColumn($BatchList, "Reference File", $LVSCW_AUTOSIZE)




; DISABLE ALL CARRIER RATES FIELDS CURRENTLY
GUICtrlSetState($AdditionalDetails_field, $GUI_DISABLE)
GUICtrlSetState($TNS_field, $GUI_DISABLE)
GUICtrlSetState($Destnination_field, $GUI_DISABLE)
GUICtrlSetState($DialCode_field, $GUI_DISABLE)
GUICtrlSetState($UidPass_field, $GUI_DISABLE)
GUICtrlSetState($Rate_field, $GUI_DISABLE)
GUICtrlSetState($EffDate_datefield, $GUI_DISABLE)
GUICtrlSetState($ExpDate_datefield, $GUI_DISABLE)

; DISABLE ALL EXTRA BUTTONS CURRENTLY
GUICtrlSetState($AddAnal_button, $GUI_DISABLE)
GUICtrlSetState($RunBatch_button, $GUI_DISABLE)
GUICtrlSetState($GridToFile_button, $GUI_DISABLE)



; GUI MESSAGE LOOP
GUISetState()

_RefreshGridData()

;~ $HideShow = $GUI_HIDE + $GUI_SHOW
;~ $tab2state = true

GUIRegisterMsg($WM_NOTIFY,"WM_Notify_Events")


; Capture and execute all button clicks
While 1
    $msg = GUIGetMsg(1)

    Switch $msg[0]
        Case $RSDeffFileLocation_button
            $var = FileSaveDialog("Choose the DB Datafiles Folder", @WorkingDir, "Text files (*.ini;*.txt)")
            GUICtrlSetData($RSDeffFileLocation_field, $var)
        Case $RefDeffFileLocation_button
            $var = FileSaveDialog("Choose the DB Datafiles Folder", @WorkingDir, "Text files (*.ini;*.txt)")
            GUICtrlSetData($RefDeffFileLocation_field, $var)
        Case $GUI_EVENT_CLOSE
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            GUIDelete()
            Exit
        Case $SaveBatch_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = ""
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "Queued"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Case Name", $TCName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = ControlGetText("Optima Rate Import Test Case Creator", "Pass Number", $TCPassNo_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = ControlGetText("Optima Rate Import Test Case Creator", "Carrier Name", $CarrierName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Additional Details", $AdditionalDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $TNS_data = ControlGetText("Optima Rate Import Test Case Creator", "TNS Name", $TNS_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TNS", $TNS_data)

            $AutoExpire_data = ControlCommand("Optima Rate Import Test Case Creator", "Automatically Expire Previously Priced Destinations", $AutoExpire_Chkbox, "IsChecked", "")
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)

            $IncrDate_data = GUICtrlRead($IncrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = GUICtrlRead($DecrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = ControlGetText("Optima Rate Import Test Case Creator", "Destination Nam", $Destnination_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $DialCode_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = ControlGetText("Optima Rate Import Test Case Creator", "User Id/Password", $UidPass_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $Rate_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = GUICtrlRead($EffDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = GUICtrlRead($ExpDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $RSDeffFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Import File", $RSDeffFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $RSDeffFileLocation_data)

            $RefDeffFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Reference File", $RefDeffFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()

        Case $RemFromGrid_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            If $SelectedRow > 1 Then
                $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
                $Ini_Section_delete = $Grid_listdata_sections[$SelectedRow]
                IniDelete($ProfilesINI, $Ini_Section_delete)
                For $c = $Grid_listdata_sections[$SelectedRow] To $Grid_listdata_sections[0]
                    IniRenameSection($ProfilesINI, $Grid_listdata_sections[$c], $Grid_listdata_sections[$c] - 1)
                Next
            EndIf
            _RefreshGridData()


        Case $MoveUp_button
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow > 1 Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Above_section = $Grid_listdata_sections[$SelectedRow - 1]

                $temp = 9999999
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Above_section, $Grid_listdata_sections[$SelectedRow])
                IniRenameSection($ProfilesINI, $temp, $Grid_listdata_sections[$SelectedRow - 1])
            EndIf

            _RefreshGridData()

        Case $MoveDown_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow < $Grid_listdata_sections[0] Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Below_section = $Grid_listdata_sections[$SelectedRow + 1]

                MsgBox(0, $Selected_section, $Below_section)
                $temp = "xxx"
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Below_section, $Selected_section)
                IniRenameSection($ProfilesINI, $temp, $Below_section)
            EndIf

            _RefreshGridData()

        Case $AddSeparator_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $TNS_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TNS", $TNS_data)

            $AutoExpire_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)

            $IncrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $RSDeffFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $RSDeffFileLocation_data)

            $RefDeffFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()

        Case $Tab_TCSuite
            $abc=GUICtrlRead($Tab_TCSuite)
                 msgbox(0,"",$abc)
            Switch GUICtrlRead($Tab_TCSuite)
            
                Case 0
                 msgbox(0,"","AAA")
          
                Case 1
                 msgbox(0,"","YYY")
            EndSwitch
;~          $iIndex=_GUICtrlTab_GetCurSel($Tab_TCSuite_handle)
;~          $Tab_Name=_GUICtrlTab_GetItemText($Tab_TCSuite_handle, $iIndex)



;~          $ProfilesINI= @ScriptDir & "\Profiles\" & "$Tab_Name"
;~          _RefreshGridData()


    EndSwitch
WEnd



Func _RefreshGridData()
    $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
    If @error Then
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
    ElseIf $Grid_listdata_sections[0] > 0 Then
        _GUICtrlListView_BeginUpdate($BatchList_handle)
        _GUICtrlListView_DeleteAllItems($BatchList_handle)

        For $a = 1 To $Grid_listdata_sections[0]

;~          _ArrayDisplay($Grid_listdata_sections)
            _ArraySort($Grid_listdata_sections, 0, 1)
;~          _ArrayDisplay($Grid_listdata_sections)
            $Grid_All_listdata = IniReadSection($ProfilesINI, $Grid_listdata_sections[$a])
            If Not @error Then
                If $Grid_All_listdata[0][0] > 0 Then
                    _GUICtrlListView_AddItem($BatchList_handle, $a)
                    _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_listdata_sections[$a], 1)
                    For $b = 2 To $Grid_All_listdata[0][0]
                        _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_All_listdata[$b][1], $b + 1)
                    Next
                EndIf
            EndIf
        Next
        For $a = 0 To _GUICtrlListView_GetColumnCount($BatchList_handle)
            _GUICtrlListView_SetColumnWidth($BatchList_handle, $a, $LVSCW_AUTOSIZE_USEHEADER)
        Next
        _GUICtrlListView_EndUpdate($BatchList_handle)
    EndIf
EndFunc   ;==>_RefreshGridData


Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
   ;#forceref $hWndGUI, $MsgID
    Local $tagNMHDR, $event
    Local Const $NM_RETURN = $NM_FIRST - 4
    Local Const $NM_RCLICK = -5
    Local Const $TCN_FIRST = -550
    Local Const $TCN_SELCHANGING = $TCN_FIRST-2
    Local $toTab
    Local $Debugit = True

    Switch $wParam
        Case $Tab_TCSuite       
            $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
            If @error Then Return
            $event = DllStructGetData($tagNMHDR, 3)
            Switch $event
                Case $TCN_SELCHANGING
                    $Event_Code = $event
                    $toTab = DllStructGetData($tagNMHDR, 2)
                    If $DebugIt Then ConsoleWrite("-->$TCN_SELCHANGING to " & $toTab & @LF)
            EndSwitch
        EndSwitch   
$tagNMHDR = 0
EndFunc;==>WM_Notify_Events
Edited by Rishav
Link to comment
Share on other sites

Hi Stefan

I tried something like that earlier but didnt succeed.

If I can have like this, it will be awesome.

Case $Tab_TCSuite
            case $msg = $Tab_TCSuite
            $current = GuiCtrlRead ($Tab_TCSuite)
            $Tab_Name=_GUICtrlTab_GetItemText($Tab_TCSuite_handle, $current)
                        Msgbox(0,"",$Tab_Name)

ie. if i can get a msgbox after every tab change about the tab name.

I tried adding it to the code but it still isn't working. >_<

EDIT: weird... I am sure i was replying to someone. :(

Edited by Rishav
Link to comment
Share on other sites

Hi,

i changed following lines in your code:

; TC SUITE TABS

;$Tab_TCSuite = _GUICtrlTab_Create($MainGUI, 0, 255, 1100)

$Tab_TCSuite = GUICtrlCreateTab (0, 255, 1100)

_GUICtrlTab_InsertItem($Tab_TCSuite, 0, "NEW PROFILE")

_GUICtrlTab_InsertItem($Tab_TCSuite, 1, "NEW PROFILE1") ; this i insert to have more tabs, with your code i only have one tab shown

_GUICtrlTab_InsertItem($Tab_TCSuite, 2, "NEW PROFILE2") ; see above

and i put this lines in your while loop:

case $msg = $Tab_TCSuite
            $current = _GUICtrlTab_GetCurSel ($Tab_TCSuite)
            MsgBox (0,"",_GUICtrlTab_GetItemText($Tab_TCSuite, $current))

If i have only 1 Tab, nothing happens. If i have 2 or more tabs the msgboxes appears as wanted.

Perhaps you could use (just before while loop)

If _GUICtrlTab_GetItemCount ($Tab_TCSuite) = 1 Then $ItemText = _GuiCtrlTab_GetItemText ($Tab_TCSuite, 0)

to work with.

This hopefully helps.....

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

Thanks for the help Stefan but the number of tabs depends on the number of ini files you have in the folder. just throw in some ini file in the @scrptdir/Profiles folder and they will come up as tabs.

EDIT: Ok it works now. but the whole grid is refreshing like crazy. o.0

Thanks Stefan. It works now. kinda...

If possible use the attached zip file and run the GUI tagb temp2.au3.

All the script does is that it reads data from the ini files into the gui and writes into ini files so you shouldn't have any problems with them.

Also, I have now tried another new thing. Depending upon what option you select in the Test type combo field, I am trying to create other fields. but failing on that count too. >_<

So, can you help me with

1. stopping the grid from refreshing crazily

2. getting some fields to show when i chage the test type?

thanks a lot.

Update:

Hmmm.. the crazy refresh is because it is getting new value for $ProfilesINI every few milliseconds and that in turn is because it is getting the tab name continuously.

Import Function.zip

Edited by Rishav
Link to comment
Share on other sites

Thanks for the help Stefan but the number of tabs depends on the number of ini files you have in the folder. just throw in some ini file in the @scrptdir/Profiles folder and they will come up as tabs.

EDIT: Ok it works now. but the whole grid is refreshing like crazy. o.0

Thanks Stefan. It works now. kinda...

If possible use the attached zip file and run the GUI tagb temp2.au3.

All the script does is that it reads data from the ini files into the gui and writes into ini files so you shouldn't have any problems with them.

Also, I have now tried another new thing. Depending upon what option you select in the Test type combo field, I am trying to create other fields. but failing on that count too. >_<

So, can you help me with

1. stopping the grid from refreshing crazily

2. getting some fields to show when i chage the test type?

thanks a lot.

Update:

Hmmm.. the crazy refresh is because it is getting new value for $ProfilesINI every few milliseconds and that in turn is because it is getting the tab name continuously.

Hi,

1. stopping the grid from refreshing crazily:

Changed at the very beginning:

$ProfilesINI = @ScriptDir & "\Profiles\NEW PROFILE.ini"
$oldcurrent = 99

Changed in While Loop in Case $msg = $Tab_TCSuite:

If $current <> $oldcurrent Then 
    _RefreshGridData()
EndIf
$oldcurrent = $current

For your 2nd problem i haven't a solution yet. I'll try further on.

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

ooo.... it did stop the epileptic twitching...

That was quite a simple and elegant solution. :(

Works awesomely. Thanks.

Any idea, whats the problem's source?

About the second issue, its mainly because of child windows creation and stuff. First time I am trying destroying and recreating child windows.

Basically my main gui is first created with a field called Test type.

There is also a child gui called ControlGUI which has some fields defined inside it.

If you select a specific option in the Test Type combo box, it will destroy the ControlGUI child GUI and recreate it with a different set of fields. most likely I am sucking somewhere in the guicreation/guisetstate stage. >_<

EDIT: Attaching the latest iteration of the code. contains some tiny fixes. Also I have changed the $oldcurrent to a text string as there is a chance that I might actually have more than 99 ini files and as such the tabs after that will refuse to refresh.

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.1.1 (beta)
    Author:         Rishav Sharan
    
    Script Function:
    GUI to create simple import test cases
    
#ce ----------------------------------------------------------------------------


;~ Includes
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GuiDateTimePicker.au3>
#include <GuiTab.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiTab.au3>


;~ GUI Backend data file. This is the temp ini file which saves all the data till a specific new file is created.
; This is to save the data in case of system failure.
; If we added the data directly to the grid, in case of accidental closure or power failure, the data will be lost.
$ProfilesINI = @ScriptDir & "\Profiles\NEW PROFILE.ini"
$GenericTempValue = "temp value"


; GUI
$MainGUI = GUICreate("Optima Rate Import Test Case Creator", 1100, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP))
GUISetIcon(@SystemDir & "\mspaint.exe", 0)
GUISetBkColor(0xFFFFFF)

$x1 = 10
$y1 = 10
GUICtrlCreateGroup("Please set the Path parameters", $x1, $y1, 920, 230)


; DETAILS FIELDS
$TCName_label = GUICtrlCreateLabel("Test Case Name", $x1 + 10, $y1 + 20, 90, 15)
$TCName_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 20, 170, 20, $ES_UPPERCASE)

$TCPassNo_label = GUICtrlCreateLabel("Pass Number", $x1 + 320, $y1 + 20, 90, 15)
$TCPassNo_field = GUICtrlCreateInput("1", $x1 + 420, $y1 + 20, 170, 20, $ES_NUMBER)

$TestType_label = GUICtrlCreateLabel("Test Type", $x1 + 630, $y1 + 20, 90, 15)
$TestType_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 20, 170, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($TestType_field, "Import Rates to Pending|Import Rates to Active|Edit Carrier Rates|Run SQL File|Run Win Batch File", "Import Rates to Pending")

; TC SUITE TABS
$Tab_TCSuite = _GUICtrlTab_Create($MainGUI, 0, 255, 1100, 650)
$Tab_TCSuite_handle = GUICtrlGetHandle($Tab_TCSuite)
_GUICtrlTab_InsertItem($Tab_TCSuite, 0, "NEW PROFILE")

; GET ALL INI FILES IN THE PROFILES FOLDER IN AN ARRAY
$IniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)

; ADD TABS TO TAB BAR BASED OFF ON THE $IniFileList_array DATA
If @error = 0 Then
    For $d = 1 To $IniFileList_array[0]
        If $IniFileList_array[$d] <> "NEW PROFILE.ini" Then
            $Tab_Insert_Name = StringTrimRight($IniFileList_array[$d], 4)
            _GUICtrlTab_InsertItem($Tab_TCSuite, $d, $Tab_Insert_Name)
        EndIf
    Next
EndIf

; BUTTONS
$SaveBatch_button = GUICtrlCreateButton("Save to Grid", $x1 + 930, $y1, 150, 25)
$AddSeparator_button = GUICtrlCreateButton("Add Separator", $x1 + 930, $y1 + 30, 150, 25)
$AddAnal_button = GUICtrlCreateButton("Add Analysis Stage", $x1 + 930, $y1 + 60, 150, 25)
$RemFromGrid_button = GUICtrlCreateButton("Remove from Grid", $x1 + 930, $y1 + 90, 150, 25)
$MoveUp_button = GUICtrlCreateButton("Move up Item", $x1 + 930, $y1 + 120, 150, 25)
$MoveDown_button = GUICtrlCreateButton("Move Down Item", $x1 + 930, $y1 + 150, 150, 25)
$GridToFile_button = GUICtrlCreateButton("Save Grid to file", $x1 + 930, $y1 + 180, 150, 25)
$RunBatch_button = GUICtrlCreateButton("Run Batch", $x1 + 930, $y1 + 210, 150, 25, $BS_DEFPUSHBUTTON)

; DISABLE ALL EXTRA BUTTONS CURRENTLY
GUICtrlSetState($AddAnal_button, $GUI_DISABLE)
GUICtrlSetState($RunBatch_button, $GUI_DISABLE)
GUICtrlSetState($GridToFile_button, $GUI_DISABLE)

; LIST VIEW
$BatchList = GUICtrlCreateListView("", 5, 280, 1090, 620, BitOR(-1, $LVS_NOSORTHEADER, $WS_VSCROLL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
$BatchList_handle = GUICtrlGetHandle($BatchList)
$Grid_serial_col = _GUICtrlListView_AddColumn($BatchList, "Serial No.")
$Grid_sequence_col = _GUICtrlListView_AddColumn($BatchList, "Sequence")
$Grid_Timestamp_col = _GUICtrlListView_AddColumn($BatchList, "Timestamp", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Status_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Status", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_OverallResult_col = _GUICtrlListView_AddColumn($BatchList, "Overall Result", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TCName_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Name", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_PassNo_col = _GUICtrlListView_AddColumn($BatchList, "Pass No.", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Carrier_col = _GUICtrlListView_AddColumn($BatchList, "Carrier Name", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TestType_col = _GUICtrlListView_AddColumn($BatchList, "Test Type", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Details_col = _GUICtrlListView_AddColumn($BatchList, "Details", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_ServerDetails_col = _GUICtrlListView_AddColumn($BatchList, "ServerDetails", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_AutoExpire_col = _GUICtrlListView_AddColumn($BatchList, "Autoexpire", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_IncrDate_col = _GUICtrlListView_AddColumn($BatchList, "Increase Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DecrDate_col = _GUICtrlListView_AddColumn($BatchList, "Decrease Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_DestName_col = _GUICtrlListView_AddColumn($BatchList, "Destination", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DialCode_col = _GUICtrlListView_AddColumn($BatchList, "Dial Code", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_UidPass_col = _GUICtrlListView_AddColumn($BatchList, "UserId/Password", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_Rate_col = _GUICtrlListView_AddColumn($BatchList, "Rate", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_EffectievDate_col = _GUICtrlListView_AddColumn($BatchList, "Effective Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_ExpiryDate_col = _GUICtrlListView_AddColumn($BatchList, "Expiry Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_RSFile_col = _GUICtrlListView_AddColumn($BatchList, "Template File", $LVSCW_AUTOSIZE)
$Grid_RefFile_col = _GUICtrlListView_AddColumn($BatchList, "Reference File", $LVSCW_AUTOSIZE)


GUISetState()

; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
$ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

; DETAILS FIELDS
$CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
$CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

$RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
$RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

$ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 80, 90, 15)
$ImportFileLocation_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 80, 250, 20)


; DATES
$IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
$IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
$IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
_GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

$DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
$DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
$DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
_GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")

GUISetState()


_RefreshGridData()



; Capture and execute all button clicks
While 1
    $msg = GUIGetMsg(1)

    Switch $msg[0]

        Case $TestType_field
            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)

            Switch $TestType_data
                Case "Import Rates to Pending"
                    GUIDelete($ControlGUI)
                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

                    $RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
                    $RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 80, 250, 20)


                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")

                    GUISetState(@SW_ENABLE)

                Case "Import Rates to Active"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x1 + 320, $y1 + 50, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x1 + 420, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Don't Autoexpire Old Data|Autoexpire Old Data", "Don't Autoexpire Old Data")

                    $RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
                    $RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 80, 250, 20)

                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")

                    GUISetState(@SW_ENABLE)

                Case "Edit Carrier Rates"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x1 + 320, $y1 + 50, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x1 + 420, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Refresh Grid|Edit Entry|Delete Entry|Clear All", "Refresh Grid")

                    $RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
                    $RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

                    ; DETAILS FIELDS
                    $Destnination_label = GUICtrlCreateLabel("Destination Name", $x1 + 10, $y1 + 110, 90, 15)
                    $Destnination_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 110, 170, 20)

                    $DialCode_label = GUICtrlCreateLabel("Dial Code", $x1 + 320, $y1 + 110, 90, 15)
                    $DialCode_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 110, 170, 20, $ES_NUMBER)

                    $Rate_label = GUICtrlCreateLabel("Rate", $x1 + 630, $y1 + 110, 90, 15)
                    $Rate_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 110, 170, 20, $ES_NUMBER)

;~ CHECKBOXED DATE
                    $tDate = 0

                    $EffDate_label = GUICtrlCreateLabel("Use Effective Date", $x1 + 320, $y1 + 140, 90, 20)
                    $EffDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $EffDate_handle = GUICtrlGetHandle($EffDate_datefield)
                    _GUICtrlDTP_SetFormat($EffDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($EffDate_handle, $tDate, True)

                    $ExpDate_label = GUICtrlCreateLabel("Use Expiry Date", $x1 + 630, $y1 + 140, 90, 20)
                    $ExpDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $ExpDate_handle = GUICtrlGetHandle($ExpDate_datefield)
                    _GUICtrlDTP_SetFormat($ExpDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($ExpDate_handle, $tDate, True)

                    GUISetState()

                Case "Run SQL File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    $ServerDetails_label = GUICtrlCreateLabel("ServerDetails Name", $x1 + 10, $y1 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 170, 170, 20)

                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x1 + 320, $y1 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 170, 170, 20)

                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

                Case "Run Win Batch File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    $ServerDetails_label = GUICtrlCreateLabel("ServerDetails Name", $x1 + 10, $y1 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 170, 170, 20)

                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x1 + 320, $y1 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 170, 170, 20)

                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")

            EndSwitch

        Case $GUI_EVENT_CLOSE
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            GUIDelete()
            Exit

        Case $SaveBatch_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = ""
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "Queued"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Case Name", $TCName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = ControlGetText("Optima Rate Import Test Case Creator", "Pass Number", $TCPassNo_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = ControlGetText("Optima Rate Import Test Case Creator", "Carrier Name", $CarrierName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Additional Details", $AdditionalDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $ServerDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "ServerDetails Name", $ServerDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "ServerDetails", $ServerDetails_data)

            $IncrDate_data = GUICtrlRead($IncrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = GUICtrlRead($DecrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = ControlGetText("Optima Rate Import Test Case Creator", "Destination Nam", $Destnination_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $DialCode_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = ControlGetText("Optima Rate Import Test Case Creator", "User Id/Password", $UidPass_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $Rate_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = GUICtrlRead($EffDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = GUICtrlRead($ExpDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $ImportFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Import File", $ImportFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)

            $RefDeffFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Reference File", $RefDeffFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()

        Case $RemFromGrid_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            If $SelectedRow > 1 Then
                $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
                $Ini_Section_delete = $Grid_listdata_sections[$SelectedRow]
                IniDelete($ProfilesINI, $Ini_Section_delete)
                For $c = $Grid_listdata_sections[$SelectedRow] To $Grid_listdata_sections[0]
                    IniRenameSection($ProfilesINI, $Grid_listdata_sections[$c], $Grid_listdata_sections[$c] - 1)
                Next
            EndIf
            _RefreshGridData()


        Case $MoveUp_button
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow > 1 Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Above_section = $Grid_listdata_sections[$SelectedRow - 1]

                $temp = 9999999
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Above_section, $Grid_listdata_sections[$SelectedRow])
                IniRenameSection($ProfilesINI, $temp, $Grid_listdata_sections[$SelectedRow - 1])
            EndIf

            _RefreshGridData()

        Case $MoveDown_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow < $Grid_listdata_sections[0] Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Below_section = $Grid_listdata_sections[$SelectedRow + 1]

                MsgBox(0, $Selected_section, $Below_section)
                $temp = "xxx"
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Below_section, $Selected_section)
                IniRenameSection($ProfilesINI, $temp, $Below_section)
            EndIf

            _RefreshGridData()

        Case $AddSeparator_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $ServerDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "ServerDetails", $ServerDetails_data)

            $AutoExpire_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)

            $IncrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $ImportFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)

            $RefDeffFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()


        Case $msg = $Tab_TCSuite

            $current = _GUICtrlTab_GetCurSel($Tab_TCSuite)
            $Tab_Name = _GUICtrlTab_GetItemText($Tab_TCSuite, $current)

            $ProfilesINI = @ScriptDir & "\Profiles\" & $Tab_Name & ".ini"
            ; This here is a temp solution to stop the contineous refrsh problem.
            If $current <> $GenericTempValue Then
                _RefreshGridData()
            EndIf
            $GenericTempValue = $current


    EndSwitch
WEnd



Func _RefreshGridData()
    $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
    If @error Then
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
    ElseIf $Grid_listdata_sections[0] > 0 Then
        _GUICtrlListView_BeginUpdate($BatchList_handle)
        _GUICtrlListView_DeleteAllItems($BatchList_handle)

        For $a = 1 To $Grid_listdata_sections[0]

;~          _ArrayDisplay($Grid_listdata_sections)
            _ArraySort($Grid_listdata_sections, 0, 1)
;~          _ArrayDisplay($Grid_listdata_sections)
            $Grid_All_listdata = IniReadSection($ProfilesINI, $Grid_listdata_sections[$a])
            If Not @error Then
                If $Grid_All_listdata[0][0] > 0 Then
                    _GUICtrlListView_AddItem($BatchList_handle, $a)
                    _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_listdata_sections[$a], 1)
                    For $b = 2 To $Grid_All_listdata[0][0]
                        _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_All_listdata[$b][1], $b + 1)
                    Next
                EndIf
            EndIf
        Next
        For $a = 0 To _GUICtrlListView_GetColumnCount($BatchList_handle)
            _GUICtrlListView_SetColumnWidth($BatchList_handle, $a, $LVSCW_AUTOSIZE_USEHEADER)
        Next
        _GUICtrlListView_EndUpdate($BatchList_handle)
    EndIf
EndFunc   ;==>_RefreshGridData
Edited by Rishav
Link to comment
Share on other sites

Hi,

not any further solution, but a hint. You have to check your GUICreate function calls:

$ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )

Your gui would have a width of $x1 = 10 and a height of $y1 = 10. I think, this isn't what you want.

;-))

Stefan

Got you, so you can go further on.

Changes in Section Case "Import Rates to Active":

$ControlGUI = GUICreate("", $x1 + 800, $y1 + 400, 0, 50, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI); it's still not correct, but you can see something

GUISetState()

Good luck!

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

Hi,

not any further solution, but a hint. You have to check your GUICreate function calls:

$ControlGUI = GUICreate("", $x1, $y1, 910, 220, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )

Your gui would have a width of $x1 = 10 and a height of $y1 = 10. I think, this isn't what you want.

;-))

Stefan

gaah... not those kind of issues again. >_<

can't believe that i made such a silly mistake.

thanks a lot. again.

brb, will check the code with the new fixes.

Link to comment
Share on other sites

some more silliness.

the ControlGUI is hidden by the MainGUI.

I tried using the following to create it

$ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, BitOR($WS_EX_MDICHILD,$WS_EX_TRANSPARENT,$WS_EX_TOPMOST), $MainGUI)
but it didn't help.

Also, the ControlGUI is being created at a different position than I wanted.

whole code;

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.1.1 (beta)
    Author:         Rishav Sharan
    
    Script Function:
    GUI to create simple import test cases
    
#ce ----------------------------------------------------------------------------


;~ Includes
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GuiDateTimePicker.au3>
#include <GuiTab.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiTab.au3>


;~ GUI Backend data file. This is the temp ini file which saves all the data till a specific new file is created.
; This is to save the data in case of system failure.
; If we added the data directly to the grid, in case of accidental closure or power failure, the data will be lost.
$ProfilesINI = @ScriptDir & "\Profiles\NEW PROFILE.ini"
$GenericTempValue = "temp value"


; GUI
$MainGUI = GUICreate("Optima Rate Import Test Case Creator", 1100, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP))
GUISetIcon(@SystemDir & "\mspaint.exe", 0)
GUISetBkColor(0xFFFFFF)

$x1 = 10
$y1 = 10
GUICtrlCreateGroup("Please set the Path parameters", $x1, $y1, 920, 230)


; DETAILS FIELDS
$TCName_label = GUICtrlCreateLabel("Test Case Name", $x1 + 10, $y1 + 20, 90, 15)
$TCName_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 20, 170, 20, $ES_UPPERCASE)

$TCPassNo_label = GUICtrlCreateLabel("Pass Number", $x1 + 320, $y1 + 20, 90, 15)
$TCPassNo_field = GUICtrlCreateInput("1", $x1 + 420, $y1 + 20, 170, 20, $ES_NUMBER)

$TestType_label = GUICtrlCreateLabel("Test Type", $x1 + 630, $y1 + 20, 90, 15)
$TestType_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 20, 170, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData($TestType_field, "Import Rates to Pending|Import Rates to Active|Edit Carrier Rates|Run SQL File|Run Win Batch File", "Import Rates to Pending")

; TC SUITE TABS
$Tab_TCSuite = _GUICtrlTab_Create($MainGUI, 0, 255, 1100, 650)
$Tab_TCSuite_handle = GUICtrlGetHandle($Tab_TCSuite)
_GUICtrlTab_InsertItem($Tab_TCSuite, 0, "NEW PROFILE")

; GET ALL INI FILES IN THE PROFILES FOLDER IN AN ARRAY
$IniFileList_array = _FileListToArray(@ScriptDir & "\Profiles\", "*.ini", 1)

; ADD TABS TO TAB BAR BASED OFF ON THE $IniFileList_array DATA
If @error = 0 Then
    For $d = 1 To $IniFileList_array[0]
        If $IniFileList_array[$d] <> "NEW PROFILE.ini" Then
            $Tab_Insert_Name = StringTrimRight($IniFileList_array[$d], 4)
            _GUICtrlTab_InsertItem($Tab_TCSuite, $d, $Tab_Insert_Name)
        EndIf
    Next
EndIf

; BUTTONS
$SaveBatch_button = GUICtrlCreateButton("Save to Grid", $x1 + 930, $y1, 150, 25)
$AddSeparator_button = GUICtrlCreateButton("Add Separator", $x1 + 930, $y1 + 30, 150, 25)
$AddAnal_button = GUICtrlCreateButton("Add Analysis Stage", $x1 + 930, $y1 + 60, 150, 25)
$RemFromGrid_button = GUICtrlCreateButton("Remove from Grid", $x1 + 930, $y1 + 90, 150, 25)
$MoveUp_button = GUICtrlCreateButton("Move up Item", $x1 + 930, $y1 + 120, 150, 25)
$MoveDown_button = GUICtrlCreateButton("Move Down Item", $x1 + 930, $y1 + 150, 150, 25)
$GridToFile_button = GUICtrlCreateButton("Save Grid to file", $x1 + 930, $y1 + 180, 150, 25)
$RunBatch_button = GUICtrlCreateButton("Run Batch", $x1 + 930, $y1 + 210, 150, 25, $BS_DEFPUSHBUTTON)

; DISABLE ALL EXTRA BUTTONS CURRENTLY
GUICtrlSetState($AddAnal_button, $GUI_DISABLE)
GUICtrlSetState($RunBatch_button, $GUI_DISABLE)
GUICtrlSetState($GridToFile_button, $GUI_DISABLE)

; LIST VIEW
$BatchList = GUICtrlCreateListView("", 5, 280, 1090, 620, BitOR(-1, $LVS_NOSORTHEADER, $WS_VSCROLL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
$BatchList_handle = GUICtrlGetHandle($BatchList)
$Grid_serial_col = _GUICtrlListView_AddColumn($BatchList, "Serial No.")
$Grid_sequence_col = _GUICtrlListView_AddColumn($BatchList, "Sequence")
$Grid_Timestamp_col = _GUICtrlListView_AddColumn($BatchList, "Timestamp", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Status_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Status", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_OverallResult_col = _GUICtrlListView_AddColumn($BatchList, "Overall Result", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TCName_col = _GUICtrlListView_AddColumn($BatchList, "Test Case Name", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_PassNo_col = _GUICtrlListView_AddColumn($BatchList, "Pass No.", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Carrier_col = _GUICtrlListView_AddColumn($BatchList, "Carrier Name", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_TestType_col = _GUICtrlListView_AddColumn($BatchList, "Test Type", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_Details_col = _GUICtrlListView_AddColumn($BatchList, "Details", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_ServerDetails_col = _GUICtrlListView_AddColumn($BatchList, "ServerDetails", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_AutoExpire_col = _GUICtrlListView_AddColumn($BatchList, "Autoexpire", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_IncrDate_col = _GUICtrlListView_AddColumn($BatchList, "Increase Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DecrDate_col = _GUICtrlListView_AddColumn($BatchList, "Decrease Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_DestName_col = _GUICtrlListView_AddColumn($BatchList, "Destination", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_DialCode_col = _GUICtrlListView_AddColumn($BatchList, "Dial Code", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_UidPass_col = _GUICtrlListView_AddColumn($BatchList, "UserId/Password", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_Rate_col = _GUICtrlListView_AddColumn($BatchList, "Rate", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_EffectievDate_col = _GUICtrlListView_AddColumn($BatchList, "Effective Date", $LVSCW_AUTOSIZE_USEHEADER)
$Grid_ExpiryDate_col = _GUICtrlListView_AddColumn($BatchList, "Expiry Date", $LVSCW_AUTOSIZE_USEHEADER)

$Grid_RSFile_col = _GUICtrlListView_AddColumn($BatchList, "Template File", $LVSCW_AUTOSIZE)
$Grid_RefFile_col = _GUICtrlListView_AddColumn($BatchList, "Reference File", $LVSCW_AUTOSIZE)

GUISetState()

;~ -----------------------------------------------------------------------------------------------------------------

; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
$ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, BitOR($WS_EX_MDICHILD,$WS_EX_TRANSPARENT,$WS_EX_TOPMOST), $MainGUI)

; DETAILS FIELDS
$CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
$CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

$RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
$RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

$ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 80, 90, 15)
$ImportFileLocation_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 80, 250, 20)


; DATES
$IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
$IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
$IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
_GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

$DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
$DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
$DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
_GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")

GUISetState()


_RefreshGridData()

;~ -----------------------------------------------------------------------------------------------------------------

; Capture and execute all button clicks
While 1
    $msg = GUIGetMsg(1)

    Switch $msg[0]

        Case $TestType_field
            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)

            Switch $TestType_data
                Case "Import Rates to Pending"
                    GUIDelete($ControlGUI)
                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

                    $RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
                    $RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 80, 250, 20)


                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")

                    GUISetState()

                Case "Import Rates to Active"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x1 + 320, $y1 + 50, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x1 + 420, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Don't Autoexpire Old Data|Autoexpire Old Data", "Don't Autoexpire Old Data")

                    $RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
                    $RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

                    $ImportFileLocation_label = GUICtrlCreateLabel("Import File", $x1 + 10, $y1 + 80, 90, 15)
                    $ImportFileLocation_field = GUICtrlCreateCombo("", $x1 + 110, $y1 + 80, 250, 20)

                    ; DATES
                    $IncrDate_label = GUICtrlCreateLabel("Increase Date", $x1 + 320, $y1 + 80, 90, 20)
                    $IncrDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 80, 170, 20)
                    $IncrDate_handle = GUICtrlGetHandle($IncrDate_datefield)
                    _GUICtrlDTP_SetFormat($IncrDate_handle, "ddd, dd/MMM/yy")

                    $DecrDate_label = GUICtrlCreateLabel("Decrease Date", $x1 + 630, $y1 + 80, 90, 20)
                    $DecrDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 80, 170, 20)
                    $DecrDate_handle = GUICtrlGetHandle($DecrDate_datefield)
                    _GUICtrlDTP_SetFormat($DecrDate_handle, "ddd, dd/MMM/yy")

                    GUISetState()

                Case "Edit Carrier Rates"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    ; DETAILS FIELDS
                    $CarrierName_label = GUICtrlCreateLabel("Carrier Name", $x1 + 10, $y1 + 50, 90, 15)
                    $CarrierName_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 50, 170, 20, $ES_UPPERCASE)

                    $AdditionalDetails_label = GUICtrlCreateLabel("Additional Details", $x1 + 320, $y1 + 50, 90, 15)
                    $AdditionalDetails_field = GUICtrlCreateCombo("", $x1 + 420, $y1 + 50, 170, 20, $CBS_DROPDOWNLIST)
                    GUICtrlSetData($AdditionalDetails_field, "Refresh Grid|Edit Entry|Delete Entry|Clear All", "Refresh Grid")

                    $RefDeffFileLocation_label = GUICtrlCreateLabel("Reference File", $x1 + 630, $y1 + 50, 90, 15)
                    $RefDeffFileLocation_field = GUICtrlCreateCombo("", $x1 + 730, $y1 + 50, 170, 20)

                    ; DETAILS FIELDS
                    $Destnination_label = GUICtrlCreateLabel("Destination Name", $x1 + 10, $y1 + 110, 90, 15)
                    $Destnination_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 110, 170, 20)

                    $DialCode_label = GUICtrlCreateLabel("Dial Code", $x1 + 320, $y1 + 110, 90, 15)
                    $DialCode_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 110, 170, 20, $ES_NUMBER)

                    $Rate_label = GUICtrlCreateLabel("Rate", $x1 + 630, $y1 + 110, 90, 15)
                    $Rate_field = GUICtrlCreateInput("", $x1 + 730, $y1 + 110, 170, 20, $ES_NUMBER)

                    ;~ CHECKBOXED DATE
                    $tDate = 0

                    $EffDate_label = GUICtrlCreateLabel("Use Effective Date", $x1 + 320, $y1 + 140, 90, 20)
                    $EffDate_datefield = GUICtrlCreateDate("", $x1 + 420, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $EffDate_handle = GUICtrlGetHandle($EffDate_datefield)
                    _GUICtrlDTP_SetFormat($EffDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($EffDate_handle, $tDate, True)

                    $ExpDate_label = GUICtrlCreateLabel("Use Expiry Date", $x1 + 630, $y1 + 140, 90, 20)
                    $ExpDate_datefield = GUICtrlCreateDate("", $x1 + 730, $y1 + 140, 170, 20, BitOR($DTS_SHOWNONE, $DTS_LONGDATEFORMAT))
                    $ExpDate_handle = GUICtrlGetHandle($ExpDate_datefield)
                    _GUICtrlDTP_SetFormat($ExpDate_handle, "ddd, dd/MMM/yy")
                    _GUICtrlDTP_SetSystemTimeEx($ExpDate_handle, $tDate, True)

                    GUISetState()

                Case "Run SQL File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    $ServerDetails_label = GUICtrlCreateLabel("ServerDetails Name", $x1 + 10, $y1 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 170, 170, 20)

                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x1 + 320, $y1 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 170, 170, 20)

                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")
                    ; Use GUIctrlsetdata to set the test type to Import til Pending so that the Case statements create all necessary fields

                Case "Run Win Batch File"
                    GUIDelete($ControlGUI)

                    ; CREATE A CHILD GUI TO THE MAIN GUI WHICH WILL HOLD ALL THE DYNAMIC CONTROLS
                    $ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

                    $ServerDetails_label = GUICtrlCreateLabel("ServerDetails Name", $x1 + 10, $y1 + 170, 90, 15)
                    $ServerDetails_field = GUICtrlCreateInput("", $x1 + 110, $y1 + 170, 170, 20)

                    $UidPass_label = GUICtrlCreateLabel("User Id/Password", $x1 + 320, $y1 + 170, 90, 15)
                    $UidPass_field = GUICtrlCreateInput("", $x1 + 420, $y1 + 170, 170, 20)

                    GUISetState()
                    MsgBox(0, "How did you end up here?", "Nothing in here. Go away.")
                    ; Use GUIctrlsetdata to set the test type to Import til Pending so that the Case statements create all necessary fields


            EndSwitch

;~ -----------------------------------------------------------------------------------------------------------------

        Case $GUI_EVENT_CLOSE
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            GUIDelete()
            Exit

        Case $SaveBatch_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = ""
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "Queued"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Case Name", $TCName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = ControlGetText("Optima Rate Import Test Case Creator", "Pass Number", $TCPassNo_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = ControlGetText("Optima Rate Import Test Case Creator", "Carrier Name", $CarrierName_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = ControlGetText("Optima Rate Import Test Case Creator", "Test Type", $TestType_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "Additional Details", $AdditionalDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $ServerDetails_data = ControlGetText("Optima Rate Import Test Case Creator", "ServerDetails Name", $ServerDetails_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "ServerDetails", $ServerDetails_data)

            $IncrDate_data = GUICtrlRead($IncrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = GUICtrlRead($DecrDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = ControlGetText("Optima Rate Import Test Case Creator", "Destination Nam", $Destnination_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $DialCode_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = ControlGetText("Optima Rate Import Test Case Creator", "User Id/Password", $UidPass_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = ControlGetText("Optima Rate Import Test Case Creator", "Rate", $Rate_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = GUICtrlRead($EffDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = GUICtrlRead($ExpDate_datefield)
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $ImportFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Import File", $ImportFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)

            $RefDeffFileLocation_data = ControlGetText("Optima Rate Import Test Case Creator", "Reference File", $RefDeffFileLocation_field)
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()

        Case $RemFromGrid_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            If $SelectedRow > 1 Then
                $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
                $Ini_Section_delete = $Grid_listdata_sections[$SelectedRow]
                IniDelete($ProfilesINI, $Ini_Section_delete)
                For $c = $Grid_listdata_sections[$SelectedRow] To $Grid_listdata_sections[0]
                    IniRenameSection($ProfilesINI, $Grid_listdata_sections[$c], $Grid_listdata_sections[$c] - 1)
                Next
            EndIf
            _RefreshGridData()


        Case $MoveUp_button
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow > 1 Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Above_section = $Grid_listdata_sections[$SelectedRow - 1]

                $temp = 9999999
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Above_section, $Grid_listdata_sections[$SelectedRow])
                IniRenameSection($ProfilesINI, $temp, $Grid_listdata_sections[$SelectedRow - 1])
            EndIf

            _RefreshGridData()

        Case $MoveDown_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            $SelectedRow = _GUICtrlListView_GetSelectedIndices($BatchList_handle) + 1
            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            _ArraySort($Grid_listdata_sections, 0, 1)
            If $SelectedRow < $Grid_listdata_sections[0] Then
                $Selected_section = $Grid_listdata_sections[$SelectedRow]
                $Below_section = $Grid_listdata_sections[$SelectedRow + 1]

                MsgBox(0, $Selected_section, $Below_section)
                $temp = "xxx"
                IniRenameSection($ProfilesINI, $Selected_section, $temp)
                IniRenameSection($ProfilesINI, $Below_section, $Selected_section)
                IniRenameSection($ProfilesINI, $temp, $Below_section)
            EndIf

            _RefreshGridData()

        Case $AddSeparator_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")

            $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
            If @error = 1 Then
                $SectionNumber_data = 1
            Else
                $SectionNumber_data = $Grid_listdata_sections[0] + 1
            EndIf
            IniWriteSection($ProfilesINI, $SectionNumber_data, "")

            $Timestamp_data = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC
            IniWrite($ProfilesINI, $SectionNumber_data, "TIMESTAMP", $Timestamp_data)

            $TestCaseStatus_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE STATUS", $TestCaseStatus_data)

            $OverallResult_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "OVERALL RESULT", $OverallResult_data)

            $TCName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST CASE NAME", $TCName_data)

            $TCPassNo_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "PASS NUMBER", $TCPassNo_data)

            $CarrierName_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "CARRIER NAME", $CarrierName_data)

            $TestType_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "TEST TYPE", $TestType_data)

            $AdditionalDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DETAILS", $AdditionalDetails_data)

            $ServerDetails_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "ServerDetails", $ServerDetails_data)

            $AutoExpire_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "AUTOEXPIRE", $AutoExpire_data)

            $IncrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "INCREASE DATE", $IncrDate_data)

            $DecrDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DECREASE DATE", $DecrDate_data)

            $Destnination_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DESTINATION", $Destnination_data)

            $DialCode_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "DIAL CODE", $DialCode_data)

            $UidPass_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "USERID AND PASSWORD", $UidPass_data)

            $Rate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "RATE", $Rate_data)

            $EffDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EFFECTIVE DATE", $EffDate_data)

            $ExpDate_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "EXPIRY DATE", $ExpDate_data)

            $ImportFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "IMPORT FILE", $ImportFileLocation_data)

            $RefDeffFileLocation_data = "------------"
            IniWrite($ProfilesINI, $SectionNumber_data, "REFERENCE FILE", $RefDeffFileLocation_data)

            _RefreshGridData()
            
;~ -----------------------------------------------------------------------------------------------------------------

        Case $msg = $Tab_TCSuite

            $current = _GUICtrlTab_GetCurSel($Tab_TCSuite)
            $Tab_Name = _GUICtrlTab_GetItemText($Tab_TCSuite, $current)

            $ProfilesINI = @ScriptDir & "\Profiles\" & $Tab_Name & ".ini"
            ; This here is a temp solution to stop the contineous refrsh problem.
            If $current <> $GenericTempValue Then
                _RefreshGridData()
            EndIf
            $GenericTempValue = $current


    EndSwitch
WEnd

;~ -----------------------------------------------------------------------------------------------------------------

Func _RefreshGridData()
    $Grid_listdata_sections = IniReadSectionNames($ProfilesINI)
    If @error Then
        _GUICtrlListView_DeleteAllItems($BatchList_handle)
    ElseIf $Grid_listdata_sections[0] > 0 Then
        _GUICtrlListView_BeginUpdate($BatchList_handle)
        _GUICtrlListView_DeleteAllItems($BatchList_handle)

        For $a = 1 To $Grid_listdata_sections[0]

;~          _ArrayDisplay($Grid_listdata_sections)
            _ArraySort($Grid_listdata_sections, 0, 1)
;~          _ArrayDisplay($Grid_listdata_sections)
            $Grid_All_listdata = IniReadSection($ProfilesINI, $Grid_listdata_sections[$a])
            If Not @error Then
                If $Grid_All_listdata[0][0] > 0 Then
                    _GUICtrlListView_AddItem($BatchList_handle, $a)
                    _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_listdata_sections[$a], 1)
                    For $b = 2 To $Grid_All_listdata[0][0]
                        _GUICtrlListView_AddSubItem($BatchList_handle, $a - 1, $Grid_All_listdata[$b][1], $b + 1)
                    Next
                EndIf
            EndIf
        Next
        For $a = 0 To _GUICtrlListView_GetColumnCount($BatchList_handle)
            _GUICtrlListView_SetColumnWidth($BatchList_handle, $a, $LVSCW_AUTOSIZE_USEHEADER)
        Next
        _GUICtrlListView_EndUpdate($BatchList_handle)
    EndIf
EndFunc   ;==>_RefreshGridData

thanks and regards.

Link to comment
Share on other sites

Hi,

1st) Your control Gui isn't hide by your main Gui, but by your Group:

GUICtrlCreateGroup("Please set the Path parameters", $x1, $y1, 920, 60) ; you will see what you mean

2nd) Change

$ControlGUI = GUICreate("", 910, 220, $x1, $y1, $WS_CHILD, $WS_EX_MDICHILD, $MainGUI)

to

$ControlGUI = GUICreate("", 920, 220, $x1, $y1 + 30, $WS_CHILD, -1, $MainGUI)

;-))

Stefan

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...