Private Sub CallBackGrid(ByVal ar As IAsyncResult)
If ar Is Nothing Then
m_waitWindow.lblMessage.Text = "Please wait.. while Loading Grid."
m_waitWindow.Show()
Dim RunDelegate As AsyncDelegate = AddressOf FillGrid
RunDelegate.BeginInvoke(ar, AddressOf CallBackGrid, RunDelegate)
ElseIf ar.IsCompleted Then
m_waitWindow.Hide()
End If
End Sub
Private Sub FillGrid(ByVal ar As IAsyncResult)
Dim entityObject As New B_Entity
Dim whereClause, orderBy As String
Dim entitySchema As String
Dim recordCount As Long
If txtLabel.Text.Trim <> "" Then
whereClause = "Label Like '" & txtLabel.Text & "%'"
End If
If txtParentEntity.Text.Trim <> "" Then
whereClause = "ParentEntity Like '" & txtParentEntity.Text & "'"
End If
If txtTableName.Text.Trim <> "" Then
whereClause = "TableName Like '" & txtTableName.Text & "'"
End If
If txtLevel.Text.Trim <> "" Then
whereClause = "Level = " & txtLevel.Text
End If
orderBy = "TableName ASC"
whereClause = ""
orderBy = ""
Try
Dim entityData As DataTable = entityObject.GetEntities(m_Page, CType(txtRecordsPerPage.Text, Integer), "*", "CRM_UDF_GetConfig_Entities()", whereClause, orderBy, recordCount)
entitySchema = "Entity_Guid,ParentEntity_Guid,TableName,SortOrder,Level,Entity_Label,ParentEntity_Label,Active"
spdEntities.ActiveSheet.RowCount = entityData.Rows.Count
Dim i, j As Integer
For i = 0 To entityData.Rows.Count - 1
spdEntities.ActiveSheet.SetActiveCell(i, 1)
spdEntities.ActiveSheet.Cells(i, 1).Value = entityData.Rows(0)("Entity_Guid").ToString
spdEntities.ActiveSheet.Cells(i, 2).Value = entityData.Rows(0)("ParentEntity_Guid").ToString
spdEntities.ActiveSheet.Cells(i, 3).Value = entityData.Rows(0)("Entity_Label").ToString
spdEntities.ActiveSheet.Cells(i, 4).Value = entityData.Rows(0)("ParentEntity_Label").ToString
spdEntities.ActiveSheet.Cells(i, 5).Value = entityData.Rows(0)("TableName").ToString
spdEntities.ActiveSheet.Cells(i, 6).Value = entityData.Rows(0)("SortOrder").ToString
spdEntities.ActiveSheet.Cells(i, 7).Value = entityData.Rows(0)("Level").ToString
spdEntities.ActiveSheet.Cells(i, 8).Value = entityData.Rows(0)("Active")
Next
txtTotalRecords.Text = CType(recordCount, String)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub