Imports FPCommon
Imports eConnect11Data
Public Class BankReconcilliation
Public Function BRBankTransactionType(bShowErrors As Boolean) As String
Dim intCurrentLine As Int16
Dim strReturnDoc As String = ""
Try
'this method call will get the data from the text files and place in the DDtaBRBankTransactionHeader and DDtaBRBankTransactionDist tables
Dim oTruist As New DataRetrieval.Truist
oTruist.RetrieveBankTransactionTypeData(bShowErrors)
'declare variables
Dim strSQLServer As String = System.Configuration.ConfigurationManager.AppSettings("SQLServer")
Dim strDabase As String = System.Configuration.ConfigurationManager.AppSettings("Database")
'declare our eConnect classes
Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
Dim oBRBankTransactionType As New Microsoft.Dynamics.GP.eConnect.Serialization.BRBankTransactionType
Dim oeConnectFunctions As New eConnectFunctions(strSQLServer, strDabase)
'the data is currently in two SQL tables (DDtaBRBankTransactionHeader and DDtaBRBankTransactionDist)
'this query will get a dataset of all the header lines
Dim oDT As DataTable = SPs.DD_DDtaBRBankTransactionHeader_SEL().getTable
For Each oRow In oDT.Rows
'interate through the header lines
intCurrentLine = 0
'populate the distributions
'this query will return a dataset for each dist line in for the header
Dim oDTDist As DataTable = SPs.DD_DDtaBRBankTransactionDist_SEL_byCMTrxNum(oRow("cmtrxnum")).getTable
For Each oRowDist In oDTDist.Rows
'iterate throuth the dists
'declare an object for the detail line
Dim taBRBankTransactionDist As New Microsoft.Dynamics.GP.eConnect.Serialization.taBRBankTransactionDist_ItemsTaBRBankTransactionDist
'populate the detail line
With taBRBankTransactionDist
ReDim Preserve oBRBankTransactionType.taBRBankTransactionDist_Items(intCurrentLine)
.Option = oRowDist("Option")
.ACTNUMST = oRowDist("ACTNUMST")
.DEBITAMT = oRowDist("DEBITAMT")
.CRDTAMNT = oRowDist("CRDTAMNT")
.DistRef = oRowDist("DistRef")
oBRBankTransactionType.taBRBankTransactionDist_Items(intCurrentLine) = taBRBankTransactionDist
End With
intCurrentLine += 1
Next
'populate the header
Dim otaBRBankTransactionHeader As New Microsoft.Dynamics.GP.eConnect.Serialization.taBRBankTransactionHeader
With otaBRBankTransactionHeader
.Option = oRow("Option")
.CMTrxType = oRow("CMTrxType")
.RcpType = oRow("RcpType")
.TRXDATE = oRow("TRXDATE")
.CHEKBKID = oRow("CHEKBKID")
.CMTrxNum = oRow("CMTRXNUM")
.DSCRIPTN = oRow("DSCRIPTN")
.TRXAMNT = oRow("TRXAMNT")
.BACHNUMB = oRow("BACHNUMB")
.DistRef = oRow("DistRef")
End With
'assign the header to the master
oBRBankTransactionType.taBRBankTransactionHeader = otaBRBankTransactionHeader
ReDim Preserve oeConnectType.BRBankTransactionType(0)
oeConnectType.BRBankTransactionType(0) = oBRBankTransactionType
'send the transaction to Dynamics
strReturnDoc = oeConnectFunctions.CreateTransactionEntity(oeConnectType)
'delete lines in the source tables
SPs.DD_DDtaBRBankTransactionHeader_DEL_byCMTrxNum(oRow("CMTrxType")).execute()
SPs.DD_DDtaBRBankTransactionDist_DEL_byCMTrxNum(oRow("CMTrxType")).execute()
Next
Catch ex As Exception
ErrorHandler.globalErrorHandler(ex, bShowErrors)
End Try
Return StrReturnDoc
End Function
End Class