This commit is contained in:
2022-09-01 10:37:14 +02:00
parent 46c14b6500
commit 5809e9c89c
13 changed files with 291 additions and 217 deletions

View File

@@ -561,7 +561,7 @@ Public Class frmStartOptions
Dim AVISO = VERAG_PROG_ALLGEMEIN.cAviso.getAvisoById(SND.tblSnd_AvisoID)
'Wenn Freigabe-Mail aktiv und Steuerbescheid oder VBD gewählt, soll bei Fremdgrenzen die BelegMail gesendet werden.
Dim sendMailFremdgrenze = False
If KD_ERW.EmailFreigabe_Art = "FG" Then
If KD_ERW.EmailFreigabe_Art = "FG" Or KD_ERW.EmailFreigabe_Export_Art = "FG" Then
If KD_ERW.EmailFreigabe_SteuerbescheidPDF Or KD_ERW.EmailFreigabe_VBDPDF Then
If AVISO IsNot Nothing Then
@@ -1128,6 +1128,13 @@ Public Class frmStartOptions
If outletGroug.Contains("4486") Then Return 0.042
Return 0.048
End Function
Function getPlattsAufschlag_SONDER(outletGroug As String) As Double
If outletGroug.Contains("4473") Then Return 0.032
If outletGroug.Contains("4474") Then Return 0.032
If outletGroug.Contains("4486") Then Return 0.042
Return 0.048
End Function
Sub doIDSPlatts()
Try
@@ -1135,23 +1142,25 @@ Public Class frmStartOptions
Dim DS As VERAG_PROG_ALLGEMEIN.cDATENSERVER = Nothing
Dim ZIEL_PFAD = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getRootDir() & "IDS\IDS_XLS\Platts_Price_Report\NEW\"
Dim DT_PLATTS As New DataTable()
If IO.Directory.Exists(ZIEL_PFAD) Then
DT_PLATTS.Columns.Add("IsoCode")
DT_PLATTS.Columns.Add("Outlet")
DT_PLATTS.Columns.Add("Group Description")
DT_PLATTS.Columns.Add("Product")
DT_PLATTS.Columns.Add("Price Period Start")
DT_PLATTS.Columns.Add("Price Period End")
DT_PLATTS.Columns.Add("Excise")
DT_PLATTS.Columns.Add("Netprice")
DT_PLATTS.Columns.Add("Currency")
DT_PLATTS.Columns.Add("NetpriceNEW")
For Each IDS_FILE In IO.Directory.GetFiles(ZIEL_PFAD)
Dim DT_PLATTS As New DataTable()
DT_PLATTS.Columns.Add("IsoCode")
DT_PLATTS.Columns.Add("Outlet")
DT_PLATTS.Columns.Add("Group Description")
DT_PLATTS.Columns.Add("Product")
DT_PLATTS.Columns.Add("Price Period Start")
DT_PLATTS.Columns.Add("Price Period End")
DT_PLATTS.Columns.Add("Excise")
DT_PLATTS.Columns.Add("Netprice")
DT_PLATTS.Columns.Add("Currency")
DT_PLATTS.Columns.Add("NetpriceNEW")
Dim DT_PLATTS_SONDER = DT_PLATTS.Clone
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
' EXCEL AUSLESEN:::::::
@@ -1195,11 +1204,20 @@ Public Class frmStartOptions
While zeile <= 10000 AndAlso Blatt.Range("A" & zeile) IsNot Nothing AndAlso Blatt.Range("A" & zeile).Value <> ""
If Blatt.Range("A" & zeile).Value.ToString.Contains("Austria") Then
'ALLGEMEIN
Dim NetpriceNEW As Double = getPlattsAufschlag(Blatt.Range("B" & zeile).Value)
If NetpriceNEW > 0 Then
NetpriceNEW += CDbl(Blatt.Range("I" & zeile).Value) ' Aufschalg + NETTO
DT_PLATTS.Rows.Add({Blatt.Range("A" & zeile).Value, Blatt.Range("B" & zeile).Value, Blatt.Range("C" & zeile).Value, Blatt.Range("D" & zeile).Value, Blatt.Range("E" & zeile).Value, Blatt.Range("F" & zeile).Value, Blatt.Range("H" & zeile).Value, Blatt.Range("I" & zeile).Value, Blatt.Range("J" & zeile).Value, NetpriceNEW})
End If
'SONDERKONDITION
Dim NetpriceNEW_SOND As Double = getPlattsAufschlag_SONDER(Blatt.Range("B" & zeile).Value)
If NetpriceNEW_SOND > 0 Then
NetpriceNEW_SOND += CDbl(Blatt.Range("I" & zeile).Value) ' Aufschalg + NETTO
DT_PLATTS_SONDER.Rows.Add({Blatt.Range("A" & zeile).Value, Blatt.Range("B" & zeile).Value, Blatt.Range("C" & zeile).Value, Blatt.Range("D" & zeile).Value, Blatt.Range("E" & zeile).Value, Blatt.Range("F" & zeile).Value, Blatt.Range("H" & zeile).Value, Blatt.Range("I" & zeile).Value, Blatt.Range("J" & zeile).Value, NetpriceNEW_SOND})
End If
End If
zeile += 1
@@ -1251,96 +1269,11 @@ Public Class frmStartOptions
End Try
End Try
'ALLGEMEIN
genXLS_NewPrice(DT_PLATTS, FILE_NEW) '--> Send XLS Mail
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'NEUES EXCEL ERSTELLEN:::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If DT_PLATTS.Rows.Count > 0 Then
Dim Excel2 As Object 'New Microsoft.Office.Interop.Excel.Application
Dim Blatt2 As Object 'Microsoft.Office.Interop.Excel.Worksheet 'As Object 'as Worksheet
Excel2 = CreateObject("Excel.Application")
Dim Datei2 As Object 'as WorkBook
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(destFull, "00", System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
Try
With Excel2
Try
Datei2 = .Workbooks.Open(System.AppDomain.CurrentDomain.BaseDirectory & "\Resources\Muster_IDS_PLATTSPR.xls",, True) 'Anpassen
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
MsgBox(ex.Message & ex.StackTrace)
End Try
Blatt2 = Datei2.Worksheets(1)
Dim zeile = 12
'Blatt2.Range("G:G").NumberFormat = "0.000"
For Each ROW In DT_PLATTS.Rows
Blatt2.Range("A" & zeile).Value = ROW("IsoCode")
Blatt2.Range("B" & zeile).Value = ROW("Outlet")
Blatt2.Range("C" & zeile).Value = ROW("Group Description")
Blatt2.Range("D" & zeile).Value = ROW("Product")
Blatt2.Range("E" & zeile).Value = ROW("Price Period Start").ToString
Blatt2.Range("F" & zeile).Value = ROW("Price Period End").ToString
Blatt2.Range("G" & zeile).Value = CDbl(ROW("NetpriceNEW")) '.ToString("N3")
Blatt2.Range("H" & zeile).Value = ROW("Currency")
zeile += 1
Next
End With
Dim FIN_FILE = FILE_NEW.Replace("_ORIG.xls", ".xls")
While IO.File.Exists(FIN_FILE)
FIN_FILE = FILE_NEW.Replace("_ORIG.xls", Now.ToString("_ddMMyy.HHmmss") & ".xls")
End While
Datei2.SaveAs(FIN_FILE)
Excel2.Workbooks.Close
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Excel2)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Blatt2)
Excel2 = Nothing
Blatt2 = Nothing
GC.Collect()
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'NEUES EXCEL PER MAIL SCHICKEN:::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Dim MAIL_attach As New List(Of String)
MAIL_attach.Add(FIN_FILE)
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail("z.batinic@verag.ag;n.ljubas@verag.ag;s.vidovic@verag.ag;ma@verag.ag;alex@verag.ag;ft@verag.ag", "IDSPRD: Platts Price Report", "*AUTO*",,,, "sales@verag.ag;al@verag.ag",, MAIL_attach)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
Try
Excel2.Workbooks.Close
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Excel2)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Blatt2)
Excel2 = Nothing
Blatt2 = Nothing
GC.Collect()
Catch ex2 As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex2.Message, ex2.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
End Try
End Try
End If
'SONDERKONDITION
' genXLS_NewPrice(DT_PLATTS_SONDER, FILE_NEW.Replace("_ORIG.xls", "_special_ORIG.xls")) '--> Send XLS Mail
Next
End If
@@ -1349,6 +1282,99 @@ Public Class frmStartOptions
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
End Try
End Sub
Sub genXLS_NewPrice(DT_PLATTS As DataTable, FILE_NEW As String)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'NEUES EXCEL ERSTELLEN:::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If DT_PLATTS.Rows.Count > 0 Then
Dim Excel2 As Object 'New Microsoft.Office.Interop.Excel.Application
Dim Blatt2 As Object 'Microsoft.Office.Interop.Excel.Worksheet 'As Object 'as Worksheet
Excel2 = CreateObject("Excel.Application")
Dim Datei2 As Object 'as WorkBook
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(destFull, "00", System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
Try
With Excel2
Try
Datei2 = .Workbooks.Open(System.AppDomain.CurrentDomain.BaseDirectory & "\Resources\Muster_IDS_PLATTSPR.xls",, True) 'Anpassen
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
MsgBox(ex.Message & ex.StackTrace)
End Try
Blatt2 = Datei2.Worksheets(1)
Dim zeile = 12
'Blatt2.Range("G:G").NumberFormat = "0.000"
For Each ROW In DT_PLATTS.Rows
Blatt2.Range("A" & zeile).Value = ROW("IsoCode")
Blatt2.Range("B" & zeile).Value = ROW("Outlet")
Blatt2.Range("C" & zeile).Value = ROW("Group Description")
Blatt2.Range("D" & zeile).Value = ROW("Product")
Blatt2.Range("E" & zeile).Value = ROW("Price Period Start").ToString
Blatt2.Range("F" & zeile).Value = ROW("Price Period End").ToString
Blatt2.Range("G" & zeile).Value = CDbl(ROW("NetpriceNEW")) '.ToString("N3")
Blatt2.Range("H" & zeile).Value = ROW("Currency")
zeile += 1
Next
End With
Dim FIN_FILE = FILE_NEW.Replace("_ORIG.xls", ".xls")
While IO.File.Exists(FIN_FILE)
FIN_FILE = FILE_NEW.Replace("_ORIG.xls", Now.ToString("_ddMMyy.HHmmss") & ".xls")
End While
Datei2.SaveAs(FIN_FILE)
Excel2.Workbooks.Close
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Excel2)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Blatt2)
Excel2 = Nothing
Blatt2 = Nothing
GC.Collect()
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'NEUES EXCEL PER MAIL SCHICKEN:::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Dim MAIL_attach As New List(Of String)
MAIL_attach.Add(FIN_FILE)
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail("z.batinic@verag.ag;n.ljubas@verag.ag;s.vidovic@verag.ag;ma@verag.ag;alex@verag.ag;ft@verag.ag", "IDSPRD: Platts Price Report", "*AUTO*",,,, "sales@verag.ag;al@verag.ag",, MAIL_attach)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
Try
Excel2.Workbooks.Close
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Excel2)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Blatt2)
Excel2 = Nothing
Blatt2 = Nothing
GC.Collect()
Catch ex2 As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex2.Message, ex2.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
End Try
End Try
End If
End Sub
Public Function FileInUse(ByVal sFile As String) As Boolean
If System.IO.File.Exists(sFile) Then