Jump to content

ListView


bvr
 Share

Recommended Posts

On my lawncare manager I want my jobs that I add to the listview so I can select them and edit them. I want it to display in the listview the Date, Name, and Address. Here is my code so far.

;Author: Brandon Royer
;Program Name: Lawn Care Manager
; Date: 2013-2014
; Version: 1.0
 
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <Array.au3>
 
$Form1 = GUICreate("Lawn Business Manager v1.0", 615, 410, 192, 124)
$Main_List1 = GUICtrlCreateListView("Date | Name | Address | Money", 24, 64, 537, 253)
$sIniFile = @ScriptDir & "\Storage.ini"
$MenuItem_File = GUICtrlCreateMenu("&File")
$MenuItem_Edit = GUICtrlCreateMenu("&Edit")
$MenuItem_Help = GUICtrlCreateMenu("&Help")
$Main_Tab1 = GUICtrlCreateTab(8, 8, 601, 377)
$Main_TabSheet1 = GUICtrlCreateTabItem("Job Manager")
$Main_Group1 = GUICtrlCreateGroup("Jobs", 16, 40, 585, 329)
 
 
$Main_Button1 = GUICtrlCreateButton("Add", 24, 336, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$Main_Button2 = GUICtrlCreateButton("Edit", 112, 336, 75, 25)
$Main_Button3 = GUICtrlCreateButton("Remove", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_TabSheet2 = GUICtrlCreateTabItem("Equipment Manager")
$Main_Group2 = GUICtrlCreateGroup("Equipment", 16, 40, 585, 329)
$Main_List2 = GUICtrlCreateList("", 24, 64, 537, 253)
$Main_Button4 = GUICtrlCreateButton("Add Unit", 24, 336, 75, 25)
$Main_Button5 = GUICtrlCreateButton("Edit Unit", 112, 336, 75, 25)
$Main_Button6 = GUICtrlCreateButton("Remove Unit", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_TabSheet3 = GUICtrlCreateTabItem("Stastistics/Money")
$Main_Group3 = GUICtrlCreateGroup("Stastistics", 16, 48, 569, 329)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_Button7 = GUICtrlCreateButton("Add Expense", 24, 344, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Main_Button1
            Add_Job()
        Case $GUI_EVENT_CLOSE
            Exit
 
    EndSwitch
WEnd
 
Func Add_Job()
 
    $Form2 = GUICreate("Add Job", 615, 578, 232, 131)
    $sIniFile = @ScriptDir & "\Storage.ini"
Local $aSections = IniReadSectionNames($sIniFile)
Global $iCurrent_Max_Section = _ArrayMax($aSections)
If @error Then
    $iCurrent_Max_Section = 0 ; This sets the value to 0 if there are no existing sections
EndIf
    $Group1 = GUICtrlCreateGroup("Job Information", 8, 8, 601, 561)
    $Label1 = GUICtrlCreateLabel("Date:", 32, 40, 30, 17)
    $Date = GUICtrlCreateDate("2013/08/25 01:14:40", 64, 40, 186, 21)
    $Label2 = GUICtrlCreateLabel("Time Started:", 32, 72, 67, 17)
    $TimeStarted = GUICtrlCreateInput("00:00", 112, 72, 49, 21)
    $TimeStart_amPM = GUICtrlCreateCombo("pm", 168, 72, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData($TimeStart_amPM, "am")
    $Label3 = GUICtrlCreateLabel("Time Finished:", 32, 104, 72, 17)
    $TimeFinished = GUICtrlCreateInput("00:00", 112, 104, 49, 21)
    $TimeFinish_amPM = GUICtrlCreateCombo("pm", 168, 104, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData($TimeFinish_amPM, "am")
    $Label4 = GUICtrlCreateLabel("First Name:", 40, 136, 57, 17)
    $FirstName = GUICtrlCreateInput("", 112, 136, 121, 21)
    $Label5 = GUICtrlCreateLabel("Last Name:", 40, 168, 58, 17)
    $LastName = GUICtrlCreateInput("", 112, 168, 121, 21)
    $Label6 = GUICtrlCreateLabel("Address:", 40, 200, 45, 17)
    $Address = GUICtrlCreateInput("", 96, 200, 129, 21)
    $Label7 = GUICtrlCreateLabel("City:", 240, 200, 24, 17)
    $City = GUICtrlCreateInput("", 280, 200, 153, 21)
    $Label8 = GUICtrlCreateLabel("State:", 40, 232, 32, 17)
    $State = GUICtrlCreateInput("", 72, 232, 121, 21)
    $Label9 = GUICtrlCreateLabel("Phone Number:", 40, 264, 78, 17)
    $Zip = GUICtrlCreateInput("", 280, 232, 105, 21)
    $Label10 = GUICtrlCreateLabel("-", 176, 264, 7, 17)
    $PhoneDigit_One = GUICtrlCreateInput("", 120, 264, 41, 21)
    $Label11 = GUICtrlCreateLabel("-", 248, 264, 7, 17)
    $PhoneDigit_Two = GUICtrlCreateInput("", 192, 264, 41, 21)
    $Label12 = GUICtrlCreateLabel("Email:", 40, 296, 32, 17)
    $PhoneDigit_Three = GUICtrlCreateInput("", 264, 264, 41, 21)
    $Label13 = GUICtrlCreateLabel("Money Made:", 40, 328, 69, 17)
    $Lable14 = GUICtrlCreateLabel("Notes:", 40, 360, 35, 17)
    $Label14 = GUICtrlCreateLabel("Zip:", 240, 232, 22, 17)
    $Email = GUICtrlCreateInput("", 80, 296, 153, 21)
    $MoneyMade = GUICtrlCreateCombo("$5", 120, 328, 57, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData($MoneyMade,"$10 | $15 | $20 | $25 | $30 | $35 | $40 | $45 | $50 | $60 | $65 | $70 | $75 | $80 | $85 | $90 | $95 | $100")
    $Notes = GUICtrlCreateEdit("", 24, 384, 577, 137)
    GUICtrlSetData(-1, "")
    $Secondary_SaveButton = GUICtrlCreateButton("Save", 24, 536, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $Secondary_CancelButton = GUICtrlCreateButton("Cancel", 112, 536, 75, 25)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
 
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Secondary_CancelButton
                GUIDelete($Form2)
                Return
Case $Secondary_SaveButton
$iCurrent_Max_Section += 1 ; Increase the value for teh next section
IniWrite($sIniFile, $iCurrent_Max_Section, "Date", GUICtrlRead($Date)) ; And use it to write the new section
IniWrite($sIniFile, $iCurrent_Max_Section, "Time Started", GUICtrlRead($TimeStarted) & GUICtrlRead($TimeStart_amPM))
IniWrite($sIniFile, $iCurrent_Max_Section, "Time Finished", GUICtrlRead($TimeFinished) & GUICtrlRead($TimeFinish_amPM))
IniWrite($sIniFile, $iCurrent_Max_Section, "First Name", GUICtrlRead($FirstName))
IniWrite($sIniFile, $iCurrent_Max_Section, "Last Name", GUICtrlRead($LastName))
IniWrite($sIniFile, $iCurrent_Max_Section, "Address",   GUICtrlRead($Address))
IniWrite($sIniFile, $iCurrent_Max_Section, "City", GUICtrlRead($City))
IniWrite($sIniFile, $iCurrent_Max_Section, "State", GUICtrlRead($State))
IniWrite($sIniFile, $iCurrent_Max_Section, "Zip", GUICtrlRead($Zip))
IniWrite($sIniFile, $iCurrent_Max_Section, "Phone Number", GUICtrlRead($PhoneDigit_One) & GUICtrlRead($PhoneDigit_Two) & GUICtrlRead($PhoneDigit_Three))
IniWrite($sIniFile, $iCurrent_Max_Section, "Email", GUICtrlRead($Email))
IniWrite($sIniFile, $iCurrent_Max_Section, "Money Made", GUICtrlRead($MoneyMade))
IniWrite($sIniFile, $iCurrent_Max_Section, "Notes", GUICtrlRead($Notes))
GUIDelete($Form2)
Return
        EndSwitch
    WEnd
EndFunc   ;==>Add_Job
Edited by bvr
Link to comment
Share on other sites

That is going to be an arrangement of:

GUICtrlCreateListViewItem

Iniread

To populate your listview with the Saved Jobs in your ini you will need to build a function that starts with your script.

 

Edit:

Something like this:

#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <Array.au3>

$Form1 = GUICreate("Lawn Business Manager v1.0", 615, 410, 192, 124)
$Main_List1 = GUICtrlCreateListView("Date | Name | Address | Money", 24, 64, 537, 253)
$sIniFile = @ScriptDir & "\Storage.ini"
;--------------------------------------------------------------------------------------------------------------
    Local $idItem1 = GUICtrlCreateListViewItem(IniRead($sIniFile, "1", "Last Name", "Default Value"), $Main_List1)
    Local $idItem2 = GUICtrlCreateListViewItem(IniRead($sIniFile, "2", "Last Name", "Default Value"), $Main_List1)
    Local $idItem3 = GUICtrlCreateListViewItem(IniRead($sIniFile, "3", "Last Name", "Default Value"), $Main_List1)
;--------------------------------------------------------------------------------------------------------------
$MenuItem_File = GUICtrlCreateMenu("&File")
$MenuItem_Edit = GUICtrlCreateMenu("&Edit")
Edited by l3ill
Link to comment
Share on other sites

No that is just an example how to get stuff in to your listview.

You will need to build a function with loops and error functions checking to get a clean list.

Edited by l3ill
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...