mit fleißiger, oder eigentlich hauptsächlicher hilfe von bugfix, hier nun die erste version von grundbuch.
hiermit können buchungssätze angelegt werden (in einer txt), in der man eine liste mit kto + nr. zur verfügung hat, die automatisch gezogen werden.
ein check überprüft, ob soll an haben gleich ist und es können einträge geändert, hinzugefügt oder gelöscht werden.
viel spaß
Version 0.01
Spoiler anzeigen
#include <guiconstants.au3>
#include <guilistview.au3>
#include <file.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("^z", 'Undo')
HotKeySet("{F1}", 'InsertAcc')
HotKeySet("{F2}", 'EditAcc')
HotKeySet("{F3}", 'DeleteAcc')
HotKeySet("{F5}", 'save')
Global $flag
Global $list
Global $nr = 1
Global $input, $iinput, $iiinput
Global Const $WM_NOTIFY = 0x004E
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
Global Const $NM_RCLICK = ($NM_FIRST - 5)
Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
Dim $pathKonten = 'konten.txt', $pathUndo = $pathKonten & '.BAK'
Dim $arKonten, $arListe[1]
FileInstall("konten.txt", "konten.txt")
[/autoit] [autoit][/autoit] [autoit]$maingui = GUICreate("Grundbuch 0.01 - thx 2 BugFix", 500, 300)
GUISetOnEvent($GUI_Event_Close, 'CloseGUI')
$menu = GUICtrlCreateMenu("&Konto")
$add = GUICtrlCreateMenuItem("&einfügen F1", $menu)
GUICtrlSetOnEvent(-1, 'InsertAcc')
$edit = GUICtrlCreateMenuItem("&bearbeiten F2", $menu)
GUICtrlSetOnEvent(-1, 'EditAcc')
$blind = GUICtrlCreateMenuItem("", $menu)
$remove = GUICtrlCreateMenuItem("&löschen F3", $menu)
GUICtrlSetOnEvent(-1, 'DeleteAcc')
$blind = GUICtrlCreateMenuItem("", $menu)
$undo = GUICtrlCreateMenuItem("&undo STRG+Z", $menu)
GUICtrlSetOnEvent(-1, 'Undo')
GUICtrlCreateGroup("Konten-Liste", 0, 5, 170, 270)
$list = GUICtrlCreateListView("Konto|Nr.", 5, 20, 160, 250, -1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
_GUICtrlListViewSetColumnWidth(-1, 0, 88)
_GUICtrlListViewSetColumnWidth(-1, 1, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Grundbuch", 170, 5, 330, 270)
GUICtrlCreateLabel("Konto", 180, 20)
GUICtrlCreateLabel("Nr.", 360, 20)
GUICtrlCreateLabel("Betrag", 430, 20)
GUICtrlCreateLabel("an...", 180, 115)
$button1 = GUICtrlCreateButton(">", 175, 35, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button2 = GUICtrlCreateButton(">", 175, 55, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button3 = GUICtrlCreateButton(">", 175, 75, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button4 = GUICtrlCreateButton(">", 175, 95, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button5 = GUICtrlCreateButton(">", 175, 135, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button6 = GUICtrlCreateButton(">", 175, 155, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button7 = GUICtrlCreateButton(">", 175, 175, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button8 = GUICtrlCreateButton(">", 175, 195, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$input1 = GUICtrlCreateInput("", 195, 35, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input2 = GUICtrlCreateInput("", 195, 55, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input3 = GUICtrlCreateInput("", 195, 75, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input4 = GUICtrlCreateInput("", 195, 95, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input5 = GUICtrlCreateInput("", 195, 135, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input6 = GUICtrlCreateInput("", 195, 155, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input7 = GUICtrlCreateInput("", 195, 175, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input8 = GUICtrlCreateInput("", 195, 195, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$iinput1 = GUICtrlCreateInput("", 360, 35, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg1')
$iinput2 = GUICtrlCreateInput("", 360, 55, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg2')
$iinput3 = GUICtrlCreateInput("", 360, 75, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg3')
$iinput4 = GUICtrlCreateInput("", 360, 95, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg4')
$iinput5 = GUICtrlCreateInput("", 360, 135, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg5')
$iinput6 = GUICtrlCreateInput("", 360, 155, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg6')
$iinput7 = GUICtrlCreateInput("", 360, 175, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg7')
$iinput8 = GUICtrlCreateInput("", 360, 195, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg8')
$iiinput1 = GUICtrlCreateInput("", 430, 35, 60, 15)
$iiinput2 = GUICtrlCreateInput("", 430, 55, 60, 15)
$iiinput3 = GUICtrlCreateInput("", 430, 75, 60, 15)
$iiinput4 = GUICtrlCreateInput("", 430, 95, 60, 15)
$iiinput5 = GUICtrlCreateInput("", 430, 135, 60, 15)
$iiinput6 = GUICtrlCreateInput("", 430, 155, 60, 15)
$iiinput7 = GUICtrlCreateInput("", 430, 175, 60, 15)
$iiinput8 = GUICtrlCreateInput("", 430, 195, 60, 15)
GUICtrlCreateLabel("File-Name", 180, 225)
$filename = GUICtrlCreateInput("", 240, 225, 200, 15)
GUICtrlSetTip(-1, "Name der Datei, OHNE Zusatzt -txt-")
GUICtrlCreateButton("speichere Buchungssatz (F5)", 265, 245)
GUICtrlSetTip(-1, "speichert den angegebenen Buchungssatz in einer txt-Datei")
GUICtrlSetOnEvent(-1, 'save')
GUICtrlCreateGroup("", -99, -99, 1, 1)
For $i = $button1 to $button8
GUICtrlSetTip($i, "übernimmt markierten Kontennamen + Konten-Nr.")
Next
For $i = $input1 To $input8
GUICtrlSetTip($i, "... gewünschter Kontenname (Nr. wird, sofern vorhanden, übernommen)")
Next
For $i = $iinput1 To $iinput8
GUICtrlSetTip($i, "... gewünschte Konten-Nr. (Name wird, sofern vorhanden, übernommen)")
Next
For $i = $iiinput1 To $iiinput8
GUICtrlSetTip($i, "... Betrag ohne Währung (wird in € angegeben)")
Next
GUISetState(@SW_SHOW, $maingui)
ReadAcc($pathKonten)
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
While 1
Sleep(100)
Wend
Func CloseGUI()
Exit
EndFunc
Func ReadAcc($PATH) ; aus Datei in ListView schreiben
_FileReadToArray($PATH, $arKonten)
If (Not IsArray($arKonten)) Then
MsgBox(0, 'Fehler', 'Kontenliste konnte nicht gelesen werden!')
Return
EndIf
ReDim $arListe[UBound($arKonten)-1]
For $i = 1 To $arKonten[0]
$arListe[$i-1] = GUICtrlCreateListViewItem($arKonten[$i], $list)
Next
EndFunc
Func WriteAcc() ; aus ListView in Datei schreiben (nach jedem Edit, Add und Löschen)
$anz = _GUICtrlListViewGetItemCount($list)
ReDim $arKonten[$anz]
For $i = 0 To UBound($arKonten)-1
$arKonten[$i] = _GUICtrlListViewGetItemText($list, $i, 0) & '|' & _GUICtrlListViewGetItemText($list, $i, 1)
Next
If FileExists($pathKonten) Then FileMove($pathKonten, $pathKonten & '.BAK', 1)
_FileWriteFromArray($pathKonten, $arKonten)
EndFunc
Func InsertAcc() ; Konto hinzufügen
ReDim $arListe[UBound($arListe)+1]
$arListe[UBound($arListe)-1] = GUICtrlCreateListViewItem( InputBox('Kontoname', 'Bitte Namen des neuen Kontos eingeben:', "", "", 300, 120) & '|' & _
InputBox('Kontonummer', 'Bitte die Nummer des neuen Kontos eingeben:', "", "", 300, 120), $list)
WriteAcc()
EndFunc
Func DeleteAcc() ; Konto löschen
$index = _GUICtrlListViewGetCurSel($list)
_GUICtrlListViewDeleteItem ($list, $index)
WriteAcc()
EndFunc
Func EditAcc() ; Konto bearbeiten
$index = _GUICtrlListViewGetCurSel($list)
$name = _GUICtrlListViewGetItemText($list, $index, 0)
$number = _GUICtrlListViewGetItemText($list, $index, 1)
$name = InputBox('Kontoname', 'Hier können Sie den Kontennamen ändern:', $name, "", 300, 120)
$number = InputBox('Kontonummer', 'Hier können Sie die Kontonummer ändern:', $number, "", 300, 120)
_GUICtrlListViewSetItemText($list, $index, 0, $name)
_GUICtrlListViewSetItemText($list, $index, 1, $number)
WriteAcc()
EndFunc
Func Undo() ; letzte Aktion (Edit, New, Delete) rückgängig machen
_GUICtrlListViewDeleteAllItems($list)
ReadAcc($pathUndo)
WriteAcc()
EndFunc
Func ListView_DoubleClick() ; Werte übertragen
$index = _GUICtrlListViewGetCurSel($list)
$name = _GUICtrlListViewGetItemText($list, $index, 0)
$number = _GUICtrlListViewGetItemText($list, $index, 1)
For $i = $input1 To $input8
If GUICtrlRead($i) = '' Then
GUICtrlSetData($i, $name)
Switch $i
Case $input1
GUICtrlSetData($iinput1, $number)
Case $input2
GUICtrlSetData($iinput2, $number)
Case $input3
GUICtrlSetData($iinput3, $number)
Case $input4
GUICtrlSetData($iinput4, $number)
Case $input5
GUICtrlSetData($iinput5, $number)
Case $input6
GUICtrlSetData($iinput6, $number)
Case $input7
GUICtrlSetData($iinput7, $number)
Case $input8
GUICtrlSetData($iinput8, $number)
EndSwitch
ExitLoop
EndIf
Next
EndFunc
Func FillIn()
$index = _GUICtrlListViewGetCurSel($list)
$name = _GUICtrlListViewGetItemText($list, $index, 0)
$number = _GUICtrlListViewGetItemText($list, $index, 1)
$i = @GUI_CTRLID
Switch $i
Case 18
GUICtrlSetData($input1, $name)
GUICtrlSetData($iinput1, $number)
Case 19
GUICtrlSetData($input2, $name)
GUICtrlSetData($iinput2, $number)
Case 20
GUICtrlSetData($input3, $name)
GUICtrlSetData($iinput3, $number)
Case 21
GUICtrlSetData($input4, $name)
GUICtrlSetData($iinput4, $number)
Case 22
GUICtrlSetData($input5, $name)
GUICtrlSetData($iinput5, $number)
Case 23
GUICtrlSetData($input6, $name)
GUICtrlSetData($iinput6, $number)
Case 24
GUICtrlSetData($input7, $name)
GUICtrlSetData($iinput7, $number)
Case 25
GUICtrlSetData($input8, $name)
GUICtrlSetData($iinput8, $number)
EndSwitch
EndFunc
Func NameChg()
$i = @GUI_CTRLID
$index = _GUICtrlListViewFindItem($list, GUICtrlRead($i))
$number = _GUICtrlListViewGetItemText($list, $index, 1)
Switch $i
Case 26
GUICtrlSetData($iinput1, $number)
Case 27
GUICtrlSetData($iinput2, $number)
Case 28
GUICtrlSetData($iinput3, $number)
Case 29
GUICtrlSetData($iinput4, $number)
Case 30
GUICtrlSetData($iinput5, $number)
Case 31
GUICtrlSetData($iinput6, $number)
Case 32
GUICtrlSetData($iinput7, $number)
Case 33
GUICtrlSetData($iinput8, $number)
EndSwitch
EndFunc
Func save()
$sum1 = GUICtrlRead($iiinput1) + GUICtrlRead($iiinput2) + GUICtrlRead($iiinput3) + GUICtrlRead($iiinput4)
$sum2 = GUICtrlRead($iiinput5) + GUICtrlRead($iiinput6) + GUICtrlRead($iiinput7) + GUICtrlRead($iiinput8)
If $sum1 <> $sum2 Then
MsgBox(16, "Fehler", "Summen stimmen nicht überein" & @CRLF & @CRLF & $sum1 & " - " & $sum2 & " = " & $sum1 - $sum2)
Else
If GUICtrlRead($filename) = "" Then
$flag = True
$file2 = InputBox("File-Name", "Geben Sie einen File-Namen ein", "", "", 300,120)
$file = $file2 & ".txt"
Else
$file = GUICtrlRead($filename) & ".txt"
EndIf
$save = FileOpen($file, 1)
FileWrite($save, "> " & $nr & "." & @CRLF)
If GUICtrlRead($input1) = "" Then
Else
FileWrite($save, GUICtrlRead($iinput1) & " " & GUICtrlRead($input1) & " " & GUICtrlRead($iiinput1) & " €" & @CRLF)
EndIf
If GUICtrlRead($input2) = "" Then
Else
FileWrite($save, GUICtrlRead($iinput2) & " " & GUICtrlRead($input2) & " " & GUICtrlRead($iiinput2) & " €" & @CRLF)
EndIf
If GUICtrlRead($input3) = "" Then
Else
FileWrite($save, GUICtrlRead($iinput3) & " " & GUICtrlRead($input3) & " " & GUICtrlRead($iiinput3) & " €" & @CRLF)
EndIf
If GUICtrlRead($input4) = "" Then
Else
FileWrite($save, GUICtrlRead($iinput4) & " " & GUICtrlRead($input4) & " " & GUICtrlRead($iiinput4) & " €" & @CRLF)
EndIf
If GUICtrlRead($input5) = "" Then
Else
FileWrite($save, "an " & GUICtrlRead($iinput5) & " " & GUICtrlRead($input5) & " " & GUICtrlRead($iiinput5) & " €" & @CRLF)
EndIf
If GUICtrlRead($input6) = "" Then
Else
FileWrite($save, "an " & GUICtrlRead($iinput6) & " " & GUICtrlRead($input6) & " " & GUICtrlRead($iiinput6) & " €" & @CRLF)
EndIf
If GUICtrlRead($input7) = "" Then
Else
FileWrite($save, "an " & GUICtrlRead($iinput7) & " " & GUICtrlRead($input7) & " " & GUICtrlRead($iiinput7) & " €" & @CRLF)
EndIf
If GUICtrlRead($input8) = "" Then
Else
FileWrite($save, "an " & GUICtrlRead($iinput8) & " " & GUICtrlRead($input8) & " " & GUICtrlRead($iiinput8) & " €" & @CRLF)
EndIf
FileWrite($save, "-" & @CRLF)
FileWrite($save, "Summe: " & $sum1 & " €" & @CRLF)
FileWrite($save, @CRLF)
FileClose($save)
For $i = $input1 To $input8
GUICtrlSetData($i, "")
Next
For $i = $iinput1 To $iinput8
GUICtrlSetData($i, "")
Next
For $i = $iiinput1 To $iiinput8
GUICtrlSetData($i, "")
Next
If $flag = True Then
GUICtrlSetData($filename, $file2)
$flag = False
Else
EndIf
$nr = $nr + 1
EndIf
EndFunc
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
;#forceref $hWndGUI, $MsgID, $wParam
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3)
Select
Case $wParam = $list
Select
Case $event = $NM_CLICK
;~ ListView_Click ()
Case $event = $NM_DBLCLK
ListView_DoubleClick ()
Case $event = $NM_RCLICK
;~ ListView_RightClick ()
Case $event = $NM_RDBLCLK
;~ ListView_RightDblClick ()
EndSelect
EndSelect
$tagNMHDR = 0
$event = 0
$lParam = 0
EndFunc ;==>WM_Notify_Events
Func NumberChg1()
$index = _LV_Search($list, GUICtrlRead($iinput1))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input1, $name)
EndFunc
Func NumberChg2()
$index = _LV_Search($list, GUICtrlRead($iinput2))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input2, $name)
EndFunc
Func NumberChg3()
$index = _LV_Search($list, GUICtrlRead($iinput3))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input3, $name)
EndFunc
Func NumberChg4()
$index = _LV_Search($list, GUICtrlRead($iinput4))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input4, $name)
EndFunc
Func NumberChg5()
$index = _LV_Search($list, GUICtrlRead($iinput5))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input5, $name)
EndFunc
Func NumberChg6()
$index = _LV_Search($list, GUICtrlRead($iinput6))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input6, $name)
EndFunc
Func NumberChg7()
$index = _LV_Search($list, GUICtrlRead($iinput7))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input7, $name)
EndFunc
Func NumberChg8()
$index = _LV_Search($list, GUICtrlRead($iinput8))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input8, $name)
EndFunc
Func _LV_Search($LV, $What2Find)
$count = _GUICtrlListViewGetItemCount($LV)
If $count < 1 Then Return -1 ; Return -1 ; leere Liste
$countSub = _GUICtrlListViewGetSubItemsCount($LV)
For $i = 0 To $count-1
For $k = 0 To $countSub-1
If _GUICtrlListViewGetItemText($LV, $i, $k) = $What2Find Then Return $i
Next
Next
Return -2 ; Return -2 ; nicht gefunden
EndFunc
Version 1.01
+Excel-Export
+Auto-Name
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Allow_Decompile=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <guiconstants.au3>
#include <guilistview.au3>
#include <file.au3>
#include <excel.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]HotKeySet("^z", 'Undo')
HotKeySet("{F1}", 'InsertAcc')
HotKeySet("{F2}", 'EditAcc')
HotKeySet("{F3}", 'DeleteAcc')
HotKeySet("{F5}", 'save')
HotKeySet("{F6}", 'excel')
Global $flag
Global $list
Global $nr = 1
Global $input, $iinput, $iiinput
Global $save
Global Const $WM_NOTIFY = 0x004E
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
Global Const $NM_RCLICK = ($NM_FIRST - 5)
Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
Dim $pathKonten = 'konten.txt', $pathUndo = $pathKonten & '.BAK'
Dim $arKonten, $arListe[1]
FileInstall("konten.txt", "konten.txt")
[/autoit] [autoit][/autoit] [autoit]$maingui = GUICreate("Grundbuch 1.01 (by Daniel von Pluto)", 500, 300)
GUISetOnEvent($GUI_Event_Close, 'CloseGUI')
$menu = GUICtrlCreateMenu("&Konto")
$add = GUICtrlCreateMenuItem("&einfügen F1", $menu)
GUICtrlSetOnEvent(-1, 'InsertAcc')
$edit = GUICtrlCreateMenuItem("&bearbeiten F2", $menu)
GUICtrlSetOnEvent(-1, 'EditAcc')
$blind = GUICtrlCreateMenuItem("", $menu)
$remove = GUICtrlCreateMenuItem("&löschen F3", $menu)
GUICtrlSetOnEvent(-1, 'DeleteAcc')
$blind = GUICtrlCreateMenuItem("", $menu)
$undo = GUICtrlCreateMenuItem("&undo STRG+Z", $menu)
GUICtrlSetOnEvent(-1, 'Undo')
GUICtrlCreateGroup("Konten-Liste", 0, 5, 170, 270)
$list = GUICtrlCreateListView("Konto|Nr.", 5, 20, 160, 250, -1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
_GUICtrlListViewSetColumnWidth(-1, 0, 88)
_GUICtrlListViewSetColumnWidth(-1, 1, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Grundbuch", 170, 5, 330, 270)
GUICtrlCreateLabel("Konto", 180, 20)
GUICtrlCreateLabel("Nr.", 360, 20)
GUICtrlCreateLabel("Betrag", 430, 20)
GUICtrlCreateLabel("an...", 180, 115)
$button1 = GUICtrlCreateButton(">", 175, 35, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button2 = GUICtrlCreateButton(">", 175, 55, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button3 = GUICtrlCreateButton(">", 175, 75, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button4 = GUICtrlCreateButton(">", 175, 95, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button5 = GUICtrlCreateButton(">", 175, 135, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button6 = GUICtrlCreateButton(">", 175, 155, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button7 = GUICtrlCreateButton(">", 175, 175, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$button8 = GUICtrlCreateButton(">", 175, 195, 15, 15)
GUICtrlSetOnEvent(-1, 'FiLLIn')
$input1 = GUICtrlCreateInput("", 195, 35, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input2 = GUICtrlCreateInput("", 195, 55, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input3 = GUICtrlCreateInput("", 195, 75, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input4 = GUICtrlCreateInput("", 195, 95, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input5 = GUICtrlCreateInput("", 195, 135, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input6 = GUICtrlCreateInput("", 195, 155, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input7 = GUICtrlCreateInput("", 195, 175, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$input8 = GUICtrlCreateInput("", 195, 195, 155, 15)
GUICtrlSetOnEvent(-1, 'NameChg')
$iinput1 = GUICtrlCreateInput("", 360, 35, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg1')
$iinput2 = GUICtrlCreateInput("", 360, 55, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg2')
$iinput3 = GUICtrlCreateInput("", 360, 75, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg3')
$iinput4 = GUICtrlCreateInput("", 360, 95, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg4')
$iinput5 = GUICtrlCreateInput("", 360, 135, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg5')
$iinput6 = GUICtrlCreateInput("", 360, 155, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg6')
$iinput7 = GUICtrlCreateInput("", 360, 175, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg7')
$iinput8 = GUICtrlCreateInput("", 360, 195, 60, 15)
GUICtrlSetOnEvent(-1, 'NumberChg8')
$iiinput1 = GUICtrlCreateInput("", 430, 35, 60, 15)
$iiinput2 = GUICtrlCreateInput("", 430, 55, 60, 15)
$iiinput3 = GUICtrlCreateInput("", 430, 75, 60, 15)
$iiinput4 = GUICtrlCreateInput("", 430, 95, 60, 15)
$iiinput5 = GUICtrlCreateInput("", 430, 135, 60, 15)
$iiinput6 = GUICtrlCreateInput("", 430, 155, 60, 15)
$iiinput7 = GUICtrlCreateInput("", 430, 175, 60, 15)
$iiinput8 = GUICtrlCreateInput("", 430, 195, 60, 15)
GUICtrlCreateLabel("File-Name", 180, 225)
$filename = GUICtrlCreateInput("", 240, 225, 200, 15)
GUICtrlSetTip(-1, "Name der Datei, OHNE Zusatzt -txt-")
GUICtrlCreateButton("speichern (F5)", 238, 245)
GUICtrlSetTip(-1, "speichert den angegebenen Buchungssatz in einer txt-Datei")
GUICtrlSetOnEvent(-1, 'save')
GUICtrlCreateButton("export 2 Excel (F6)", 345, 245)
GUICtrlSetTip(-1, "exportiert die gespeicherten Buchungssätze nach Excel")
GUICtrlSetOnEvent(-1, 'excel')
GUICtrlCreateGroup("", -99, -99, 1, 1)
For $i = $button1 to $button8
GUICtrlSetTip($i, "übernimmt markierten Kontennamen + Konten-Nr.")
Next
For $i = $input1 To $input8
GUICtrlSetTip($i, "... gewünschter Kontenname (Nr. wird, sofern vorhanden, übernommen)")
Next
For $i = $iinput1 To $iinput8
GUICtrlSetTip($i, "... gewünschte Konten-Nr. (Name wird, sofern vorhanden, übernommen)")
Next
For $i = $iiinput1 To $iiinput8
GUICtrlSetTip($i, "... Betrag ohne Währung (wird in € angegeben)")
Next
GUISetState(@SW_SHOW, $maingui)
ReadAcc($pathKonten)
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
While 1
Sleep(100)
Wend
Func CloseGUI()
Exit
EndFunc
Func ReadAcc($PATH) ; aus Datei in ListView schreiben
_FileReadToArray($PATH, $arKonten)
If (Not IsArray($arKonten)) Then
MsgBox(0, 'Fehler', 'Kontenliste konnte nicht gelesen werden!')
Return
EndIf
ReDim $arListe[UBound($arKonten)-1]
For $i = 1 To $arKonten[0]
$arListe[$i-1] = GUICtrlCreateListViewItem($arKonten[$i], $list)
Next
EndFunc
Func WriteAcc() ; aus ListView in Datei schreiben (nach jedem Edit, Add und Löschen)
$anz = _GUICtrlListViewGetItemCount($list)
ReDim $arKonten[$anz]
For $i = 0 To UBound($arKonten)-1
$arKonten[$i] = _GUICtrlListViewGetItemText($list, $i, 0) & '|' & _GUICtrlListViewGetItemText($list, $i, 1)
Next
If FileExists($pathKonten) Then FileMove($pathKonten, $pathKonten & '.BAK', 1)
_FileWriteFromArray($pathKonten, $arKonten)
EndFunc
Func InsertAcc() ; Konto hinzufügen
ReDim $arListe[UBound($arListe)+1]
$arListe[UBound($arListe)-1] = GUICtrlCreateListViewItem( InputBox('Kontoname', 'Bitte Namen des neuen Kontos eingeben:', "", "", 300, 120) & '|' & _
InputBox('Kontonummer', 'Bitte die Nummer des neuen Kontos eingeben:', "", "", 300, 120), $list)
WriteAcc()
EndFunc
Func DeleteAcc() ; Konto löschen
$index = _GUICtrlListViewGetCurSel($list)
_GUICtrlListViewDeleteItem ($list, $index)
WriteAcc()
EndFunc
Func EditAcc() ; Konto bearbeiten
$index = _GUICtrlListViewGetCurSel($list)
$name = _GUICtrlListViewGetItemText($list, $index, 0)
$number = _GUICtrlListViewGetItemText($list, $index, 1)
$name = InputBox('Kontoname', 'Hier können Sie den Kontennamen ändern:', $name, "", 300, 120)
$number = InputBox('Kontonummer', 'Hier können Sie die Kontonummer ändern:', $number, "", 300, 120)
_GUICtrlListViewSetItemText($list, $index, 0, $name)
_GUICtrlListViewSetItemText($list, $index, 1, $number)
WriteAcc()
EndFunc
Func Undo() ; letzte Aktion (Edit, New, Delete) rückgängig machen
_GUICtrlListViewDeleteAllItems($list)
ReadAcc($pathUndo)
WriteAcc()
EndFunc
Func ListView_DoubleClick() ; Werte übertragen
$index = _GUICtrlListViewGetCurSel($list)
$name = _GUICtrlListViewGetItemText($list, $index, 0)
$number = _GUICtrlListViewGetItemText($list, $index, 1)
For $i = $input1 To $input8
If GUICtrlRead($i) = '' Then
GUICtrlSetData($i, $name)
Switch $i
Case $input1
GUICtrlSetData($iinput1, $number)
Case $input2
GUICtrlSetData($iinput2, $number)
Case $input3
GUICtrlSetData($iinput3, $number)
Case $input4
GUICtrlSetData($iinput4, $number)
Case $input5
GUICtrlSetData($iinput5, $number)
Case $input6
GUICtrlSetData($iinput6, $number)
Case $input7
GUICtrlSetData($iinput7, $number)
Case $input8
GUICtrlSetData($iinput8, $number)
EndSwitch
ExitLoop
EndIf
Next
EndFunc
Func FillIn()
$index = _GUICtrlListViewGetCurSel($list)
$name = _GUICtrlListViewGetItemText($list, $index, 0)
$number = _GUICtrlListViewGetItemText($list, $index, 1)
$i = @GUI_CTRLID
Switch $i
Case 18
GUICtrlSetData($input1, $name)
GUICtrlSetData($iinput1, $number)
Case 19
GUICtrlSetData($input2, $name)
GUICtrlSetData($iinput2, $number)
Case 20
GUICtrlSetData($input3, $name)
GUICtrlSetData($iinput3, $number)
Case 21
GUICtrlSetData($input4, $name)
GUICtrlSetData($iinput4, $number)
Case 22
GUICtrlSetData($input5, $name)
GUICtrlSetData($iinput5, $number)
Case 23
GUICtrlSetData($input6, $name)
GUICtrlSetData($iinput6, $number)
Case 24
GUICtrlSetData($input7, $name)
GUICtrlSetData($iinput7, $number)
Case 25
GUICtrlSetData($input8, $name)
GUICtrlSetData($iinput8, $number)
EndSwitch
EndFunc
Func NameChg()
$i = @GUI_CTRLID
$index = _GUICtrlListViewFindItem($list, GUICtrlRead($i))
$name = _GUICtrlListViewGetItemText($list, $index, 0)
$number = _GUICtrlListViewGetItemText($list, $index, 1)
Switch $i
Case 26
GUICtrlSetData($input1, $name)
GUICtrlSetData($iinput1, $number)
Case 27
GUICtrlSetData($input2, $name)
GUICtrlSetData($iinput2, $number)
Case 28
GUICtrlSetData($input3, $name)
GUICtrlSetData($iinput3, $number)
Case 29
GUICtrlSetData($input4, $name)
GUICtrlSetData($iinput4, $number)
Case 30
GUICtrlSetData($input5, $name)
GUICtrlSetData($iinput5, $number)
Case 31
GUICtrlSetData($input6, $name)
GUICtrlSetData($iinput6, $number)
Case 32
GUICtrlSetData($input7, $name)
GUICtrlSetData($iinput7, $number)
Case 33
GUICtrlSetData($input8, $name)
GUICtrlSetData($iinput8, $number)
EndSwitch
EndFunc
Func save()
$sum1 = GUICtrlRead($iiinput1) + GUICtrlRead($iiinput2) + GUICtrlRead($iiinput3) + GUICtrlRead($iiinput4)
$sum2 = GUICtrlRead($iiinput5) + GUICtrlRead($iiinput6) + GUICtrlRead($iiinput7) + GUICtrlRead($iiinput8)
If $sum1 <> $sum2 Then
MsgBox(16, "Fehler", "Summen stimmen nicht überein" & @CRLF & @CRLF & $sum1 & " - " & $sum2 & " = " & $sum1 - $sum2)
Else
If GUICtrlRead($filename) = "" Then
$flag = True
$file2 = InputBox("File-Name", "Geben Sie einen File-Namen ein", "", "", 300,120)
$file = $file2 & ".txt"
Else
$file = GUICtrlRead($filename) & ".txt"
EndIf
$save = FileOpen($file, 1)
FileWrite($save, "> " & $nr & "." & @CRLF)
If GUICtrlRead($input1) = "" Then
Else
FileWrite($save, ";" & GUICtrlRead($iinput1) & ";" & GUICtrlRead($input1) & ";" & GUICtrlRead($iiinput1) & " €" & @CRLF)
EndIf
If GUICtrlRead($input2) = "" Then
Else
FileWrite($save, ";" & GUICtrlRead($iinput2) & ";" & GUICtrlRead($input2) & ";" & GUICtrlRead($iiinput2) & " €" & @CRLF)
EndIf
If GUICtrlRead($input3) = "" Then
Else
FileWrite($save, ";" & GUICtrlRead($iinput3) & ";" & GUICtrlRead($input3) & ";" & GUICtrlRead($iiinput3) & " €" & @CRLF)
EndIf
If GUICtrlRead($input4) = "" Then
Else
FileWrite($save, ";" & GUICtrlRead($iinput4) & ";" & GUICtrlRead($input4) & ";" & GUICtrlRead($iiinput4) & " €" & @CRLF)
EndIf
If GUICtrlRead($input5) = "" Then
Else
FileWrite($save, "an;" & GUICtrlRead($iinput5) & ";" & GUICtrlRead($input5) & ";;" & GUICtrlRead($iiinput5) & " €" & @CRLF)
EndIf
If GUICtrlRead($input6) = "" Then
Else
FileWrite($save, "an;" & GUICtrlRead($iinput6) & ";" & GUICtrlRead($input6) & ";;" & GUICtrlRead($iiinput6) & " €" & @CRLF)
EndIf
If GUICtrlRead($input7) = "" Then
Else
FileWrite($save, "an;" & GUICtrlRead($iinput7) & ";" & GUICtrlRead($input7) & ";;" & GUICtrlRead($iiinput7) & " €" & @CRLF)
EndIf
If GUICtrlRead($input8) = "" Then
Else
FileWrite($save, "an;" & GUICtrlRead($iinput8) & ";" & GUICtrlRead($input8) & ";;" & GUICtrlRead($iiinput8) & " €" & @CRLF)
EndIf
FileWrite($save, "-" & @CRLF)
FileWrite($save, "Summe:;;;;" & $sum1 & " €" & @CRLF)
FileWrite($save, @CRLF)
FileClose($save)
For $i = $input1 To $input8
GUICtrlSetData($i, "")
Next
For $i = $iinput1 To $iinput8
GUICtrlSetData($i, "")
Next
For $i = $iiinput1 To $iiinput8
GUICtrlSetData($i, "")
Next
If $flag = True Then
GUICtrlSetData($filename, $file2)
$flag = False
Else
EndIf
$nr = $nr + 1
EndIf
EndFunc
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
;#forceref $hWndGUI, $MsgID, $wParam
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3)
Select
Case $wParam = $list
Select
Case $event = $NM_CLICK
;~ ListView_Click ()
Case $event = $NM_DBLCLK
ListView_DoubleClick ()
Case $event = $NM_RCLICK
;~ ListView_RightClick ()
Case $event = $NM_RDBLCLK
;~ ListView_RightDblClick ()
EndSelect
EndSelect
$tagNMHDR = 0
$event = 0
$lParam = 0
EndFunc ;==>WM_Notify_Events
Func NumberChg1()
$index = _LV_Search($list, GUICtrlRead($iinput1))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input1, $name)
EndFunc
Func NumberChg2()
$index = _LV_Search($list, GUICtrlRead($iinput2))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input2, $name)
EndFunc
Func NumberChg3()
$index = _LV_Search($list, GUICtrlRead($iinput3))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input3, $name)
EndFunc
Func NumberChg4()
$index = _LV_Search($list, GUICtrlRead($iinput4))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input4, $name)
EndFunc
Func NumberChg5()
$index = _LV_Search($list, GUICtrlRead($iinput5))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input5, $name)
EndFunc
Func NumberChg6()
$index = _LV_Search($list, GUICtrlRead($iinput6))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input6, $name)
EndFunc
Func NumberChg7()
$index = _LV_Search($list, GUICtrlRead($iinput7))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input7, $name)
EndFunc
Func NumberChg8()
$index = _LV_Search($list, GUICtrlRead($iinput8))
If $index < 0 Then
MsgBox(0, 'Fehler', 'Kontonummer nicht vorhanden!')
Return
EndIf
$name = _GUICtrlListViewGetItemText($list, $index, 0)
GUICtrlSetData($input8, $name)
EndFunc
Func _LV_Search($LV, $What2Find)
$count = _GUICtrlListViewGetItemCount($LV)
If $count < 1 Then Return -1 ; Return -1 ; leere Liste
$countSub = _GUICtrlListViewGetSubItemsCount($LV)
For $i = 0 To $count-1
For $k = 0 To $countSub-1
If _GUICtrlListViewGetItemText($LV, $i, $k) = $What2Find Then Return $i
Next
Next
Return -2 ; Return -2 ; nicht gefunden
EndFunc
Func excel()
$export = @ScriptDir & "\" & GUICtrlRead($filename) & ".txt"
_ExcelBookOpenTxt($export, ";", 1, 1, 1, False, 1)
EndFunc