242 lines
8.0 KiB
AutoIt
242 lines
8.0 KiB
AutoIt
;createCSV.au3
|
|
|
|
#include <File.au3>
|
|
#include <Array.au3>
|
|
#include <Debug.au3>
|
|
|
|
|
|
|
|
#include <ButtonConstants.au3>
|
|
#include <DateTimeConstants.au3>
|
|
#include <EditConstants.au3>
|
|
#include <GUIConstantsEx.au3>
|
|
#include <WindowsConstants.au3>
|
|
|
|
|
|
#Region ### START Koda GUI section ### Form=
|
|
$_1 = GUICreate("Daten Eingabe", 401, 301, 192, 125)
|
|
$po_number_input = GUICtrlCreateInput("4212007585", 10, 10, 180, 21)
|
|
$po_item_input = GUICtrlCreateInput("00010", 10, 40, 180, 21)
|
|
$finalMark_input = GUICtrlCreateInput("No", 10, 70, 180, 21)
|
|
$lzvon_input = GUICtrlCreateInput("YYYY-MM-DD", 10, 100, 180, 21)
|
|
$lzbis_input = GUICtrlCreateInput("YYYY-MM-DD", 10, 130, 180, 21)
|
|
$txz01_input = GUICtrlCreateInput("Hier steht Kurztext mit max 40 Zeichen", 10, 160, 380, 21)
|
|
$sbnaman_input = GUICtrlCreateInput("Rutta / Frau Erdmann", 10, 190, 380, 21)
|
|
$dlort_input = GUICtrlCreateInput("77749 HohbergSM Auft...", 10, 220, 380, 21)
|
|
$generate_button = GUICtrlCreateButton("Generieren", 10, 250, 80, 30)
|
|
$date_start = GUICtrlCreateDate(@YEAR & "-" & @MON& "-" & @MDAY, 200, 100, 129, 21)
|
|
$date_end = GUICtrlCreateDate(@YEAR & "-" & @MON& "-" & @MDAY, 200, 130, 130, 21)
|
|
; Button zum Generieren der Ausgabe
|
|
$generate_button = GUICtrlCreateButton("Generieren", 10, 250, 80, 30)
|
|
#EndRegion ### END Koda GUI section ###
|
|
|
|
Local $sStyle = "yyyy/MM/dd"
|
|
GUICtrlSendMsg($date_start, $DTM_SETFORMATW, 0, $sStyle)
|
|
GUICtrlSendMsg($date_end, $DTM_SETFORMATW, 0, $sStyle)
|
|
|
|
|
|
GUISetState(@SW_SHOW)
|
|
|
|
; GUI Nachrichtenschleife
|
|
While 1
|
|
Switch GUIGetMsg()
|
|
Case $GUI_EVENT_CLOSE
|
|
Exit
|
|
|
|
Case $generate_button
|
|
|
|
MsgBox(64, "", "")
|
|
|
|
$po_number = GUICtrlRead($po_number_input)
|
|
$po_item = GUICtrlRead($po_item_input)
|
|
$finalMark = GUICtrlRead($finalMark_input)
|
|
$lzvon = GUICtrlRead($lzvon_input)
|
|
$lzbis = GUICtrlRead($lzbis_input)
|
|
$txz01 = GUICtrlRead($txz01_input)
|
|
$sbnaman = GUICtrlRead($sbnaman_input)
|
|
$dlort = GUICtrlRead($dlort_input)
|
|
|
|
Local $sFilePath, $aArray
|
|
;~ _GUICtrlListView_DeleteAllItems($LV_Aufm)
|
|
$aListeImport = ""
|
|
Local $message = "Bitte wählen Sie die Import Datei aus!"
|
|
|
|
Local $sFilePath = FileOpenDialog($message, @ScriptDir & "\..\_Aufmaße\", "Text (*.txt)", 1 + 4)
|
|
If @error Then
|
|
MsgBox(4096, "", "Keine Datei(en) ausgewählt")
|
|
Return "No Datei"
|
|
Else
|
|
$sFilePath = StringReplace($sFilePath, "|", @CRLF)
|
|
;~ MsgBox(4096, "", "Es wurde(n) " & $var & " ausgewählt")
|
|
_FileReadToArray($sFilePath, $aArray)
|
|
If IsArray($aArray) Then
|
|
Dim $aListeImport[$aArray[0] - 15][13]
|
|
$iZ = 0
|
|
For $i = 16 To UBound($aArray) - 1
|
|
$aTemp = StringSplit($aArray[$i], "|")
|
|
For $ii = 1 To UBound($aTemp) - 1
|
|
$aListeImport[$iZ][$ii - 1] = $aTemp[$ii]
|
|
Next
|
|
$iZ = $iZ + 1
|
|
Next
|
|
|
|
EndIf
|
|
_DebugArrayDisplay($aArray)
|
|
_DebugArrayDisplay($aListeImport)
|
|
|
|
;~ $S_srvpos = _ArrayToString($aListeImport, ";", Default , Default , )
|
|
;~ $S_menge =
|
|
;~ $S_longText =
|
|
;~ $S_sectionText =
|
|
$aData = $aListeImport
|
|
|
|
|
|
$S_srvpos = ""
|
|
$S_sectionText = ""
|
|
$S_longText = ""
|
|
$S_menge = ""
|
|
|
|
;~ Bachstr. 11||||||||||||
|
|
;~ |10034578|1,0||||1|ST|FTTH- GrundstüeksersehIieI?ung HP PIus||1|67,80|67,8
|
|
;~ |10037463|1,0|2||||M|Einbringen v. KabeI/Rohren unbeIegt|||1,81|
|
|
;~ |10037473|1,0|22|||22|M|Ein-/Ausbr. v. KabeI/Rohren beIegt||22|2,37|52,14
|
|
;~ |10034682|1,0|3,8|||3,8|M|ZuIage HausansehIuss >10m||3,8|42,77|162,526
|
|
;~ |10034642|1,0||||1|ST|Gf-HausansehIuss hersteIIen||1|680,00|680
|
|
|
|
|
|
For $i = 0 To UBound($aData) - 1
|
|
If $aData[$i][2] <> "" Then
|
|
$S_srvpos &= $aData[$i][1] & ";"
|
|
$S_sectionText &= $aData[$i][0] & ";"
|
|
$S_longText &= $aData[$i][9] & ";"
|
|
|
|
$aData[$i][$j] = StringReplace($aData[$i][$j], "ä", "ae")
|
|
$aData[$i][$j] = StringReplace($aData[$i][$j], "ö", "oe")
|
|
$aData[$i][$j] = StringReplace($aData[$i][$j], "ü", "ue")
|
|
$aData[$i][$j] = StringReplace($aData[$i][$j], "ß", "ss")
|
|
; Überprüfen, ob der Inhalt eine Zahl ist, und dann Punkt durch Komma ersetzen
|
|
If StringRegExp($aData[$i][$j], "^[\d+\.?\d*]$") Then
|
|
$aData[$i][$j] = StringReplace($aData[$i][$j], ".", ",")
|
|
EndIf
|
|
|
|
; Anpassung der Zeichenkette für $S_menge ohne Berechnung, nur Ausdruck
|
|
Local $expr = ""
|
|
Switch $aData[$i][7]
|
|
Case "ST"
|
|
$expr = $aData[$i][2] & "*" & $aData[$i][6]
|
|
Case "M"
|
|
$expr = $aData[$i][2] & "*" & $aData[$i][3]
|
|
Case "M2"
|
|
$expr = $aData[$i][2] & "*" & $aData[$i][3] & "*" & $aData[$i][4]
|
|
Case "M3"
|
|
$expr = $aData[$i][2] & "*" & $aData[$i][3] & "*" & $aData[$i][4] & "*" & $aData[$i][5]
|
|
EndSwitch
|
|
$S_menge &= $expr & ";"
|
|
EndIf
|
|
Next
|
|
|
|
; Entfernen des letzten Semikolons von jeder Variable, um Übereinstimmung zu gewährleisten
|
|
$S_srvpos = StringTrimRight($S_srvpos, 1)
|
|
$S_sectionText = StringTrimRight($S_sectionText, 1)
|
|
$S_longText = StringTrimRight($S_longText, 1)
|
|
$S_menge = StringTrimRight($S_menge, 1)
|
|
|
|
; Ausgabe generieren
|
|
$sFirst = "po_number;po_item;finalMark;lzvon;lzbis;txz01;sbnaman;dlort;srvpos;menge;longText;sectionText"
|
|
$dataLine = $po_number & ";" & $po_item & ";" & $finalMark & ";" & $lzvon & ";" & $lzbis & ";" & _
|
|
$txz01 & ";" & $sbnaman & ";" & $dlort & ';"' & $S_srvpos & '";"' & $S_menge & '";"' & _
|
|
$S_longText & '";"' & $S_sectionText
|
|
|
|
; Ausgabe in Konsole
|
|
ConsoleWrite($sFirst & @CRLF & $dataLine & @CRLF)
|
|
|
|
; Ausgabedateipfad definieren
|
|
$sOutputFilePath = @ScriptDir & "\..\ausgabe.csv"
|
|
|
|
; Datei im Schreibmodus öffnen, UTF-8 ohne BOM
|
|
$hFile = FileOpen($sOutputFilePath, $FO_OVERWRITE + $FO_UTF8_NOBOM)
|
|
|
|
If $hFile = -1 Then
|
|
MsgBox($MB_SYSTEMMODAL, "Fehler", "Konnte die Ausgabedatei nicht öffnen.")
|
|
Exit
|
|
EndIf
|
|
|
|
; Kopfzeile und Datenzeile schreiben
|
|
FileWrite($hFile, $sFirst & @CRLF & $dataLine & @CRLF)
|
|
|
|
; Datei schließen
|
|
FileClose($hFile)
|
|
; FileWrite(@ScriptDir & "\..\ausgabe.csv", $sFirst & @CRLF & $dataLine)
|
|
EndIf
|
|
|
|
case $date_start
|
|
GUICtrlSetData($lzvon_input, GUICtrlRead($date_start))
|
|
case $date_end
|
|
GUICtrlSetData($lzbis_input, GUICtrlRead($date_end))
|
|
EndSwitch
|
|
WEnd
|
|
|
|
|
|
|
|
|
|
;~ ; Ausgabe der Variablen zur Überprüfung
|
|
;~ ConsoleWrite("S_srvpos: " & $S_srvpos & @CRLF)
|
|
;~ ConsoleWrite("S_sectionText: " & $S_sectionText & @CRLF)
|
|
;~ ConsoleWrite("S_longText: " & $S_longText & @CRLF)
|
|
;~ ConsoleWrite("S_menge: " & $S_menge & @CRLF)
|
|
;~ $sTeilaufma = StringReplace($aArray[2], "Teilaufma=", "")
|
|
;~ If $sTeilaufma = "X" Then
|
|
|
|
;~ Else
|
|
|
|
;~ EndIf
|
|
;~ $sSchlussaufma = StringReplace($aArray[3], "Schlussaufma=", "")
|
|
;~ If $sSchlussaufma = "X" Then
|
|
|
|
;~ Else
|
|
|
|
;~ EndIf
|
|
|
|
|
|
;~ $kopf_tab_txt_datum = StringReplace($aArray[4], "Datum=", "")
|
|
;~ $kopf_tab_txt_baustelle = StringReplace($aArray[5], "Baustelle=", "")
|
|
;~ $kopf_tab_txt_abrufnr = StringReplace($aArray[6], "AbrufNr=", "")
|
|
;~ $kopf_tab_txt_smnr = StringReplace($aArray[7], "SMNr=", "")
|
|
;~ $kopf_tab_chb_vertrag = StringReplace($aArray[8], "Vertrag=", "")
|
|
;~ $kopf_tab_datum_start = StringReplace($aArray[9], "StartZ=", "")
|
|
;~ $kopf_tab_txt_datum_ende = StringReplace($aArray[10], "EndZ=", "")
|
|
;~ $kopf_tab_txt_aspa = StringReplace($aArray[11], "AspaN=", "")
|
|
;~ $kopf_tab_txt_telnr = StringReplace($aArray[12], "AspaTel=", "")
|
|
;~ $kopf_tab_txt_bauabschnitt = StringReplace($aArray[13], "Bauabschnitt=", "")
|
|
;~ $kopf_tab_txt_kolone = StringReplace($aArray[14], "Kolone=", "")
|
|
|
|
;~ $lve_tab_chb_vertrag = StringReplace($aArray[8], "Vertrag=", "")
|
|
;~ $kopf_tab_chb_vertrag = StringReplace($aArray[8], "Vertrag=", "")
|
|
|
|
|
|
|
|
;~ $aStartDatum = StringSplit($kopf_tab_datum_start, ".")
|
|
|
|
;~ If IsArray($aStartDatum) Then
|
|
;~ If UBound($aStartDatum) = 3 Then
|
|
;~ $iYear = $aStartDatum[3]
|
|
;~ $iMonth = $aStartDatum[2]
|
|
;~ $iDay = $aStartDatum[1]
|
|
;~ $kopf_tab_datumfeld_start = $iYear & "-" & $iMonth & "-" & $iDay
|
|
;~ EndIf
|
|
|
|
;~ EndIf
|
|
|
|
;~ $aStartDatum = StringSplit($kopf_tab_txt_datum_ende, ".")
|
|
;~ If IsArray($aStartDatum) Then
|
|
;~ If UBound($aStartDatum) = 3 Then
|
|
;~ $iYear = $aStartDatum[3]
|
|
;~ $iMonth = $aStartDatum[2]
|
|
;~ $iDay = $aStartDatum[1]
|
|
;~ $kopf_tab_datumfeld_ende = $iYear & "-" & $iMonth & "-" & $iDay
|
|
;~ EndIf
|
|
;~ EndIf
|
|
|
|
;~ EndIf
|
|
;~
|