Yaerox Posted November 23, 2012 Posted November 23, 2012 Hey guys,first of all, excuse me please for bad english :/I got two problems which i could not solve with google or the german forums. That's why i decided to try it here in english and hopeful u will understand me (:- So, first i got exactly the same problem like 'Seeker' but i could not find any solution :/- The second problem is more difficult i think. I wrote an program which works fine excepet the usage of RAM. A little story:When i finished the code my program needed around 15MB RAM, after two days of running it was around 1,7GB. I looked up the Task-Manager -> Process -> Resource Monitors and tooko a look at AutoIt.exe. There i could find some columns like: Mirror, ProcessID, (in english the next column is called) Page Fault 8i think), and now its the important column i think (red) where i dont have an idea how its calles in english, maybe saved/vested/warranted ?Now i got the problem that this usage of RAM is rising up (slowly) and it shouldnt. There are two parts of my script where i could imagine the problem is there...AdlibRegister("_clear_memory", 5000) Func _clear_memory() _ReduceMemory(@AutoItPID) EndFunc Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then ;kernel32.dll - OpenProcess - Opens an existing local process object. Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) ;psapi.dll - EmptyWorkingSet - Removes as many pages as possible from the working set of the specified process. Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else ;s.o. Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] ;egal ob auskommentiert oder nicht, ändert nichts :/ EndFunc ;==>_ReduceMemorySo my question is: Is it possible, that the function AdlibRegister maybe uses this (red marked) memory for any reasons? I mean like we can see abouve, usually this function _ReduceMemory will not be the reason for a constant rising memory, or?The last alternativ i thought about was _SQLite_ ...ofc I'm using _SQLite_Open at the top of my script and close it on my last 2 lines of code. There the same question, Is it possible, that the function maybe uses this (red marked) memory for any reasons?All tests without success :/Hopeful someone of you guys can help me.Thanks and again I'd like to excuse for bad english.Regards.
BrewManNH Posted November 23, 2012 Posted November 23, 2012 ReduceMemory doesn't reduce the memory used, it just pages it to the hard drive, so it's an artificial reduction in memory. Calling it every 5 seconds is pointless, figure out where your memory leak is coming from before you start trying to find workarounds to bad code. It's like you're building a house on mud, every day it sinks a little bit more unless you jack it up, you're not fixing the problem you're just fixing the symptom, the house is still sinking only you don't see that it's happening anymore. Out of sight out of mind is not good coding practice. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Yaerox Posted November 23, 2012 Author Posted November 23, 2012 Ofc youre right ... well im a beginner in AutoIt, working with it for ~6/7 weeks now and ofc i'd like to find the memory leaks but this isnt as easy at it looks/sounds But why red the marked memory on the image is still rising up nothing else except this funktion is running :/ ?
BrewManNH Posted November 23, 2012 Posted November 23, 2012 It's not the Adlib function causing the issue, it's definitely something else. I don't know what that memory usage you're pointing to in the first post refers to in English, but I don't see any abnormal memory usage when running just the adlib function and the reducememory function together. It has to be something else in your code causing the memory leak. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
jchd Posted November 24, 2012 Posted November 24, 2012 Without having a chance to look at your code we can only guess. And there are peta-zillions of possibilities to leak memory or let it grow wildly by not correctly disposing of objects, growing array, creating new GUI elements instead of re-using previous ones, a.s.o. I don't see how SQLite could leak that much but it all depends of your usage of the library. Prune down your code by removing non-vital decorations until you can post a simple self-contained reproducer which we can look at. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Yaerox Posted November 26, 2012 Author Posted November 26, 2012 Thanks alot guys, then i'll read my code again and try to find the real issues ... if i cant find anything maybe id like to talk to you guys again and post my code... Regards
Yaerox Posted November 26, 2012 Author Posted November 26, 2012 (edited) @jchd: Dunno if i can do this because got actual around 2700 lines, and you would need a SQLite DB but i did it as .zip and if someone wanna try to help me ill ad this on the post.Maybe a little explaination: This should be a automatic sequence control. U can create 'work processing sheets' where u can add tasks. hw.bat should be a test-task-file.A part of my Script looks like: To try this Script u need to edit the config.ini ... on top you have to edit path=pathtothisdbablaufstrg.db and the second path need to be the folder where u saved the SQLite.exe. expandcollapse popup#Region #AutoIt3Wrapper_Add_Constants=n #EndRegion #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <SQLite.au3> #include <SQLite.dll.au3> #include <String.au3> #include <WindowsConstants.au3> Local $paracheck = $CmdLine[0] If $paracheck = 0 Then Global $usedb = IniRead("config.ini", "Datenbank", "pfad", "default") Global $path = IniRead("config.ini", "SQLite3.exe", "pfad", "default") Else Local $param = $CmdLine[1] Global $usedb = IniRead($param, "Datenbank", "pfad", "default") Global $path = IniRead($param, "SQLite3.exe", "pfad", "default") EndIf Global $Query, $Row, $Query2, $Row2 Global $ablaufstatus Global $abzusetzender_query _SQLite_Startup() Global $DB = _SQLite_Open($usedb) Global $aufgabenlistefenster = GUICreate("Aufgabenliste", 250, 390) Global $amenue_datei = GUICtrlCreateMenu("Datei") Global $amenue_datei_beenden = GUICtrlCreateMenuItem("Beenden", $amenue_datei) Global $amenue_fragezeichen = GUICtrlCreateMenu("?") Global $amenue_fragezeichen_hilfe = GUICtrlCreateMenuItem("Hilfe", $amenue_fragezeichen) Global $amenue_fragezeichen_info = GUICtrlCreateMenuItem("Info", $amenue_fragezeichen) Local $gfx = GUICtrlCreateGraphic(5, 10, 18, 18) GUICtrlSetBkColor($gfx, 0xFF0000) GUICtrlSetColor($gfx, 0) Global $aadmintool_button = GUICtrlCreateButton("AdminTool", 160, 5, 80, 30) Global $aladeaktiveap_button = GUICtrlCreateButton("Lade aktive AP", 140, 40, 100, 30) Global $astart_button = GUICtrlCreateButton("Start", 30, 5, 50, 30) Global $astop_button = GUICtrlCreateButton("Stop", 30, 40, 50, 30) Global $a_statustop_label = GUICtrlCreateLabel("Status:", 5, 72, 50, 20) Global $a_progressbar = GUICtrlCreateProgress(5, 86, 240, 17) Global $a_listview_top = GUICtrlCreateListView("Laufende Nr. |Arbeitspunkt ", 5, 105, 240, 120, $WS_BORDER, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($a_listview_top, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($a_listview_top, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetExtendedListViewStyle($a_listview_top, $LVS_EX_FULLROWSELECT) Global $a_statusbot_label = GUICtrlCreateLabel("Warteschlange:", 5, 230, 200, 20) Global $a_listview_bot = GUICtrlCreateListView("ID |Geplante Startzeit |Arbeitsplan ", 5, 245, 240, 120, $WS_BORDER, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($a_listview_bot, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_HideColumn($a_listview_bot, 0) _GUICtrlListView_SetColumnWidth($a_listview_bot, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($a_listview_bot, 2, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetExtendedListViewStyle($a_listview_bot, $LVS_EX_FULLROWSELECT) Global $admintoolfenster = GUICreate("Admin Tool", 1000, 700) Global $atmenue_datei = GUICtrlCreateMenu("Datei") Global $atmenue_datei_beenden = GUICtrlCreateMenuItem("Beenden", $atmenue_datei) Global $atmenue_fragezeichen = GUICtrlCreateMenu("?") Global $atmenue_fragezeichen_hilfe = GUICtrlCreateMenuItem("Hilfe", $atmenue_fragezeichen) Global $atmenue_fragezeichen_info = GUICtrlCreateMenuItem("Info", $atmenue_fragezeichen) Global $at_tab = GUICtrlCreateTab(10, 10, 980, 660) Global $at_tab_ap = GUICtrlCreateTabItem("Arbeitspläne verwalten") Global $atap_listview = GUICtrlCreateListView("ID|Arbeitsplan Name|Geplante Startzeit|Status", 20, 70, 480, 590, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $WS_BORDER), $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($atap_listview, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atap_listview, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atap_listview, 2, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atap_listview, 3, $LVSCW_AUTOSIZE_USEHEADER) GUISetFont(12) Global $atap_arbeitsplanid_label = GUICtrlCreateLabel("Arbeitsplan ID:", 520, 73, 105, 20) Global $atap_arbeitsplanid_input = GUICtrlCreateInput("", 670, 70, 260, 25, $ES_READONLY) Global $atap_arbeitsplanname_label = GUICtrlCreateLabel("Arbeitsplan Name:*", 520, 113, 135, 20) Global $atap_arbeitsplanname_input = GUICtrlCreateInput("", 670, 110, 260, 25) Global $atap_geplantestartzeit_label = GUICtrlCreateLabel("Geplante Startzeit:", 520, 153, 130, 20) Global $atap_geplantestartzeit_setzen_button = GUICtrlCreateButton("setzen", 670, 150, 60, 25) Global $atap_geplantestartzeit_input = GUICtrlCreateInput("", 740, 150, 190, 25, $ES_READONLY) Global $atap_geplantestartzeitinfo_label = GUICtrlCreateLabel("Info:" & @TAB & "Die 'Geplante Startzeit' muss im Format HH:MM mit : als" & @CR & @TAB & "Trennzeichen eingegeben werden! (Beispiel: 13:55)", 520, 233, 450, 60) Global $atap_status_label = GUICtrlCreateLabel("Status:", 520, 193, 50, 20) Global $atap_status_checkbox = GUICtrlCreateCheckbox("", 670, 193, 17, 17) Global $atap_sofortstarten_button = GUICtrlCreateButton("Sofort starten", 813, 515, 150, 30) Global $atap_spontaneinplanen_button = GUICtrlCreateButton("Spontan Einplanen", 813, 555, 150, 30) Global $atap_group = GUICtrlCreateGroup("", 513, 587, 460, 73) Global $atap_dublizieren_button = GUICtrlCreateButton("Dublizieren", 523, 613, 110, 30) Global $atap_aendern_button = GUICtrlCreateButton("Ändern", 653, 613, 80, 30) Global $atap_hinzufuegen_button = GUICtrlCreateButton("Hinzufügen", 753, 613, 110, 30) Global $atap_loeschen_button = GUICtrlCreateButton("Löschen", 883, 613, 80, 30) GUISetFont(8.5) Global $at_tab_app = GUICtrlCreateTabItem("Arbeitspunkte verwalten") Global $atapp_combo = GUICtrlCreateCombo("", 20, 40, 235, 20) Global $atapp_listview = GUICtrlCreateListView("ID |Laufende Nr.|Arbeitspunkt Name|Pfad|Datei|Parameter|Status", 20, 70, 480, 590) _GUICtrlListView_SetColumnWidth($atapp_listview, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_HideColumn($atapp_listview, 0) _GUICtrlListView_SetColumnWidth($atapp_listview, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atapp_listview, 2, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atapp_listview, 3, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atapp_listview, 4, $LVSCW_AUTOSIZE_USEHEADER) GUISetFont(12) Global $atapp_funktionstyp_label = GUICtrlCreateLabel("Funktionstyp:", 520, 73, 100, 20) Global $atapp_funktionstyp_combo = GUICtrlCreateCombo("", 670, 70, 260, 25) _GUICtrlComboBox_AddString($atapp_funktionstyp_combo, "Interne Funktionen") _GUICtrlComboBox_AddString($atapp_funktionstyp_combo, "Externe Funktionen") Global $atapp_laufendenr_label = GUICtrlCreateLabel("Laufende Nr.:*", 520, 113, 100, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_laufendenr_input = GUICtrlCreateInput("", 670, 110, 260, 25, $ES_NUMBER) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_arbeitspunktname_label = GUICtrlCreateLabel("Arbeitspunkt Name:*", 520, 153, 145, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_arbeitspunktname_input = GUICtrlCreateInput("", 670, 150, 260, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_listview_intern = GUICtrlCreateListView("Name", 713, 250, 250, 250) GUICtrlSetState(-1, $GUI_HIDE) _GUICtrlListView_SetColumnWidth($atapp_listview_intern, 0, $LVSCW_AUTOSIZE_USEHEADER) GUICtrlCreateListViewItem("_neu_einplanen", $atapp_listview_intern) GUICtrlCreateListViewItem("_test", $atapp_listview_intern) Global $atapp_pfad_label = GUICtrlCreateLabel("Pfad:*", 520, 233, 50, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_pfad_input = GUICtrlCreateInput("", 670, 230, 260, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_pfad_button = GUICtrlCreateButton("...", 940, 230, 40, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_datei_label = GUICtrlCreateLabel("Datei:", 520, 273, 50, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_datei_input = GUICtrlCreateInput("", 670, 270, 260, 25, $ES_READONLY) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_parameter_label = GUICtrlCreateLabel("Parameter:", 520, 313, 95, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_parameter_input = GUICtrlCreateInput("", 670, 313, 260, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_status_label = GUICtrlCreateLabel("Status:", 520, 193, 45, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_status_checkbox = GUICtrlCreateCheckbox("", 670, 190, 17, 17) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_neunummerieren_button = GUICtrlCreateButton("Neu nummerieren", 813, 515, 150, 30) Global $atapp_inanderenarbeitsplankopieren_button = GUICtrlCreateButton("In anderen Arbeitsplan kopieren", 713, 555, 250, 30) Global $atapp_group = GUICtrlCreateGroup("", 643, 587, 330, 73) Global $atapp_aendern_button = GUICtrlCreateButton("Ändern", 653, 613, 80, 30) Global $atapp_hinzufuegen_button = GUICtrlCreateButton("Hinzufügen", 753, 613, 110, 30) Global $atapp_loeschen_button = GUICtrlCreateButton("Löschen", 883, 613, 80, 30) Global $at_tab_db = GUICtrlCreateTabItem("DB erzeugen") Global $atdb_name_label = GUICtrlCreateLabel("Datenbank-Name:", 30, 50, 130, 25) Global $atdb_name_input = GUICtrlCreateInput("", 170, 47, 260, 25) Global $atdb_ok_button = GUICtrlCreateButton("OK", 445, 46, 40, 25) Global $atdb_pfad_label = GUICtrlCreateLabel("Ziel-Pfad:", 30, 90, 75, 25) GUICtrlSetState($atdb_pfad_label, $GUI_HIDE) Global $atdb_pfad_input = GUICtrlCreateInput("", 170, 87, 260, 25, $ES_READONLY) GUICtrlSetState($atdb_pfad_input, $GUI_HIDE) Global $atdb_pfad_button = GUICtrlCreateButton("Pfad auswählen", 445, 87, 130, 25) GUICtrlSetState($atdb_pfad_button, $GUI_HIDE) Global $atdb_dberstellen_button = GUICtrlCreateButton("DB erstellen", 170, 127, 100, 40) GUICtrlSetState($atdb_dberstellen_button, $GUI_HIDE) Global $atdb_hinweis_label = GUICtrlCreateLabel("Um diese Funktion nutzen zu können muss in der angegebenen config.ini ein Pfad zu einer SQLite3.exe angegeben sein! Für genauere Informationen schauen Sie unter dem Menüpunkt '? >> Hilfe'", 30, 620, 840, 40) GUICtrlCreateTabItem("") Global $startzeitfenster = GUICreate("Startzeit festlegen", 650, 300) GUISetFont(12) Global $sserienmuster_label = GUICtrlCreateLabel("Serienmuster:" & @TAB & @TAB & "Wochentag:", 20, 10, 260, 25) Global $s1 = GUICtrlCreateRadio("Feste Uhrzeit", 10, 35, 120, 25) Global $s2 = GUICtrlCreateRadio("Alle X Min", 10, 60, 120, 25) Local $sstrich = GUICtrlCreateGraphic(150, 10, 5, 240) GUICtrlSetGraphic($sstrich, $GUI_GR_PENSIZE, 10) GUICtrlSetGraphic($sstrich, $GUI_GR_LINE, 0, 240) Global $s_montag_checkbox = GUICtrlCreateCheckbox("Montag", 190, 35) Global $s_dienstag_checkbox = GUICtrlCreateCheckbox("Dienstag", 190, 65) Global $s_mittwoch_checkbox = GUICtrlCreateCheckbox("Mittwoch", 190, 95) Global $s_donnerstag_checkbox = GUICtrlCreateCheckbox("Donnerstag", 190, 125) Global $s_freitag_checkbox = GUICtrlCreateCheckbox("Freitag", 190, 155) Global $s_samstag_checkbox = GUICtrlCreateCheckbox("Samstag", 190, 185) Global $s_sonntag_checkbox = GUICtrlCreateCheckbox("Sonntag", 190, 215) Global $s1_startzeit_label = GUICtrlCreateLabel("Startzeit:", 360, 10, 100, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s1_date = GUICtrlCreateDate("", 360, 35, 130, 25, $DTS_TIMEFORMAT) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_von_label = GUICtrlCreateLabel("Von:", 360, 10, 50, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_von_date = GUICtrlCreateDate("", 360, 35, 130, 25, $DTS_TIMEFORMAT) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_bis_label = GUICtrlCreateLabel("Bis:", 360, 70, 50, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_bis_date = GUICtrlCreateDate("", 360, 95, 130, 25, $DTS_TIMEFORMAT) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_alle_label = GUICtrlCreateLabel("alle", 360, 135, 50, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_combo = GUICtrlCreateCombo("", 395, 130, 130, 25) GUICtrlSetState(-1, $GUI_HIDE) _GUICtrlComboBox_AddString($s2_combo, "5") _GUICtrlComboBox_AddString($s2_combo, "10") _GUICtrlComboBox_AddString($s2_combo, "15") _GUICtrlComboBox_AddString($s2_combo, "20") _GUICtrlComboBox_AddString($s2_combo, "25") _GUICtrlComboBox_AddString($s2_combo, "30") _GUICtrlComboBox_AddString($s2_combo, "35") _GUICtrlComboBox_AddString($s2_combo, "40") _GUICtrlComboBox_AddString($s2_combo, "45") _GUICtrlComboBox_AddString($s2_combo, "50") _GUICtrlComboBox_AddString($s2_combo, "55") _GUICtrlComboBox_AddString($s2_combo, "60") Global $s2_minuten_label = GUICtrlCreateLabel("Minuten.", 535, 135, 60, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $sallemarkieren_button = GUICtrlCreateButton("Alle markieren", 105, 260, 120, 25) Global $salleabwaehlen_button = GUICtrlCreateButton("Alle abwählen", 235, 260, 120, 25) Global $sfertig_button = GUICtrlCreateButton("Fertig", 490, 260, 60, 30) Global $sbeenden_button = GUICtrlCreateButton("Beenden", 560, 260, 80, 30) GUISetState(@SW_SHOW, $aufgabenlistefenster) GUICtrlSetState($at_tab_ap, $GUI_SHOW) GUICtrlSetOnEvent($amenue_datei_beenden, "_exit") GUICtrlSetOnEvent($amenue_fragezeichen_hilfe, "hilfe") GUICtrlSetOnEvent($amenue_fragezeichen_info, "info") GUICtrlSetOnEvent($aadmintool_button, "open_admintool") GUICtrlSetOnEvent($aladeaktiveap_button, "lade_aktive_aps") GUICtrlSetOnEvent($astart_button, "pruefe_ablauf") GUICtrlSetOnEvent($astop_button, "beende_ablauf") GUISetOnEvent($GUI_EVENT_CLOSE, "_exit", $aufgabenlistefenster) GUICtrlSetOnEvent($atmenue_datei_beenden, "close_admintool") GUICtrlSetOnEvent($atmenue_fragezeichen_hilfe, "hilfe") GUICtrlSetOnEvent($atmenue_fragezeichen_info, "info") GUICtrlSetOnEvent($atap_geplantestartzeit_setzen_button, "open_startzeit") GUICtrlSetOnEvent($atap_dublizieren_button, "ap_dublizieren") GUICtrlSetOnEvent($atap_aendern_button, "ap_aendern") GUICtrlSetOnEvent($atap_hinzufuegen_button, "ap_hinzufuegen") GUICtrlSetOnEvent($atap_loeschen_button, "ap_loeschen") GUICtrlSetOnEvent($atap_sofortstarten_button, "ap_sofortstarten") GUICtrlSetOnEvent($atap_spontaneinplanen_button, "ap_spontaneinplanen") GUICtrlSetOnEvent($atapp_combo, "atapp_combo") GUICtrlSetOnEvent($atapp_funktionstyp_combo, "atapp_funktionstyp_combo") GUICtrlSetOnEvent($atapp_pfad_button, "app_pfad_auswaehlen") GUICtrlSetOnEvent($atapp_aendern_button, "app_aendern") GUICtrlSetOnEvent($atapp_hinzufuegen_button, "app_hinzufuegen") GUICtrlSetOnEvent($atapp_loeschen_button, "app_loeschen") GUICtrlSetOnEvent($atapp_neunummerieren_button, "app_laufendenr_neu_nummerieren") GUICtrlSetOnEvent($atapp_inanderenarbeitsplankopieren_button, "app_in_anderen_ap_kopieren") GUICtrlSetOnEvent($atdb_ok_button, "schritt1_lese_datenbankname_aus_inputbox_und_blende_schritt2_ein") GUICtrlSetOnEvent($atdb_pfad_button, "schritt2_lese_pfad_ein_und_blende_schritt3_ein") GUICtrlSetOnEvent($atdb_dberstellen_button, "dberzeugen") GUICtrlSetOnEvent($s1, "_s1_ausklappen") GUICtrlSetOnEvent($s2, "_s2_ausklappen") GUICtrlSetOnEvent($sallemarkieren_button, "_s_alle_markieren") GUICtrlSetOnEvent($salleabwaehlen_button, "_s_alle_abwaehlen") GUICtrlSetOnEvent($sfertig_button, "zeitplan_eintragen") GUICtrlSetOnEvent($sbeenden_button, "close_startzeit") GUISetOnEvent($GUI_EVENT_CLOSE, "close_admintool", $admintoolfenster) GUISetOnEvent($GUI_EVENT_CLOSE, "close_startzeit", $startzeitfenster) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Opt("GUIOnEventMode", 1) AdlibRegister("_clear_memory", 5000) While 1 Sleep(100) WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $idFrom, $iCode, $tNMHDR, $selected $tNMHDR = DllStructCreate("int;int;int", $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, 1)) $idFrom = DllStructGetData($tNMHDR, 2) $iCode = DllStructGetData($tNMHDR, 3) Switch $hWndFrom Case GUICtrlGetHandle($atap_listview) Switch $iCode Case $NM_CLICK $selected = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected = 1 Then ap_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Else ap_clear_inputs() EndIf EndSwitch Case GUICtrlGetHandle($atapp_listview) Switch $iCode Case $NM_CLICK $selected = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected = 1 Then app_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Else app_clear_inputs() _interne_inputs_zuklappen() _externe_inputs_zuklappen() EndIf EndSwitch Case GUICtrlGetHandle($atapp_listview_intern) Switch $iCode Case $NM_CLICK $selected = _GUICtrlListView_GetSelectedCount($atapp_listview_intern) If $selected = 1 Then app_stelle_listviewinternauswahl_in_inputs_dar() EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func open_admintool() If $ablaufstatus = True Then _tooltip() Else GUISetState(@SW_HIDE, $aufgabenlistefenster) GUISetState(@SW_SHOW, $admintoolfenster) GUISwitch($admintoolfenster) ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() app_lese_arbeitsplaene_aus_db_und_schreibe_in_combobox() EndIf EndFunc Func _tooltip() Global $Form1 = GUICreate("INFO", 221, 119, 465, 342) GUISetFont(10) $Label1 = GUICtrlCreateLabel("Solange die Ablaufsteuerung aktiv am arbeiten ist kann das AdminTool nicht aufgerufen werden.", 10, 10, 201, 65) $Button1 = GUICtrlCreateButton("OK", 131, 80, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) GUICtrlSetOnEvent($Button1, "_closeinfobox") GUISetOnEvent($GUI_EVENT_CLOSE, "_closeinfobox") Opt("GUIOnEventMode", 1) EndFunc Func _closeinfobox() GUIDelete($Form1) EndFunc Func close_admintool() GUISetState(@SW_HIDE, $admintoolfenster) GUISetState(@SW_SHOW, $aufgabenlistefenster) GUISwitch($aufgabenlistefenster) $ablaufstatus = False If _GUICtrlListView_GetItemCount($a_listview_bot) > 0 Then lade_aktive_aps() EndIf EndFunc Func lade_aktive_aps() _GUICtrlListView_BeginUpdate($a_listview_bot) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($a_listview_bot)) If _SQLite_Query($DB, "SELECT id, geplante_startzeit, arbeitsplan_id FROM aufgabenliste ORDER BY geplante_startzeit ASC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $Row2, $Query2 While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If _SQLite_Query($DB, "SELECT arbeitsplan_name FROM arbeitsplaene WHERE arbeitsplan_id=" & $Row[2], $Query2) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query2, $Row2) = $SQLITE_OK GUICtrlCreateListViewItem($Row[0] & "|" & $Row[1] & "|" & $Row2[0], $a_listview_bot) WEnd WEnd _GUICtrlListView_EndUpdate($a_listview_bot) EndFunc Func pruefe_ablauf() GUICtrlSetBkColor($gfx, 0x32CD32) $ablaufstatus = True AdlibRegister("vergleiche_zeitstempel", 1000) EndFunc Func _clear_memory() _ReduceMemory(@AutoItPID) EndFunc Func vergleiche_zeitstempel() If _SQLite_Query($DB, "SELECT geplante_startzeit FROM aufgabenliste ORDER BY geplante_startzeit ASC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_FetchData($Query, $Row) <> $SQLITE_OK Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $a_row0 = StringSplit($Row[0], " ") Local $naechste_geplante_startdatum = $a_row0[1] $a_row0 = StringSplit($a_row0[2], ":") Local $sekunden_naechste_startzeit = $a_row0[1] * 3600 + $a_row0[2] * 60 Local $sekunden_systime = @HOUR * 3600 + @MIN * 60 + @SEC Local $aDatumForm = StringSplit($naechste_geplante_startdatum, "/") Local $sTage = ($aDatumForm[3]-1) * 365 + ($aDatumForm[2]-1) * 30 + $aDatumForm[1] Local $sTage_systime = (@Year-1) * 365 + (@MON-1)*30 + @MDAY If $sTage = $sTage_systime Then If $sekunden_naechste_startzeit = $sekunden_systime Or $sekunden_naechste_startzeit < $sekunden_systime Then starte_ablauf() EndIf ElseIf $sTage < $sTage_systime Then starte_ablauf() EndIf EndFunc So if I start the script, i would just press "Lade aktive AP's" which I'd translate to something like 'load aktive work processing sheets' and then id press the 'Start' (GO) button and now the only Func who will run is: vergleiche_zeitstempel.If I change the func vergleiche_zeitstempel to the nonsense: Func vergleiche_zeitstempel() Local $Row, $Query _SQLite_Query($DB, "SELECT geplante_startzeit FROM aufgabenliste ORDER BY geplante_startzeit ASC", $Query) _SQLite_FetchData($Query, $Row) EndFunc this virtual memory is still rising up. In my opinion nothing else is running which means SQL is the reason for my prob ? o.O I cant imagine this :/ Again, thanks alot, even if you just read it once, i know, my english isnt very well but like I said, this is something like my last hope of getting the prolem fixed :/ YaeroxXO.rar Edited November 26, 2012 by MikeWenzel
dany Posted November 26, 2012 Posted November 26, 2012 Don't start or load SQLite and let vergleiche_zeitstempel() simply return 1 without running a query. Then we'll see if SQLite is really the problem or if it's something else. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF
Yaerox Posted November 26, 2012 Author Posted November 26, 2012 if i change the Func to: Func vergleiche_zeitstempel() Return 1 EndFunc the memory isnt moving ... maybe could someone give me a tip where i now should start to look for the reason :/ Thanks alot.
KaFu Posted November 26, 2012 Posted November 26, 2012 Always use _SQLite_QueryFinalize() to close queries before you return. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Yaerox Posted November 26, 2012 Author Posted November 26, 2012 Okay, ill try it ... give me some minutes because there are a lot of Querys ^^
dany Posted November 26, 2012 Posted November 26, 2012 Always use _SQLite_QueryFinalize() to close queries before you return.Yea, in b4 that solved it. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF
jchd Posted November 26, 2012 Posted November 26, 2012 Instead of the sequence { _SQLite_Query, looping *_FetchData and *_Finalize }, you should always prefer _SQLite_GetTable2d, *_GetTable or *_QuerySingleRow depending on the number of rows expected. Not only that simplifies the code a great lot, but these calls handle errors or retries much easier. I confirm that not invoking *_Finalize is where you leak memory, look no further. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Yaerox Posted November 28, 2012 Author Posted November 28, 2012 Well, i edited a part of my code which is actual running, and I start around 15.8MB memory usage and before i edited i was around 2GB after 2 days. Now im around 18MB and ill now edit the last part and change some _SQLite_Statements like jchd said. Ill post a feedback as fast as i get new results. Thanks
jchd Posted November 28, 2012 Posted November 28, 2012 Of course I can't vouch that it's the only way your code could be bleeding but at least fixing this will bleed less! Keep us informed. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Yaerox Posted November 29, 2012 Author Posted November 29, 2012 (edited) I edited my code and added _SQLite_Finalize ... now it isnt rising up that fast as before but it looks like i got still a/some little leaks...ill add my actual script for ppl who would take a look again (: Actual have to edit the query for getting the next working process to run because did some mistakes there. When finished ill go on to find my leaks. Regards expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include #include #include #include #include #include #include #include ;~ #include "RestrictControlRegExp.au3" Local $paracheck = $CmdLine[0] If $paracheck = 0 Then Global $usedb = IniRead("config.ini", "Datenbank", "pfad", "default") Global $path = IniRead("config.ini", "SQLite3.exe", "pfad", "default") Else Local $param = $CmdLine[1] Global $usedb = IniRead($param, "Datenbank", "pfad", "default") Global $path = IniRead($param, "SQLite3.exe", "pfad", "default") EndIf Global $ablaufstatus Global $abzusetzender_query _SQLite_Startup() Global $DB = _SQLite_Open($usedb) ;#GUI 1 Global $aufgabenlistefenster = GUICreate("Aufgabenliste", 250, 390) Global $amenue_datei = GUICtrlCreateMenu("Datei") Global $amenue_datei_beenden = GUICtrlCreateMenuItem("Beenden", $amenue_datei) Global $amenue_fragezeichen = GUICtrlCreateMenu("?") Global $amenue_fragezeichen_hilfe = GUICtrlCreateMenuItem("Hilfe", $amenue_fragezeichen) Global $amenue_fragezeichen_info = GUICtrlCreateMenuItem("Info", $amenue_fragezeichen) Local $gfx = GUICtrlCreateGraphic(5, 10, 18, 18) GUICtrlSetBkColor($gfx, 0xFF0000) GUICtrlSetColor($gfx, 0) Global $aadmintool_button = GUICtrlCreateButton("AdminTool", 160, 5, 80, 30) Global $aladeaktiveap_button = GUICtrlCreateButton("Lade aktive AP", 140, 40, 100, 30) Global $astart_button = GUICtrlCreateButton("Start", 30, 5, 50, 30) Global $astop_button = GUICtrlCreateButton("Stop", 30, 40, 50, 30) Global $a_statustop_label = GUICtrlCreateLabel("Status:", 5, 72, 50, 20) Global $a_progressbar = GUICtrlCreateProgress(5, 86, 240, 17) Global $a_listview_top = GUICtrlCreateListView("Laufende Nr. |Arbeitspunkt ", 5, 105, 240, 120, $WS_BORDER, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($a_listview_top, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($a_listview_top, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetExtendedListViewStyle($a_listview_top, $LVS_EX_FULLROWSELECT) Global $a_statusbot_label = GUICtrlCreateLabel("Warteschlange:", 5, 230, 200, 20) Global $a_listview_bot = GUICtrlCreateListView("ID |Geplante Startzeit |Arbeitsplan ", 5, 245, 240, 120, $WS_BORDER, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($a_listview_bot, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_HideColumn($a_listview_bot, 0) _GUICtrlListView_SetColumnWidth($a_listview_bot, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($a_listview_bot, 2, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetExtendedListViewStyle($a_listview_bot, $LVS_EX_FULLROWSELECT) ;#GUI 2 Global $admintoolfenster = GUICreate("Admin Tool", 1000, 700) Global $atmenue_datei = GUICtrlCreateMenu("Datei") Global $atmenue_datei_beenden = GUICtrlCreateMenuItem("Beenden", $atmenue_datei) Global $atmenue_fragezeichen = GUICtrlCreateMenu("?") Global $atmenue_fragezeichen_hilfe = GUICtrlCreateMenuItem("Hilfe", $atmenue_fragezeichen) Global $atmenue_fragezeichen_info = GUICtrlCreateMenuItem("Info", $atmenue_fragezeichen) Global $at_tab = GUICtrlCreateTab(10, 10, 980, 660) Global $at_tab_ap = GUICtrlCreateTabItem("Arbeitspläne verwalten") Global $atap_listview = GUICtrlCreateListView("ID|Arbeitsplan Name|Geplante Startzeit|Status", 20, 70, 480, 590, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $WS_BORDER), $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($atap_listview, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atap_listview, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atap_listview, 2, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atap_listview, 3, $LVSCW_AUTOSIZE_USEHEADER) GUISetFont(12) Global $atap_arbeitsplanid_label = GUICtrlCreateLabel("Arbeitsplan ID:", 520, 73, 105, 20) Global $atap_arbeitsplanid_input = GUICtrlCreateInput("", 670, 70, 260, 25, $ES_READONLY) Global $atap_arbeitsplanname_label = GUICtrlCreateLabel("Arbeitsplan Name:*", 520, 113, 135, 20) Global $atap_arbeitsplanname_input = GUICtrlCreateInput("", 670, 110, 260, 25) Global $atap_geplantestartzeit_label = GUICtrlCreateLabel("Geplante Startzeit:", 520, 153, 130, 20) Global $atap_geplantestartzeit_setzen_button = GUICtrlCreateButton("setzen", 670, 150, 60, 25) Global $atap_geplantestartzeit_input = GUICtrlCreateInput("", 740, 150, 190, 25, $ES_READONLY) ;~ _RegEx_RestrictControl_add($atap_geplantestartzeit_input, "^[012]{1}[0-9]{1}\:[0-6]{1}[0-9]{1}$", "13:37") Global $atap_geplantestartzeitinfo_label = GUICtrlCreateLabel("Info:" & @TAB & "Die 'Geplante Startzeit' muss im Format HH:MM mit : als" & @CR & @TAB & "Trennzeichen eingegeben werden! (Beispiel: 13:55)", 520, 233, 450, 60) Global $atap_status_label = GUICtrlCreateLabel("Status:", 520, 193, 50, 20) Global $atap_status_checkbox = GUICtrlCreateCheckbox("", 670, 193, 17, 17) Global $atap_sofortstarten_button = GUICtrlCreateButton("Sofort starten", 813, 515, 150, 30) Global $atap_spontaneinplanen_button = GUICtrlCreateButton("Spontan Einplanen", 813, 555, 150, 30) Global $atap_group = GUICtrlCreateGroup("", 513, 587, 460, 73) Global $atap_dublizieren_button = GUICtrlCreateButton("Dublizieren", 523, 613, 110, 30) Global $atap_aendern_button = GUICtrlCreateButton("Ändern", 653, 613, 80, 30) Global $atap_hinzufuegen_button = GUICtrlCreateButton("Hinzufügen", 753, 613, 110, 30) Global $atap_loeschen_button = GUICtrlCreateButton("Löschen", 883, 613, 80, 30) GUISetFont(8.5) Global $at_tab_app = GUICtrlCreateTabItem("Arbeitspunkte verwalten") Global $atapp_combo = GUICtrlCreateCombo("", 20, 40, 235, 20) Global $atapp_listview = GUICtrlCreateListView("ID |Laufende Nr.|Arbeitspunkt Name|Pfad|Datei|Parameter|Status", 20, 70, 480, 590) _GUICtrlListView_SetColumnWidth($atapp_listview, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_HideColumn($atapp_listview, 0) _GUICtrlListView_SetColumnWidth($atapp_listview, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atapp_listview, 2, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atapp_listview, 3, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($atapp_listview, 4, $LVSCW_AUTOSIZE_USEHEADER) GUISetFont(12) Global $atapp_funktionstyp_label = GUICtrlCreateLabel("Funktionstyp:", 520, 73, 100, 20) Global $atapp_funktionstyp_combo = GUICtrlCreateCombo("", 670, 70, 260, 25) _GUICtrlComboBox_AddString($atapp_funktionstyp_combo, "Interne Funktionen") _GUICtrlComboBox_AddString($atapp_funktionstyp_combo, "Externe Funktionen") Global $atapp_laufendenr_label = GUICtrlCreateLabel("Laufende Nr.:*", 520, 113, 100, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_laufendenr_input = GUICtrlCreateInput("", 670, 110, 260, 25, $ES_NUMBER) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_arbeitspunktname_label = GUICtrlCreateLabel("Arbeitspunkt Name:*", 520, 153, 145, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_arbeitspunktname_input = GUICtrlCreateInput("", 670, 150, 260, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_listview_intern = GUICtrlCreateListView("Name", 713, 250, 250, 250) GUICtrlSetState(-1, $GUI_HIDE) _GUICtrlListView_SetColumnWidth($atapp_listview_intern, 0, $LVSCW_AUTOSIZE_USEHEADER) GUICtrlCreateListViewItem("_neu_einplanen", $atapp_listview_intern) GUICtrlCreateListViewItem("_test", $atapp_listview_intern) Global $atapp_pfad_label = GUICtrlCreateLabel("Pfad:*", 520, 233, 50, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_pfad_input = GUICtrlCreateInput("", 670, 230, 260, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_pfad_button = GUICtrlCreateButton("...", 940, 230, 40, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_datei_label = GUICtrlCreateLabel("Datei:", 520, 273, 50, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_datei_input = GUICtrlCreateInput("", 670, 270, 260, 25, $ES_READONLY) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_parameter_label = GUICtrlCreateLabel("Parameter:", 520, 313, 95, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_parameter_input = GUICtrlCreateInput("", 670, 313, 260, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_status_label = GUICtrlCreateLabel("Status:", 520, 193, 45, 20) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_status_checkbox = GUICtrlCreateCheckbox("", 670, 190, 17, 17) GUICtrlSetState(-1, $GUI_HIDE) Global $atapp_neunummerieren_button = GUICtrlCreateButton("Neu nummerieren", 813, 515, 150, 30) Global $atapp_inanderenarbeitsplankopieren_button = GUICtrlCreateButton("In anderen Arbeitsplan kopieren", 713, 555, 250, 30) Global $atapp_group = GUICtrlCreateGroup("", 643, 587, 330, 73) Global $atapp_aendern_button = GUICtrlCreateButton("Ändern", 653, 613, 80, 30) Global $atapp_hinzufuegen_button = GUICtrlCreateButton("Hinzufügen", 753, 613, 110, 30) Global $atapp_loeschen_button = GUICtrlCreateButton("Löschen", 883, 613, 80, 30) Global $at_tab_db = GUICtrlCreateTabItem("DB erzeugen") Global $atdb_name_label = GUICtrlCreateLabel("Datenbank-Name:", 30, 50, 130, 25) Global $atdb_name_input = GUICtrlCreateInput("", 170, 47, 260, 25) Global $atdb_ok_button = GUICtrlCreateButton("OK", 445, 46, 40, 25) Global $atdb_pfad_label = GUICtrlCreateLabel("Ziel-Pfad:", 30, 90, 75, 25) GUICtrlSetState($atdb_pfad_label, $GUI_HIDE) Global $atdb_pfad_input = GUICtrlCreateInput("", 170, 87, 260, 25, $ES_READONLY) GUICtrlSetState($atdb_pfad_input, $GUI_HIDE) Global $atdb_pfad_button = GUICtrlCreateButton("Pfad auswählen", 445, 87, 130, 25) GUICtrlSetState($atdb_pfad_button, $GUI_HIDE) Global $atdb_dberstellen_button = GUICtrlCreateButton("DB erstellen", 170, 127, 100, 40) GUICtrlSetState($atdb_dberstellen_button, $GUI_HIDE) Global $atdb_hinweis_label = GUICtrlCreateLabel("Um diese Funktion nutzen zu können muss in der angegebenen config.ini ein Pfad zu einer SQLite3.exe angegeben sein! Für genauere Informationen schauen Sie unter dem Menüpunkt '? >> Hilfe'", 30, 620, 840, 40) GUICtrlCreateTabItem("") ;#GUI 3 Global $startzeitfenster = GUICreate("Startzeit festlegen", 650, 300) GUISetFont(12) Global $sserienmuster_label = GUICtrlCreateLabel("Serienmuster:" & @TAB & @TAB & "Wochentag:", 20, 10, 260, 25) Global $s1 = GUICtrlCreateRadio("Feste Uhrzeit", 10, 35, 120, 25) Global $s2 = GUICtrlCreateRadio("Alle X Min", 10, 60, 120, 25) Local $sstrich = GUICtrlCreateGraphic(150, 10, 5, 240) GUICtrlSetGraphic($sstrich, $GUI_GR_PENSIZE, 10) GUICtrlSetGraphic($sstrich, $GUI_GR_LINE, 0, 240) Global $s_montag_checkbox = GUICtrlCreateCheckbox("Montag", 190, 35) Global $s_dienstag_checkbox = GUICtrlCreateCheckbox("Dienstag", 190, 65) Global $s_mittwoch_checkbox = GUICtrlCreateCheckbox("Mittwoch", 190, 95) Global $s_donnerstag_checkbox = GUICtrlCreateCheckbox("Donnerstag", 190, 125) Global $s_freitag_checkbox = GUICtrlCreateCheckbox("Freitag", 190, 155) Global $s_samstag_checkbox = GUICtrlCreateCheckbox("Samstag", 190, 185) Global $s_sonntag_checkbox = GUICtrlCreateCheckbox("Sonntag", 190, 215) Global $s1_startzeit_label = GUICtrlCreateLabel("Startzeit:", 360, 10, 100, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s1_date = GUICtrlCreateDate("", 360, 35, 130, 25, $DTS_TIMEFORMAT) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_von_label = GUICtrlCreateLabel("Von:", 360, 10, 50, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_von_date = GUICtrlCreateDate("", 360, 35, 130, 25, $DTS_TIMEFORMAT) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_bis_label = GUICtrlCreateLabel("Bis:", 360, 70, 50, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_bis_date = GUICtrlCreateDate("", 360, 95, 130, 25, $DTS_TIMEFORMAT) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_alle_label = GUICtrlCreateLabel("alle", 360, 135, 50, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $s2_combo = GUICtrlCreateCombo("", 395, 130, 130, 25) GUICtrlSetState(-1, $GUI_HIDE) _GUICtrlComboBox_AddString($s2_combo, "5") _GUICtrlComboBox_AddString($s2_combo, "10") _GUICtrlComboBox_AddString($s2_combo, "15") _GUICtrlComboBox_AddString($s2_combo, "20") _GUICtrlComboBox_AddString($s2_combo, "25") _GUICtrlComboBox_AddString($s2_combo, "30") _GUICtrlComboBox_AddString($s2_combo, "35") _GUICtrlComboBox_AddString($s2_combo, "40") _GUICtrlComboBox_AddString($s2_combo, "45") _GUICtrlComboBox_AddString($s2_combo, "50") _GUICtrlComboBox_AddString($s2_combo, "55") _GUICtrlComboBox_AddString($s2_combo, "60") Global $s2_minuten_label = GUICtrlCreateLabel("Minuten.", 535, 135, 60, 25) GUICtrlSetState(-1, $GUI_HIDE) Global $sallemarkieren_button = GUICtrlCreateButton("Alle markieren", 105, 260, 120, 25) Global $salleabwaehlen_button = GUICtrlCreateButton("Alle abwählen", 235, 260, 120, 25) Global $sfertig_button = GUICtrlCreateButton("Fertig", 490, 260, 60, 30) Global $sbeenden_button = GUICtrlCreateButton("Beenden", 560, 260, 80, 30) GUISetState(@SW_SHOW, $aufgabenlistefenster) GUICtrlSetState($at_tab_ap, $GUI_SHOW) ;Aufgabenliste GUICtrlSetOnEvent($amenue_datei_beenden, "_exit") GUICtrlSetOnEvent($amenue_fragezeichen_hilfe, "hilfe") GUICtrlSetOnEvent($amenue_fragezeichen_info, "info") GUICtrlSetOnEvent($aadmintool_button, "open_admintool") GUICtrlSetOnEvent($aladeaktiveap_button, "lade_aktive_aps") GUICtrlSetOnEvent($astart_button, "pruefe_ablauf") GUICtrlSetOnEvent($astop_button, "beende_ablauf") GUISetOnEvent($GUI_EVENT_CLOSE, "_exit", $aufgabenlistefenster) ; Admin-Tool GUICtrlSetOnEvent($atmenue_datei_beenden, "close_admintool") GUICtrlSetOnEvent($atmenue_fragezeichen_hilfe, "hilfe") GUICtrlSetOnEvent($atmenue_fragezeichen_info, "info") GUICtrlSetOnEvent($atap_geplantestartzeit_setzen_button, "open_startzeit") GUICtrlSetOnEvent($atap_dublizieren_button, "ap_dublizieren") GUICtrlSetOnEvent($atap_aendern_button, "ap_aendern") GUICtrlSetOnEvent($atap_hinzufuegen_button, "ap_hinzufuegen") GUICtrlSetOnEvent($atap_loeschen_button, "ap_loeschen") GUICtrlSetOnEvent($atap_sofortstarten_button, "ap_sofortstarten") GUICtrlSetOnEvent($atap_spontaneinplanen_button, "ap_spontaneinplanen") GUICtrlSetOnEvent($atapp_combo, "atapp_combo") GUICtrlSetOnEvent($atapp_funktionstyp_combo, "atapp_funktionstyp_combo") GUICtrlSetOnEvent($atapp_pfad_button, "app_pfad_auswaehlen") GUICtrlSetOnEvent($atapp_aendern_button, "app_aendern") GUICtrlSetOnEvent($atapp_hinzufuegen_button, "app_hinzufuegen") GUICtrlSetOnEvent($atapp_loeschen_button, "app_loeschen") GUICtrlSetOnEvent($atapp_neunummerieren_button, "app_laufendenr_neu_nummerieren") GUICtrlSetOnEvent($atapp_inanderenarbeitsplankopieren_button, "app_in_anderen_ap_kopieren") GUICtrlSetOnEvent($atdb_ok_button, "schritt1_lese_datenbankname_aus_inputbox_und_blende_schritt2_ein") GUICtrlSetOnEvent($atdb_pfad_button, "schritt2_lese_pfad_ein_und_blende_schritt3_ein") GUICtrlSetOnEvent($atdb_dberstellen_button, "dberzeugen") GUICtrlSetOnEvent($s1, "_s1_ausklappen") GUICtrlSetOnEvent($s2, "_s2_ausklappen") GUICtrlSetOnEvent($sallemarkieren_button, "_s_alle_markieren") GUICtrlSetOnEvent($salleabwaehlen_button, "_s_alle_abwaehlen") GUICtrlSetOnEvent($sfertig_button, "zeitplan_eintragen") GUICtrlSetOnEvent($sbeenden_button, "close_startzeit") GUISetOnEvent($GUI_EVENT_CLOSE, "close_admintool", $admintoolfenster) GUISetOnEvent($GUI_EVENT_CLOSE, "close_startzeit", $startzeitfenster) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Opt("GUIOnEventMode", 1) AdlibRegister("_clear_memory", 5000) While 1 Sleep(100) WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $idFrom, $iCode, $tNMHDR, $selected $tNMHDR = DllStructCreate("int;int;int", $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, 1)) $idFrom = DllStructGetData($tNMHDR, 2) $iCode = DllStructGetData($tNMHDR, 3) Switch $hWndFrom Case GUICtrlGetHandle($atap_listview) Switch $iCode Case $NM_CLICK $selected = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected = 1 Then ap_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Else ap_clear_inputs() EndIf EndSwitch Case GUICtrlGetHandle($atapp_listview) Switch $iCode Case $NM_CLICK $selected = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected = 1 Then app_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Else app_clear_inputs() _interne_inputs_zuklappen() _externe_inputs_zuklappen() EndIf EndSwitch Case GUICtrlGetHandle($atapp_listview_intern) Switch $iCode Case $NM_CLICK $selected = _GUICtrlListView_GetSelectedCount($atapp_listview_intern) If $selected = 1 Then app_stelle_listviewinternauswahl_in_inputs_dar() EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func open_admintool() If $ablaufstatus = True Then _tooltip() Else GUISetState(@SW_HIDE, $aufgabenlistefenster) GUISetState(@SW_SHOW, $admintoolfenster) GUISwitch($admintoolfenster) ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() app_lese_arbeitsplaene_aus_db_und_schreibe_in_combobox() EndIf EndFunc Func _tooltip() Global $Form1 = GUICreate("INFO", 221, 119, 465, 342) GUISetFont(10) $Label1 = GUICtrlCreateLabel("Solange die Ablaufsteuerung aktiv am arbeiten ist kann das AdminTool nicht aufgerufen werden.", 10, 10, 201, 65) $Button1 = GUICtrlCreateButton("OK", 131, 80, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) GUICtrlSetOnEvent($Button1, "_closeinfobox") GUISetOnEvent($GUI_EVENT_CLOSE, "_closeinfobox") Opt("GUIOnEventMode", 1) EndFunc Func _closeinfobox() GUIDelete($Form1) EndFunc Func close_admintool() GUISetState(@SW_HIDE, $admintoolfenster) GUISetState(@SW_SHOW, $aufgabenlistefenster) GUISwitch($aufgabenlistefenster) $ablaufstatus = False If _GUICtrlListView_GetItemCount($a_listview_bot) > 0 Then lade_aktive_aps() EndIf EndFunc Func lade_aktive_aps() Local $Row, $Query _GUICtrlListView_BeginUpdate($a_listview_bot) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($a_listview_bot)) If _SQLite_Query($DB, "SELECT id, geplante_startzeit, arbeitsplan_id FROM aufgabenliste ORDER BY geplante_startzeit ASC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $i = 0, $x = 1, $aGeplante_startzeit[1][4] While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ReDim $aGeplante_startzeit[$x+1][4] $aGeplante_startzeit[$x][0] = $Row[0] ;x = Zeile # y = Spalte Local $a = StringSplit($Row[1], " ") $aGeplante_startzeit[$x][1] = $a[1] $aGeplante_startzeit[$x][2] = $a[2] $aGeplante_startzeit[$x][3] = $Row[2] $x = $x + 1 WEnd _SQLite_QueryFinalize($Query) ;~ _ArrayDisplay($aGeplante_startzeit, "unsort") ;Bubblesort Local $n = UBound($aGeplante_startzeit) - 1 Do For $i = 0 to ($n - 1) ;~ ConsoleWrite("$i: " & $i & " ") If $aGeplante_startzeit[$i][1] < $aGeplante_startzeit[$i+1][1] Then _ArraySwap($aGeplante_startzeit[$i+1][0], $aGeplante_startzeit[$i][0]) _ArraySwap($aGeplante_startzeit[$i+1][1], $aGeplante_startzeit[$i][1]) _ArraySwap($aGeplante_startzeit[$i+1][2], $aGeplante_startzeit[$i][2]) _ArraySwap($aGeplante_startzeit[$i+1][3], $aGeplante_startzeit[$i][3]) EndIf Next ConsoleWrite(@CR) $n = $n - 1 Until $n = 1 ;~ _ArrayDisplay($aGeplante_startzeit, "sort") For $i = 0 To UBound($aGeplante_startzeit) - 2 If _SQLite_Query($DB, "SELECT arbeitsplan_name FROM arbeitsplaene WHERE arbeitsplan_id=" & $aGeplante_startzeit[$i][3], $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK GUICtrlCreateListViewItem($aGeplante_startzeit[$i][0]&"|"&$aGeplante_startzeit[$i][1]&" "&$aGeplante_startzeit[$i][2]&"|"&$Row[0], $a_listview_bot) WEnd _SQLite_QueryFinalize($Query) Next _GUICtrlListView_EndUpdate($a_listview_bot) EndFunc Func pruefe_ablauf() GUICtrlSetBkColor($gfx, 0x32CD32) $ablaufstatus = True AdlibRegister("vergleiche_zeitstempel", 1000) EndFunc Func _clear_memory() _ReduceMemory(@AutoItPID) EndFunc Func vergleiche_zeitstempel() ;~ Local $Row, $Query ;~ If _SQLite_Query($DB, "SELECT geplante_startzeit FROM aufgabenliste ORDER BY geplante_startzeit ASC", $Query) <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf ;~ If _SQLite_FetchData($Query, $Row) <> $SQLITE_OK Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf ;~ _SQLite_QueryFinalize($Query) Local $a_row0 = StringSplit(_GUICtrlListView_GetItemText($a_listview_bot, 0, 1), " ") Local $naechste_geplante_startdatum = $a_row0[1] $a_row0 = StringSplit($a_row0[2], ":") Local $sekunden_naechste_startzeit = $a_row0[1] * 3600 + $a_row0[2] * 60 Local $sekunden_systime = @HOUR * 3600 + @MIN * 60 + @SEC Local $aDatumForm = StringSplit($naechste_geplante_startdatum, "/") Local $sTage = ($aDatumForm[3]-1) * 365 + ($aDatumForm[2]-1) * 30 + $aDatumForm[1] Local $sTage_systime = (@Year-1) * 365 + (@MON-1)*30 + @MDAY If $sTage = $sTage_systime Then If $sekunden_naechste_startzeit = $sekunden_systime Or $sekunden_naechste_startzeit < $sekunden_systime Then starte_ablauf() EndIf ElseIf $sTage < $sTage_systime Then starte_ablauf() EndIf EndFunc Func starte_ablauf() _GUICtrlListView_SetItemSelected($a_listview_bot, 0) Local $Row, $Query, $Row2, $Query2 If _SQLite_Query($DB, "SELECT laufende_nr, arbeitspunkt_name FROM arbeitspunkte WHERE arbeitsplan_id=(SELECT arbeitsplan_id FROM aufgabenliste WHERE id=" & _GUICtrlListView_GetItemText($a_listview_bot, 0, 0) & ") AND status='Aktiv' ORDER BY laufende_nr ASC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK GUICtrlCreateListViewItem($Row[0] & "|" & $Row[1], $a_listview_top) WEnd _SQLite_QueryFinalize($Query) Local $anzahlarbeitspunkte = _GUICtrlListView_GetItemCount($a_listview_top) & "_" & _GUICtrlListView_GetItemCount($a_listview_bot) Local $progresspropart = 100 / $anzahlarbeitspunkte Local $i = 0 Local $icount = 0 GUICtrlSetBkColor(GUICtrlRead($a_listview_bot), 0x00BFFF) GUICtrlSetBkColor($a_listview_top, 0x00BFFF) If _SQLite_Query($DB, "SELECT befehl, parameter, arbeitspunkt_id FROM arbeitspunkte WHERE arbeitsplan_id=(SELECT arbeitsplan_id FROM aufgabenliste WHERE id=" & _GUICtrlListView_GetItemText($a_listview_bot, 0, 0) & ") AND status='Aktiv' ORDER BY laufende_nr", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ;~ ConsoleWrite("|======== VOR WHILE =========>>" & @CR) While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ ConsoleWrite("|======== anfang WHILE =========>>" & @CR) Local $sBefehl = $Row[0] Local $sParameter = $Row[1] _SQLite_Exec($DB, "UPDATE aufgabenliste SET startzeit=" & @HOUR & @MIN & @SEC & ", arbeitspunkt_id=(SELECT arbeitspunkt_id FROM arbeitspunkte WHERE arbeitsplan_id=(SELECT arbeitsplan_id FROM aufgabenliste WHERE id=" & _GUICtrlListView_GetItemText($a_listview_bot, 0, 0) & ") AND laufende_nr=" & _GUICtrlListView_GetItemText($a_listview_top, 0, 0) & ") WHERE id=" & _GUICtrlListView_GetItemText($a_listview_bot, 0, 0)) If _SQLite_Query($DB, "SELECT a.arbeitsplan_id, ap.arbeitsplan_name, a.geplante_startzeit, app.arbeitspunkt_name FROM aufgabenliste a, arbeitsplaene ap, arbeitspunkte app WHERE a.arbeitsplan_id=(SELECT arbeitsplan_id FROM aufgabenliste WHERE id=" & _GUICtrlListView_GetItemText($a_listview_bot, 0, 0) & ") AND a.arbeitsplan_id=ap.arbeitsplan_id AND a.arbeitsplan_id=app.arbeitsplan_id AND app.arbeitspunkt_name='" & _GUICtrlListView_GetItemText($a_listview_top, 0, 1) & "'", $Query2) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query2, $Row2) = $SQLITE_OK Local $sAp_id = $Row2[0] Local $sAp_name = $Row2[1] Local $sGeplante_startzeit = $Row2[2] Local $sApp_name = $Row2[3] WEnd _SQLite_QueryFinalize($Query2) Local $sStatus = " ... wird gestartet" If $sBefehl = "" Then Local $sFehler = " " _schreibe_log($sFehler, $sAp_id, $sAp_name, $sGeplante_startzeit, $sApp_name, $sBefehl, $sParameter, $sStatus) Local $neuer_starttermin = _neu_einplanen($sAp_id) If _SQLite_Exec($DB, "UPDATE aufgabenliste set geplante_startzeit='" & $neuer_starttermin & "' WHERE arbeitsplan_id=" & $sAp_id) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $sFehler = "OK" Local $sStatus = " ... ist beendet" _schreibe_log($sFehler, $sAp_id, $sAp_name, $sGeplante_startzeit, $sApp_name, $sBefehl, $sParameter, $sStatus) Else Local $sFehler = " " _schreibe_log($sFehler, $sAp_id, $sAp_name, $sGeplante_startzeit, $sApp_name, $sBefehl, $sParameter, $sStatus) If ShellExecuteWait($sBefehl, $sParameter, "") <> 0 Then Local $sFehler = "FEHLER" Local $sStatus = " Es ist ein Fehler aufgetreten." Else Local $sFehler = "OK" Local $sStatus = " ... ist beendet" EndIf _schreibe_log($sFehler, $sAp_id, $sAp_name, $sGeplante_startzeit, $sApp_name, $sBefehl, $sParameter, $sStatus) EndIf _GUICtrlListView_DeleteItem(GUICtrlGetHandle($a_listview_top), 0) For $si = $icount To $progresspropart GUICtrlSetData($a_progressbar, $si) Next $icount = $progresspropart $progresspropart = $progresspropart * 2 WEnd _SQLite_QueryFinalize($Query) Sleep(1000) GUICtrlSetData($a_progressbar, 0) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($a_listview_bot), 0) GUICtrlSetBkColor($a_listview_top, 0xffffff) lade_aktive_aps() EndFunc Func beende_ablauf() AdlibUnRegister("vergleiche_zeitstempel") $ablaufstatus = False GUICtrlSetBkColor($gfx, 0xFF0000) ;~ rot Return 0 EndFunc ;==>beende_ablauf Func datum_hochzaehlen($hochzaehlen_datum) If @MON = 01 Or @MON = 03 Or @MON = 03 Or @MON = 05 Or @MON = 07 Or @MON = 08 Or @MON = 10 Or @MON = 12 Then Local $monatsgroesse = 31 ; großer Monat ElseIf @MON = 04 Or @MON = 06 Or @MON = 09 Or @MON = 11 Then Local $monatsgroesse = 30 ; mittlerer Monat ElseIf @MON = 02 Then If Mod(@YEAR, 4) = 0 Then Local $monatsgroesse = 29 ; Schaltjahr Else Local $monatsgroesse = 28 ; kleiner Monat EndIf EndIf If @MDAY + $hochzaehlen_datum > $monatsgroesse Then ; Wenn Tage größer als Monat, Monat erhöhen If @MON + 1 > 12 Then ; Wenn Monat größer als 12 wird, Jahr erhöhen Local $mday = "01" Local $mon = "01" Local $year = @YEAR + 1 Else Local $mday = "01" Local $mon = @MON + 1 Local $year = @YEAR EndIf Else Local $mday = @MDAY + $hochzaehlen_datum Local $mon = @MON Local $year = @YEAR EndIf If StringLen($mday) < 2 Then $mday = "0" & $mday EndIf If StringLen($mon) < 2 Then $mon = "0" & $mon EndIf If StringLen($year) < 2 Then $year = "0" & $year EndIf $datum = $mday & "/" & $mon & "/" & $year Return $datum EndFunc ;==>datum_hochzaehlen Func uhrzeit_hochzaehlen($hochzaehlen_uhrzeit, $intervall) Local $auhrzeit = StringSplit($hochzaehlen_uhrzeit, ":") If $intervall > 60 Then ;~ ConsoleWrite("$intervall =" & $intervall & " # > 60 # " & @CR) Local $intervall_std = Int($intervall / 60, 0) Local $intervall_min = Int(Mod($intervall, 60)) ;~ ConsoleWrite("$intervall_std = " & $intervall_std & " # $intervall_min = " & $intervall_min & @CR) If $auhrzeit[2] + $intervall_min > 60 Then If $auhrzeit[1] + $intervall_std + 1 > 24 Then Local $min = ($auhrzeit[2] + $intervall_min) - 60 Local $hour = 0 Else Local $min = ($auhrzeit[2] + $intervall_min) - 60 Local $hour = $auhrzeit[1] + $intervall_std + 1 EndIf Else Local $min = $auhrzeit[2] + $intervall_min Local $hour = $auhrzeit[1] + $intervall_std EndIf Else ;~ ConsoleWrite("$intervall =" & $intervall & @CR) If $auhrzeit[2] + $intervall > 60 Then If $auhrzeit[1] + 1 > 24 Then Local $min = ($auhrzeit[2] + $intervall) - 60 Local $hour = 0 Else Local $min = ($auhrzeit[2] + $intervall) - 60 Local $hour = $auhrzeit[1] + 1 EndIf ElseIf $auhrzeit[2] + $intervall = 60 Then If $auhrzeit[1] + 1 > 24 Then Local $min = ($auhrzeit[2] + $intervall) - 60 Local $hour = 0 ElseIf $auhrzeit[1] + 1 = 24 Then Local $min = "00" Local $hour = "00" Else Local $min = "00" Local $hour = $auhrzeit[1] + 1 EndIf Else Local $min = $auhrzeit[2] + $intervall Local $hour = $auhrzeit[1] EndIf EndIf If StringLen($min) < 2 Then $min = "0" & $min EndIf If StringLen($hour) < 2 Then $hour = "0" & $hour EndIf $uhrzeit = $hour & ":" & $min ;~ ConsoleWrite("$uhrzeit = " & $uhrzeit & @CR & @CR) Return $uhrzeit EndFunc ;==>uhrzeit_hochzaehlen Func wochentagsarray_sortieren($array) If $array[1] = @WDAY Then Return $array Else For $i = 1 To $array[0] If $array[$i] > @WDAY Then $array = wochentagsarray_sortieren_wochentag_groesser($array) Return $array EndIf Next $array = wochentagsarray_sortieren_wochentag_kleiner($array) Return $array EndIf EndFunc ;==>wochentagsarray_sortieren Func wochentagsarray_sortieren_wochentag_groesser($array) _ArrayAdd($array, "") If $array[1] > @WDAY Then Else Do $array[$array[0] + 1] = $array[1] Local $i = 1 Do $array[$i] = $array[$i + 1] $i = $i + 1 Until $i = $array[0] + 1 Until $array[1] = @WDAY Or $array[1] > @WDAY EndIf _ArrayDelete($array, UBound($array)) Return $array EndFunc ;==>wochentagsarray_sortieren_wochentag_groesser Func wochentagsarray_sortieren_wochentag_kleiner($array) _ArrayAdd($array, "") Do $array[$array[0] + 1] = $array[1] Local $i = 1 Do $array[$i] = $array[$i + 1] $i = $i + 1 Until $i = $array[0] + 1 Until $array[1] = @WDAY Or $array[1] < @WDAY _ArrayDelete($array, UBound($array)) Return $array EndFunc ;==>wochentagsarray_sortieren_wochentag_kleiner Func _neu_einplanen($ap_id) Local $Row, $Query If _SQLite_Query($DB, "SELECT minute, wochentag, von, bis FROM zeitplan WHERE arbeitsplan_id=" & $ap_id, $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_FetchData($Query, $Row) <> $SQLITE_OK Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf _SQLite_QueryFinalize($Query) Local $awochentag = StringSplit($Row[1], ",") ;~ For $i = 0 To $awochentag[0] ;~ ConsoleWrite("$awochentag[" & $i & "] = " & $awochentag[$i] & @CR) ;~ Next $awochentag = wochentagsarray_sortieren($awochentag) Local $z = @WDAY ;~ For $i = 0 To UBound($Row)-1 ;~ ConsoleWrite("Row[" & $i & "] = " & $Row[$i] & @CR) ;~ Next ;~ For $i = 0 To $awochentag[0] ;~ ConsoleWrite("$awochentag[" & $i & "] = " & $awochentag[$i] & @CR) ;~ Next If $Row[0] = "" Then ;FALL 1 For $i = 1 To $awochentag[0] If $awochentag[$i] = @WDAY Then ;FALL 1.1/1.2 If $Row[3] > @HOUR & ":" & @MIN & ":" & @SEC Then ;FALL 1.1 ConsoleWrite("Fall 1 . 1: Wochentag = Heute -> Uhrzeit noch nicht erreicht: " & @MDAY & "/" & @MON & "/" & @YEAR & " " & $Row[3] & @CR) Return @MDAY & "/" & @MON & "/" & @YEAR & " " & $Row[3] ElseIf $Row[3] <= @HOUR & ":" & @MIN & ":" & @SEC Then ;FALL 1.2 If $Row[1] = @WDAY Then ;Wochentag: NUR HEUTE Local $hochzaehlen_datum = 7 Else If ($awochentag[2] - $z) > 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) ElseIf ($awochentag[2] - $z) < 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) + 7 ElseIf $awochentag[2] = @WDAY Then Local $hochzaehlen_datum = 7 EndIf EndIf Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 1 . 2: Wochentag = Heute -> Uhrzeit vorbei: " & $datum_hochgezaehlt & " " & $Row[3] & @CR) Return $datum_hochgezaehlt & " " & $Row[3] EndIf EndIf Next ;FALL 1.3 If ($awochentag[1] - $z) > 0 Then ; #1 Local $hochzaehlen_datum = ($awochentag[1] - $z) Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 1 . 3: Wochentag <> Heute -> Datum von naechsten gewuenschten Tag, Gewuenschte Uhrzeit #1: " & $datum_hochgezaehlt & " " & $Row[3] & @CR) Return $datum_hochgezaehlt & " " & $Row[3] ElseIf ($awochentag[1] - $z) < 0 Then ; #2 Local $hochzaehlen_datum = ($awochentag[1] - $z) + 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 1 . 3: Wochentag <> Heute -> Datum von naechsten gewuenschten Tag, Gewuenschte Uhrzeit #2: " & $datum_hochgezaehlt & " " & $Row[3] & @CR) Return $datum_hochgezaehlt & " " & $Row[3] EndIf Else ;FALL 2 For $i = 1 To $awochentag[0] If $awochentag[$i] = @WDAY Then ;FALL 2.1/2.2/2.3/2.4 If $Row[2] > @HOUR & ":" & @MIN & ":" & @SEC Then ;FALL 2.1 ConsoleWrite("Fall 2 . 1: Wochentag = Heute -> Uhrzeit noch nicht erreicht: " & @MDAY & "/" & @MON & "/" & @YEAR & " " & $Row[2] & @CR) Return @MDAY & "/" & @MON & "/" & @YEAR & " " & $Row[2] ElseIf $Row[2] < @HOUR & ":" & @MIN & ":" & @SEC <= $Row[3] Then ;FALL 2.2 Local $z = 1 Do Local $uhrzeit_hochgezaehlt = uhrzeit_hochzaehlen($Row[2], ($Row[0] * $z)) $z = $z + 1 ;~ ConsoleWrite($uhrzeit_hochgezaehlt &">"& @HOUR & ":" & @MIN & ":" & @SEC) Until $uhrzeit_hochgezaehlt > @HOUR & ":" & @MIN & ":" & @SEC If $uhrzeit_hochgezaehlt <= $Row[3] Then ;FALL 2.2 ConsoleWrite("Fall 2 . 2 " & @MDAY & "/" & @MON & "/" & @YEAR & " " & $uhrzeit_hochgezaehlt & @CR) Return @MDAY & "/" & @MON & "/" & @YEAR & " " & $uhrzeit_hochgezaehlt Else ;FALL 2.3 Local $z = @WDAY $awochentag = wochentagsarray_sortieren($awochentag) ;~ If $awochentag[1] = @WDAY Then ;~ Local $hochzaehlen_datum = 7 ;~ Else If ($awochentag[2] - $z) > 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) ElseIf ($awochentag[2] - $z) < 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) + 7 EndIf Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 3 " & $datum_hochgezaehlt & " " & $Row[2] & @CR) Return $datum_hochgezaehlt & " " & $Row[2] EndIf ElseIf @HOUR & ":" & @MIN & ":" & @SEC > $Row[3] Then ;FALL 2.4 Local $z = @WDAY $awochentag = wochentagsarray_sortieren($awochentag) If UBound($awochentag) = 2 And $awochentag[1] = @WDAY Then Local $hochzaehlen_datum = 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 4 #3: " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date)) Return $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) ElseIf UBound($awochentag) > 2 And $awochentag[1] = @WDAY Then If ($awochentag[2] - $z) > 0 Then ; #1 Local $hochzaehlen_datum = ($awochentag[2] - $z) Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 4 #1: " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & $Row[2]) Return $datum_hochgezaehlt & " " & $Row[2] ElseIf ($awochentag[2] - $z) < 0 Then ; #2 Local $hochzaehlen_datum = ($awochentag[2] - $z) + 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 4 #2: " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & $Row[2]) Return $datum_hochgezaehlt & " " & $Row[2] EndIf EndIf EndIf EndIf Next Local $z = @WDAY $awochentag = wochentagsarray_sortieren($awochentag) If ($awochentag[1] - $z) > 0 Then ; #1 Local $hochzaehlen_datum = ($awochentag[2] - $z) Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 5 #1 " & $datum_hochgezaehlt & " " & $Row[2] & @CR) Return $datum_hochgezaehlt & " " & $Row[2] ElseIf ($awochentag[1] - $z) < 0 Then ; #2 Local $hochzaehlen_datum = ($awochentag[2] - $z) + 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 5 #2 " & $datum_hochgezaehlt & " " & $Row[2] & @CR) Return $datum_hochgezaehlt & " " & $Row[2] EndIf EndIf EndFunc ;==>_neu_einplanen Func erstmalig_einplanen($wochentag) Local $awochentag = StringSplit($wochentag, ",") $awochentag = wochentagsarray_sortieren($awochentag) Local $z = @WDAY If GUICtrlRead($s1) = $GUI_CHECKED Then ;FALL 1 For $i = 1 To $awochentag[0] If $awochentag[$i] = @WDAY Then ;FALL 1.1/1.2 If GUICtrlRead($s1_date) > @HOUR&":"&@MIN&":"&@SEC Then ;Fall 1.1 ConsoleWrite("Fall 1 . 1: Wochentag = Heute -> Uhrzeit noch nicht erreicht: " & @MDAY & "/" & @MON & "/" & @YEAR & " " & GUICtrlRead($s1_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, @MDAY & "/" & @MON & "/" & @YEAR & " " & GUICtrlRead($s1_date)) Return 0 ElseIf GUICtrlRead($s1_date) < @HOUR&":"&@MIN&":"&@SEC Then ;Fall 1.2 If $wochentag = @WDAY Then Local $hochzaehlen_datum = 7 Else If ($awochentag[2] - $z) > 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) ElseIf ($awochentag[2] - $z) <= 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) + 7 ElseIf $awochentag[2] = @WDAY Then Local $hochzaehlen_datum = 7 EndIf EndIf Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 1 . 2: Wochentag = Heute -> Uhrzeit vorbei: " & $datum_hochgezaehlt & " " & GUICtrlRead($s1_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s1_date)) Return 0 EndIf EndIf Next ;FALL 1.3 If ($awochentag[1] - $z) > 0 Then ; #1 Local $hochzaehlen_datum = ($awochentag[1] - $z) Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 1 . 3 #1: " & $datum_hochgezaehlt & " " & GUICtrlRead($s1_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s1_date)) Return 0 ElseIf ($awochentag[1] - $z) < 0 Then ; #2 Local $hochzaehlen_datum = ($awochentag[1] - $z) + 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 1 . 3 #2: " & $datum_hochgezaehlt & " " & GUICtrlRead($s1_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s1_date)) Return 0 EndIf ElseIf GUICtrlRead($s2) = $GUI_CHECKED Then ;FALL 2 For $i = 1 To $awochentag[0] If $awochentag[$i] = @WDAY Then ;FALL 2.1/2.2/2.3/2.4 If GUICtrlRead($s2_von_date) > @HOUR&":"&@MIN&":"&@SEC Then ;FALL 2.1 ConsoleWrite("Fall 2 . 1: Wochentag = Heute -> Uhrzeit noch nicht erreicht: " & @MDAY & "/" & @MON & "/" & @YEAR & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, @MDAY & "/" & @MON & "/" & @YEAR & " " & GUICtrlRead($s2_von_date)) Return 0 ElseIf GUICtrlRead($s2_von_date) < @HOUR&":"&@MIN&":"&@SEC And @HOUR&":"&@MIN&":"&@SEC < GUICtrlRead($s2_bis_date) Then ;FALL 2.2 Local $z = 1 Do Local $uhrzeit_hochgezaehlt = uhrzeit_hochzaehlen(GUICtrlRead($s2_von_date), (GUICtrlRead($s2_combo) * $z)) $z = $z + 1 ;~ ConsoleWrite($uhrzeit_hochgezaehlt &">"& @HOUR & ":" & @MIN & ":" & @SEC) Until $uhrzeit_hochgezaehlt > @HOUR & ":" & @MIN & ":" & @SEC If $uhrzeit_hochgezaehlt <= GUICtrlRead($s2_bis_date) Then ;FALL 2.2 ConsoleWrite("Fall 2 . 2 " & @MDAY & "/" & @MON & "/" & @YEAR & " " & $uhrzeit_hochgezaehlt & @CR) GUICtrlSetData($atap_geplantestartzeit_input, @MDAY & "/" & @MON & "/" & @YEAR & " " & $uhrzeit_hochgezaehlt) Return 0 Else ;FALL 2.3 Local $z = @WDAY $awochentag = wochentagsarray_sortieren($awochentag) If ($awochentag[2] - $z) > 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) ElseIf ($awochentag[2] - $z) < 0 Then Local $hochzaehlen_datum = ($awochentag[2] - $z) + 7 EndIf Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 3 " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date)) Return 0 EndIf ElseIf @HOUR & ":" & @MIN & ":" & @SEC > GUICtrlRead($s2_bis_date) Then ;FALL 2.4 Local $z = @WDAY $awochentag = wochentagsarray_sortieren($awochentag) If UBound($awochentag) = 2 And $awochentag[1] = @WDAY Then Local $hochzaehlen_datum = 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 4 #3: " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date)) Return 0 ElseIf UBound($awochentag) > 2 And $awochentag[1] = @WDAY Then If ($awochentag[2] - $z) > 0 Then ; #1 Local $hochzaehlen_datum = ($awochentag[2] - $z) Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 4 #1: " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date)) Return 0 ElseIf ($awochentag[2] - $z) < 0 Then ; #2 Local $hochzaehlen_datum = ($awochentag[2] - $z) + 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 4 #2: " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date)) Return 0 EndIf EndIf EndIf EndIf Next Local $z = @WDAY $awochentag = wochentagsarray_sortieren($awochentag) If ($awochentag[1] - $z) > 0 Then ; #1 Local $hochzaehlen_datum = ($awochentag[1] - $z) Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 5 #1 " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " &GUICtrlRead($s2_von_date)) Return 0 ElseIf ($awochentag[1] - $z) < 0 Then ; #2 Local $hochzaehlen_datum = ($awochentag[1] - $z) + 7 Local $datum_hochgezaehlt = datum_hochzaehlen($hochzaehlen_datum) ConsoleWrite("Fall 2 . 5 #2 " & $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date) & @CR) GUICtrlSetData($atap_geplantestartzeit_input, $datum_hochgezaehlt & " " & GUICtrlRead($s2_von_date)) Return 0 EndIf EndIf EndFunc ;==>erstmalig_einplanen ; Hilfe MsgBox Func hilfe() MsgBox(64, "Hilfe", "Hilfe") ;~ COOMING SOON EndFunc ;==>hilfe ; Info MsgBox Func info() MsgBox(64, "Info", "Info") ;~ COOMING SOON EndFunc ;==>info expandcollapse popup;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Arbeitspläne verwalten ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() Local $Row, $Query _GUICtrlListView_BeginUpdate($atap_listview) ;~ Veraenderungen der '$atap_listview' die fuer den User sichtbar sind erst vornehmen wenn '_GUICtrlListView_EndUpdate($atap_listview)' erreicht ist! _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($atap_listview)) ;~ Loesche alle vorhandenen Items der '$atap_listview'. If _SQLite_Query($DB, "SELECT arbeitsplan_id, arbeitsplan_name, (SELECT a.geplante_startzeit FROM aufgabenliste a WHERE a.arbeitsplan_id=ap.arbeitsplan_id), status FROM arbeitsplaene ap ORDER BY ap.arbeitsplan_id ASC", $Query) <> 0 Then ;~ Wenn die Abfrage 'Selektiere die arbeitsplan_id, den arbeitsplan_namen, (Selektiere die geplante_startzeit von der aufgabenliste-Tabelle wo die arbeitsplan_id gleich der arbeitsplan_id der arbeitsplaene ist) von der arbeitsplaene-Tabelle sortiert nach arbeitsplan_id aufsteigend der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... ;~ If $Row[2] = "" Then ;~ Wenn '$Row[2]' gleich einem Leerstring ist, dann ;~ Local $form_uhrzeit = $Row[2] ;~ Deklariere '$form_uhrzeit' local mit dem Wert '$Row[2]', ;~ Else ;~ ansonsten ;~ Local $form_uhrzeit = StringMid($Row[2], 1, 2) & ":" & StringMid($Row[2], 3, 2) ;~ Deklariere '$form_uhrzeit' local mit dem Wert 'StringMid($Row[2], 1, 2) & ":" & StringMid($Row[2], 3, 2)'. ;~ EndIf ;~ ==>>EndIf GUICtrlCreateListViewItem($Row[0] & "|" & $Row[1] & "|" & $Row[2] & "|" & $Row[3], $atap_listview) ;~ Erstelle ein Listview-Eintrag mit dem Inhalt '$Row[0] & "|" & $Row[1] & "|" & $form_uhrzeit & "|" & $Row[3]' in die '$atap_listview'. WEnd ;~ ==>>WEnd _SQLite_QueryFinalize($Query) _GUICtrlListView_EndUpdate($atap_listview) ;~ Zeige nun alle fuer den User sichtbaren Aenderungen der '$atap_listview' an. EndFunc ;==>ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar Func ap_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Local $Row, $Query Local $selected_items = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected_items = 1 Then Local $dateiindex = _GUICtrlListView_GetSelectionMark($atap_listview) If $dateiindex <> -1 Then If _SQLite_Query($DB, "SELECT arbeitsplan_id, arbeitsplan_name, (SELECT a.geplante_startzeit FROM aufgabenliste a WHERE a.arbeitsplan_id=ap.arbeitsplan_id), status FROM arbeitsplaene ap WHERE ap.arbeitsplan_id=" & _GUICtrlListView_GetItemText($atap_listview, $dateiindex, 0) & " ORDER BY ap.arbeitsplan_id ASC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... ;~ If $Row[2] = "" Then ;~ Local $form_uhrzeit = $Row[2] ;~ Else ;~ Local $form_uhrzeit = StringMid($Row[2], 1, 2) & ":" & StringMid($Row[2], 3, 2) ;~ EndIf GUICtrlSetData($atap_arbeitsplanid_input, $Row[0]) GUICtrlSetData($atap_arbeitsplanname_input, $Row[1]) GUICtrlSetData($atap_geplantestartzeit_input, $Row[2]) If $Row[3] = "Aktiv" Then GUICtrlSetState($atap_status_checkbox, $GUI_CHECKED) Else GUICtrlSetState($atap_status_checkbox, $GUI_UNCHECKED) EndIf WEnd _SQLite_QueryFinalize($Query) EndIf EndIf EndFunc Func ap_clear_inputs() GUICtrlSetData($atap_arbeitsplanid_input, "") ;~ Initialisiere den Wert des Controls '$atap_arbeitsplanid_input'. GUICtrlSetData($atap_arbeitsplanname_input, "") ;~ Initialisiere den Wert des Controls '$atap_arbeitsplanname_input'. GUICtrlSetData($atap_geplantestartzeit_input, "") ;~ Initialisiere den Wert des Controls '$atap_geplantestartzeit_input'. GUICtrlSetState($atap_status_checkbox, $GUI_UNCHECKED) ;~ Initialisiere die 'Checkbox' und setze sie als nicht angekreuzt. EndFunc ;==>ap_clear_inputs Func ap_sofortstarten() Local $Row, $Query Local $selected_items = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected_items = 1 Then If GUICtrlRead($atap_arbeitsplanid_input) = "" Then MsgBox(48, "Fehler", "Bitte wählen Sie einen Arbeitsplan aus.") Return 0 EndIf If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET status='Inaktiv' WHERE arbeitspunkt_name='_neu_einplanen' AND arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, "INSERT INTO aufgabenliste VALUES(NULL, NULL, NULL," & GUICtrlRead($atap_arbeitsplanid_input) & ", NULL)") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $iLirid = _SQLite_LastInsertRowID($DB) close_admintool() lade_aktive_aps() GUICtrlSetBkColor($gfx, 0x32CD32) ;~ gruen starte_ablauf() GUICtrlSetBkColor($gfx, 0xFF0000) ;~ rot If _SQLite_Exec($DB, "DELETE FROM aufgabenliste WHERE id=" & $iLirid) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf lade_aktive_aps() If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET status='Aktiv' WHERE arbeitspunkt_name='_neu_einplanen' AND arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf EndFunc Func ap_spontaneinplanen() Local $Row, $Query Local $selected_items = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected_items = 1 Then Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atap_listview) Local $check_input = True If GUICtrlRead($atap_arbeitsplanid_input) = "" Then MsgBox(48, "Fehler", "Bitte wählen Sie einen Arbeitsplan aus.") Return 0 ElseIf GUICtrlRead($atap_arbeitsplanname_input) = "" Then MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") Return 0 EndIf If GUICtrlRead($atap_geplantestartzeit_input) <> "" Then MsgBox(64, "INFO", "Die eingegebene Startzeit wird nicht berücksichtigt, da sie spontan einplanan möchten.") EndIf If _SQLite_Query($DB, "SELECT geplante_startzeit FROM aufgabenliste WHERE geplante_startzeit LIKE '" & @MDAY & "/" & @MON & "/" & @YEAR & "_________' ORDER BY geplante_startzeit DESC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_FetchData($Query, $Row) <> $SQLITE_OK Then Local $date = @MDAY & "/" & @MON & "/" & @YEAR Local $time = @HOUR & ":" & @MIN & ":" & @SEC Else Local $time = uhrzeit_hochzaehlen(StringMid($Row[0], 12, 5), 1) If $time < StringMid($Row[0], 12, 5) Then Local $date = datum_hochzaehlen(1) EndIf EndIf _SQLite_QueryFinalize($Query) If _SQLite_Query($DB, "SELECT arbeitsplan_id FROM aufgabenliste WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> $SQLITE_OK Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_FetchData($Query, $Row) <> $SQLITE_OK Then If _SQLite_Exec($DB, "INSERT INTO aufgabenliste VALUES(NULL, '" & $time & " " & $date & "', NULL, " & GUICtrlRead($atap_arbeitsplanid_input) & ", NULL)") <> 0 Then ;~ Wenn die Abfrage 'Fuege in die aufgabenliste-Tabelle eine Zeile mit den Werten(NULL,$spontan,NULL,GUICtrlRead($atap_arbeitsplanid_input),NULL) der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf If _SQLite_Exec($DB, "UPDATE arbeitsplaene SET status='Aktiv' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then ;~ Wenn die Abfrage 'Aendere in der aufgabenliste-Tabelle die Werte status=Aktiv wo die arbeitsplan_id=GUICtrlRead($atap_arbeitsplanid_input) ist' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf Else If _SQLite_Exec($DB, "UPDATE aufgabenliste SET geplante_startzeit='" & $time & " " & $date & "' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then ;~ Wenn die Abfrage 'Aendere in der aufgabenliste-Tabelle die Werte status=Aktiv wo die arbeitsplan_id=GUICtrlRead($atap_arbeitsplanid_input) ist' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf If _SQLite_Exec($DB, "UPDATE arbeitsplaene SET status='Aktiv' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then ;~ Wenn die Abfrage 'Aendere in der aufgabenliste-Tabelle die Werte status=Aktiv wo die arbeitsplan_id=GUICtrlRead($atap_arbeitsplanid_input) ist' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf EndIf _SQLite_QueryFinalize($Query) Local $selected_items2 = _GUICtrlListView_GetSelectedCount($atap_listview) ;~ Pruefe wie viele Items ausgewaehlt worden sind. If $selected_items2 = 1 Then ;~ Wenn ein Item ausgewaehlt ist, dann Local $dateiindex = _GUICtrlListView_GetSelectionMark($atap_listview) ;~ setze '$dateiindex' gleich dem 'SelectionMark' des ausgewaehlten Items EndIf ;~ ==>>EndIF MsgBox(0, "", "Arbeitsplan: " & GUICtrlRead($atap_arbeitsplanname_input) & " wurde erfolgreich eingeplant.") ;~ MsgBox ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() ;~ Lese die arbeitsplaene aus der Datenbank und stelle sie in der Tabellenansicht dar. _GUICtrlListView_SetItemSelected($atap_listview, $dateiindex, True, True) ;~ Waehle das zuletzt ausgewaehlte Item wieder aus. ap_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() ;~ Suche in der Datenbank nach dem ausgewaehltem Item und lade die dazugehoerigen Informationen in die Eingabefelder. GUICtrlSetState($atap_listview, $GUI_FOCUS) ;~ Setze einen Focus auf das Control '$atap_listview' Else ;~ansonsten MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") ;~ MsgBox EndIf ;~ ==>>EndIf EndFunc ;==>ap_spontaneinplanen Func ap_dublizieren() Local $Row, $Query Local $selected_items = _GUICtrlListView_GetSelectedCount($atap_listview) ;~ Pruefe wie viele Items ausgewaehlt worden sind. If $selected_items = 1 Then ;~ Wenn ein Item ausgewaehlt ist, dann Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atap_listview) ;~ schreibe alle ItemTexte in ein Array, Local $check_input = True ;~ deklariere '$check_input' mit True. If GUICtrlRead($atap_arbeitsplanid_input) = "" Then ;~ Wenn die Information des Controls '$atap_arbeitsplanid_input' gleich einem Leerstring ist, dann MsgBox(48, "Fehler", "Bitte wählen Sie einen Arbeitsplan aus.") ;~ MsgBox Return 0 ;~ und gebe 0 zurueck. ElseIf GUICtrlRead($atap_arbeitsplanname_input) = "" Then ;~ Wenn die Information des Controls '$atap_arbeitsplanname_input' gleich einem Leerstring ist, dann MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") ;~ MsgBox Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf ;~ If GUICtrlRead($atap_geplantestartzeit_input) <> "" Then ;~ Wenn die Information des Controls '$atap_geplantestartzeit_input' gleich einem Leerstring ist, dann ;~ If StringLen(GUICtrlRead($atap_geplantestartzeit_input)) <> 5 Then ;~ Wenn die Laenge der Zeichen des Werts des Controls '$atap_geplantestartzeit_input' undgleich fuenf ist, dann ;~ MsgBox(48, "Fehler", "Es ist ein Fehler bei der Eingabe der geplanten Startzeit aufgetreten." & @CRLF & "Beachten Sie die unten stehende Information oder schauen Sie in die Hilfe.") ;~ MsgBox ;~ Return 0 ;~ und gebe 0 zurueck. ;~ EndIf ;~ ==>>EndIf ;~ EndIf ;~ ==>>EndIf ;~ ############################# FALL 1 ############################# FALL 1 ############################# FALL 1 ############################# If GUICtrlRead($atap_geplantestartzeit_input) = "" And GUICtrlRead($atap_status_checkbox) = $GUI_UNCHECKED Then ;~ Wenn die Information des Controls '$atap_geplantestartzeit_input' gleich einem Leerstring >UND< die Information des Controls '$atap_status_checkbox' gleich unmarkiert ist, dann If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Inaktiv')") <> 0 Then ;~ Wenn die Abfrage 'Fuege eine neue Zeile in die arbeitsplaene-Tabelle mit den Werten(NULL,GUICtrlRead($atap_arbeitsplanname_input),Inaktiv) der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf Local $lastinsertrowid = _SQLite_LastInsertRowID() ;~ Deklariere '$lastinsertrowid' lokal If _SQLite_Query($DB, "SELECT * FROM arbeitspunkte WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then ;~ Wenn die Abfrage 'Selektiere alles von der arbeitspunkte-Tabelle wo die arbeitsplan_id gleich GUICtrlRead($atap_arbeitsplanid_input) ist der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', " & $lastinsertrowid & ", NULL, '" & $Row[5] & "', '" & $Row[6] & "', '" & $Row[7] & "')") <> 0 Then Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf WEnd ;~ ==>>EndIf _SQLite_QueryFinalize($Query) If _SQLite_Query($DB, "SELECT minute, wochentag, von, bis FROM zeitplan WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then ;~ Wenn die Abfrage 'Selektiere alles von der arbeitspunkte-Tabelle wo die arbeitsplan_id gleich GUICtrlRead($atap_arbeitsplanid_input) ist der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(NULL, '" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', '" & $Row[3] & "')") <> 0 Then Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf WEnd ;~ ==>>EndIf _SQLite_QueryFinalize($Query) ; ############################# FALL 2 ############################# FALL 2 ############################# FALL 2 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) <> "" And GUICtrlRead($atap_status_checkbox) = $GUI_UNCHECKED Then ;~ Wenn die Information des Controls '$atap_geplantestartzeit_input' ungleich einem Leerstring >UND< die Information des Controls '$atap_status_checkbox' gleich unmarkiert ist, dann MsgBox(64, "INFO", "Die geplante Startzeit wird nicht gesetzt!" & @CR & "Eine geplante Startzeit kann nur angegeben werden, wenn der Arbeitsplan-Status Aktiv gesetzt ist/wird!") If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Inaktiv')") <> 0 Then ;~ Wenn die Abfrage 'Fuege eine neue Zeile in die arbeitsplaene-Tabelle mit den Werten(NULL,GUICtrlRead($atap_arbeitsplanname_input),Inaktiv) der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf Local $lastinsertrowid = _SQLite_LastInsertRowID() ;~ Deklariere '$lastinsertrowid' lokal If _SQLite_Query($DB, "SELECT * FROM arbeitspunkte WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', " & $lastinsertrowid & ", NULL, '" & $Row[5] & "', '" & $Row[6] & "', '" & $Row[7] & "')") <> 0 Then Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf WEnd ;~ ==>>WEnd _SQLite_QueryFinalize($Query) If _SQLite_Query($DB, "SELECT minute, wochentag, von, bis FROM zeitplan WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then ;~ Wenn die Abfrage 'Selektiere alles von der arbeitspunkte-Tabelle wo die arbeitsplan_id gleich GUICtrlRead($atap_arbeitsplanid_input) ist der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(NULL, '" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', '" & $Row[3] & "')") <> 0 Then Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf WEnd ;~ ==>>EndIf _SQLite_QueryFinalize($Query) ; ############################# FALL 3 ############################# FALL 3 ############################# FALL 3 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) = "" And GUICtrlRead($atap_status_checkbox) = $GUI_CHECKED Then MsgBox(64, "INFO", "Der Arbeitsplan-Status wird Inaktiv gesetzt!" & @CR & "Geben Sie eine geplante Startzeit an um einen Arbeitsplan aktiv zu schalten!") If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Inaktiv')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ; If _SQLite_Query($DB, "SELECT * FROM arbeitspunkte WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $lastinsertrowid = _SQLite_LastInsertRowID() While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', " & $lastinsertrowid & ", NULL, '" & $Row[5] & "', '" & $Row[6] & "', '" & $Row[7] & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If _SQLite_Query($DB, "SELECT minute, wochentag, von, bis FROM zeitplan WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then ;~ Wenn die Abfrage 'Selektiere alles von der arbeitspunkte-Tabelle wo die arbeitsplan_id gleich GUICtrlRead($atap_arbeitsplanid_input) ist der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(NULL, '" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', '" & $Row[3] & "')") <> 0 Then Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf WEnd ;~ ==>>EndIf _SQLite_QueryFinalize($Query) ; ############################# FALL 4 ############################# FALL 4 ############################# FALL 4 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) <> "" And GUICtrlRead($atap_status_checkbox) = $GUI_CHECKED Then ;~ Local $uform_uhrzeit = StringMid(GUICtrlRead($atap_geplantestartzeit_input), 1, 2) & StringMid(GUICtrlRead($atap_geplantestartzeit_input), 4, 2) ;~ If _SQLite_Query($DB, "SELECT geplante_startzeit FROM aufgabenliste WHERE geplante_startzeit=" & $uform_uhrzeit, $Query) <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf ;~ While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ If $Row[0] = $uform_uhrzeit Then ;~ MsgBox(48, "Fehler", "Die Geplante Startzeit ist bereits vorhanden. Bitte wählen Sie eine andere.") ;~ Return 0 ;~ EndIf ;~ WEnd If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Aktiv')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $lastinsertrowid = _SQLite_LastInsertRowID() If _SQLite_Query($DB, "SELECT * FROM arbeitspunkte WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', " & $lastinsertrowid & ", NULL, '" & $Row[5] & "', '" & $Row[6] & "', '" & $Row[7] & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If _SQLite_Query($DB, "SELECT minute, wochentag, von, bis FROM zeitplan WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then ;~ Wenn die Abfrage 'Selektiere alles von der arbeitspunkte-Tabelle wo die arbeitsplan_id gleich GUICtrlRead($atap_arbeitsplanid_input) ist der geoeffneten Datenbank' ungleich 0 ist, dann Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ Solange der Abruf erfolgreich ist, ... If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(NULL, '" & $Row[0] & "', '" & $Row[1] & "', '" & $Row[2] & "', '" & $Row[3] & "')") <> 0 Then Global $sql_error = @error ;~ Deklariere '$sql_error' als globale Variable mit @error, _check_sqlite_query_errors() ;~ rufe die Funktion '_check_sqlite_query_errors' auf, Return 0 ;~ und gebe 0 zurueck. EndIf ;~ ==>>EndIf WEnd ;~ ==>>EndIf _SQLite_QueryFinalize($Query) If _SQLite_Exec($DB, "INSERT INTO aufgabenliste VALUES(NULL, '" & GUICtrlRead($atap_geplantestartzeit_input) & "', NULL, " & $lastinsertrowid & ", NULL)") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Arbeitsplan: " & GUICtrlRead($atap_arbeitsplanname_input) & " erfolgreich dubliziert.") Local $dateiindex = _GUICtrlListView_GetItemCount($atap_listview) ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() _GUICtrlListView_SetItemSelected($atap_listview, $dateiindex, True, True) ap_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() GUICtrlSetState($atap_listview, $GUI_FOCUS) Else ;~ ansonsten MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf ;~ ==>>EndIf app_lese_arbeitsplaene_aus_db_und_schreibe_in_combobox() EndFunc ;==>ap_dublizieren Func ap_aendern() Local $Row, $Query Local $selected_items = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected_items = 1 Then Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atap_listview) Local $check_input = True If GUICtrlRead($atap_arbeitsplanid_input) = "" Then $check_input = False ElseIf GUICtrlRead($atap_arbeitsplanname_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") Return 0 EndIf ;~ If GUICtrlRead($atap_geplantestartzeit_input) <> "" Then ;~ If StringLen(GUICtrlRead($atap_geplantestartzeit_input)) <> 5 Then ;~ MsgBox(48, "Fehler", "Es ist ein Fehler bei der Eingabe der geplanten Startzeit aufgetreten." & @CRLF & "Beachten Sie die unten stehende Information oder schauen Sie in die Hilfe.") ;~ Return 0 ;~ EndIf ;~ EndIf ConsoleWrite("~~~" & @CR & $abzusetzender_query & @CR & "~~~" & @CR) ; ############################# FALL 1 ############################# FALL 1 ############################# FALL 1 ############################# If GUICtrlRead($atap_geplantestartzeit_input) = "" And GUICtrlRead($atap_status_checkbox) = $GUI_UNCHECKED Then ConsoleWrite("Fall 1" & @CR) If _SQLite_Exec($DB, "UPDATE arbeitsplaene SET arbeitsplan_name='" & GUICtrlRead($atap_arbeitsplanname_input) & "', status='Inaktiv' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, "DELETE FROM aufgabenliste WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ; ############################# FALL 2 ############################# FALL 2 ############################# FALL 2 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) <> "" And GUICtrlRead($atap_status_checkbox) = $GUI_UNCHECKED Then ConsoleWrite("Fall2" & @CR) MsgBox(64, "INFO", "Die geplante Startzeit wird nicht gesetzt!" & @CR & "Eine geplante Startzeit kann nur angegeben werden, wenn der Arbeitsplan-Status Aktiv gesetzt ist/wird!") If _SQLite_Exec($DB, "UPDATE arbeitsplaene SET arbeitsplan_name='" & GUICtrlRead($atap_arbeitsplanname_input) & "', status='Inaktiv' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, "DELETE FROM aufgabenliste WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ; ############################# FALL 3 ############################# FALL 3 ############################# FALL 3 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) = "" And GUICtrlRead($atap_status_checkbox) = $GUI_CHECKED Then ConsoleWrite("Fall 3" & @CR) MsgBox(64, "INFO", "Der Arbeitsplan-Status wird Inaktiv gesetzt!" & @CR & "Geben Sie eine geplante Startzeit an um einen Arbeitsplan aktiv zu schalten!") If _SQLite_Exec($DB, "UPDATE arbeitsplaene SET arbeitsplan_name='" & GUICtrlRead($atap_arbeitsplanname_input) & "', status='Inaktiv' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, "DELETE FROM aufgabenliste WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ; ############################# FALL 4 ############################# FALL 4 ############################# FALL 4 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) <> "" And GUICtrlRead($atap_status_checkbox) = $GUI_CHECKED Then ConsoleWrite("Fall 4" & @CR) Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atap_listview) If _SQLite_Exec($DB, "UPDATE aufgabenliste SET geplante_startzeit=NULL WHERE arbeitsplan_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Query($DB, "SELECT arbeitsplan_id FROM aufgabenliste WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_FetchData($Query, $Row) <> 0 Then ; ==>> wenn ein Fehler (sprich kein AP in Aufgabenliste vorhanden), dann ;~ Local $uform_uhrzeit = StringMid(GUICtrlRead($atap_geplantestartzeit_input), 1, 2) & StringMid(GUICtrlRead($atap_geplantestartzeit_input), 4, 2) ;~ If _SQLite_Query($DB, "SELECT geplante_startzeit FROM aufgabenliste WHERE geplante_startzeit=" & $uform_uhrzeit, $Query) <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf ;~ While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ If $Row[0] = $uform_uhrzeit Then ;~ MsgBox(48, "Fehler", "Die Geplante Startzeit ist bereits vorhanden. Bitte wählen Sie eine andere.") ;~ Return 0 ;~ EndIf ;~ WEnd If _SQLite_Exec($DB, "UPDATE arbeitsplaene SET arbeitsplan_name='" & GUICtrlRead($atap_arbeitsplanname_input) & "', status='Aktiv' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, "INSERT INTO aufgabenliste VALUES(NULL, '" & GUICtrlRead($atap_geplantestartzeit_input) & "', NULL, '" & GUICtrlRead($atap_arbeitsplanid_input) & "', NULL)") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf $Row[0] = GUICtrlRead($atap_arbeitsplanid_input) Then ;~ Local $uform_uhrzeit = StringMid(GUICtrlRead($atap_geplantestartzeit_input), 1, 2) & StringMid(GUICtrlRead($atap_geplantestartzeit_input), 4, 2) ;~ If _SQLite_Query($DB, "SELECT geplante_startzeit FROM aufgabenliste WHERE geplante_startzeit=" & $uform_uhrzeit, $Query) <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf ;~ While _SQLite_FetchData($Query, $Row) = $SQLITE_OK ;~ If $Row[0] = $uform_uhrzeit Then ;~ MsgBox(48, "Fehler", "Die Geplante Startzeit ist bereits vorhanden. Bitte wählen Sie eine andere.") ;~ Return 0 ;~ EndIf ;~ WEnd If _SQLite_Exec($DB, "UPDATE arbeitsplaene SET arbeitsplan_name='" & GUICtrlRead($atap_arbeitsplanname_input) & "', status='Aktiv' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ;~ MsgBox(0,"",GUICtrlRead($atap_geplantestartzeit_input)) If _SQLite_Exec($DB, "UPDATE aufgabenliste SET geplante_startzeit='" & GUICtrlRead($atap_geplantestartzeit_input) & "' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf _SQLite_QueryFinalize($Query) EndIf MsgBox(0, "", "Arbeitsplan: " & GUICtrlRead($atap_arbeitsplanid_input) & " erfolgreich geändert.") Local $selected_items2 = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected_items2 = 1 Then Local $dateiindex = _GUICtrlListView_GetSelectionMark($atap_listview) EndIf ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() _GUICtrlListView_SetItemSelected($atap_listview, $dateiindex, True, True) ap_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() GUICtrlSetState($atap_listview, $GUI_FOCUS) Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf EndFunc ;==>ap_aendern Func ap_hinzufuegen() Local $Row, $Query Local $check_input = True If GUICtrlRead($atap_arbeitsplanname_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") Return 0 EndIf ;~ If GUICtrlRead($atap_geplantestartzeit_input) <> "" Then ;~ If StringLen(GUICtrlRead($atap_geplantestartzeit_input)) <> 5 Then ;~ MsgBox(48, "Fehler", "Es ist ein Fehler bei der Eingabe der geplanten Startzeit aufgetreten." & @CRLF & "Beachten Sie die unten stehende Information oder schauen Sie in die Hilfe.") ;~ Return 0 ;~ EndIf ;~ EndIf ; ############################# FALL 1 ############################# FALL 1 ############################# FALL 1 ############################# If GUICtrlRead($atap_geplantestartzeit_input) = "" And GUICtrlRead($atap_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Inaktiv')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ; ############################# FALL 2 ############################# FALL 2 ############################# FALL 2 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) <> "" And GUICtrlRead($atap_status_checkbox) = $GUI_UNCHECKED Then MsgBox(64, "INFO", "Die geplante Startzeit wird nicht gesetzt!" & @CR & "Eine geplante Startzeit kann nur angegeben werden, wenn der Arbeitsplan-Status Aktiv gesetzt ist/wird!") If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Inaktiv')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ; ############################# FALL 3 ############################# FALL 3 ############################# FALL 3 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) = "" And GUICtrlRead($atap_status_checkbox) = $GUI_CHECKED Then MsgBox(64, "INFO", "Der Arbeitsplan-Status wird Inaktiv gesetzt!" & @CR & "Geben Sie eine geplante Startzeit an um einen Arbeitsplan aktiv zu schalten!") If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Inaktiv')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ; ############################# FALL 4 ############################# FALL 4 ############################# FALL 4 ############################# ElseIf GUICtrlRead($atap_geplantestartzeit_input) <> "" And GUICtrlRead($atap_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitsplaene VALUES(NULL, '" & GUICtrlRead($atap_arbeitsplanname_input) & "', 'Aktiv')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $lastinsertrowid = _SQLite_LastInsertRowID() If _SQLite_Exec($DB, "INSERT INTO aufgabenliste VALUES(NULL, '" & GUICtrlRead($atap_geplantestartzeit_input) & "', NULL, " & $lastinsertrowid & ", NULL)") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($DB, $abzusetzender_query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Arbeitsplan: " & GUICtrlRead($atap_arbeitsplanname_input) & " erfolgreich erstellt.") app_lese_arbeitsplaene_aus_db_und_schreibe_in_combobox() Local $dateiindex = _GUICtrlListView_GetItemCount($atap_listview) ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() _GUICtrlListView_SetItemSelected($atap_listview, $dateiindex, True, True) ap_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() GUICtrlSetState($atap_listview, $GUI_FOCUS) EndFunc ;==>ap_hinzufuegen Func ap_loeschen() Local $Row, $Query Local $selected_items = _GUICtrlListView_GetSelectedCount($atap_listview) If $selected_items = 1 Then Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atap_listview) If MsgBox(4, "", "Wollen Sie den Arbeitsplan: " & GUICtrlRead($atap_arbeitsplanname_input) & " wirklich löschen?") = 6 Then If _SQLite_Exec($DB, "DELETE FROM arbeitsplaene WHERE arbeitsplan_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf MsgBox(0, "", "Arbeitsplan: " & GUICtrlRead($atap_arbeitsplanname_input) & " erfolgreich gelöscht.") ap_lese_arbeitsplaene_aus_db_und_stelle_in_listview_dar() ap_clear_inputs() Else Return 0 EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf app_lese_arbeitsplaene_aus_db_und_schreibe_in_combobox() EndFunc ;==>ap_loeschen Func wochentag_errechnen() Local $wochentag Local $i = 0 If GUICtrlRead($s_montag_checkbox) = $GUI_CHECKED Then $wochentag = $wochentag & 2 EndIf If GUICtrlRead($s_dienstag_checkbox) = $GUI_CHECKED Then $wochentag = $wochentag & 3 EndIf If GUICtrlRead($s_mittwoch_checkbox) = $GUI_CHECKED Then $wochentag = $wochentag & 4 EndIf If GUICtrlRead($s_donnerstag_checkbox) = $GUI_CHECKED Then $wochentag = $wochentag & 5 EndIf If GUICtrlRead($s_freitag_checkbox) = $GUI_CHECKED Then $wochentag = $wochentag & 6 EndIf If GUICtrlRead($s_samstag_checkbox) = $GUI_CHECKED Then $wochentag = $wochentag & 7 EndIf If GUICtrlRead($s_sonntag_checkbox) = $GUI_CHECKED Then $wochentag = $wochentag & 1 EndIf $i = 1 Local $z = StringLen($wochentag) While ($i < $z * 2 - 1) $wochentag = _StringInsert($wochentag, ",", $i) $i = $i + 2 WEnd Return $wochentag ;~ If $wochentag = "2,3,4,5,6,7,1" Then ;~ $wochentag = "*" ;~ EndIf ;~ ConsoleWrite($wochentag & @CR) EndFunc ;==>wochentag_errechnen Func zeitplan_eintragen() Local $Row, $Query If GUICtrlRead($s1) = $GUI_UNCHECKED And GUICtrlRead($s2) = $GUI_UNCHECKED Then MsgBox(64, "INFO", "Um einen Zeitplan zu setzen müssen Sie eine Eingabe tätigen.") Return 0 EndIf Local $wochentag = wochentag_errechnen() If $wochentag = "" Then MsgBox(48, "Fehler", "Sie müssen mindestens einen Wochentag angeben!") Return 0 EndIf If GUICtrlRead($s1) = $GUI_CHECKED Then If GUICtrlRead($atap_arbeitsplanid_input) <> "" Then If _SQLite_Query($DB, "SELECT arbeitsplan_id FROM zeitplan WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_FetchData($Query, $Row) = $SQLITE_OK Then ;~ If _SQLite_Exec($DB, "UPDATE zeitplan SET minute=NULL, wochentag='" & $wochentag & "', von='" & GUICtrlRead($s1_date) & "', bis='" & GUICtrlRead($s1_date) & "' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf $abzusetzender_query = "UPDATE zeitplan SET minute=NULL, wochentag='" & $wochentag & "', von='" & GUICtrlRead($s1_date) & "', bis='" & GUICtrlRead($s1_date) & "' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input) Else ;~ If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(" & GUICtrlRead($atap_arbeitsplanid_input) & ", NULL, '" & $wochentag & "', '" & GUICtrlRead($s1_date) & "', '" & GUICtrlRead($s1_date) & "')") <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf $abzusetzender_query = "INSERT INTO zeitplan VALUES(" & GUICtrlRead($atap_arbeitsplanid_input) & ", NULL, '" & $wochentag & "', '" & GUICtrlRead($s1_date) & "', '" & GUICtrlRead($s1_date) & "')" EndIf _SQLite_QueryFinalize($Query) Else ;~ ConsoleWrite("else" & @CR) ;~ If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(NULL, NULL, '" & $wochentag & "', '" & GUICtrlRead($s1_date) & "', '" & GUICtrlRead($s1_date) & "')") <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf $abzusetzender_query = "INSERT INTO zeitplan VALUES(NULL, NULL, '" & $wochentag & "', '" & GUICtrlRead($s1_date) & "', '" & GUICtrlRead($s1_date) & "')" ;~ Local $lastinsertrowid_zeitplan = _SQLite_LastInsertRowID($DB) ;~ ConsoleWrite("zeitplan_eintragen # $lastinsertrowid_zeitplan: " & $lastinsertrowid_zeitplan) EndIf ElseIf GUICtrlRead($s2) = $GUI_CHECKED Then If GUICtrlRead($s2_combo) = "" Then MsgBox(48, "Fehler", "Sie müssen ein Minuteninvtervall angeben!") Return 0 EndIf If GUICtrlRead($atap_arbeitsplanid_input) <> "" Then If _SQLite_Query($DB, "SELECT arbeitsplan_id FROM zeitplan WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input), $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_FetchData($Query, $Row) = $SQLITE_OK Then ;~ If _SQLite_Exec($DB, "UPDATE zeitplan SET minute='" & GUICtrlRead($s2_combo) & "', wochentag='" & $wochentag & "', von='" & GUICtrlRead($s2_von_date) & "', bis='" & GUICtrlRead($s2_bis_date) & "' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input)) <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf $abzusetzender_query = "UPDATE zeitplan SET minute='" & GUICtrlRead($s2_combo) & "', wochentag='" & $wochentag & "', von='" & GUICtrlRead($s2_von_date) & "', bis='" & GUICtrlRead($s2_bis_date) & "' WHERE arbeitsplan_id=" & GUICtrlRead($atap_arbeitsplanid_input) Else ;~ If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(" & GUICtrlRead($atap_arbeitsplanid_input) & ", '" & GUICtrlRead($s2_combo) & "', '" & $wochentag & "', '" & GUICtrlRead($s2_von_date) & "', '" & GUICtrlRead($s2_bis_date) & "')") <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf $abzusetzender_query = "INSERT INTO zeitplan VALUES(" & GUICtrlRead($atap_arbeitsplanid_input) & ", '" & GUICtrlRead($s2_combo) & "', '" & $wochentag & "', '" & GUICtrlRead($s2_von_date) & "', '" & GUICtrlRead($s2_bis_date) & "')" EndIf _SQLite_QueryFinalize($Query) Else ;~ If _SQLite_Exec($DB, "INSERT INTO zeitplan VALUES(NULl, NULL, '" & $wochentag & "', '" & GUICtrlRead($s1_date) & "', '" & GUICtrlRead($s1_date) & "')") <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf $abzusetzender_query = "INSERT INTO zeitplan VALUES(NULl, NULL, '" & $wochentag & "', '" & GUICtrlRead($s1_date) & "', '" & GUICtrlRead($s1_date) & "')" ;~ Local $lastinsertrowid_zeitplan = _SQLite_LastInsertRowID($DB) EndIf EndIf erstmalig_einplanen($wochentag) close_startzeit() EndFunc ;==>zeitplan_eintragen ;s1 ;~ConsoleWrite(" RadioButton " & @TAB & @TAB & " -> " & @TAB & "Wochentage" & @TAB & " -> " & @TAB & "Zeiten" & @CR) ;~ConsoleWrite("Feste Uhrzeit setzen" & @TAB & " -> " & @TAB & GUICtrlRead($s_montag_checkbox) & @TAB & @TAB & " -> " & @TAB & GUICtrlRead($s1_date) & @CR & @TAB & @TAB & @TAB & @TAB & GUICtrlRead($s_dienstag_checkbox) & @CR & @TAB & @TAB & @TAB & @TAB & GUICtrlRead($s_mittwoch_checkbox) & @CR & @TAB & @TAB & @TAB & @TAB & GUICtrlRead($s_donnerstag_checkbox) & @CR & @TAB & @TAB & @TAB & @TAB & GUICtrlRead($s_freitag_checkbox) & @CR & @TAB & @TAB & @TAB & @TAB & GUICtrlRead($s_samstag_checkbox) & @CR & @TAB & @TAB & @TAB & @TAB & GUICtrlRead($s_sonntag_checkbox) & @TAB) ;s2 ;~ConsoleWrite(" RadioButton " & @TAB & " -> " & @TAB & "Wochentage" & @TAB & " -> " & @TAB & "Zeiten" & @CR) ;~ConsoleWrite("Alle X Min" & @TAB & " -> " & @TAB & GUICtrlRead($s_montag_checkbox) & @TAB & @TAB & " -> " & @TAB & GUICtrlRead($s2_von_date) & @CR & @TAB & @TAB & @TAB & GUICtrlRead($s_dienstag_checkbox) & @TAB & @TAB & @TAB & GUICtrlRead($s2_bis_date) & @CR & @TAB & @TAB & @TAB & GUICtrlRead($s_mittwoch_checkbox) & @TAB & @TAB & @TAB & GUICtrlRead($s2_combo) & @CR & @TAB & @TAB & @TAB & GUICtrlRead($s_donnerstag_checkbox) & @CR & @TAB & @TAB & @TAB & GUICtrlRead($s_freitag_checkbox) & @CR & @TAB & @TAB & @TAB & GUICtrlRead($s_samstag_checkbox) & @CR & @TAB & @TAB & @TAB & GUICtrlRead($s_sonntag_checkbox) & @TAB) Func _s_alle_markieren() GUICtrlSetState($s_montag_checkbox, $GUI_CHECKED) GUICtrlSetState($s_dienstag_checkbox, $GUI_CHECKED) GUICtrlSetState($s_mittwoch_checkbox, $GUI_CHECKED) GUICtrlSetState($s_donnerstag_checkbox, $GUI_CHECKED) GUICtrlSetState($s_freitag_checkbox, $GUI_CHECKED) GUICtrlSetState($s_samstag_checkbox, $GUI_CHECKED) GUICtrlSetState($s_sonntag_checkbox, $GUI_CHECKED) EndFunc ;==>_s_alle_markieren Func _s_alle_abwaehlen() GUICtrlSetState($s_montag_checkbox, $GUI_UNCHECKED) GUICtrlSetState($s_dienstag_checkbox, $GUI_UNCHECKED) GUICtrlSetState($s_mittwoch_checkbox, $GUI_UNCHECKED) GUICtrlSetState($s_donnerstag_checkbox, $GUI_UNCHECKED) GUICtrlSetState($s_freitag_checkbox, $GUI_UNCHECKED) GUICtrlSetState($s_samstag_checkbox, $GUI_UNCHECKED) GUICtrlSetState($s_sonntag_checkbox, $GUI_UNCHECKED) EndFunc ;==>_s_alle_abwaehlen Func open_startzeit() ;~ Local $selected_items = _GUICtrlListView_GetSelectedCount($atap_listview) ;~ If $selected_items = 1 Then GUISetState(@SW_SHOW, $startzeitfenster) GUISwitch($startzeitfenster) ;~ Else ;~ MsgBox(48, "FEHLER", "Sie müssen erst einen Arbeitsplan auswählen!") ;~ EndIf EndFunc ;==>open_startzeit Func close_startzeit() GUISetState(@SW_HIDE, $startzeitfenster) GUISwitch($admintoolfenster) EndFunc ;==>close_startzeit Func _s1_ausklappen() _s2_zuklappen() GUICtrlSetState($s1_startzeit_label, $GUI_SHOW) GUICtrlSetState($s1_date, $GUI_SHOW) EndFunc ;==>_s1_ausklappen Func _s1_zuklappen() GUICtrlSetState($s1_startzeit_label, $GUI_HIDE) GUICtrlSetState($s1_date, $GUI_HIDE) EndFunc ;==>_s1_zuklappen Func _s2_ausklappen() _s1_zuklappen() GUICtrlSetState($s2_von_label, $GUI_SHOW) GUICtrlSetState($s2_von_date, $GUI_SHOW) GUICtrlSetState($s2_bis_label, $GUI_SHOW) GUICtrlSetState($s2_bis_date, $GUI_SHOW) GUICtrlSetState($s2_alle_label, $GUI_SHOW) GUICtrlSetState($s2_combo, $GUI_SHOW) GUICtrlSetState($s2_minuten_label, $GUI_SHOW) EndFunc ;==>_s2_ausklappen Func _s2_zuklappen() GUICtrlSetState($s2_von_label, $GUI_HIDE) GUICtrlSetState($s2_von_date, $GUI_HIDE) GUICtrlSetState($s2_bis_label, $GUI_HIDE) GUICtrlSetState($s2_bis_date, $GUI_HIDE) GUICtrlSetState($s2_alle_label, $GUI_HIDE) GUICtrlSetState($s2_combo, $GUI_HIDE) GUICtrlSetState($s2_minuten_label, $GUI_HIDE) EndFunc ;==>_s2_zuklappen ;====================================== Arbeitspläne verwalten ====================================== ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Arbeitspunkte verwalten ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func app_lese_arbeitsplaene_aus_db_und_schreibe_in_combobox() Local $Row, $Query _GUICtrlComboBox_ResetContent($atapp_combo) If _SQLite_Query($DB, "SELECT arbeitsplan_id, arbeitsplan_name FROM arbeitsplaene", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK _GUICtrlComboBox_AddString($atapp_combo, $Row[0] & " | " & $Row[1]) WEnd _SQLite_QueryFinalize($Query) EndFunc ;==>app_lese_arbeitsplaene_aus_db_und_schreibe_in_combobox Func app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() Local $Row, $Query _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($atapp_listview)) Local $auswahl = _GUICtrlComboBox_GetEditText($atapp_combo) If $auswahl <> "" Then Local $auswahl_split = StringSplit($auswahl, " | ", 1) If _SQLite_Query($DB, "SELECT arbeitspunkt_id, laufende_nr, arbeitspunkt_name, befehl, parameter, status FROM arbeitspunkte WHERE arbeitsplan_id=" & $auswahl_split[1] & " ORDER BY laufende_nr ASC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf _GUICtrlListView_BeginUpdate($atapp_listview) While _SQLite_FetchData($Query, $Row) = $SQLITE_OK Local $array = StringSplit($Row[3], "\") GUICtrlCreateListViewItem($Row[0] & "|" & $Row[1] & "|" & $Row[2] & "|" & $Row[3] & "|" & $array[$array[0]] & "|" & $Row[4] & "|" & $Row[5], $atapp_listview) WEnd _SQLite_QueryFinalize($Query) _GUICtrlListView_EndUpdate($atapp_listview) EndIf EndFunc ;==>app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar Edited November 29, 2012 by MikeWenzel
Yaerox Posted November 29, 2012 Author Posted November 29, 2012 (edited) expandcollapse popupFunc app_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Local $Row, $Query Local $selected_items = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items = 1 Then Local $dateiindex = _GUICtrlListView_GetSelectionMark($atapp_listview) If $dateiindex <> -1 Then If _SQLite_Query($DB, "SELECT laufende_nr, arbeitspunkt_name, befehl, parameter, status, funktionstyp FROM arbeitspunkte WHERE arbeitspunkt_id=" & _GUICtrlListView_GetItemText($atapp_listview, $dateiindex, 0), $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[5] = 'Intern' Then GUICtrlSetData($atapp_funktionstyp_combo, "Interne Funktionen") _interne_inputs_ausklappen() GUICtrlSetData($atapp_laufendenr_input, $Row[0]) GUICtrlSetData($atapp_arbeitspunktname_input, $Row[1]) If $Row[4] = "Aktiv" Then GUICtrlSetState($atapp_status_checkbox, $GUI_CHECKED) Else GUICtrlSetState($atapp_status_checkbox, $GUI_UNCHECKED) EndIf ElseIf $Row[5] = 'Extern' Then GUICtrlSetData($atapp_funktionstyp_combo, "Externe Funktionen") _externe_inputs_ausklappen() Local $array = StringSplit($Row[2], "") GUICtrlSetData($atapp_laufendenr_input, $Row[0]) GUICtrlSetData($atapp_arbeitspunktname_input, $Row[1]) GUICtrlSetData($atapp_pfad_input, $Row[2]) GUICtrlSetData($atapp_datei_input, $array[$array[0]]) GUICtrlSetData($atapp_parameter_input, $Row[3]) If $Row[4] = "Aktiv" Then GUICtrlSetState($atapp_status_checkbox, $GUI_CHECKED) Else GUICtrlSetState($atapp_status_checkbox, $GUI_UNCHECKED) EndIf Else MsgBox(48, "Fehler", "Es ist ein Fehler aufgetreten: Kein Funktionstyp gefunden") EndIf WEnd _SQLite_QueryFinalize($Query) EndIf EndIf EndFunc ;==>app_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar Func app_stelle_listviewinternauswahl_in_inputs_dar() Local $selected_items = _GUICtrlListView_GetSelectedCount($atapp_listview_intern) If $selected_items = 1 Then Local $dateiindex = _GUICtrlListView_GetSelectionMark($atapp_listview_intern) If $dateiindex <> -1 Then GUICtrlSetData($atapp_arbeitspunktname_input, _GUICtrlListView_GetItemText($atapp_listview_intern, $dateiindex)) EndIf EndIf EndFunc ;==>app_stelle_listviewinternauswahl_in_inputs_dar Func _interne_inputs_ausklappen() _externe_inputs_zuklappen() GUICtrlSetState($atapp_laufendenr_label, $GUI_SHOW) GUICtrlSetState($atapp_laufendenr_input, $GUI_SHOW) GUICtrlSetState($atapp_arbeitspunktname_label, $GUI_SHOW) GUICtrlSetState($atapp_arbeitspunktname_input, $GUI_SHOW) GUICtrlSetStyle($atapp_arbeitspunktname_input, $ES_READONLY) GUICtrlSetState($atapp_status_label, $GUI_SHOW) GUICtrlSetState($atapp_status_checkbox, $GUI_SHOW) GUICtrlSetState($atapp_listview_intern, $GUI_SHOW) EndFunc ;==>_interne_inputs_ausklappen Func _interne_inputs_zuklappen() GUICtrlSetState($atapp_laufendenr_label, $GUI_HIDE) GUICtrlSetState($atapp_laufendenr_input, $GUI_HIDE) GUICtrlSetState($atapp_arbeitspunktname_label, $GUI_HIDE) GUICtrlSetState($atapp_arbeitspunktname_input, $GUI_HIDE) GUICtrlSetState($atapp_status_label, $GUI_HIDE) GUICtrlSetState($atapp_status_checkbox, $GUI_HIDE) GUICtrlSetState($atapp_listview_intern, $GUI_HIDE) EndFunc ;==>_interne_inputs_zuklappen Func _externe_inputs_ausklappen() _interne_inputs_zuklappen() GUICtrlSetState($atapp_laufendenr_label, $GUI_SHOW) GUICtrlSetState($atapp_laufendenr_input, $GUI_SHOW) GUICtrlSetState($atapp_arbeitspunktname_label, $GUI_SHOW) GUICtrlSetState($atapp_arbeitspunktname_input, $GUI_SHOW) GUICtrlSetStyle($atapp_arbeitspunktname_input, $GUI_SS_DEFAULT_INPUT) GUICtrlSetData($atapp_arbeitspunktname_input, "") GUICtrlSetState($atapp_status_label, $GUI_SHOW) GUICtrlSetState($atapp_status_checkbox, $GUI_SHOW) GUICtrlSetState($atapp_pfad_label, $GUI_SHOW) GUICtrlSetState($atapp_pfad_input, $GUI_SHOW) GUICtrlSetState($atapp_pfad_button, $GUI_SHOW) GUICtrlSetState($atapp_datei_label, $GUI_SHOW) GUICtrlSetState($atapp_datei_input, $GUI_SHOW) GUICtrlSetState($atapp_parameter_label, $GUI_SHOW) GUICtrlSetState($atapp_parameter_input, $GUI_SHOW) EndFunc ;==>_externe_inputs_ausklappen Func _externe_inputs_zuklappen() GUICtrlSetState($atapp_laufendenr_label, $GUI_HIDE) GUICtrlSetState($atapp_laufendenr_input, $GUI_HIDE) GUICtrlSetState($atapp_arbeitspunktname_label, $GUI_HIDE) GUICtrlSetState($atapp_arbeitspunktname_input, $GUI_HIDE) GUICtrlSetState($atapp_status_label, $GUI_HIDE) GUICtrlSetState($atapp_status_checkbox, $GUI_HIDE) GUICtrlSetState($atapp_pfad_label, $GUI_HIDE) GUICtrlSetState($atapp_pfad_input, $GUI_HIDE) GUICtrlSetState($atapp_pfad_button, $GUI_HIDE) GUICtrlSetState($atapp_datei_label, $GUI_HIDE) GUICtrlSetState($atapp_datei_input, $GUI_HIDE) GUICtrlSetState($atapp_parameter_label, $GUI_HIDE) GUICtrlSetState($atapp_parameter_input, $GUI_HIDE) EndFunc ;==>_externe_inputs_zuklappen Func app_clear_inputs() GUICtrlSetData($atapp_laufendenr_input, "") GUICtrlSetData($atapp_arbeitspunktname_input, "") GUICtrlSetData($atapp_pfad_input, "") GUICtrlSetData($atapp_datei_input, "") GUICtrlSetData($atapp_parameter_input, "") GUICtrlSetState($atapp_status_checkbox, $GUI_UNCHECKED) EndFunc ;==>app_clear_inputs Func app_pfad_auswaehlen() If GUICtrlRead($atapp_pfad_input) = "" Then GUICtrlSetData($atapp_pfad_input, FileOpenDialog("", @DesktopDir, "All (*.*)", 1 + 2)) If GUICtrlRead($atapp_pfad_input) = "" Then GUICtrlSetData($atapp_datei_input, "") Else Local $array = StringSplit(GUICtrlRead($atapp_pfad_input), "") GUICtrlSetData($atapp_datei_input, $array[$array[0]]) EndIf Else Local $msg = MsgBox(4, "", "Eingabe verwerfen und Pfad auswählen?") If $msg = 6 Then GUICtrlSetData($atapp_pfad_input, FileOpenDialog("", @DesktopDir, "All (*.*)", 1 + 2)) If GUICtrlRead($atapp_pfad_input) = "" Then GUICtrlSetData($atapp_datei_input, "") Else Local $array = StringSplit(GUICtrlRead($atapp_pfad_input), "") GUICtrlSetData($atapp_datei_input, $array[$array[0]]) EndIf ElseIf $msg = 7 Then Local $array = StringSplit(GUICtrlRead($atapp_pfad_input), "") GUICtrlSetData($atapp_datei_input, $array[$array[0]]) EndIf EndIf EndFunc ;==>app_pfad_auswaehlen Func app_hinzufuegen() Local $Row, $Query Local $auswahl = _GUICtrlComboBox_GetEditText($atapp_combo) If $auswahl <> "" Then If GUICtrlRead($atapp_funktionstyp_combo) = "Externe Funktionen" Then Local $auswahl_split = StringSplit($auswahl, " | ", 1) Local $check_input = True If GUICtrlRead($atapp_laufendenr_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_arbeitspunktname_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_pfad_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Bitte alle durch * markierten Felder ausfüllen um einen Arbeitspunkt hinzuzufügen.") Return 0 EndIf If StringMid(GUICtrlRead($atapp_arbeitspunktname_input), 1, 1) = "_" Then MsgBox(48, "Fehler", "Arbeitspunkte dürfen nicht mit einem '_' beginnen!") Return 0 EndIf If _SQLite_Query($DB, "SELECT laufende_nr FROM arbeitspunkte WHERE laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " AND arbeitsplan_id=" & $auswahl_split[1], $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_laufendenr_input) Then MsgBox(48, "Fehler", "Die Laufende Nr. ist bereits vorhanden. Bitte wählen Sie eine andere.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If GUICtrlRead($atapp_parameter_input) = "" And GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', NULL, 'Inaktiv', " & $auswahl_split[1] & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', " & GUICtrlRead($atapp_laufendenr_input) & ")") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) <> "" And GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', '" & GUICtrlRead($atapp_parameter_input) & "', 'Inaktiv', " & $auswahl_split[1] & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', " & GUICtrlRead($atapp_laufendenr_input) & ")") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) = "" And GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', NULL, 'Aktiv', " & $auswahl_split[1] & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', " & GUICtrlRead($atapp_laufendenr_input) & ")") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) <> "" And GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', '" & GUICtrlRead($atapp_parameter_input) & "', 'Aktiv', " & $auswahl_split[1] & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', " & GUICtrlRead($atapp_laufendenr_input) & ")") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " erfolgreich erstellt.") app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() app_clear_inputs() Else Local $auswahl_split = StringSplit($auswahl, " | ", 1) Local $check_input = True If GUICtrlRead($atapp_laufendenr_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_arbeitspunktname_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Bitte alle durch * markierten Felder ausfüllen um einen Arbeitspunkt hinzuzufügen.") Return 0 EndIf If _SQLite_Query($DB, "SELECT laufende_nr FROM arbeitspunkte WHERE laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " AND arbeitsplan_id=" & $auswahl_split[1], $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_laufendenr_input) Then MsgBox(48, "Fehler", "Die Laufende Nr. ist bereits vorhanden. Bitte wählen Sie eine andere.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If _SQLite_Query($DB, "SELECT arbeitspunkt_name FROM arbeitspunkte WHERE arbeitsplan_id=" & $auswahl_split[1], $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_arbeitspunktname_input) Then MsgBox(48, "Fehler", "Die interne Funktion " & GUICtrlRead($atapp_arbeitspunktname_input) & " ist bereits im Arbeitsplan vorhanden." & @CR & "Interne Funktionen können sich maximal ein mal in einem Arbeitsplan befinden!") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Intern', NULL, 'Inaktiv', " & $auswahl_split[1] & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', NULL, " & GUICtrlRead($atapp_laufendenr_input) & ")") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Intern', NULL, 'Aktiv', " & $auswahl_split[1] & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', NULL, " & GUICtrlRead($atapp_laufendenr_input) & ")") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " erfolgreich erstellt.") app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() app_clear_inputs() EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf EndFunc ;==>app_hinzufuegen Func app_aendern() Local $Row, $Query Local $auswahl = _GUICtrlComboBox_GetEditText($atapp_combo) If $auswahl <> "" Then If GUICtrlRead($atapp_funktionstyp_combo) = "Externe Funktionen" Then Local $selected_items = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items = 1 Then Local $check_input = True If GUICtrlRead($atapp_laufendenr_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_arbeitspunktname_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_pfad_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") Return 0 EndIf If StringMid(GUICtrlRead($atapp_arbeitspunktname_input), 1, 1) = "_" Then MsgBox(48, "Fehler", "Arbeitspunkte dürfen nicht mit einem '_' beginnen!") Return 0 EndIf Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atapp_listview) If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET laufende_nr=NULL WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $auswahl_split = StringSplit($auswahl, " | ", 1) If _SQLite_Query($DB, "SELECT laufende_nr FROM arbeitspunkte WHERE laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " AND arbeitsplan_id=" & $auswahl_split[1], $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_laufendenr_input) Then MsgBox(48, "Fehler", "Die Laufende Nr. ist bereits vorhanden. Bitte wählen Sie eine andere.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If GUICtrlRead($atapp_parameter_input) = "" And GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET funktionstyp='Extern', parameter=NULL, status='Inaktiv', arbeitspunkt_name='" & GUICtrlRead($atapp_arbeitspunktname_input) & "', befehl='" & GUICtrlRead($atapp_pfad_input) & "', laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) <> "" And GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET funktionstyp='Extern', parameter='" & GUICtrlRead($atapp_parameter_input) & "', status='Inaktiv', arbeitspunkt_name='" & GUICtrlRead($atapp_arbeitspunktname_input) & "', befehl='" & GUICtrlRead($atapp_pfad_input) & "', laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) = "" And GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET funktionstyp='Extern', parameter=NULL, status='Aktiv', arbeitspunkt_name='" & GUICtrlRead($atapp_arbeitspunktname_input) & "', befehl='" & GUICtrlRead($atapp_pfad_input) & "', laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) <> "" And GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET funktionstyp='Extern', parameter='" & GUICtrlRead($atapp_parameter_input) & "', status='Aktiv', arbeitspunkt_name='" & GUICtrlRead($atapp_arbeitspunktname_input) & "', befehl='" & GUICtrlRead($atapp_pfad_input) & "', laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " erfolgreich geändert.") Local $selected_items2 = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items2 = 1 Then Local $dateiindex = _GUICtrlListView_GetSelectionMark($atapp_listview) EndIf app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() _GUICtrlListView_SetItemSelected($atapp_listview, $dateiindex) app_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitspunkt aus.") EndIf Else Local $selected_items = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items = 1 Then Local $check_input = True If GUICtrlRead($atapp_laufendenr_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_arbeitspunktname_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") Return 0 EndIf Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atapp_listview) If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET laufende_nr=NULL WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $auswahl_split = StringSplit($auswahl, " | ", 1) If _SQLite_Query($DB, "SELECT laufende_nr FROM arbeitspunkte WHERE laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " AND arbeitsplan_id=" & $auswahl_split[1], $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_laufendenr_input) Then MsgBox(48, "Fehler", "Die Laufende Nr. ist bereits vorhanden. Bitte wählen Sie eine andere.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atapp_listview) If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET arbeitspunkt_name=NULL WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Query($DB, "SELECT arbeitspunkt_name FROM arbeitspunkte WHERE arbeitsplan_id=" & $auswahl_split[1], $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_arbeitspunktname_input) Then MsgBox(48, "Fehler", "Die interne Funktion " & GUICtrlRead($atapp_arbeitspunktname_input) & " ist bereits im Arbeitsplan vorhanden." & @CR & "Interne Funktionen können sich maximal ein mal in einem Arbeitsplan befinden!") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET funktionstyp='Intern', parameter=NULL, status='Inaktiv', arbeitspunkt_name='" & GUICtrlRead($atapp_arbeitspunktname_input) & "', befehl=NULL, laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET funktionstyp='Intern', parameter=NULL, status='Aktiv', arbeitspunkt_name='" & GUICtrlRead($atapp_arbeitspunktname_input) & "', befehl=NULL, laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " erfolgreich geändert.") Local $selected_items2 = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items2 = 1 Then Local $dateiindex = _GUICtrlListView_GetSelectionMark($atapp_listview) EndIf app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() _GUICtrlListView_SetItemSelected($atapp_listview, $dateiindex) app_suche_in_der_db_nach_listviewauswahl_und_stelle_in_inputs_dar() Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitspunkt aus.") EndIf EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf EndFunc ;==>app_aendern Func app_loeschen() Local $Row, $Query Local $auswahl = _GUICtrlComboBox_GetEditText($atapp_combo) If $auswahl <> "" Then Local $selected_items = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items = 1 Then Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atapp_listview) If MsgBox(4, "", "Wollen Sie den Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " wirklich löschen?") = 6 Then If _SQLite_Exec($DB, "DELETE FROM arbeitspunkte WHERE arbeitspunkt_id=" & $selecteditemtext[1]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf MsgBox(0, "", "Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " erfolgreich gelöscht.") app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() app_clear_inputs() Else Return 0 EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitspunkt aus.") EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf EndFunc ;==>app_loeschen Func app_laufendenr_neu_nummerieren() Local $Row, $Query Local $auswahl = _GUICtrlComboBox_GetEditText($atapp_combo) If $auswahl <> "" Then If MsgBox(4, "", "Wenn sie neu nummerieren gehen alle nicht gespeicherten Daten verloren. Wirklich neu nummerieren?") = 6 Then Local $auswahl = _GUICtrlComboBox_GetEditText($atapp_combo) If $auswahl <> "" Then Local $auswahl_split = StringSplit($auswahl, " | ", 1) If _SQLite_Query($DB, "SELECT arbeitspunkt_id FROM arbeitspunkte WHERE arbeitsplan_id=" & $auswahl_split[1] & " ORDER BY laufende_nr ASC", $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf Local $lnr = 10 While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If _SQLite_Exec($DB, "UPDATE arbeitspunkte SET laufende_nr=" & $lnr & " WHERE arbeitsplan_id=" & $auswahl_split[1] & " AND arbeitspunkt_id=" & $Row[0]) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf $lnr = $lnr + 10 WEnd _SQLite_QueryFinalize($Query) EndIf MsgBox(0, "", "Die Arbeitspunkte wurden erfolgreich neu nummeriert.") app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() Else MsgBox(48, "Fehler", "Neu nummerieren fehlgeschlagen.") Return 0 EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf EndFunc ;==>app_laufendenr_neu_nummerieren Func app_in_anderen_ap_kopieren() Local $Row, $Query Local $auswahl = _GUICtrlComboBox_GetEditText($atapp_combo) If $auswahl <> "" Then If GUICtrlRead($atapp_funktionstyp_combo) = "Externe Funktionen" Then Local $auswahl_split = StringSplit($auswahl, " | ", 1) Local $selected_items = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items = 1 Then Local $msg = InputBox("Kopieren in einen anderen Arbeitsplan", "Bitte geben sie die Arbeitsplan ID an, in dem Sie diesen Arbeitspunkt kopieren möchten") If @error = 0 Then If $msg = $auswahl_split[1] Then app_hinzufuegen() Return 0 EndIf Local $auswahl_split = StringSplit($auswahl, " | ", 1) If _SQLite_Query($DB, "SELECT arbeitsplan_id FROM arbeitsplaene WHERE arbeitsplan_id=" & $msg, $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) If $Row[0] <> $msg Then MsgBox(48, "Fehler", "Der angegebene Arbeitsplan konnte nicht gefunden werden.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) ElseIf @error = 1 Then Return 0 EndIf Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atapp_listview) Local $check_input = True If GUICtrlRead($atapp_laufendenr_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_arbeitspunktname_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_pfad_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") Return 0 EndIf If _SQLite_Query($DB, "SELECT laufende_nr FROM arbeitspunkte WHERE laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " AND arbeitsplan_id=" & $msg, $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_laufendenr_input) Then MsgBox(48, "Fehler", "Die Laufende Nr. ist bereits vorhanden. Bitte wählen Sie eine andere.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If GUICtrlRead($atapp_parameter_input) = "" And GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', NULL, 'Inaktiv', " & $msg & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', '" & GUICtrlRead($atapp_laufendenr_input) & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) <> "" And GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', '" & GUICtrlRead($atapp_parameter_input) & "', 'Inaktiv', " & $msg & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', '" & GUICtrlRead($atapp_laufendenr_input) & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) = "" And GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', NULL, 'Aktiv', " & $msg & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', '" & GUICtrlRead($atapp_laufendenr_input) & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_parameter_input) <> "" And GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Extern', '" & GUICtrlRead($atapp_parameter_input) & "', 'Aktiv', " & $msg & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', '" & GUICtrlRead($atapp_pfad_input) & "', '" & GUICtrlRead($atapp_laufendenr_input) & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Der Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " konnte erfolgreich in den Arbeitsplan: " & $msg & " kopiert werden.") app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() app_clear_inputs() Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitspunkt aus.") EndIf Else ;HIER FEHLT NOCH EINIGES ... scheinbar nicht? Local $auswahl_split = StringSplit($auswahl, " | ", 1) Local $selected_items = _GUICtrlListView_GetSelectedCount($atapp_listview) If $selected_items = 1 Then Local $msg = InputBox("Kopieren in einen anderen Arbeitsplan", "Bitte geben sie die Arbeitsplan ID an, in dem Sie diesen Arbeitspunkt kopieren möchten") If @error = 0 Then If $msg = $auswahl_split[1] Then app_hinzufuegen() Return 0 EndIf Local $auswahl_split = StringSplit($auswahl, " | ", 1) If _SQLite_Query($DB, "SELECT arbeitsplan_id FROM arbeitsplaene WHERE arbeitsplan_id=" & $msg, $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) If $Row[0] <> $msg Then MsgBox(48, "Fehler", "Der angegebene Arbeitsplan konnte nicht gefunden werden.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) ElseIf @error = 1 Then Return 0 EndIf Local $selecteditemtext = _GUICtrlListView_GetItemTextArray($atapp_listview) Local $check_input = True If GUICtrlRead($atapp_laufendenr_input) = "" Then $check_input = False ElseIf GUICtrlRead($atapp_arbeitspunktname_input) = "" Then $check_input = False EndIf If $check_input = False Then MsgBox(48, "Fehler", "Alle durch * markierten Felder benötigen eine Eingabe.") Return 0 EndIf If _SQLite_Query($DB, "SELECT arbeitspunkt_name FROM arbeitspunkte WHERE arbeitspunkt_name='" & GUICtrlRead($atapp_arbeitspunktname_input) & "' AND arbeitsplan_id=" & $msg, $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_arbeitspunktname_input) Then MsgBox(48, "Fehler", "Die interne Funktion " & GUICtrlRead($atapp_arbeitspunktname_input) & " ist bereits im Arbeitsplan vorhanden." & @CR & "Interne Funktionen können sich maximal ein mal in einem Arbeitsplan befinden!") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If _SQLite_Query($DB, "SELECT laufende_nr FROM arbeitspunkte WHERE laufende_nr=" & GUICtrlRead($atapp_laufendenr_input) & " AND arbeitsplan_id=" & $msg, $Query) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf While _SQLite_FetchData($Query, $Row) = $SQLITE_OK If $Row[0] = GUICtrlRead($atapp_laufendenr_input) Then MsgBox(48, "Fehler", "Die Laufende Nr. ist bereits vorhanden. Bitte wählen Sie eine andere.") Return 0 EndIf WEnd _SQLite_QueryFinalize($Query) If GUICtrlRead($atapp_status_checkbox) = $GUI_UNCHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Intern', NULL, 'Inaktiv', " & $msg & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', NULL, '" & GUICtrlRead($atapp_laufendenr_input) & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf ElseIf GUICtrlRead($atapp_status_checkbox) = $GUI_CHECKED Then If _SQLite_Exec($DB, "INSERT INTO arbeitspunkte VALUES('Intern', NULL, 'Aktiv', " & $msg & ", NULL, '" & GUICtrlRead($atapp_arbeitspunktname_input) & "', NULL, '" & GUICtrlRead($atapp_laufendenr_input) & "')") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf EndIf MsgBox(0, "", "Der Arbeitspunkt: " & GUICtrlRead($atapp_arbeitspunktname_input) & " konnte erfolgreich in den Arbeitsplan: " & $msg & " kopiert werden.") app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() app_clear_inputs() Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitspunkt aus.") EndIf EndIf Else MsgBox(48, "Fehler", "Bitte wählen Sie erst einen Arbeitsplan aus.") EndIf EndFunc ;==>app_in_anderen_ap_kopieren Func atapp_combo() app_suche_in_der_db_nach_comboauswahl_und_stelle_in_listview_dar() _interne_inputs_zuklappen() _externe_inputs_zuklappen() app_clear_inputs() EndFunc ;==>atapp_combo Func atapp_funktionstyp_combo() If GUICtrlRead($atapp_funktionstyp_combo) = 'Externe Funktionen' Then _externe_inputs_ausklappen() Else _interne_inputs_ausklappen() EndIf EndFunc ;==>atapp_funktionstyp_combo ;====================================== Arbeitspunkte verwalten ====================================== ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB erzeugen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func schritt1_lese_datenbankname_aus_inputbox_und_blende_schritt2_ein() Local $dbname = GUICtrlRead($atdb_name_input) If $dbname = "" Then Local $msg = MsgBox(4, "Fehler", "Es wurde kein Name eingegeben. Die Eingabe des Namens nochmal versuchen?") If $msg = 7 Then MsgBox(48, "DB erstellen", "DB erstellen fehlgeschlagen.") GUICtrlSetState($at_tab_ap, $GUI_SHOW) Return 0 ElseIf $msg = 6 Then Return 0 EndIf Else GUICtrlSetState($atdb_pfad_label, $GUI_SHOW) GUICtrlSetState($atdb_pfad_input, $GUI_SHOW) GUICtrlSetState($atdb_pfad_button, $GUI_SHOW) EndIf EndFunc ;==>schritt1_lese_datenbankname_aus_inputbox_und_blende_schritt2_ein Func schritt2_lese_pfad_ein_und_blende_schritt3_ein() Local $pfad = FileSelectFolder("Ziel-Pfad auswählen...", "", 1 + 2, @WindowsDir & "") If $pfad = "" Or @error = 1 Then Local $msg = MsgBox(4, "Fehler", "Es ist ein Fehler aufgetreten. Die Auswahl des Pfads nochmal versuchen?") If $msg = 7 Then ; Nein MsgBox(48, "Fehler", "DB erstellen fehlgeschlagen.") GUICtrlSetData($atdb_name_input, "") GUICtrlSetData($atdb_pfad_input, "") GUICtrlSetState($atdb_pfad_label, $GUI_HIDE) GUICtrlSetState($atdb_pfad_input, $GUI_HIDE) GUICtrlSetState($atdb_pfad_button, $GUI_HIDE) GUICtrlSetState($atdb_dberstellen_button, $GUI_HIDE) GUICtrlSetState($at_tab_ap, $GUI_SHOW) Return 0 ElseIf $msg = 6 Then ; Ja Return 0 EndIf Else GUICtrlSetData($atdb_pfad_input, $pfad) GUICtrlSetState($atdb_dberstellen_button, $GUI_SHOW) EndIf EndFunc ;==>schritt2_lese_pfad_ein_und_blende_schritt3_ein Func dberzeugen() Local $Row, $Query If FileExists(GUICtrlRead($atdb_pfad_input) & "" & GUICtrlRead($atdb_name_input) & ".db") = 1 Then Local $msg = MsgBox(4, "Fehler", "Es existiert bereits eine Datei mit diesem Namen im angegebenen Ordner. Nochmal versuchen?") If $msg = 7 Then ; Nein MsgBox(48, "Fehler", "DB erstellen fehlgeschlagen.") GUICtrlSetData($atdb_name_input, "") GUICtrlSetData($atdb_pfad_input, "") GUICtrlSetState($atdb_pfad_label, $GUI_HIDE) GUICtrlSetState($atdb_pfad_input, $GUI_HIDE) GUICtrlSetState($atdb_pfad_button, $GUI_HIDE) GUICtrlSetState($atdb_dberstellen_button, $GUI_HIDE) GUICtrlSetState($at_tab_ap, $GUI_SHOW) Return 0 ElseIf $msg = 6 Then ; Ja GUICtrlSetData($atdb_name_input, "") GUICtrlSetData($atdb_pfad_input, "") GUICtrlSetState($atdb_pfad_label, $GUI_HIDE) GUICtrlSetState($atdb_pfad_input, $GUI_HIDE) GUICtrlSetState($atdb_pfad_button, $GUI_HIDE) GUICtrlSetState($atdb_dberstellen_button, $GUI_HIDE) Return 0 EndIf EndIf Local $dbfile = _SQLite_Open(GUICtrlRead($atdb_pfad_input) & "" & GUICtrlRead($atdb_name_input) & ".db") If @error Then MsgBox(16, "Fehler", "Die Datenbank konnte nicht erstellt werden.") GUICtrlSetData($atdb_name_input, "") GUICtrlSetData($atdb_pfad_input, "") GUICtrlSetState($atdb_pfad_label, $GUI_HIDE) GUICtrlSetState($atdb_pfad_input, $GUI_HIDE) GUICtrlSetState($atdb_pfad_button, $GUI_HIDE) GUICtrlSetState($atdb_dberstellen_button, $GUI_HIDE) GUICtrlSetState($at_tab_ap, $GUI_SHOW) Return 0 EndIf If _SQLite_Exec($dbfile, "CREATE TABLE arbeitsplaene (arbeitsplan_id INTEGER PRIMARY KEY, arbeitsplan_name TEXT, status NUMERIC)") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($dbfile, "CREATE TABLE aufgabenliste (id INTEGER PRIMARY KEY, geplante_startzeit TEXT, startzeit TEXT, arbeitsplan_id NUMERIC, arbeitspunkt_id NUMERIC)") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Exec($dbfile, "CREATE TABLE arbeitspunkte (funktionstyp TEXT, parameter TEXT, status TEXT, arbeitsplan_id NUMERIC, arbeitspunkt_id INTEGER PRIMARY KEY, arbeitspunkt_name TEXT, befehl TEXT, laufende_nr NUMERIC)") <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf If _SQLite_Close($dbfile) <> 0 Then Global $sql_error = @error _check_sqlite_query_errors() Return 0 EndIf MsgBox(0, "DB erstellen", GUICtrlRead($atdb_name_input) & ".db wurde erfolgreich im Verzeichnis: " & GUICtrlRead($atdb_pfad_input) & " erstellt.") GUICtrlSetData($atdb_name_input, "") GUICtrlSetData($atdb_pfad_input, "") GUICtrlSetState($atdb_pfad_label, $GUI_HIDE) GUICtrlSetState($atdb_pfad_input, $GUI_HIDE) GUICtrlSetState($atdb_pfad_button, $GUI_HIDE) GUICtrlSetState($atdb_dberstellen_button, $GUI_HIDE) GUICtrlSetState($at_tab_ap, $GUI_SHOW) Return 0 EndFunc ;==>dberzeugen ;====================================== DB erstellen ====================================== Func _exit() AdlibUnRegister("_clear_memory") Exit EndFunc ;==>_exit Func _schreibe_log($sFehler, $sAp_id, $sAp_name, $sGeplante_startzeit, $sApp_name, $sBefehl, $sParameter, $sStatus) Local $hfile = FileOpen("log.txt", 1) ;Beispiel: [12.11.2012 16:14:30][OK] Arbeitsplan_ID: 1 | Arbeitsplan_Name: AP 1 | Geplante_Startzeit: 16:00 | Arbeitspunkt_Name: Hello World | Status: wurde gestartet FileWriteLine($hfile, "[" & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "][" & $sFehler & "] " & $sAp_id & " | " & _ $sAp_name & " | " & $sGeplante_startzeit & " | " & $sApp_name & " | " & $sBefehl & " " & $sParameter & " | " & $sStatus) FileClose($hfile) EndFunc ;~ =============================================== ;~ SQL Querys/Execs wie folgt schreiben: ;~ ;~ If QUERY/EXEC <> 0 Then ;~ Global $sql_error = @error ;~ _check_sqlite_query_errors() ;~ Return 0 ;~ EndIf ;~ =============================================== Func _check_sqlite_query_errors() If $sql_error = -1 Then ;~ MsgBox(48, "Fehler", "_SQLite_Exec Error: " & $sql_error & @CR & "SQLite reported an error (Check return value)") ConsoleWriteError("Fehler, _SQLite_Exec Error: " & $sql_error & ". SQLite reported an error (Check return value)") ElseIf $sql_error = 1 Then ;~ MsgBox(48, "Fehler", "_SQLite_Exec Error: " & $sql_error & @CR & "Error calling SQLite API 'sqlite3_exec'") ConsoleWriteError("Fehler, _SQLite_Exec Error: " & $sql_error & ". Error calling SQLite API 'sqlite3_exec'") ElseIf $sql_error = 2 Then ;~ MsgBox(48, "Fehler", "_SQLite_Exec Error: " & $sql_error & @CR & "Call prevented by SafeMode") ConsoleWriteError("Fehler, _SQLite_Exec Error: " & $sql_error & ". Call prevented by SafeMode") ElseIf $sql_error = 3 Then ;~ MsgBox(48, "Fehler", "_SQLite_Exec Error: " & $sql_error & @CR & "Error Processing Callback from within _SQLite_GetTable2d") ConsoleWriteError("Fehler, _SQLite_Exec Error: " & $sql_error & ". Error Processing Callback from within _SQLite_GetTable2d") ElseIf $sql_error = 4 Then ;~ MsgBox(48, "Fehler", "_SQLite_Exec Error: " & $sql_error & @CR & "Error while converting SQL statement to UTF-8") ConsoleWriteError("Fehler, _SQLite_Exec Error: " & $sql_error & ". Error while converting SQL statement to UTF-8") EndIf EndFunc ;==>_check_sqlite_query_errors Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then ;kernel32.dll - OpenProcess - Opens an existing local process object. Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) ;psapi.dll - EmptyWorkingSet - Removes as many pages as possible from the working set of the specified process. Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) ;kernel32.dll - CloseHandle - Closes an existing local process object. DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else ;s.o. Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf ;~ Return $ai_Return[0] EndFunc ;==>_ReduceMemory ;#################################################### ; SQLite Datenbank schließen # ;#################################################### _SQLite_Close($usedb) _SQLite_Shutdown() Had to use 3 boxes because upload max is 6K :/ Edited November 29, 2012 by MikeWenzel
jchd Posted November 29, 2012 Posted November 29, 2012 OK I'm looking at it. After first browse there are a number of mistakes and many improvements. Also it makes me remind of german (loooong ago!). Before going much deeper, please confirm that the DBs are local to the machine running the script (no remote user) and tell me if several processes may access a given DB concurrently. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Yaerox Posted November 29, 2012 Author Posted November 29, 2012 DB is just running local ... at my first post there is a .zip where you could find the required db and config.ini ... no remote users, and no other processes need/want/get access on the given db ... Regards
jchd Posted December 1, 2012 Posted December 1, 2012 Please see follow-up in PM. This is going to go to some length are there is little point posting too much here. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now