Private Sub ImportGetFile()
dlgOpen.ShowDialog()
End Sub
Private Sub dlgOpen_FileOk(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles dlgOpen.FileOk
Import(dlgOpen.FileName)
MessageBox.Show("Bye")
End Sub
Private Sub Import(ByVal FileName As String)
Try
Me.Activate()
Application.DoEvents()
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
dlgOpen = Nothing
Dim results As Interfaces.UpdateResults = Me.BusLayer.ModuleSpecificOptions("AssetsScannedTruncate", Nothing)
If results.errorNumber = 0 Then
FormLoadedDataView()
Dim ds As DataSet = dcMainDataControl.SearchDataView.Table.DataSet
Dim ScannerFile As New System.IO.StreamReader(FileName)
Dim SiteID, BuildingID, RoomID, AssetID As String
SiteID = ScannerFile.ReadLine
Do While Not SiteID Is Nothing
BuildingID = ScannerFile.ReadLine
RoomID = ScannerFile.ReadLine
AssetID = ScannerFile.ReadLine
Dim dr As DataRow = ds.Tables(0).NewRow
dr.Item("AssetID") = AssetID
dr.Item("SiteID") = SiteID
dr.Item("BuildingID") = BuildingID
dr.Item("RoomID") = RoomID
dr.Item("Scanned") = True
dr.Item("Processed") = False
ds.Tables(0).Rows.Add(dr)
SiteID = ScannerFile.ReadLine
Loop
ScannerFile.Close()
If dcMainDataControl.DataSaveAll() = DialogResult.Yes Then
results = Me.BusLayer.ModuleSpecificOptions("AssetsScannedVariance", Nothing)
If results.errorNumber = 0 Then
StatusMessage("Import completed")
End If
End If
End If
If results.errorNumber <> 0 Then StatusMessage("Database error", True, results.resultMessage)
Catch exIO As System.IO.IOException
StatusMessage("Error importing data.", True, exIO.Message)
Catch ex As SystemException
LogError(ex)
Finally
FormLoadedDataView()
Me.Cursor = System.Windows.Forms.Cursors.Default
End Try
End Sub