Guest User

Untitled

a guest
Sep 23rd, 2011
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.48 KB | None | 0 0
  1. DataLayer:
  2. Sub GetStatistics(ByVal ProductNumbers As List(Of String), ByRef Passed As Integer, ByRef TestList As List(Of KeyValuePair(Of String, Integer)))
  3.         For Each productNumber As String In ProductNumbers
  4.             Dim TestAddIndex As Integer
  5.             Using context As New SelmaEntities
  6.                 context.CommandTimeout = 150
  7.                 Dim Table = (From GoodProducts In context.TestResults
  8.                             Where (GoodProducts.Art_no = productNumber)
  9.                             Select GoodProducts.Art_no, GoodProducts.Failed).AsQueryable
  10.  
  11.                 Dim GetTPDesc = (From tpProducts In context.TestResultLim
  12.                                 Where tpProducts.Art_no = productNumber
  13.                                 Order By tpProducts.TP_no
  14.                                 Select tpProducts.TP_desc)
  15.                 For Each key In GetTPDesc
  16.                     TestList.Add(New KeyValuePair(Of String, Integer)(key.ToString, 0))
  17.                 Next
  18.  
  19.                 Passed += Table.Where(Function(p) p.Failed <> 0 And p.Art_no = productNumber).Count
  20.                 For Each ArtFailedPair In Table
  21.                     TestAddIndex = ArtFailedPair.Failed
  22.                     If TestAddIndex <> 0 Then
  23.                         TestList(TestAddIndex - 1) = New KeyValuePair(Of String, Integer)(TestList(TestAddIndex - 1).Key, TestList(TestAddIndex - 1).Value + 1)
  24.                     End If
  25.                 Next
  26.             End Using
  27.         Next
  28.     End Sub
  29.  
  30. UserInterface:
  31.  
  32. Sub GetStatistics(ByRef listView As ListView, ByRef label As Label)
  33.  
  34.         Dim passed As Integer
  35.         dataLayer.GetStatistics(ProductNumbers, passed, TestList)
  36.         label.Text = passed.ToString
  37.         ListViewReBind(listView)
  38.         passed = 0
  39.     End Sub
  40.  
  41.     Sub ListViewReBind(ByRef listView As ListView)
  42.         listView.DataSource = TestList
  43.         listView.DataBind()
  44.     End Sub
  45.  
  46. And Code-Behind:
  47.  
  48. Public Sub ListView1_PagePropertiesChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.PagePropertiesChangingEventArgs) Handles ListView1.PagePropertiesChanging
  49.  
  50.         userInterface.ListViewReBind(ListView1)
  51.  
  52.     End Sub
  53.  
  54. And the pager:
  55.  
  56. <asp:DataPager ID="DataPager1" runat="server" PageSize="5">
  57.             <Fields>
  58.               <asp:NextPreviousPagerField
  59.                 ButtonType="Button"
  60.                 ShowFirstPageButton="true"
  61.                 ShowLastPageButton="true" />
  62.             </Fields>
  63. </asp:DataPager>
Advertisement
Add Comment
Please, Sign In to add comment