Jump to content
Sign in to follow this  
Lord_Doominik

problems with an addressbook

Recommended Posts

i've got a problem... the program works fine, but it don't can show the saved users data... i dont know how i could integrate it in the chocie part... i first tryed it with an array but hugh, it dont worked... i think my problem is, how to get this in another variable for each name:

GUICtrlCreateListViewItem($LastNames[$i][1] & "|" & $FirstNames[$i][1], $Contacts)

#include <GUIConstants.au3>

;Variable declaration
$i = IniRead("Settings.set", "Variables", "i", 1)

;create GUI
GUICreate("Adressbook", 640, 480,(@DesktopWidth-640)/2, (@DesktopHeight-480)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

;Labels und Inputs
$Label1 = GUICtrlCreateLabel("Contacts", 30, 10, 250, 20, $SS_CENTER)
$Contacts = GUICtrlCreateListView("LastName                |FirstName                  ", 30, 40, 250, 409)
$Label2 = GUICtrlCreateLabel("FirstName", 320, 70, 70, 20)
$FirstName = GUICtrlCreateInput("", 390, 70, 160, 20)
$Label3 = GUICtrlCreateLabel("LastName", 320, 110, 70, 20)
$LastName = GUICtrlCreateInput("", 390, 110, 160, 20)
$Label4 = GUICtrlCreateLabel("Birthdate", 320, 150, 70, 20)
$Birthdate = GUICtrlCreateDate("", 390, 150, 160, 20, $DTS_SHORTDATEFORMAT)
$Label5 = GUICtrlCreateLabel("Adress", 320, 190, 70, 20)
$Adress = GUICtrlCreateEdit("", 390, 190, 160, 90, $ES_WANTRETURN + $ES_AUTOVSCROLL)
$Label6 = GUICtrlCreateLabel("Notices", 320, 300, 70, 20)
$Notice = GUICtrlCreateEdit("", 390, 300, 160, 90, $ES_WANTRETURN + $ES_AUTOVSCROLL)

;Button
$Add = GUICtrlCreateButton("Add", 350, 415, 100)
$Edit = GUICtrlCreateButton("Edit", 500, 415, 100)

GUISetState()

;Functions
Func Refresh()
    $LastNames = IniReadSection("Contacts.add", "LastNames")
    If  @error Then
        MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
    Else
        $FirstNames = IniReadSection("Contacts.add", "FirstNames")
        If  @error Then
            MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
        Else
            $Birthdates = IniReadSection("Contacts.add", "Birthdates")
            If  @error Then
                MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
            Else
                $Adresses = IniReadSection("Contacts.add", "Adresses")
                If  @error Then
                    MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
                Else
                    $Notices = IniReadSection("Contacts.add", "Notices")
                    If  @error Then
                        MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
                    Else
                        For $j = 1 To $LastNames[0][0]
                            GUICtrlCreateListViewItem($LastNames[$j][1] & "|" & $FirstNames[$j][1], $Contacts)
                        Next
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
EndFunc

Func Add()
    $FirstNameSave = GUICtrlRead($FirstName)
    $LastNameSave = GUICtrlRead($LastName)
    $BirthdateSave = GUICtrlRead($Birthdate)
    $AdressSave = GUICtrlRead($Adress)
    $NoticeSave = GUICtrlRead($Notice)
    IniWrite("Contacts.add", "FirstNames", $i, $FirstNameSave)
    IniWrite("Contacts.add", "LastNames", $i, $LastNameSave)
    IniWrite("Contacts.add", "Birthdates", $i, $BirthdateSave)
    IniWrite("Contacts.add", "Adresses", $i, $AdressSave)
    IniWrite("Contacts.add", "Notices", $i, $NoticeSave)
    $LastNames = IniReadSection("Contacts.add", "LastNames")
    If  @error Then
        MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
    Else
        $FirstNames = IniReadSection("Contacts.add", "FirstNames")
        If  @error Then
            MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
        Else
            $BirthDates = IniReadSection("Contacts.add", "Birthdates")
            If  @error Then
                MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
            Else
                $Adresses = IniReadSection("Contacts.add", "Adresses")
                If  @error Then
                    MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
                Else
                    $Notices = IniReadSection("Contacts.add", "Notices")
                    If  @error Then
                        MsgBox(64, "Fehler", "Es ist Ein Fehler aufgetreten: Keine Daten gefunden.")
                    Else
                        GUICtrlCreateListViewItem($LastNames[$i][1] & "|" & $FirstNames[$i][1], $Contacts)
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
    $i = $i + 1
    IniWrite("Settings.set", "Variables", "i", $i)
EndFunc

If FileExists("Contacts.add") Then
    Refresh()
EndIf

;Choice
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Contacts
    ;Sort
    Case $msg = $Add
        Add()
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...