Public Sub ReadXml()
Dim settings As New XmlReaderSettings()
Dim sXMLFile As String
Dim dsDataset As DataSet = New DataSet("dsXMLData")
Dim dtDataTable As DataTable = New DataTable("refund")
Dim sXMLFileLocation As String = "P:\"
Dim currDir As String = Directory.GetCurrentDirectory
Dim exp As String = "IIF(issuingCountry = 'FRA', 'VAT - Global Refund', 'International VAT - Global Refund')"
Try
Directory.SetCurrentDirectory(sXMLFileLocation)
Catch nopath As Exception
MsgBox("REX XML Files directory not available. Please make sure USB object is connected.")
Exit Sub
End Try
Try
Dim dirs As String() = Directory.GetFiles(sXMLFileLocation, "*.xml")
Catch nopath As Exception
Me.StatusStrip1.Text = "Ready......"
MsgBox("No REX refunds to process.")
Exit Sub
End Try
For Each sXMLFile In Directory.GetFiles(sXMLFileLocation, "*.xml")
Dim lfx As XmlDocument = New XmlDocument
Try
lfx.Load(sXMLFile)
Dim reader As XmlReader = XmlReader.Create(sXMLFile, settings)
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.IgnoreWhitespace = True
settings.IgnoreComments = True
Dim nodetransact As New XmlNodeReader(lfx)
If nodetransact.MoveToContent() = XmlNodeType.Element And nodetransact.Name = "transaction" _
And nodetransact.GetAttribute("transactionType").Equals("refund") Then
dsDataset.ReadXml(sXMLFile)
Try
dsDataset.Tables("refund").Columns.Add("Product", GetType(String), exp)
dsDataset.Tables("refund").Columns("Product").Expression = exp
dsDataset.Tables("refund").Columns.Add("Confirm", GetType(Boolean))
dsDataset.Tables("refund").Columns.Add("Fee", GetType(Decimal))
dsDataset.Tables("refund").Columns.Add("REXRefund", GetType(Boolean))
Catch exAddColumn As Exception
End Try
dgvTaxRefunds.DataSource = dsDataset
dgvTaxRefunds.DataMember = "refund"
End If
Catch empty As XmlException
Finally
' Finished with XmlDocument
lfx = Nothing
Directory.SetCurrentDirectory(currDir)
End Try
Next
'Sets each REX Records checkbox as true, for future use in manual adding new trans or editing records
For Each dr As DataRow In dsDataset.Tables("refund").Rows
dr.Item("REXRefund") = 1
dr.Item("Confirm") = 1
Next
ComputeTotalAmount(dsDataset)
Try
Me.ProductsTableAdapter.FillByManualRefundCategory(DsGTMProd.Products)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Me.cmbProduct.Text = "DETAXE Tax Free"
Me.tbAddAmount.Text = ""
Me.tbAddAmount.Enabled = True
Me.tbIssueCountry.Text = ""
Me.tbIssueCountry.Enabled = True
Me.tbChequeNo.Text = ""
Me.tbChequeNo.Enabled = True
End Sub
Private Sub ComputeTotalAmount(ByVal dataset As DataSet)
Dim dsDataset As DataSet = dataset
Try
For Each dr As DataRow In dt.Rows
MsgBox(dr.Item("refundAmount").ToString.Contains(1))
Next
aTotalRefundAmounttest = dsDataset.Tables("refund").Compute("Sum(refundAmount)", "Confirm = 1")
If IsDBNull(aTotalRefundAmount) Then tbTotalAmount.Text = 0 Else tbTotalAmount.Text = aTotalRefundAmounttest
If tbTotalAmount.Text = vbNullString Or Val(tbTotalAmount.Text) = 0 Then
tbTotalAmount.Text = Format(0, "0.00")
End If
aTotalRefundAmount = tbTotalAmount.Text
Catch exComputeTotalAmount As Exception
MsgBox(exComputeTotalAmount.Message)
End Try
End Sub