simplify getdocumentfromdatarow

This commit is contained in:
Jonathan Jenne 2022-05-25 10:45:54 +02:00
parent 143823aae2
commit beb0ee8ae5
2 changed files with 19 additions and 25 deletions

View File

@ -11,9 +11,6 @@ Namespace Winline.Entities
End Get End Get
End Property End Property
Public Property Kind As DocumentKind Public Property Kind As DocumentKind
Public Property RunningNumber As String Public Property RunningNumber As String
Public Property Number As String Public Property Number As String
@ -25,7 +22,6 @@ Namespace Winline.Entities
Public Property IsSelected As Boolean = False Public Property IsSelected As Boolean = False
Public Property IsExported As Boolean Public Property IsExported As Boolean
Public Property ExportType As Integer
Public Property FilenameExport As String Public Property FilenameExport As String
Public Property ExportedWhen As Date Public Property ExportedWhen As Date
Public Property ExportedWho As String Public Property ExportedWho As String

View File

@ -1012,9 +1012,8 @@ Namespace Winline
Dim oExportedType As Integer = pDataRow.ItemEx("ALREADY_EXPORTED", 0) Dim oExportedType As Integer = pDataRow.ItemEx("ALREADY_EXPORTED", 0)
Dim oExportedWho As String = pDataRow.ItemEx("EXPORTED_WHO", "") Dim oExportedWho As String = pDataRow.ItemEx("EXPORTED_WHO", "")
Dim oExportedWhen As Date = pDataRow.ItemEx(Of Date)("EXPORTED_WHEN", Nothing) Dim oExportedWhen As Date = pDataRow.ItemEx(Of Date)("EXPORTED_WHEN", Nothing)
Dim oExportFile As String = pDataRow.ItemEx("EXPORTED_FILE", "") Dim oExportedFile As String = pDataRow.ItemEx("EXPORTED_FILE", "")
Dim oDocumentType2 As Integer = 0 Dim oIsExported As Boolean = GetIsExported(oExportedType, pDocumentType)
Dim oIsExported As Boolean = False
Dim oDocumentNumber As String = Nothing Dim oDocumentNumber As String = Nothing
Dim oDocumentDate As Date = Nothing Dim oDocumentDate As Date = Nothing
@ -1033,40 +1032,24 @@ Namespace Winline
oDocumentNumber = pDataRow.Item("OFFER_NUMBER") oDocumentNumber = pDataRow.Item("OFFER_NUMBER")
oDocumentDate = pDataRow.Item("OFFER_DATE") oDocumentDate = pDataRow.Item("OFFER_DATE")
oDocumentDateColumn = "c027" oDocumentDateColumn = "c027"
oDocumentType2 = Math.Abs(oDocumentType)
Case 2, -2 Case 2, -2
oDocumentNumber = pDataRow.Item("ORDER_NUMBER") oDocumentNumber = pDataRow.Item("ORDER_NUMBER")
oDocumentDate = pDataRow.Item("ORDER_DATE") oDocumentDate = pDataRow.Item("ORDER_DATE")
oDocumentDateColumn = "c028" oDocumentDateColumn = "c028"
oDocumentType2 = Math.Abs(oDocumentType)
Case 3, -3 Case 3, -3
oDocumentNumber = pDataRow.Item("DELIVERY_NUMBER") oDocumentNumber = pDataRow.Item("DELIVERY_NUMBER")
oDocumentDate = pDataRow.Item("DELIVERY_DATE") oDocumentDate = pDataRow.Item("DELIVERY_DATE")
oDocumentDateColumn = "c029" oDocumentDateColumn = "c029"
oDocumentType2 = Math.Abs(oDocumentType)
Case 4, -4 Case 4, -4
oDocumentNumber = pDataRow.Item("INVOICE_NUMBER") oDocumentNumber = pDataRow.Item("INVOICE_NUMBER")
oDocumentDate = pDataRow.Item("INVOICE_DATE") oDocumentDate = pDataRow.Item("INVOICE_DATE")
oDocumentDateColumn = "c032" oDocumentDateColumn = "c032"
oDocumentType2 = Math.Abs(oDocumentType)
End Select End Select
'---
If oExportedType = 1 AndAlso (pDocumentType = DocumentType.IncomingOffer Or pDocumentType = DocumentType.OutgoingOffer) Then
oIsExported = True
ElseIf oExportedType = 2 AndAlso (pDocumentType = DocumentType.IncomingOrder Or pDocumentType = DocumentType.OutgoingOrder) Then
oIsExported = True
ElseIf oExportedType = 3 AndAlso (pDocumentType = DocumentType.IncomingDeliveryNote Or pDocumentType = DocumentType.OutgoingDeliveryNote) Then
oIsExported = True
ElseIf oExportedType = 4 AndAlso (pDocumentType = DocumentType.IncomingInvoice Or pDocumentType = DocumentType.OutgoingInvoice) Then
oIsExported = True
End If
'---
Dim oDocument As New ExportDocument With { Dim oDocument As New ExportDocument With {
.Account = oAccount, .Account = oAccount,
.RunningNumber = oRunningNumber, .RunningNumber = oRunningNumber,
@ -1078,14 +1061,29 @@ Namespace Winline
.NetAmount = oNetAmount, .NetAmount = oNetAmount,
.ExportedWhen = oExportedWhen, .ExportedWhen = oExportedWhen,
.ExportedWho = oExportedWho, .ExportedWho = oExportedWho,
.FilenameExport = oExportFile, .FilenameExport = oExportedFile,
.ExportType = oDocumentType2,
.IsExported = oIsExported .IsExported = oIsExported
} }
Return oDocument Return oDocument
End Function End Function
Private Function GetIsExported(pExportedType As Integer, pDocumentType As DocumentType) As Boolean
Dim oIsExported = False
If pExportedType = 1 AndAlso (pDocumentType = DocumentType.IncomingOffer Or pDocumentType = DocumentType.OutgoingOffer) Then
oIsExported = True
ElseIf pExportedType = 2 AndAlso (pDocumentType = DocumentType.IncomingOrder Or pDocumentType = DocumentType.OutgoingOrder) Then
oIsExported = True
ElseIf pExportedType = 3 AndAlso (pDocumentType = DocumentType.IncomingDeliveryNote Or pDocumentType = DocumentType.OutgoingDeliveryNote) Then
oIsExported = True
ElseIf pExportedType = 4 AndAlso (pDocumentType = DocumentType.IncomingInvoice Or pDocumentType = DocumentType.OutgoingInvoice) Then
oIsExported = True
End If
Return oIsExported
End Function
''' <summary> ''' <summary>
''' Turns a database info like "SQLCWLDATEN on SERVER\INSTANCE" into a Tuple of two strings ''' Turns a database info like "SQLCWLDATEN on SERVER\INSTANCE" into a Tuple of two strings
''' </summary> ''' </summary>