Click here to Skip to main content
14,302,993 members
   

C#

 
QuestionGetting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Member 1453381917-Jul-19 11:29
memberMember 1453381917-Jul-19 11:29 
AnswerRe: Getting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Luc Pattyn17-Jul-19 11:49
professionalLuc Pattyn17-Jul-19 11:49 
GeneralRe: Getting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Member 1453381917-Jul-19 12:00
memberMember 1453381917-Jul-19 12:00 
GeneralRe: Getting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Luc Pattyn17-Jul-19 12:13
professionalLuc Pattyn17-Jul-19 12:13 
AnswerRe: Getting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Eddy Vluggen17-Jul-19 13:51
mveEddy Vluggen17-Jul-19 13:51 
AnswerRe: Getting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
phil.o17-Jul-19 22:13
mvephil.o17-Jul-19 22:13 
AnswerRe: Getting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Richard Deeming17-Jul-19 22:52
mveRichard Deeming17-Jul-19 22:52 
QuestionOutOfMemoryException help please Pin
DTGeek17-Jul-19 5:07
memberDTGeek17-Jul-19 5:07 
The new company I just started working for has had a problem doing full price sync from their database this part of the program is visual basic.net while a lot of the code has been redone in C# we have other programs to pull from the same data link that was created and updates just fine. Any help would be appreciated.


<pre lang="vb"><pre>

Public Class ImportPricing

    Public dbUpgrade As Boolean
    Public dbFull As Boolean
    Dim Failed As Boolean = True
    Dim Silent As Boolean = False

    Dim msg As String
    Dim secondLevelMsg As String

    Private printingFont As Font
    Private objReader As StreamReader

    Public File As String
    Public ReadMe As String

    Dim Progress As Double

    Private Config As Models.Config
    Private ConfigService As IConfig = ServiceLocator.Current.GetInstance(Of IConfig)

    Private ReadOnly DataSetPricing As New DataSetPricing

    Private Alpha As ICollection(Of Models.Alpha)
    Private Commodities As ICollection(Of Models.Commodity)
    Private LevelTypes As ICollection(Of Models.LevelType)
    Private Manufacturers As ICollection(Of Models.Manufacturer)
    Private WorkGroups As ICollection(Of Models.Workgroup)
    Private ItemStatus As ICollection(Of Models.ItemStatusType)
    Private UOM As ICollection(Of Models.Uom)

    Delegate Sub OverallProgressSafe(ByVal Task As Enums.CurrentTask, ByVal Status As Enums.CurrentStatus)

    Private Sub ImportPricing_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        lblSaving.Visible = False
        MemoEdit1.Properties.ReadOnly = True

        Config = ConfigService.GetById(1)

        If dbFull Or dbUpgrade Then
            MemoEdit1.EditValue = "This is a Full Database update and may take 15+ minutes.  Press Next to begin the update."
            btnPrint.Enabled = False
        Else
            objReader = New StreamReader(ReadMe)
            MemoEdit1.EditValue = objReader.ReadToEnd()
            objReader.Close()
        End If
    End Sub

    Private Sub WizardControl1_SelectedPageChanged(ByVal sender As Object, ByVal e As WizardPageChangedEventArgs) Handles WizardControl1.SelectedPageChanged
        If e.Page Is WizardPage1 Then
            e.Page.AllowBack = False
            e.Page.AllowNext = False
            e.Page.AllowCancel = False
            btnPrint.Visible = False
            Failed = False
            BackgroundWorker.RunWorkerAsync()
        End If
        If e.Page Is CompletionWizardPage1 Then
            e.Page.AllowBack = False
            e.Page.AllowCancel = False
            btnPrint.Enabled = True
            btnPrint.Visible = True

            If Failed = False Then
                If dbFull Then
                    GridControl1.Visible = False
                    MemoEdit2.Visible = True
                    MemoEdit2.Dock = DockStyle.Fill

                    MemoEdit2.EditValue = "Full Price Update has completed.  You should restart Quantum before continuing."
                Else
                    MemoEdit2.Visible = False

                    ManufacturersBS.DataSource = DataSetPricing.Manufacturers
                    'ManufacturersBS.DataMember = "Manufacturers"
                    cboManufacturers.DataSource = ManufacturersBS
                    cboManufacturers.DisplayMember = "Description"
                    cboManufacturers.ValueMember = "PK_ManufacturerID"

                    UOMsBS.DataSource = DataSetPricing.UOM
                    'UOMsBS.DataMember = "UOM"
                    cboUOMs.DataSource = UOMsBS
                    cboUOMs.DisplayMember = "ShortDescription"
                    cboUOMs.ValueMember = "PK_UOMID"

                    GridControl1.DataSource = DataSetPricing.Items
                    'GridControl1.DataMember = "Items"

                    Try
                        Dim column As DevExpress.XtraGrid.Columns.GridColumn
                        Dim imageCombo As DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox = TryCast(GridControl1.RepositoryItems.Add("ImageComboBoxEdit"), DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox)
                        imageCombo.SmallImages = ImageCollection1
                        imageCombo.Items.Add(New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Add", 1, 0))
                        imageCombo.Items.Add(New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Delete", 2, 1))
                        imageCombo.Items.Add(New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Arrow_Down", 3, 2))
                        imageCombo.Items.Add(New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Arrow_Up", 4, 3))
                        imageCombo.GlyphAlignment = DevExpress.Utils.HorzAlignment.Center
                        column = GridView1.Columns("ItemChange")
                        column.ColumnEdit = imageCombo
                        column = GridView1.Columns("CostChange")
                        column.ColumnEdit = imageCombo
                    Catch ex As Exception
                        Exit Try
                    End Try
                End If
            Else
                GridControl1.Visible = False
                MemoEdit2.Visible = True
                MemoEdit2.Dock = DockStyle.Fill

                MemoEdit2.EditValue = msg & vbCrLf & vbCrLf & secondLevelMsg
            End If
        End If
    End Sub

    Private Sub BackgroundWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker.DoWork
        Dim safeDelegate As New OverallProgressSafe(AddressOf OverallProgress)

        If File = Nothing Then
            Invoke(safeDelegate, Enums.CurrentTask.Download, Enums.CurrentStatus.InProgress)
            If DoGetFiles() = True Then
                Invoke(safeDelegate, Enums.CurrentTask.Download, Enums.CurrentStatus.Done)
            Else
                Invoke(safeDelegate, Enums.CurrentTask.Download, Enums.CurrentStatus.Failed)
                Exit Sub
            End If
        End If

        Invoke(safeDelegate, Enums.CurrentTask.Extract, Enums.CurrentStatus.InProgress)
        If DoExtract() = True Then
            Invoke(safeDelegate, Enums.CurrentTask.Extract, Enums.CurrentStatus.Done)
        Else
            Invoke(safeDelegate, Enums.CurrentTask.Extract, Enums.CurrentStatus.Failed)
            Exit Sub
        End If

        Invoke(safeDelegate, Enums.CurrentTask.Alpha, Enums.CurrentStatus.InProgress)
        If DoImpAlpha() = True Then
            Invoke(safeDelegate, Enums.CurrentTask.Alpha, Enums.CurrentStatus.Done)
        Else
            Invoke(safeDelegate, Enums.CurrentTask.Alpha, Enums.CurrentStatus.Failed)
            Exit Sub
        End If

        Invoke(safeDelegate, Enums.CurrentTask.Commodities, Enums.CurrentStatus.InProgress)
        If DoImpCommodities() = True Then
            Invoke(safeDelegate, Enums.CurrentTask.Commodities, Enums.CurrentStatus.Done)
        Else
            Invoke(safeDelegate, Enums.CurrentTask.Commodities, Enums.CurrentStatus.Failed)
            Exit Sub
        End If

        Invoke(safeDelegate, Enums.CurrentTask.Manufacturers, Enums.CurrentStatus.InProgress)
        If DoImpManufacturers() = True Then
            Invoke(safeDelegate, Enums.CurrentTask.Manufacturers, Enums.CurrentStatus.Done)
        Else
            Invoke(safeDelegate, Enums.CurrentTask.Manufacturers, Enums.CurrentStatus.Failed)
            Exit Sub
        End If

        Invoke(safeDelegate, Enums.CurrentTask.WorkGroups, Enums.CurrentStatus.InProgress)
        If DoImpWorkGroups() = True Then
            Invoke(safeDelegate, Enums.CurrentTask.WorkGroups, Enums.CurrentStatus.Done)
        Else
            Invoke(safeDelegate, Enums.CurrentTask.WorkGroups, Enums.CurrentStatus.Failed)
            Exit Sub
        End If

        Invoke(safeDelegate, Enums.CurrentTask.Items, Enums.CurrentStatus.InProgress)
        If DoImpItems() = True Then
            Invoke(safeDelegate, Enums.CurrentTask.Items, Enums.CurrentStatus.Done)
        Else
            Invoke(safeDelegate, Enums.CurrentTask.Items, Enums.CurrentStatus.Failed)
            Exit Sub
        End If

        Config.LastUpdateOn = Date.Now
        Config.UpdateEffectiveDate = Date.Now
        ConfigService.Update(Config)
    End Sub

    Private Sub BackgroundWorker_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker.ProgressChanged
        CurrentTask.Position = e.ProgressPercentage
        If e.ProgressPercentage = 100 Then
            lblSaving.Visible = True
        Else
            lblSaving.Visible = False
        End If
    End Sub

    Private Sub BackgroundWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker.RunWorkerCompleted
        WizardControl1.SelectedPage = CompletionWizardPage1
    End Sub

    Public Sub OverallProgress(ByVal Task As Enums.CurrentTask, ByVal Status As Enums.CurrentStatus)
        Select Case Task
            Case Enums.CurrentTask.Download
                If Status = Enums.CurrentStatus.InProgress Then
                    imgDownload.Image = My.Resources.DoubleRightArrowHS
                    lblDownload.Font = New Font("Tahoma", 10.0!, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Done Then
                    imgDownload.Image = My.Resources.PushpinHS
                    Progress = 25
                    lblDownload.Font = New Font("Tahoma", 10.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Failed Then
                    imgDownload.Image = My.Resources.WarningHS
                    Progress = 100
                    msg = "Download failed.  Please contact support."
                    Failed = True
                End If

            Case Enums.CurrentTask.Extract
                If Status = Enums.CurrentStatus.InProgress Then
                    imgExtracting.Image = My.Resources.DoubleRightArrowHS
                    lblExtracting.Font = New Font("Tahoma", 10.0!, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Done Then
                    imgExtracting.Image = My.Resources.PushpinHS
                    Progress = 37.5
                    lblExtracting.Font = New Font("Tahoma", 10.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Failed Then
                    imgExtracting.Image = My.Resources.WarningHS
                    Progress = 100
                    msg = "Extract failed.  Please contact support."
                    Failed = True
                End If

            Case Enums.CurrentTask.Alpha
                If Status = Enums.CurrentStatus.InProgress Then
                    imgImpAlpha.Image = My.Resources.DoubleRightArrowHS
                    lblImpAlpha.Font = New Font("Tahoma", 10.0!, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Done Then
                    imgImpAlpha.Image = My.Resources.PushpinHS
                    Progress = 50
                    lblImpAlpha.Font = New Font("Tahoma", 10.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Failed Then
                    imgImpAlpha.Image = My.Resources.WarningHS
                    Progress = 100
                    msg = "Alpha Import failed.  Please contact support."
                    Failed = True
                End If

            Case Enums.CurrentTask.Commodities
                If Status = Enums.CurrentStatus.InProgress Then
                    imgImpCommodities.Image = My.Resources.DoubleRightArrowHS
                    lblImpCommodities.Font = New Font("Tahoma", 10.0!, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Done Then
                    imgImpCommodities.Image = My.Resources.PushpinHS
                    Progress = 62.5
                    lblImpCommodities.Font = New Font("Tahoma", 10.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Failed Then
                    imgImpCommodities.Image = My.Resources.WarningHS
                    Progress = 100
                    msg = "Commodities Import failed.  Please contact support."
                    Failed = True
                End If

            Case Enums.CurrentTask.Manufacturers
                If Status = Enums.CurrentStatus.InProgress Then
                    imgImpManufacturers.Image = My.Resources.DoubleRightArrowHS
                    lblImpManufacturers.Font = New Font("Tahoma", 10.0!, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Done Then
                    imgImpManufacturers.Image = My.Resources.PushpinHS
                    Progress = 75
                    lblImpManufacturers.Font = New Font("Tahoma", 10.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Failed Then
                    imgImpManufacturers.Image = My.Resources.WarningHS
                    Progress = 100
                    msg = "Manufacturers Import failed.  Please contact support."
                    Failed = True
                End If

            Case Enums.CurrentTask.WorkGroups
                If Status = Enums.CurrentStatus.InProgress Then
                    imgImpWorkGroups.Image = My.Resources.DoubleRightArrowHS
                    lblImpWorkGroups.Font = New Font("Tahoma", 10.0!, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Done Then
                    imgImpWorkGroups.Image = My.Resources.PushpinHS
                    Progress = 87.5
                    lblImpWorkGroups.Font = New Font("Tahoma", 10.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Failed Then
                    imgImpWorkGroups.Image = My.Resources.WarningHS
                    Progress = 100
                    msg = "WorkGroup Import failed.  Please contact support."
                    Failed = True
                End If

            Case Enums.CurrentTask.Items
                If Status = Enums.CurrentStatus.InProgress Then
                    imgImpItems.Image = My.Resources.DoubleRightArrowHS
                    lblImpItems.Font = New Font("Tahoma", 10.0!, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Done Then
                    imgImpItems.Image = My.Resources.PushpinHS
                    Progress = 100
                    lblImpItems.Font = New Font("Tahoma", 10.0!, FontStyle.Regular, GraphicsUnit.Point, CType(0, Byte))
                ElseIf Status = Enums.CurrentStatus.Failed Then
                    imgImpItems.Image = My.Resources.WarningHS
                    Progress = 100
                    msg = "Item Import failed.  Please contact support."
                    Failed = True
                End If
            Case Else
                Progress = 100
        End Select

        AllTasks.Position = CInt(Progress)
    End Sub

    Private Function DoGetFiles() As Boolean
        Dim theResponse As HttpWebResponse
        Dim theRequest As HttpWebRequest

        Try
            If dbUpgrade Or dbFull Then
                theRequest = CType(WebRequest.Create("https://www.electricalresources.com/Price/Full/DataLink.zip"), HttpWebRequest)
            Else
                theRequest = CType(WebRequest.Create("https://www.electricalresources.com/Price/DataLink.zip"), HttpWebRequest)
            End If
            theResponse = CType(theRequest.GetResponse, HttpWebResponse)
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Try
            Dim length As Long = theResponse.ContentLength 'Size of the response (in bytes)
            File = My.Computer.FileSystem.GetTempFileName
            Using writeStream As New IO.FileStream(File, IO.FileMode.Append)
                'Replacement for Stream.Position (webResponse stream doesn't support seek)
                Dim nRead As Integer
                'To calculate the download speed
                Dim speedtimer As New Stopwatch()
                Do
                    speedtimer.Start()
                    Dim readBytes(4095) As Byte
                    Dim bytesread As Integer = theResponse.GetResponseStream.Read(readBytes, 0, 4096)
                    nRead += bytesread
                    Dim percent As Integer = CInt((nRead * 100) / length)
                    BackgroundWorker.ReportProgress(percent)
                    If bytesread = 0 Then Exit Do
                    writeStream.Write(readBytes, 0, bytesread)
                    speedtimer.Stop()
                Loop
                'Close the streams
                theResponse.GetResponseStream.Close()
                writeStream.Close()
            End Using
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Return True
    End Function

    Private Function DoExtract() As Boolean
        Try
            'Dim extractFile As String

            'If Not File = Nothing Then
            '    extractFile = File
            'Else
            '    extractFile = My.Computer.FileSystem.GetTempFileName
            'End If

            'Dim AlphaFile As String = My.Computer.FileSystem.GetTempFileName

            Using zip As ZipFile = ZipFile.Read(File)
                zip.Password = "dr@gon"
                zip.Encryption = EncryptionAlgorithm.WinZipAes128
                For Each e As ZipEntry In zip
                    'Select Case e.FileName
                    '    Case = "Alpha.xml"
                    '        e.Extract(AlphaFile, ExtractExistingFileAction.OverwriteSilently)
                    'End Select
                    e.Extract(My.Computer.FileSystem.SpecialDirectories.Temp, ExtractExistingFileAction.OverwriteSilently)
                Next
            End Using

            DataSetPricing.Alpha.BeginLoadData()
            DataSetPricing.Alpha.DataSet.ReadXml(My.Computer.FileSystem.SpecialDirectories.Temp & "\Alpha.xml", XmlReadMode.InferTypedSchema)
            DataSetPricing.Alpha.EndLoadData()
            BackgroundWorker.ReportProgress(20)

            DataSetPricing.Commodities.BeginLoadData()
            DataSetPricing.Commodities.DataSet.ReadXml(My.Computer.FileSystem.SpecialDirectories.Temp & "\Commodities.xml", XmlReadMode.InferTypedSchema)
            DataSetPricing.Commodities.EndLoadData()
            BackgroundWorker.ReportProgress(40)

            'TestReader()

            DataSetPricing.Items.BeginLoadData()
            DataSetPricing.Items.DataSet.ReadXml(String.Format("{0}\Items.xml", My.Computer.FileSystem.SpecialDirectories.Temp), XmlReadMode.InferTypedSchema)
            DataSetPricing.Items.EndLoadData()
            BackgroundWorker.ReportProgress(60)

            DataSetPricing.Manufacturers.BeginLoadData()
            DataSetPricing.Manufacturers.DataSet.ReadXml(My.Computer.FileSystem.SpecialDirectories.Temp & "\Manufacturers.xml", XmlReadMode.InferTypedSchema)
            DataSetPricing.Manufacturers.EndLoadData()
            BackgroundWorker.ReportProgress(80)

            DataSetPricing.WorkGroups.BeginLoadData()
            DataSetPricing.WorkGroups.DataSet.ReadXml(My.Computer.FileSystem.SpecialDirectories.Temp & "\WorkGroups.xml", XmlReadMode.InferTypedSchema)
            DataSetPricing.WorkGroups.EndLoadData()

            DataSetPricing.LevelTypes.BeginLoadData()
            DataSetPricing.LevelTypes.DataSet.ReadXml(My.Computer.FileSystem.SpecialDirectories.Temp & "\LevelTypes.xml", XmlReadMode.InferTypedSchema)
            DataSetPricing.LevelTypes.EndLoadData()

            DataSetPricing.Status.BeginLoadData()
            DataSetPricing.Status.DataSet.ReadXml(My.Computer.FileSystem.SpecialDirectories.Temp & "\Status.xml", XmlReadMode.InferTypedSchema)
            DataSetPricing.Status.EndLoadData()

            DataSetPricing.UOM.BeginLoadData()
            DataSetPricing.UOM.DataSet.ReadXml(My.Computer.FileSystem.SpecialDirectories.Temp & "\UOM.xml", XmlReadMode.InferTypedSchema)
            DataSetPricing.UOM.EndLoadData()

            If Not dbFull Then
                Dim col1 As New DataColumn("ItemChange", GetType(Integer))
                Dim col2 As New DataColumn("CostChange", GetType(Integer))
                DataSetPricing.Items.Columns.Add(col1)
                DataSetPricing.Items.Columns.Add(col2)
                Dim Item As Models.Item
                For Each row In DataSetPricing.Items
                    Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(row.RowID)
                    If Not Item Is Nothing Then
                        row("ItemChange") = 0
                        row("CostChange") = 0
                        If row.Cost < Item.Cost Then
                            row("CostChange") = 3
                        End If
                        If row.Cost > Item.Cost Then
                            row("CostChange") = 4
                        End If
                    Else
                        row("ItemChange") = 1
                    End If
                    If row.FK_StatusID = 3 Then
                        row("ItemChange") = 2
                    End If
                Next
            End If

            BackgroundWorker.ReportProgress(100)
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Return True
    End Function

    Private Function DoImpAlpha() As Boolean
        Dim percent As Integer = 0
        Dim currentRow As Integer = 0
        Dim objRow As DataSetPricing.AlphaRow

        'AlphaDB.LoadAll()
        Alpha = ServiceLocator.Current.GetInstance(Of IAlpha).Get()

        'Check for new items
        'Using scope As New esTransactionScope()
        Try
            currentRow = 0

            For Each row In DataSetPricing.Alpha
                Dim x = (From c In Alpha Where c.RowId = row.RowID).SingleOrDefault
                If x Is Nothing Then
                    Dim entity As New Models.Alpha() With {.ParentId = 0}
                    If Not row.ParentID = 0 Then
                        Try
                            objRow = DataSetPricing.Alpha.Where(Function(d) d.PK_AlphaID = row.ParentID).SingleOrDefault
                            If Not objRow Is Nothing Then
                                Dim q = (From c In Alpha Where c.RowId = objRow.RowID).SingleOrDefault
                                entity.ParentId = q.AlphaId
                            End If
                        Catch ex As Exception
                            Exit Try
                        End Try
                    End If
                    entity.Description = row.Description
                    entity.DisplayEri = row.DisplayERI
                    entity.IndexNumber = row.IndexNumber
                    entity.Level = 0
                    entity.RowId = row.RowID

                    ServiceLocator.Current.GetInstance(Of IAlpha).Add(entity)
                    Alpha.Add(entity)
                End If

                currentRow += 1
                percent = CInt((currentRow / DataSetPricing.Alpha.Rows.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next

            'AlphaDB.Save()
            'scope.Complete()
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try
        'End Using

        'Correct any issues with Parent ID
        'Using scope As New esTransactionScope()
        Try
            currentRow = 0

            For Each row In DataSetPricing.Alpha
                Try
                    Dim x = (From c In Alpha Where c.RowId = row.RowID).SingleOrDefault
                    If Not x Is Nothing Then
                        objRow = DataSetPricing.Alpha.Where(Function(d) d.PK_AlphaID = row.ParentID).SingleOrDefault
                        If Not objRow Is Nothing Then
                            Dim q = (From c In Alpha Where c.RowId = objRow.RowID).SingleOrDefault
                            If x.ParentId <> q.AlphaId Then
                                x.ParentId = q.AlphaId
                                ServiceLocator.Current.GetInstance(Of IAlpha).Update(x)
                            End If
                        End If
                    End If
                Catch ex As Exception
                    Exit Try
                End Try

                currentRow += 1
                percent = CInt((currentRow / DataSetPricing.Alpha.Rows.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next

            'AlphaDB.Save()
            'scope.Complete()
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try
        'End Using

        'Remove obsolete items and update descriptions
        'Using scope As New esTransactionScope()
        Try
            currentRow = 0
            For Each row In Alpha
                objRow = DataSetPricing.Alpha.Where(Function(d) d.RowID = row.RowId).SingleOrDefault
                If Not objRow Is Nothing Then
                    If row.IndexNumber <> objRow.IndexNumber Or row.Description <> objRow.Description Then
                        row.IndexNumber = objRow.IndexNumber
                        row.Description = objRow.Description
                        ServiceLocator.Current.GetInstance(Of IAlpha).Update(row)
                    End If
                Else
                    ServiceLocator.Current.GetInstance(Of IAlpha).DeleteById(row.AlphaId)
                    'Alpha.Delete(CInt(row.AlphaId))
                End If

                currentRow += 1
                percent = CInt((currentRow / Alpha.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next

            'AlphaDB.Save()
            'scope.Complete()
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try
        'End Using

        Return True
    End Function

    Private Function DoImpCommodities() As Boolean
        Dim percent As Integer = 0
        Dim currentRow As Integer = 0
        Dim objRow As DataSetPricing.CommoditiesRow

        Commodities = ServiceLocator.Current.GetInstance(Of ICommodities).Get

        'Check for new items
        Try
            currentRow = 0

            For Each row In DataSetPricing.Commodities
                Dim RowID As String = row.RowID
                Dim x = (From c In Commodities Where c.RowId = RowID).SingleOrDefault
                If x Is Nothing Then
                    Dim entity As New Models.Commodity() With {.ParentId = 0}
                    If Not row.ParentID = 0 Then
                        objRow = DataSetPricing.Commodities.Where(Function(d) d.PK_CommodityID = row.ParentID).SingleOrDefault
                        If Not objRow Is Nothing Then
                            Dim q = (From c In Commodities Where c.RowId = objRow.RowID).SingleOrDefault
                            entity.ParentId = q.PkCommodityId
                        End If
                    End If
                    entity.Description = row.Description
                    entity.ImageIndex = row.ImageIndex
                    If Len(row.BeginERI) = 0 Then
                        entity.BeginEri = "000000000000000"
                    Else
                        entity.BeginEri = row.BeginERI
                    End If
                    If Len(row.EndERI) = 0 Then
                        entity.EndEri = "000000000000000"
                    Else
                        entity.EndEri = row.BeginERI
                    End If
                    entity.RowId = row.RowID
                    ServiceLocator.Current.GetInstance(Of ICommodities).Add(entity)
                    Commodities.Add(entity)
                End If

                currentRow += 1
                percent = CInt((currentRow / DataSetPricing.Commodities.Rows.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        'Remove obsolete items and update descriptions
        Try
            currentRow = 0

            For Each row In Commodities
                objRow = DataSetPricing.Commodities.Where(Function(d) d.RowID = row.RowId).SingleOrDefault
                If Not objRow Is Nothing Then
                    row.Description = objRow.Description
                Else
                    ServiceLocator.Current.GetInstance(Of ICommodities).DeleteById(row.PkCommodityId)
                End If

                currentRow += 1
                percent = CInt((currentRow / Commodities.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Commodities.Clear()

        Return True
    End Function

    Private Function DoImpManufacturers() As Boolean
        Dim percent As Integer = 0
        Dim currentRow As Integer = 0
        Dim objRow As DataSetPricing.ManufacturersRow

        Manufacturers = ServiceLocator.Current.GetInstance(Of IManufacturers).Get

        Try
            Dim list = Manufacturers.AsQueryable().Where(Function(d) d.RowId Is Nothing)

            For Each entity As Models.Manufacturer In list
                For Each row In DataSetPricing.Manufacturers
                    If Trim(entity.ManufacturerName) = Trim(row.Description) Then
                        entity.RowId = row.RowID
                    End If
                    ServiceLocator.Current.GetInstance(Of IManufacturers).Update(entity)
                Next

                currentRow += 1
                percent = CInt((currentRow / DataSetPricing.Manufacturers.Rows.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        'Update items
        Try
            currentRow = 0

            For Each row In Manufacturers
                objRow = DataSetPricing.Manufacturers.Where(Function(d) d.RowID = row.RowId).SingleOrDefault
                If Not objRow Is Nothing Then
                    row.ManufacturerName = objRow.Description
                    row.Upc = objRow.UPC
                    ServiceLocator.Current.GetInstance(Of IManufacturers).Update(row)
                End If

                currentRow += 1
                percent = CInt((currentRow / Manufacturers.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        'Add new items
        Try
            currentRow = 0

            For Each row In DataSetPricing.Manufacturers
                Dim RowID As String = row.RowID
                Dim x = (From c In Manufacturers Where c.RowId = RowID).FirstOrDefault
                If x Is Nothing Then
                    Dim entity As New Models.Manufacturer

                    entity.ManufacturerName = row.Description
                    entity.Upc = row.UPC
                    entity.RowId = row.RowID

                    ServiceLocator.Current.GetInstance(Of IManufacturers).Add(entity)
                End If

                currentRow += 1
                percent = CInt((currentRow / DataSetPricing.Manufacturers.Rows.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Return True
    End Function

    Private Function DoImpWorkGroups() As Boolean
        Dim percent As Integer = 0
        Dim currentRow As Integer = 0

        WorkGroups = ServiceLocator.Current.GetInstance(Of IWorkgroups).Get
        LevelTypes = ServiceLocator.Current.GetInstance(Of ILevelTypes).Get

        Try
            If dbFull Or dbUpgrade Then
                For Each entity As Models.Workgroup In WorkGroups
                    For Each row In DataSetPricing.WorkGroups
                        If entity.Description = row.Description Then
                            entity.RowId = row.RowID
                            'entity.MarkAllColumnsAsDirty(EntitySpaces.Interfaces.esDataRowState.Modified)
                        End If
                    Next
                    ServiceLocator.Current.GetInstance(Of IWorkgroups).Update(entity)

                    currentRow += 1
                    percent = CInt((currentRow / WorkGroups.Count) * 100)
                    BackgroundWorker.ReportProgress(percent)
                Next
            End If
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Try
            currentRow = 0
            If dbFull Or dbUpgrade Then
                For Each entity As Models.LevelType In LevelTypes
                    For Each row In DataSetPricing.LevelTypes
                        If entity.LevelTypeId = row.PK_LevelTypeID Then
                            entity.RowId = row.RowID
                            'entity.MarkAllColumnsAsDirty(EntitySpaces.Interfaces.esDataRowState.Modified)
                        End If
                    Next
                    ServiceLocator.Current.GetInstance(Of ILevelTypes).Update(entity)

                    currentRow += 1
                    percent = CInt((currentRow / LevelTypes.Count) * 100)
                    BackgroundWorker.ReportProgress(percent)
                Next
            End If
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Return True
    End Function

    Private Sub TestReader()
        Dim reader As XmlReader = XmlReader.Create(String.Format("{0}\Items.xml", My.Computer.FileSystem.SpecialDirectories.Temp))
        reader.MoveToContent()

        While reader.Read
            If reader.NodeType = XmlNodeType.Element And reader.Name = "Items" Then
                Dim row As DataSetPricing.ItemsRow = New DataSetPricing.ItemsDataTable().NewItemsRow
                While reader.Read
                    If reader.NodeType = XmlNodeType.Element Then
                        Dim element As XElement = XElement.ReadFrom(reader)
                        Select Case reader.Name
                            Case "PK_ItemID"
                                row.PK_ItemID = element.Value
                                Exit Select
                            Case "ParentID"
                                row.ParentID = element.Value
                                Exit Select
                            Case "ERINumber"
                                row.ERINumber = element.Value
                                Exit Select
                            Case "Comparative"
                                row.Comparative = element.Value
                                Exit Select
                            Case "AlphaIndex"
                                row.AlphaIndex = element.Value
                                Exit Select
                            Case "Description"
                                row.Description = element.Value
                                Exit Select
                            Case "ImKing"
                                row.ImKing = element.Value
                                Exit Select
                            Case "FK_ManufacturerID"
                                row.PK_ItemID = element.Value
                                Exit Select
                            Case "FK_StatusID"
                                row.FK_StatusID = element.Value
                                Exit Select
                            Case "FK_LevelTypeID"
                                row.FK_LevelTypeID = element.Value
                                Exit Select
                            Case "FK_WorkGroupID"
                                row.FK_WorkgroupID = element.Value
                                Exit Select
                            Case "FK_CommodityID"
                                row.FK_CommodityID = element.Value
                                Exit Select
                            Case "UPC"
                                row.CatalogNumber = element.Value
                                Exit Select
                            Case "FK_UOMID"
                                row.FK_UOMID = element.Value
                                Exit Select
                            Case "Retail"
                                row.Retail = element.Value
                                Exit Select
                            Case "Cost"
                                row.Cost = element.Value
                                Exit Select
                            Case "Labor"
                                row.Labor = element.Value
                                Exit Select
                            Case "Multiplier"
                                row.Multiplier = element.Value
                                Exit Select
                            Case "ReportGroup"
                                row.ReportGroup = element.Value
                                Exit Select
                            Case "DateEffective"
                                row.DateEffective = element.Value
                                Exit Select
                            Case "ImageURL"
                                row.ImageURL = element.Value.ToString
                                Exit Select
                            Case "CatalogPageURL"
                                row.CatalogPageURL = element.Value.ToString
                                Exit Select
                            Case "LastUpdateDateTime"
                                row.LastUpdateDateTime = element.Value
                                Exit Select
                            Case "RowID"
                                row.RowID = element.Value
                                Exit Select
                        End Select
                    End If
                End While
            End If
        End While
    End Sub

    Private Function DoImpItems() As Boolean
        Dim percent As Integer = 0
        Dim currentRow As Integer = 0
        Dim ItemDataRow As DataSetPricing.ItemsRow
        Dim CommodityDataRow As DataSetPricing.CommoditiesRow
        Dim LevelTypeDataRow As DataSetPricing.LevelTypesRow
        Dim StatusDataRow As DataSetPricing.StatusRow
        Dim ManufacturerDataRow As DataSetPricing.ManufacturersRow
        Dim UomDataRow As DataSetPricing.UOMRow
        Dim WorkgroupDataRow As DataSetPricing.WorkGroupsRow
        Dim Item As Models.Item

        Manufacturers = ServiceLocator.Current.GetInstance(Of IManufacturers).Get
        WorkGroups = ServiceLocator.Current.GetInstance(Of IWorkgroups).Get
        LevelTypes = ServiceLocator.Current.GetInstance(Of ILevelTypes).Get
        ItemStatus = ServiceLocator.Current.GetInstance(Of IItemStatusTypes).Get
        UOM = ServiceLocator.Current.GetInstance(Of IUom).Get

        'If dbFull Then
        '    Try
        '        currentRow = 0

        '        Items = ServiceLocator.Current.GetInstance(Of IItems).Get("RowId Is Null")
        '        If Items.Count > 0 Then
        '            For Each row In Items
        '                'objRow = ItemsDS.Tables("Items").Select(String.Format("ERINumber = {0} And Convert(ImKing, System.Boolean) = True And Description = '{1}'", row.EriNumber, row.Description))
        '                Dim obj = ItemsDS.Tables("Items").AsEnumerable.Where(Function(d) d.Item("ERINumber").ToString = row.EriNumber.ToString And d.Item("Description").ToString = row.Description.ToString And d.Item("CatalogNumber").ToString = row.CatalogNumber.ToString And CBool(d.Item("ImKing")) = True).SingleOrDefault
        '                If Not obj Is Nothing Then
        '                    'If CStr(objRow(0).Item("ERINumber")) = row.EriNumber Then
        '                    row.RowId = CStr(obj.Item("RowID"))
        '                    'End If
        '                    ServiceLocator.Current.GetInstance(Of IItems).Update(row)
        '                End If

        '                currentRow += 1
        '                percent = CInt((currentRow / Items.Count) * 100)
        '                BackgroundWorker.ReportProgress(percent)
        '            Next
        '        End If
        '    Catch ex As Exception
        '        secondLevelMsg = ex.Message

        '        Return False

        '        Exit Function

        '    End Try

        '    Items = ServiceLocator.Current.GetInstance(Of IItems).Get("RowId is Null And ImKing = False")
        '    For Each row In Items
        '        ServiceLocator.Current.GetInstance(Of IItems).DeleteById(row.PkItems)
        '    Next
        'End If

        'Update Existing Items
        Try
            currentRow = 0

            For Each row In DataSetPricing.Items
                Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(row.RowID)

                If Not Item Is Nothing Then
                    If Not Item.DoNotUpdate Then
                        Item.EriNumber = row.ERINumber
                        Item.EriNumberSearch = row.ERINumber
                        Item.Comparative = row.Comparative
                        If row.ParentID <> 0 Then
                            ItemDataRow = DataSetPricing.Items.Where(Function(d) d.PK_ItemID = row.ParentID).SingleOrDefault
                            If Not ItemDataRow Is Nothing Then
                                Dim ItemParent As Models.Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(ItemDataRow.RowID)
                                If Not ItemParent Is Nothing Then
                                    Item.ParentId = ItemParent.PkItems
                                Else
                                    Item.ParentId = 0
                                End If
                            Else
                                Item.ParentId = 0
                            End If
                        Else
                            Item.ParentId = 0
                        End If

                        Item.CatalogNumber = row.CatalogNumber
                        Item.Description = row.Description
                        Item.MyCost = CDec(Math.Round(row.Cost * IIf(IsDBNull(Item.MyMultiplier), 1, Item.MyMultiplier), 2))
                        Item.Cost = row.Cost
                        Item.Retail = row.Retail
                        If Not Config.NoUpdateLabor Then
                            Item.Labor = row.Labor
                        End If
                        Item.EffectiveDate = row.DateEffective
                        Item.Comparative = row.Comparative
                        Item.UPC = Strings.Right(row.UPC, 5)
                        Item.AlphaIndex = row.AlphaIndex
                        Item.ReportGroup = row.ReportGroup
                        Item.ImKing = row.ImKing
                        Item.ImageUrl = IIf(IsDBNull(row.ImageURL), String.Empty, row.ImageURL)
                        Item.CatalogPageUrl = IIf(IsDBNull(row.CatalogPageURL), String.Empty, row.CatalogPageURL)
                        Item.LastCostUpdate = Date.Now

                        LevelTypeDataRow = DataSetPricing.LevelTypes.Where(Function(d) d.PK_LevelTypeID = row.FK_LevelTypeID).SingleOrDefault
                        If Not LevelTypeDataRow Is Nothing Then
                            Dim q = (From c In LevelTypes Where c.RowId = LevelTypeDataRow.RowID).SingleOrDefault
                            Item.FkLevel = q.LevelTypeId
                        Else
                            Item.FkLevel = 1
                        End If

                        StatusDataRow = DataSetPricing.Status.Where(Function(d) d.PK_StatusID = row.FK_StatusID).SingleOrDefault
                        If Not StatusDataRow Is Nothing Then
                            Dim q = (From c In ItemStatus Where c.Status = StatusDataRow.Description).SingleOrDefault
                            Item.FkStatus = q.PkItemStatusTypes
                        Else
                            Item.FkStatus = 1
                        End If

                        UomDataRow = DataSetPricing.UOM.Where(Function(d) d.PK_UOMID = row.FK_UOMID).SingleOrDefault
                        If Not UomDataRow Is Nothing Then
                            Dim q = (From c In UOM Where c.UOM = UomDataRow.ShortDescription).SingleOrDefault
                            Item.FkUom = q.IdUom
                        Else
                            Item.FkUom = 0
                        End If

                        WorkgroupDataRow = DataSetPricing.WorkGroups.Where(Function(d) d.PK_WorkGroupID = row.FK_WorkgroupID).SingleOrDefault
                        If Not WorkgroupDataRow Is Nothing Then
                            Dim q = (From c In WorkGroups Where c.RowId = WorkgroupDataRow.RowID).SingleOrDefault
                            Item.FkWorkgroup = q.PkWorkgroups
                        Else
                            Item.FkWorkgroup = 0
                        End If

                        CommodityDataRow = DataSetPricing.Commodities.Where(Function(d) d.PK_CommodityID = row.FK_CommodityID).SingleOrDefault
                        If Not CommodityDataRow Is Nothing Then
                            Dim q = ServiceLocator.Current.GetInstance(Of ICommodities).GetByRowId(CommodityDataRow.RowID)
                            Item.FkCommodityId = q.PkCommodityId
                        Else
                            Item.FkCommodityId = 0
                        End If

                        ManufacturerDataRow = DataSetPricing.Manufacturers.Where(Function(d) d.PK_ManufacturerID = row.FK_ManufacturerID).SingleOrDefault
                        If Not ManufacturerDataRow Is Nothing Then
                            Dim q = (From c In Manufacturers Where c.RowId = ManufacturerDataRow.RowID).FirstOrDefault
                            Item.FkManufacturer = q.PkManufacturerId
                        Else
                            Item.FkManufacturer = 0
                        End If
                    End If

                    ServiceLocator.Current.GetInstance(Of IItems).Update(Item)
                Else
                    Dim entity As New Models.Item

                    entity.EriNumber = row.ERINumber
                    entity.EriNumberSearch = row.ERINumber
                    entity.CatalogNumber = row.CatalogNumber
                    entity.Description = row.Description
                    entity.MyCost = row.Cost
                    entity.Cost = row.Cost
                    entity.Retail = row.Retail
                    entity.Labor = row.Labor
                    entity.EffectiveDate = row.DateEffective
                    entity.Comparative = row.Comparative
                    entity.UPC = Strings.Right(CStr(row.UPC), 5)
                    entity.AlphaIndex = row.AlphaIndex
                    entity.ReportGroup = row.ReportGroup
                    entity.ImKing = row.ImKing
                    entity.MyMultiplier = 1
                    entity.RowId = row.RowID
                    entity.ImageUrl = row.ImageURL
                    entity.CatalogPageUrl = row.CatalogPageURL
                    entity.LastCostUpdate = Date.Now
                    entity.DefaultCostCode = 0

                    If row.ParentID <> 0 Then
                        ItemDataRow = DataSetPricing.Items.Where(Function(d) d.PK_ItemID = row.ParentID).SingleOrDefault
                        If Not ItemDataRow Is Nothing Then
                            Dim ItemParent As Models.Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(ItemDataRow.RowID)
                            If Not ItemParent Is Nothing Then
                                entity.ParentId = ItemParent.PkItems
                            Else
                                entity.ParentId = 0
                            End If
                        Else
                            entity.ParentId = 0
                        End If
                    Else
                        entity.ParentId = 0
                    End If

                    LevelTypeDataRow = DataSetPricing.LevelTypes.Where(Function(d) d.PK_LevelTypeID = row.FK_LevelTypeID).SingleOrDefault
                    If Not LevelTypeDataRow Is Nothing Then
                        Dim q = (From c In LevelTypes Where c.RowId = LevelTypeDataRow.RowID).SingleOrDefault
                        entity.FkLevel = q.LevelTypeId
                    Else
                        entity.FkLevel = 1
                    End If

                    StatusDataRow = DataSetPricing.Status.Where(Function(d) d.PK_StatusID = row.FK_StatusID).SingleOrDefault
                    If Not StatusDataRow Is Nothing Then
                        Dim q = (From c In ItemStatus Where c.Status = StatusDataRow.Description).SingleOrDefault
                        entity.FkStatus = q.PkItemStatusTypes
                    Else
                        entity.FkStatus = 1
                    End If

                    UomDataRow = DataSetPricing.UOM.Where(Function(d) d.PK_UOMID = row.FK_UOMID).SingleOrDefault
                    If Not UomDataRow Is Nothing Then
                        Dim q = (From c In UOM Where c.UOM = UomDataRow.ShortDescription).SingleOrDefault
                        entity.FkUom = q.IdUom
                    Else
                        entity.FkUom = 0
                    End If

                    WorkgroupDataRow = DataSetPricing.WorkGroups.Where(Function(d) d.PK_WorkGroupID = row.FK_WorkgroupID).SingleOrDefault
                    If Not WorkgroupDataRow Is Nothing Then
                        Dim q = (From c In WorkGroups Where c.RowId = WorkgroupDataRow.RowID).SingleOrDefault
                        entity.FkWorkgroup = q.PkWorkgroups
                    Else
                        entity.FkWorkgroup = 0
                    End If

                    CommodityDataRow = DataSetPricing.Commodities.Where(Function(d) d.PK_CommodityID = row.FK_CommodityID).SingleOrDefault
                    If Not CommodityDataRow Is Nothing Then
                        Dim q = ServiceLocator.Current.GetInstance(Of ICommodities).GetByRowId(CommodityDataRow.RowID)
                        entity.FkCommodityId = q.PkCommodityId
                    Else
                        entity.FkCommodityId = 0
                    End If

                    ManufacturerDataRow = DataSetPricing.Manufacturers.Where(Function(d) d.PK_ManufacturerID = row.FK_ManufacturerID).SingleOrDefault
                    If Not ManufacturerDataRow Is Nothing Then
                        Dim q = (From c In Manufacturers Where c.RowId = ManufacturerDataRow.RowID).FirstOrDefault
                        entity.FkManufacturer = q.PkManufacturerId
                    Else
                        entity.FkManufacturer = 0
                    End If

                    ServiceLocator.Current.GetInstance(Of IItems).Add(entity)
                End If

                currentRow += 1
                percent = CInt((currentRow / DataSetPricing.Items.Rows.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Return True
    End Function

    Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPrint.Click
        If WizardControl1.SelectedPage Is WelcomeWizardPage1 Then
            Dim pd As New PrintDocument()

            AddHandler pd.PrintPage, AddressOf pd_PrintPage

            printingFont = New Font("Arial", 10)
            objReader = New StreamReader(ReadMe)

            With PrintDialog1
                .Document = pd
                .AllowPrintToFile = True
                .AllowSelection = True
                .AllowSomePages = True

                If .ShowDialog() = DialogResult.OK Then
                    pd.Print()
                End If
            End With

            objReader.Close()
            pd.Dispose()
        End If

        If WizardControl1.SelectedPage Is CompletionWizardPage1 Then
            GridControl1.Print()
        End If
    End Sub

    Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
        Dim linesPerPage As Single = 0
        Dim yPos As Single = 0
        Dim count As Integer = 0
        Dim leftMargin As Single = ev.MarginBounds.Left
        Dim topMargin As Single = ev.MarginBounds.Top
        Dim line As String = Nothing

        linesPerPage = ev.MarginBounds.Height / printingFont.GetHeight(ev.Graphics)

        While count < linesPerPage
            line = objReader.ReadLine()
            If line Is Nothing Then
                Exit While
            End If
            yPos = topMargin + count * printingFont.GetHeight(ev.Graphics)
            ev.Graphics.DrawString(line, printingFont, Brushes.Black, leftMargin, yPos, New StringFormat())
            count += 1
        End While

        If Not (line Is Nothing) Then
            ev.HasMorePages = True
        Else
            ev.HasMorePages = False
        End If
    End Sub

    Private Sub ImportPricing_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles MyBase.FormClosing
        If Failed Then
            DialogResult = Windows.Forms.DialogResult.Abort
        Else
            DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub
End Class

AnswerRe: OutOfMemoryException help please Pin
OriginalGriff17-Jul-19 5:21
protectorOriginalGriff17-Jul-19 5:21 
AnswerRe: OutOfMemoryException help please Pin
Gerry Schmitz17-Jul-19 6:07
mveGerry Schmitz17-Jul-19 6:07 
GeneralRe: OutOfMemoryException help please Pin
DTGeek17-Jul-19 6:11
memberDTGeek17-Jul-19 6:11 
AnswerRe: OutOfMemoryException help please Pin
Luc Pattyn17-Jul-19 7:42
professionalLuc Pattyn17-Jul-19 7:42 
GeneralRe: OutOfMemoryException help please Pin
DTGeek17-Jul-19 8:17
memberDTGeek17-Jul-19 8:17 
GeneralRe: OutOfMemoryException help please Pin
Luc Pattyn17-Jul-19 8:20
professionalLuc Pattyn17-Jul-19 8:20 
GeneralRe: OutOfMemoryException help please Pin
Luc Pattyn17-Jul-19 12:53
professionalLuc Pattyn17-Jul-19 12:53 
AnswerRe: OutOfMemoryException help please Pin
Eddy Vluggen17-Jul-19 13:50
mveEddy Vluggen17-Jul-19 13:50 
QuestionQuick Question - Data Validation Range with DateTime Pin
Kevin Marois16-Jul-19 7:05
professionalKevin Marois16-Jul-19 7:05 
AnswerRe: Quick Question - Data Validation Range with DateTime Pin
OriginalGriff16-Jul-19 8:16
protectorOriginalGriff16-Jul-19 8:16 
AnswerRe: Quick Question - Data Validation Range with DateTime Pin
Richard Deeming16-Jul-19 9:15
mveRichard Deeming16-Jul-19 9:15 
AnswerRe: Quick Question - Data Validation Range with DateTime Pin
BillWoodruff16-Jul-19 20:34
mveBillWoodruff16-Jul-19 20:34 
AnswerRe: Quick Question - Data Validation Range with DateTime Pin
Eddy Vluggen16-Jul-19 23:22
mveEddy Vluggen16-Jul-19 23:22 
GeneralRe: Quick Question - Data Validation Range with DateTime Pin
BillWoodruff17-Jul-19 0:43
mveBillWoodruff17-Jul-19 0:43 
GeneralRe: Quick Question - Data Validation Range with DateTime Pin
Eddy Vluggen17-Jul-19 1:09
mveEddy Vluggen17-Jul-19 1:09 
GeneralRe: Quick Question - Data Validation Range with DateTime Pin
OriginalGriff17-Jul-19 2:49
protectorOriginalGriff17-Jul-19 2:49 
GeneralRe: Quick Question - Data Validation Range with DateTime Pin
Eddy Vluggen17-Jul-19 13:53
mveEddy Vluggen17-Jul-19 13:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.