Moin zusammen.
Es "Datenbankproblem" kommt hier.
Ich suche nach Büchern, z. B. über den Autor und das läuft auch super. Nun würde ich gerne, von dem Suchergebniss mir die dann mit der Maus ausgewählten/markierten (angeklickt und dann ist es blau hinterlegt)
Bücher...
a) in eine *.txt Datei speichern
und
b) so in eine Variable "exportieren", das ich dann das Array (???) dazu nutzen kann, um noch zu bestellende Bücher via Email bei meiner Buchhandlung zu melden.
AutoIt
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\Dies & Das\Autoit\_Icons\book_2.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.13.10 (Beta)
Author: Kanashius
Script Function:
Buchsammlung
So. Suche ist mit dabei (Live, während du tippst wird gesucht. Kann in den Einstellungen ausgeschaltet werden).
Bei bearbeiten/erstellen kann das Datum bei ausgeliehen von/bis nur eingegeben werden, wenn eingegeben wurde, wer das buch hat
(sonst wird auch in die db dort nichts eingetragen, beim bearbeiten verschwinden vorherige daten).
Beim Datumsfeld kann man tippen, indem man auf den tag/monat/jahr klickt und lostippt. Das Datumsformat (tt.mm.yyyy) kann oben
im Script geändert werden (Zeile 26: $sDataFormat="yyyy.MM.dd", wichtig dabei, dass das MM groß ist, sonst werden dort die Minuten
genommen.), MUSS dann aber in der Datenbank auch überall geändert werden. Ich hatte in der DB nachgesehen, das Datum war als
yyyy.mm.tt abgespeichert, weshalb ich das übernommen habe.
Header sind jetzt auch Einstellbar.
Jetzt hör ich erstmal auf, die Livesuche kann zwar in der settings.ini schon ausgestellt werden (0 statt der Standard 1), da kommt
aber noch nen Fenster für Allgemeine Einstellungen, wo das gesetzt werden kann :)
Edit: Hatte doch noch nen moment und hab die Gui für die Allgemeinen Einstellungen noch eingebaut. Livesuche kann jetzt ein- und
ausgeschaltet werden.
(Achja, wenn getippt wird, während die Livesuche noch läuft, wird die aktuelle Suche abgebrochen.)
#ce ----------------------------------------------------------------------------
#Include <SQLite.au3>
#Include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
;Datenbankstruktur
Global $SQL_DATABASECOLS=["ID","Titel","Autor","Verlag","Erscheinungsdatum","Genre","Preis","Einband","ISBN","Seiten","Lagerplatz","Serie","Bestellt","Gelesen","Note","Zusatz","Information","Ausgeliehen_an","Ausgeliehen_am","Ausgeliehen_bis","LfdNr"]
;MainGui
Global $sDataFormat="dd.MM.yyyy"; Global $sDataFormat="yyyy.MM.dd"
Global $MainGui_Gui,$MainGui_ListView,$MainGui_Menu[2],$MainGui_ListView_ContextMenu,$MainGui_SearchInput,$MainGui_SearchTarget,$MainGui_SearchType,$MainGui_SearchButton,$MainGui_ListView
Global $MainGui_Width=1400,$MainGui_Height=900,$MainGui_MenuHeight=20
Global $InfoGui_InputHeight=20
Global $InfoGui_EditHeight=200
;LabelNames|SQLNames|Height|Type
;Type=L->Label;I->Input,E->Edit,C->Combo,D->Date
;Ausgeliehen am und ausgeliehen bis MÜSSEN DIREKT hinter ausgeliehen an stehen, rest ist egal
Global $InfoGui_ControlInfos=[["ID:","ID",$InfoGui_InputHeight,"L"], _
["Titel:","Titel",$InfoGui_InputHeight,"I"],["Autor:","Autor",$InfoGui_InputHeight,"I"],["Verlag:","Verlag",$InfoGui_InputHeight,"I"], _
["Genre:","Genre",$InfoGui_InputHeight,"I"],["Erscheinungsdatum:","Erscheinungsdatum",$InfoGui_InputHeight,"I"], _
["Serie:","Serie",$InfoGui_InputHeight,"I"],["Preis:","Preis",$InfoGui_InputHeight,"I"],["Lagerplatz:","Lagerplatz",$InfoGui_InputHeight,"I"], _
["Einband:","Einband",$InfoGui_InputHeight,"I"],["ISBN:","ISBN",$InfoGui_InputHeight,"I"],["Seiten:","Seiten",$InfoGui_InputHeight,"I"], _
["Lfd.-Nr:","LfdNr",$InfoGui_InputHeight,"I"],["ausgeliehen an:","Ausgeliehen_an",$InfoGui_InputHeight,"I"],["ausgeliehen am","Ausgeliehen_am",$InfoGui_InputHeight,"I"], _
["ausgeliehen bis:","Ausgeliehen_bis",$InfoGui_InputHeight,"I"],["Bestellt:","Bestellt",$InfoGui_InputHeight,"C:| |Ja|Nein"],["Gelesen:","Gelesen",$InfoGui_InputHeight,"C:| |Ja|Nein"], _
["Note:","Note",$InfoGui_InputHeight,"C:| |1|2|3|4|5|6"],["Zusatz:","Zusatz",$InfoGui_InputHeight,"I"],["Information:","Information",$InfoGui_EditHeight,"E"] _
]
Global $InfoGui_ControlAusgeliehenAnIndex=0
Global $InfoGui_Gui,$InfoGui_Controls[UBound($InfoGui_ControlInfos)][2]
Global $InfoGui_Width=650,$InfoGui_Height=420
Global $LastListViewFillParams,$searching=false,$InterruputSearch=false
Global $SettingsGui_ListviewHeader_Gui,$SettingsGui_ListviewHeader_Controls[UBound($SQL_DATABASECOLS)][2],$SettingsGui_ListviewHeader_Width=340,$SettingsGui_ListviewHeader_Height=560
Global $SettingsGui_General_Gui,$SettingsGui_General_Controls[1][2],$SettingsGui_General_Width=340,$SettingsGui_General_Height=80
Global $SettingsFile=@ScriptDir&"\"&"settings.ini"
Global $DoLiveSearching
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
for $i=0 to UBound($InfoGui_ControlInfos)-1 step 1
if $InfoGui_ControlInfos[$i][1]="Ausgeliehen_an" then
$InfoGui_ControlAusgeliehenAnIndex=$i
ExitLoop
endif
next
if NOT FileExists($SettingsFile) then
FileClose(FileOpen($SettingsFile,8))
IniWriteSection($SettingsFile,"HeaderData","")
$startHeader="|Titel|Autor|Erscheinungsdatum|Genre|Seiten|Bestellt|Gelesen|Information"
for $i=0 to UBound($SQL_DATABASECOLS)-1 step 1
IniWrite($SettingsFile,"HeaderData",$SQL_DATABASECOLS[$i],StringInStr($startHeader,"|"&$SQL_DATABASECOLS[$i])>0?"1":"0")
next
IniWrite($SettingsFile,"General","Livesearch","1")
endif
_SQLite_Startup(@ScriptDir & "\sqlite3.dll", False, 1)
Global $SQL_DATABASE = _SQLite_Open(@ScriptDir & "\buchverwaltung.db")
_SQLite_Exec($SQL_DATABASE, "CREATE TABLE IF NOT EXISTS Buchverwaltung(ID INTEGER PRIMARY KEY AUTOINCREMENT,Titel,Autor,Verlag,Erscheinungsdatum,Genre,Preis,Einband,ISBN,Seiten,Lagerplatz,Serie,Bestellt,Gelesen,Note,Zusatz,Information,Ausgeliehen_an,Ausgeliehen_am,Ausgeliehen_bis,LfdNr);")
_setLivesearch()
_MainGui_Start()
_loadListviewHeader()
_fillListviewWithArray($MainGui_ListView,_SQL_GetColData(_getListviewHeaderNames($MainGui_ListView,true),-1,true))
while sleep(10)
WEnd
Func _MainGui_Start()
local $MainGui_SubMenu1[1]
$MainGui_Gui=GUICreate("Buchverwaltung 1.0",$MainGui_Width,$MainGui_Height)
;Menu
;Filemenu
$MainGui_Menu[0]=GUICtrlCreateMenu("Datei")
GUICtrlCreateMenuItem("Neuer Eintrag",$MainGui_Menu[0])
GUICtrlSetOnEvent(-1,"_newEntry")
$MainGui_Menu[1]=GUICtrlCreateMenu("Einstellungen")
GUICtrlCreateMenuItem("Allgemein",$MainGui_Menu[1])
GUICtrlSetOnEvent(-1,"_SettingsGui_General_start")
GUICtrlCreateMenuItem("ListviewSpalten",$MainGui_Menu[1])
GUICtrlSetOnEvent(-1,"_SettingsGui_ListviewHeader_start")
;Listview
$MainGui_SearchInput=GUICtrlCreateInput("",10,7,$MainGui_Width-60-270,25)
GUICtrlSendMsg(-1, 0x1501, 0, "Suchtext")
GUICtrlSetFont(-1,10)
$MainGui_SearchTarget=GUICtrlCreateCombo("All",10+$MainGui_Width-60-270+5,8,100,25)
$sSearchTargets=""
for $i=0 to UBound($SQL_DATABASECOLS)-1 step 1
$sSearchTargets&=$SQL_DATABASECOLS[$i]&($i<>UBound($SQL_DATABASECOLS)-1?"|":"")
next
GUICtrlSetData($MainGui_SearchTarget,$sSearchTargets)
$MainGui_SearchType=GUICtrlCreateCombo("LIKE",10+$MainGui_Width-60-270+110,8,60,25)
GUICtrlSetData(-1,"<=|<|=|>|>=|NOT LIKE")
$MainGui_SearchButton=GUICtrlCreateButton("Suchen",10+$MainGui_Width-60-270+175,7,55,25)
GUICtrlSetOnEvent(-1,"_startSearch")
$MainGui_SearchCancel=GUICtrlCreateButton("Abbrechen",10+$MainGui_Width-60-270+235,7,75,25)
GUICtrlSetOnEvent(-1,"_resetSearch")
$MainGui_ListView=GUICtrlCreateListView("ID",10,35,$MainGui_Width-20,$MainGui_Height-45-$MainGui_MenuHeight,$LVS_SHOWSELALWAYS)
_GUICtrlListView_SetColumnWidth(-1,0,0)
$MainGui_ListView_ContextMenu=GUICtrlCreateContextMenu($MainGui_ListView)
GUICtrlCreateMenuItem("Bearbeite Buchinfos",$MainGui_ListView_ContextMenu)
GUICtrlSetOnEvent(-1,"_editBookInfos")
GUICtrlCreateMenuItem("Lösche Buchinfos",$MainGui_ListView_ContextMenu)
GUICtrlSetOnEvent(-1,"_delBookInfos")
GUISetOnEvent($GUI_EVENT_CLOSE, "_MainGui_Close",$MainGui_Gui)
GUISetState(@SW_SHOW,$MainGui_Gui)
GUICtrlSetState($MainGui_ListView,$GUI_FOCUS)
EndFunc
Func _MainGui_Close()
GUIDelete($MainGui_Gui)
_SQLite_Close($SQL_DATABASE)
exit
EndFunc
Func _actListview()
if $LastListViewFillParams<>"" then
_fillListviewWithArray($MainGui_ListView,_SQL_GetData($LastListViewFillParams))
endif
EndFunc
Func _delBookInfos()
local $arSel[0]
$arSel=_GUICtrlListView_GetSelectedIndices($MainGui_ListView,true)
if $arSel[0]>0 then
for $i=1 to UBound($arSel)-1 step 1
_SQLite_Exec($SQL_DATABASE,"DELETE FROM Buchverwaltung WHERE ID="&_GUICtrlListView_GetItemText($MainGui_ListView,$arSel[$i],0))
next
endif
_actListview()
EndFunc
Func _editBookInfos()
local $arSel[0]
$arSel=_GUICtrlListView_GetSelectedIndices($MainGui_ListView,true)
if $arSel[0]>0 then
_InfoGui(_GUICtrlListView_GetItemText($MainGui_ListView,$arSel[1],0))
endif
EndFunc
Func _newEntry()
_InfoGui(-1)
EndFunc
Func _InfoGui($id=-1)
Local $arInfos,$AktHeight=0,$AktWidth=0,$i=0
Local $disableNext=0
Local $Title="Bearbeite Buchinfos"
if $id<0 then
$Title="Neuer Eintrag"
$i=1
else
local $sqlcols=""
for $i=0 to UBound($InfoGui_ControlInfos)-1 step 1
$sqlcols&=$InfoGui_ControlInfos[$i][1]&($i<>UBound($InfoGui_ControlInfos)-1?",":"")
next
$arInfos=_SQL_GetColData($sqlcols,$id)
endif
$InfoGui_Gui=GUICreate($Title,$InfoGui_Width,$InfoGui_Height,-1,-1,-1,-1,$MainGui_Gui)
for $i=0 to UBound($InfoGui_ControlInfos)-1 step 1
if $AktHeight+$InfoGui_ControlInfos[$i][2]>$InfoGui_Height-20-30 then
$AktWidth+=1
$AktHeight=0
endif
$InfoGui_Controls[$i][0]=GUICtrlCreateLabel($InfoGui_ControlInfos[$i][0],10+20*$AktWidth+(100+200)*$AktWidth,10+$AktHeight,100,20)
;Type=L->Label;I->Input,E->Edit,C->Combo,D->Date
if StringInStr($InfoGui_ControlInfos[$i][3],"I")=1 then
$InfoGui_Controls[$i][1]=GUICtrlCreateInput("",120+20*$AktWidth+(100+200)*$AktWidth,10+$AktHeight,200,$InfoGui_ControlInfos[$i][2])
if UBound($arInfos)>0 then
GUICtrlSetData($InfoGui_Controls[$i][1],$arInfos[1][$i])
endif
elseif StringInStr($InfoGui_ControlInfos[$i][3],"L")=1 then
$InfoGui_Controls[$i][1]=GUICtrlCreateLabel("",120+20*$AktWidth+(100+200)*$AktWidth,10+$AktHeight,200,$InfoGui_ControlInfos[$i][2])
if UBound($arInfos)>0 then
GUICtrlSetData($InfoGui_Controls[$i][1],$arInfos[1][$i])
endif
elseif StringInStr($InfoGui_ControlInfos[$i][3],"E")=1 then
$InfoGui_Controls[$i][1]=GUICtrlCreateEdit("",120+20*$AktWidth+(100+200)*$AktWidth,10+$AktHeight,200,$InfoGui_ControlInfos[$i][2])
if UBound($arInfos)>0 then
GUICtrlSetData($InfoGui_Controls[$i][1],$arInfos[1][$i])
endif
elseif StringInStr($InfoGui_ControlInfos[$i][3],"C")=1 then
$data=StringMid($InfoGui_ControlInfos[$i][3],StringInStr($InfoGui_ControlInfos[$i][3],":")+1)
$ar=StringSplit($data,"|",1+2)
$InfoGui_Controls[$i][1]=GUICtrlCreateCombo($ar[0],120+20*$AktWidth+(100+200)*$AktWidth,10+$AktHeight,200,$InfoGui_ControlInfos[$i][2])
$string=""
for $l=1 to UBound($ar)-1 step 1
$string&=$ar[$l]&($l<>UBound($ar)-1?"|":"")
next
GUICtrlSetData($InfoGui_Controls[$i][1],$string)
if UBound($arInfos)>0 then
_GUICtrlComboBox_SelectString($InfoGui_Controls[$i][1],$arInfos[1][$i])
endif
elseif StringInStr($InfoGui_ControlInfos[$i][3],"D")=1 then
$InfoGui_Controls[$i][1]=GUICtrlCreateDate("",120+20*$AktWidth+(100+200)*$AktWidth,10+$AktHeight,200,$InfoGui_ControlInfos[$i][2])
GUICtrlSendMsg($InfoGui_Controls[$i][1], $DTM_SETFORMATW, 0, $sDataFormat)
if UBound($arInfos)>0 then
GUICtrlSetData($InfoGui_Controls[$i][1],$arInfos[1][$i])
endif
endif
if $disableNext>0 then
$disableNext-=1
GUICtrlSetState($InfoGui_Controls[$i][1],$GUI_DISABLE)
endif
if $i=$InfoGui_ControlAusgeliehenAnIndex then
if GUICtrlRead($InfoGui_Controls[$i][1])="" then
$disableNext=2
endif
endif
$AktHeight+=$InfoGui_ControlInfos[$i][2]+5
next
GUICtrlCreateButton("Abbrechen",(($InfoGui_Width-400)/2)-10,$InfoGui_Height-30,200,25)
GUICtrlSetOnEvent(-1,"_InfoGui_Close")
GUICtrlCreateButton($id<0?"Erstellen":"Speichern",(($InfoGui_Width-400)/2)-10+210,$InfoGui_Height-30,200,25)
GUICtrlSetOnEvent(-1,"_createNewBook")
GUISetOnEvent($GUI_EVENT_CLOSE, "_InfoGui_Close",$InfoGui_Gui)
GUISetState(@SW_SHOW,$InfoGui_Gui)
;$InfoGui_Controls[0][0]=GUICtrlCreateInput()
EndFunc
Func _InfoGui_Close()
GUIDelete($InfoGui_Gui)
EndFunc
Func _createNewBook()
local $sql,$data
if GUICtrlRead($InfoGui_Controls[0][1])="" then
$sql="INSERT INTO 'Buchverwaltung'("
for $i=1 to UBound($InfoGui_ControlInfos)-1 step 1
$sql&="'"&$InfoGui_ControlInfos[$i][1]&"'"&($i<>UBound($InfoGui_ControlInfos)-1?",":"")
next
$sql&=") VALUES ("
for $i=1 to UBound($InfoGui_ControlInfos)-1 step 1
$data=StringReplace(GUICtrlRead($InfoGui_Controls[$i][1]),"'","''")
if NOT ControlCommand($InfoGui_Gui,"",$InfoGui_Controls[$i][1],"IsEnabled","") then
$data=""
endif
$sql&="'"&$data&"'"&($i<>UBound($InfoGui_ControlInfos)-1?",":"")
next
$sql&=");"
else
$sql="UPDATE Buchverwaltung SET "
for $i=1 to UBound($InfoGui_ControlInfos)-1 step 1
$data=StringReplace(GUICtrlRead($InfoGui_Controls[$i][1]),"'","''")
if NOT ControlCommand($InfoGui_Gui,"",$InfoGui_Controls[$i][1],"IsEnabled","") then
$data=""
endif
$sql&="'"&$InfoGui_ControlInfos[$i][1]&"' = '"&$data&"'"&($i<>UBound($InfoGui_ControlInfos)-1?",":"")
next
$sql&=" WHERE ID="&StringReplace(GUICtrlRead($InfoGui_Controls[0][1]),"'","''")&";"
endif
_SQL_Execute($sql)
_InfoGui_Close()
_actListview()
EndFunc
Func _SettingsGui_ListviewHeader_start()
$SettingsGui_ListviewHeader_Gui=GUICreate("Listviewheader setzen",$SettingsGui_ListviewHeader_Width,$SettingsGui_ListviewHeader_Height,-1,-1,-1,-1,$MainGui_Gui)
for $i=0 to UBound($SettingsGui_ListviewHeader_Controls)-1 step 1
$SettingsGui_ListviewHeader_Controls[$i][0]=GUICtrlCreateLabel($SQL_DATABASECOLS[$i],10,10+25*$i,200,20)
$SettingsGui_ListviewHeader_Controls[$i][1]=GUICtrlCreateCheckbox("anzeigen",220,10+25*$i,100,20)
if IniRead($SettingsFile,"HeaderData",$SQL_DATABASECOLS[$i],"1")="1" then
GUICtrlSetState($SettingsGui_ListviewHeader_Controls[$i][1],$GUI_CHECKED)
endif
next
GUICtrlCreateButton("Abbrechen",(($SettingsGui_ListviewHeader_Width-300)/2)-10,$SettingsGui_ListviewHeader_Height-30,150,25)
GUICtrlSetOnEvent(-1,"_SettingsGui_ListviewHeader_close")
GUICtrlCreateButton("Speichern",(($SettingsGui_ListviewHeader_Width-300)/2)-10+160,$SettingsGui_ListviewHeader_Height-30,150,25)
GUICtrlSetOnEvent(-1,"_setListviewHeader")
GUISetOnEvent($GUI_EVENT_CLOSE, "_SettingsGui_ListviewHeader_close",$SettingsGui_ListviewHeader_Gui)
GUISetState(@SW_SHOW,$SettingsGui_ListviewHeader_Gui)
EndFunc
Func _SettingsGui_ListviewHeader_close()
if $SettingsGui_ListviewHeader_Gui<>"" then
GUIDelete($SettingsGui_ListviewHeader_Gui)
$SettingsGui_ListviewHeader_Gui=""
endif
EndFunc
Func _SettingsGui_General_start()
$SettingsGui_General_Gui=GUICreate("Allgemeine Einstellungen",$SettingsGui_General_Width,$SettingsGui_General_Height,-1,-1,-1,-1,$MainGui_Gui)
$SettingsGui_General_Controls[0][0]=GUICtrlCreateLabel("Livesuche",10,10,200,20)
$SettingsGui_General_Controls[0][1]=GUICtrlCreateCheckbox("anzeigen",220,10,100,20)
if IniRead($SettingsFile,"General","Livesearch","1")="1" then
GUICtrlSetState($SettingsGui_General_Controls[0][1],$GUI_CHECKED)
endif
GUICtrlCreateButton("Abbrechen",(($SettingsGui_General_Width-300)/2)-10,$SettingsGui_General_Height-30,150,25)
GUICtrlSetOnEvent(-1,"_SettingsGui_General_close")
GUICtrlCreateButton("Speichern",(($SettingsGui_General_Width-300)/2)-10+160,$SettingsGui_General_Height-30,150,25)
GUICtrlSetOnEvent(-1,"_SettingsGui_General_save")
GUISetOnEvent($GUI_EVENT_CLOSE, "_SettingsGui_General_close",$SettingsGui_General_Gui)
GUISetState(@SW_SHOW,$SettingsGui_General_Gui)
EndFunc
Func _SettingsGui_General_close()
GUIDelete($SettingsGui_General_Gui)
EndFunc
Func _SettingsGui_General_save()
if _IsChecked($SettingsGui_General_Controls[0][1]) then
IniWrite($SettingsFile,"General","Livesearch",1)
else
IniWrite($SettingsFile,"General","Livesearch",0)
endif
_setLivesearch()
_SettingsGui_General_close()
EndFunc
Func _setLivesearch()
if IniRead($SettingsFile,"General","Livesearch","1")="1" then
$DoLiveSearching=true
else
$DoLiveSearching=false
endif
EndFunc
Func _setListviewHeader()
for $i=0 to UBound($SettingsGui_ListviewHeader_Controls)-1 step 1
if _IsChecked($SettingsGui_ListviewHeader_Controls[$i][1]) then
IniWrite($SettingsFile,"HeaderData",$SQL_DATABASECOLS[$i],1)
else
IniWrite($SettingsFile,"HeaderData",$SQL_DATABASECOLS[$i],0)
endif
next
_loadListviewHeader()
EndFunc
Func _loadListviewHeader()
$HeaderCols=""
for $i=0 to UBound($SettingsGui_ListviewHeader_Controls)-1 step 1
if IniRead($SettingsFile,"HeaderData",$SQL_DATABASECOLS[$i],"1")="1" then
if $HeaderCols<>"" then
$HeaderCols&="|"
endif
$HeaderCols&=$SQL_DATABASECOLS[$i]
endif
next
_MainGui_SetListviewHeader($HeaderCols)
_SettingsGui_ListviewHeader_close()
EndFunc
Func _MainGui_SetListviewHeader($HeaderCols)
_GUICtrlListView_BeginUpdate($MainGui_ListView)
for $i=0 to _GUICtrlListView_GetColumnCount($MainGui_ListView)-1 step 1
_GUICtrlListView_DeleteColumn($MainGui_ListView,0)
next
_GUICtrlListView_AddColumn($MainGui_ListView,"ID")
_GUICtrlListView_SetColumnWidth($MainGui_ListView,0,0)
if UBound($HeaderCols)=0 then
$HeaderCols=StringSplit($HeaderCols,"|",1+2)
endif
for $i=0 to UBound($HeaderCols)-1 step 1
_GUICtrlListView_AddColumn($MainGui_ListView,$HeaderCols[$i])
next
for $i=0 to UBound($HeaderCols)-1 step 1
_GUICtrlListView_SetColumnWidth($MainGui_ListView,$i+1,$LVSCW_AUTOSIZE_USEHEADER)
next
_GUICtrlListView_EndUpdate($MainGui_ListView)
_resetSearch()
if $LastListViewFillParams<>"" then
_fillListviewWithArray($MainGui_ListView,_SQL_GetColData(_getListviewHeaderNames($MainGui_ListView,true),-1,true))
endif
EndFunc
Func _getListviewHeaderNames($ListView,$getString=false)
local $arColNames[_GUICtrlListView_GetColumnCount($ListView)]
for $i=0 to _GUICtrlListView_GetColumnCount($ListView)-1 step 1
$arColNames[$i]=_GUICtrlListView_GetColumn($ListView,$i)[5]
next
if $getString then
$str=""
for $i=0 to UBound($arColNames)-1 step 1
$str&=$arColNames[$i]&($i<>UBound($arColNames)-1?",":"")
next
return $str
endif
return $arColNames
EndFunc
Func _fillListviewWithArray($Listview,$arData,$header=true)
_GUICtrlListView_BeginUpdate($Listview)
_GUICtrlListView_DeleteAllItems($Listview)
local $i=$header?1:0
for $i=$i to UBound($arData)-1 step 1
$line=""
for $j=0 to UBound($arData,2)-1 step 1
$line&=$arData[$i][$j]&($j<>UBound($arData,2)-1?"|":"")
next
GUICtrlCreateListViewItem($line,$Listview)
if Mod($i,2)>0 then
GUICtrlSetBkColor(-1,0xEEEEEE)
endif
next
_GUICtrlListView_EndUpdate($Listview)
EndFunc
Func _startSearch()
if $searching then
AdlibRegister("_waitNextSearch",100)
$InterruputSearch=true
return -1
endif
$searching=true
$search=GUICtrlRead($MainGui_SearchInput)
if $search="" then
$SearchMode=false
else
$SearchMode=true
_GUICtrlListView_DeleteAllItems($MainGui_ListView)
_GUICtrlListView_BeginUpdate($MainGui_ListView)
$sTarget=GUICtrlRead($MainGui_SearchTarget)
$sSearchExtension=""
$sSearchParam="OR"
$sSearchText=StringReplace(GUICtrlRead($MainGui_SearchInput),"%","%%")
$sSearchType=GUICtrlRead($MainGui_SearchType)
$sSearchCondition=$sTarget&" "&$sSearchType&" '"&$sSearchExtension&$sSearchText&$sSearchExtension&"'"
if $sSearchType="LIKE" or $sSearchType="NOT LIKE" then
$sSearchExtension="%"
endif
if $sSearchType="NOT LIKE" then
$sSearchParam="AND"
endif
if $sTarget="All" then
$sSearchCondition=""
for $i=0 to UBound($SQL_DATABASECOLS)-1 step 1
$sSearchCondition&=$SQL_DATABASECOLS[$i]&" "&$sSearchType&" '"&$sSearchExtension&$sSearchText&$sSearchExtension&"'"&($i<>UBound($SQL_DATABASECOLS)-1?" "&$sSearchParam&" ":"")
next
endif
$sSql="SELECT "&_getListviewHeaderNames($MainGui_ListView,true)&" FROM Buchverwaltung WHERE "&$sSearchCondition&";"
$sqlData=_SQL_GetData($sSql,true)
for $i=1 to UBound($sqlData)-1 step 1
if $InterruputSearch then
ExitLoop
endif
$string=""
for $j=0 to UBound($sqlData,2)-1 step 1
$string&=$sqlData[$i][$j]
if $j<UBound($sqlData,2) then
$string&="|"
endif
next
GUICtrlCreateListViewItem($string,$MainGui_ListView)
if Mod($i,2)>0 then
GUICtrlSetBkColor(-1,0xEEEEEE)
endif
next
_GUICtrlListView_EndUpdate($MainGui_ListView)
endif
$InterruputSearch=false
$searching=false
EndFunc
Func _waitNextSearch()
if NOT $searching then
AdlibUnRegister("_waitNextSearch")
;ConsoleWrite("Warten beendet"&@crlf)
_startSearch()
endif
EndFunc
Func _resetSearch()
GUICtrlSetData($MainGui_SearchInput,"")
_fillListviewWithArray($MainGui_ListView,_SQL_GetColData(_getListviewHeaderNames($MainGui_ListView,true),-1,true))
EndFunc
Func _SQL_Execute($sql)
_SQLite_Exec($SQL_DATABASE,$sql)
if @error then
msgbox(16,"Error","Error Executing SQL-STATEMENT"&@crlf&@crlf&$sql,0,$MainGui_Gui)
endif
EndFunc
Func _SQL_GetColData($cols,$id=-1,$userSql=false)
$sql="SELECT "&$cols&" FROM Buchverwaltung WHERE "&($id<0?"1":"ID='"&$id&"'")
$sqlData=_SQL_GetData($sql,$userSql)
return $sqlData
EndFunc
Func _SQL_GetData($sql,$userSql=false)
local $sqlData,$sqlRows,$sqlColumns
if $userSql then
$LastListViewFillParams=$sql
endif
_SQLite_GetTable2d($SQL_DATABASE,$sql,$sqlData,$sqlRows,$sqlColumns)
if @error then
MsgBox(16,"Error","Error Executing SQL-STATEMENT"&@crlf&@crlf&$sql,0,$MainGui_Gui)
endif
return $sqlData
EndFunc
#cs
GUICtrlSetState($InfoGui_Controls[$i][1],$GUI_DISABLE)
endif
if $i=$InfoGui_ControlAusgeliehenAnIndex then
if GUICtrlRead($InfoGui_Controls[$i][1])="" then
#ce
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $nNotifyCode = _HiWord($wParam)
Local $nID = _LoWord($wParam)
; Local $hCtrl = $lParam
Switch $lParam
Case GUICtrlGetHandle($MainGui_SearchInput)
if $DoLiveSearching then
if $nNotifyCode=256 then
_resetSearch()
_startSearch()
endif
if $nNotifyCode=1024 or $nNotifyCode=786 then
_startSearch()
EndIf
endif
Case GUICtrlGetHandle($InfoGui_Controls[$InfoGui_ControlAusgeliehenAnIndex][1])
if $nNotifyCode=768 then
if GUICtrlRead($InfoGui_Controls[$InfoGui_ControlAusgeliehenAnIndex][1])<>"" then
GUICtrlSetState($InfoGui_Controls[$InfoGui_ControlAusgeliehenAnIndex+1][1],$GUI_ENABLE)
GUICtrlSetState($InfoGui_Controls[$InfoGui_ControlAusgeliehenAnIndex+2][1],$GUI_ENABLE)
else
GUICtrlSetState($InfoGui_Controls[$InfoGui_ControlAusgeliehenAnIndex+1][1],$GUI_DISABLE)
GUICtrlSetState($InfoGui_Controls[$InfoGui_ControlAusgeliehenAnIndex+2][1],$GUI_DISABLE)
endif
endif
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_COMMAND
Func _HiWord($x)
Return BitShift($x, 16)
EndFunc ;==>_HiWord
Func _LoWord($x)
Return BitAND($x, 0xFFFF)
EndFunc ;==>_LoWord
Func _IsChecked($idControlID)
Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsChecked
Alles anzeigen