This commit is contained in:
2025-05-21 10:19:00 +02:00
parent d7722fe0d7
commit 4ee38e0965
3 changed files with 219 additions and 14 deletions

View File

@@ -67,6 +67,24 @@ Public Class cIDS
End Sub
Sub New(YearMonthDay, Paymentsummarynumber, CustomerCode, OutletCountryCode, OutletCode, ProductTypeCode, _PARAM, isOBO)
Me.YearMonthDay = YearMonthDay
Me.Paymentsummarynumber = Paymentsummarynumber
Me.CustomerCode = CustomerCode
Me.OutletCountryCode = OutletCountryCode
Me.OutletCode = OutletCode
Me.ProductTypeCode = ProductTypeCode
If isOBO Then
Me.OBONumber = _PARAM
LOADBYOBO()
Else
Me.VRNumber = _PARAM
LOADBYVR()
End If
End Sub
Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
@@ -111,6 +129,30 @@ Public Class cIDS
Public Function SAVE_OBO() As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblIDSTransactionsNew WHERE YearMonthDay=@YearMonthDay AND Paymentsummarynumber=@Paymentsummarynumber AND CustomerCode=@CustomerCode AND OutletCountryCode=@OutletCountryCode AND OutletCode=@OutletCode AND ProductTypeCode=@ProductTypeCode and OBONumber=@OBONumber and isnull(charged,0) = 0) " &
" BEGIN " & getUpdateCmd("OBONumber", "@OBONumber") & " END " &
" Else " &
" BEGIN " & getInsertCmd() & " END " &
" commit tran "
Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
End Function
Public Function SAVE_VR() As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblIDSTransactionsNew WHERE YearMonthDay=@YearMonthDay AND Paymentsummarynumber=@Paymentsummarynumber AND CustomerCode=@CustomerCode AND OutletCountryCode=@OutletCountryCode AND OutletCode=@OutletCode AND ProductTypeCode=@ProductTypeCode and VRNumber=@VRNumber and isnull(charged,0) = 0) " &
" BEGIN " & getUpdateCmd("VRNumber", "@VRNumber") & " END " &
" Else " &
" BEGIN " & getInsertCmd() & " END " &
" commit tran "
Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
End Function
Public Function SAVE() As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
@@ -183,9 +225,76 @@ Public Class cIDS
End Try
End Sub
Public Sub LOADBYOBO()
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT * FROM tblIDSTransactionsNew WHERE YearMonthDay=@YearMonthDay AND Paymentsummarynumber=@Paymentsummarynumber AND CustomerCode=@CustomerCode AND OutletCountryCode=@OutletCountryCode AND OutletCode=@OutletCode AND ProductTypeCode=@ProductTypeCode AND OBONumber=@OBONumber", conn)
cmd.Parameters.AddWithValue("@YearMonthDay", YearMonthDay)
cmd.Parameters.AddWithValue("@Paymentsummarynumber", Paymentsummarynumber)
cmd.Parameters.AddWithValue("@CustomerCode", CustomerCode)
cmd.Parameters.AddWithValue("@OutletCountryCode", OutletCountryCode)
cmd.Parameters.AddWithValue("@OutletCode", OutletCode)
cmd.Parameters.AddWithValue("@ProductTypeCode", ProductTypeCode)
cmd.Parameters.AddWithValue("@OBONumber", OBONumber)
Dim dr = cmd.ExecuteReader()
If dr.Read Then
For Each li In getParameterList()
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(li.Scalarvariable)
If dr.Item(li.Text) Is DBNull.Value Then
propInfo.SetValue(Me, Nothing)
Else
propInfo.SetValue(Me, dr.Item(li.Text))
End If
Next
hasEntry = True
End If
dr.Close()
End Using
End Using
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Public Sub LOADBYVR()
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT * FROM tblIDSTransactionsNew WHERE YearMonthDay=@YearMonthDay AND Paymentsummarynumber=@Paymentsummarynumber AND CustomerCode=@CustomerCode AND OutletCountryCode=@OutletCountryCode AND OutletCode=@OutletCode AND ProductTypeCode=@ProductTypeCode AND VRNumber=@VRNumber", conn)
cmd.Parameters.AddWithValue("@YearMonthDay", YearMonthDay)
cmd.Parameters.AddWithValue("@Paymentsummarynumber", Paymentsummarynumber)
cmd.Parameters.AddWithValue("@CustomerCode", CustomerCode)
cmd.Parameters.AddWithValue("@OutletCountryCode", OutletCountryCode)
cmd.Parameters.AddWithValue("@OutletCode", OutletCode)
cmd.Parameters.AddWithValue("@ProductTypeCode", ProductTypeCode)
cmd.Parameters.AddWithValue("@VRNumber", VRNumber)
Dim dr = cmd.ExecuteReader()
If dr.Read Then
For Each li In getParameterList()
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(li.Scalarvariable)
If dr.Item(li.Text) Is DBNull.Value Then
propInfo.SetValue(Me, Nothing)
Else
propInfo.SetValue(Me, dr.Item(li.Text))
End If
Next
hasEntry = True
End If
dr.Close()
End Using
End Using
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Public Function getUpdateCmd() As String
Public Function getUpdateCmd(Optional PARAM As String = "", Optional VALUE As String = "") As String
Try
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
@@ -196,7 +305,7 @@ Public Class cIDS
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
Return (" UPDATE [tblIDSTransactionsNew] SET " & str & " WHERE YearMonthDay=@YearMonthDay AND Paymentsummarynumber=@Paymentsummarynumber AND CustomerCode=@CustomerCode AND OutletCountryCode=@OutletCountryCode AND OutletCode=@OutletCode AND ProductTypeCode=@ProductTypeCode AND isnull(charged,0) = 0 ")
Return (" UPDATE [tblIDSTransactionsNew] SET " & str & " WHERE YearMonthDay=@YearMonthDay AND Paymentsummarynumber=@Paymentsummarynumber AND CustomerCode=@CustomerCode AND OutletCountryCode=@OutletCountryCode AND OutletCode=@OutletCode AND ProductTypeCode=@ProductTypeCode " & IIf(PARAM <> "" AndAlso VALUE <> "", " AND " & PARAM & "=" & VALUE, "") & " AND isnull(charged,0) = 0 ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
@@ -256,10 +365,29 @@ Public Class cIDS
Dim occ = isleernothing((currentRow(5)))
Dim oc = isleernothing((currentRow(6)))
Dim ptc = isleernothing((currentRow(7)))
Dim ids As New cIDS(ymd, pyn, cc, occ, oc, ptc)
Dim vr = isleernothing((currentRow(13)))
Dim obo = isleernothing((currentRow(14)))
'.VRNumber = isleernothing((currentRow(13)))
'.OBONumber = isleernothing((currentRow(14)))
Dim zusParam = ""
Dim isOBO As Boolean = False
If vr IsNot Nothing AndAlso vr <> "" Then
zusParam = vr
ElseIf obo IsNot Nothing AndAlso obo <> "" Then
zusParam = obo
isOBO = True
End If
Dim ids As New cIDS(ymd, pyn, cc, occ, oc, ptc, zusParam, isOBO)
Dim avprive = isleernothing((currentRow(12)))
With ids
.YearMonthDay = isleernothing((currentRow(0)))
.CustomerCode = isleernothing((currentRow(1)))
@@ -269,16 +397,86 @@ Public Class cIDS
.OutletCountryCode = isleernothing((currentRow(5)))
.OutletCode = isleernothing((currentRow(6)))
.ProductTypeCode = isleernothing((currentRow(7)))
'Dim transVol_old = .TransactionVolume
'Dim transVol_new = isleernothing((currentRow(8)))
'If transVol_old IsNot Nothing AndAlso IsNumeric(transVol_old) AndAlso transVol_new IsNot Nothing AndAlso IsNumeric(transVol_new) Then
' Dim AmininclVat_old = CDbl(.AmminclVAT)
' Dim AmininclVat_new = CDbl(isleernothing((currentRow(9)).Replace(".", ",")))
' Dim TotalNetAmount_old = CDbl(.TotalNetAmount)
' Dim TotalNetAmount_new = CDbl(isleernothing((currentRow(10)).Replace(".", ",")))
' Dim VATAmount_old = CDbl(.VATAmount)
' Dim VATAmount_new = CDbl(isleernothing((currentRow(11)).Replace(".", ",")))
' If (CDec(transVol_old) <> CDec(transVol_new)) AndAlso Math.Abs(CDbl(transVol_old)) = Math.Abs(CDbl(transVol_new.replace(".", ","))) Then 'case1: gleiche Transaktionshohe -> nicht abziehen, sondern nur Preis anpassen!
' If AmininclVat_old <> AmininclVat_new Then
' .TransactionVolume = transVol_old + transVol_new
' .AmminclVAT = AmininclVat_old + AmininclVat_new
' .TotalNetAmount = TotalNetAmount_old + TotalNetAmount_new
' .VATAmount = VATAmount_old + VATAmount_new
' End If
' ElseIf Math.Abs(CDbl(transVol_old)) > Math.Abs(CDbl(transVol_new.replace(".", ","))) AndAlso (CDec(transVol_old) <> CDec(transVol_new)) Then 'case2: alte Transaktionshohe höher als neue, abziehen!
' If AmininclVat_old <> AmininclVat_new Then
' .TransactionVolume = transVol_old + transVol_new
' .AmminclVAT = AmininclVat_old + AmininclVat_new
' .TotalNetAmount = TotalNetAmount_old + TotalNetAmount_new
' .VATAmount = VATAmount_old + VATAmount_new
' 'If .TransactionVolume < 0 Then .TransactionVolume = .TransactionVolume * -1
' End If
' ElseIf Math.Abs(CDbl(transVol_old)) < Math.Abs(CDbl(transVol_new.replace(".", ","))) AndAlso (CDec(transVol_old) <> CDec(transVol_new)) Then 'case3: alte Transaktionshohe niedriger als neue, dazuzählen (weil die "Stornierung" vor der eig. Transk. importiert werden kann)!
' If AmininclVat_old <> AmininclVat_new Then
' .TransactionVolume = transVol_old + transVol_new
' .AmminclVAT = AmininclVat_old + AmininclVat_new
' .TotalNetAmount = TotalNetAmount_old + TotalNetAmount_new
' .VATAmount = VATAmount_old + VATAmount_new
' 'If .TransactionVolume < 0 Then .TransactionVolume = .TransactionVolume * -1
' End If
' End If
'Else
.TransactionVolume = isleernothing((currentRow(8)))
.AmminclVAT = isleernothing((currentRow(9)))
.TotalNetAmount = isleernothing((currentRow(10)))
.VATAmount = isleernothing((currentRow(11)))
.avpriceexclVAT = IIf(avprive <> "" AndAlso IsNumeric(avprive), avprive, 0)
.VRNumber = isleernothing((currentRow(13)))
.OBONumber = isleernothing((currentRow(14)))
.AmminclVAT = isleernothing((currentRow(9)))
.TotalNetAmount = isleernothing((currentRow(10)))
.VATAmount = isleernothing((currentRow(11)))
.avpriceexclVAT = IIf(avprive <> "" AndAlso IsNumeric(avprive), avprive, 0)
' End If
'.VRNumber = isleernothing((currentRow(13)))
'.OBONumber = isleernothing((currentRow(14)))
Console.WriteLine("IDS: " & isleernothing((currentRow(1))) & " - " & lngRecordCount & " - " & isleernothing((currentRow(10))))
.SAVE()
If isOBO Then
.SAVE_OBO()
Else
.SAVE_VR()
End If
'.SAVE()
End With
@@ -426,7 +624,7 @@ Public Class cIDS
Shared apiSettingsloaded As Boolean = False
Shared SQL As New VERAG_PROG_ALLGEMEIN.SQL
Shared Function GET_PARAM_ByName(tcParam_name, TESTSYSTEM) As String
Return SQL.getValueTxtBySql("SELECT TOP 1 [Param_value] FROM [tblPartnersystem_Paramter] WHERE Param_system='IDS' AND [Param_name]='" & tcParam_name & "' AND Param_testsystem = " & IIf(TESTSYSTEM, 1, 0), , , SQL.GetNewOpenConnectionFMZOLL_SYSTEM(TESTSYSTEM))
Return SQL.getValueTxtBySql("SELECT TOP 1 [Param_value] FROM [tblPartnersystem_Paramter] WHERE Param_system='IDS' AND [Param_name]='" & tcParam_name & "' AND Param_testsystem = " & IIf(TESTSYSTEM, 1, 0), , , SQL.GetNewOpenConnectionFMZOLL_SYSTEM(False))
End Function
Shared Function getFTPConenction(ByRef API_String As String, ByRef API As DataTable, ByRef program As String) As Boolean