home *** CD-ROM | disk | FTP | other *** search
/ 61.19.244.139 / 61.19.244.139.zip / 61.19.244.139 / CompulWeb_Realtime / CarCode.aspx.vb.orig < prev    next >
Text File  |  2013-06-06  |  4KB  |  68 lines

  1. 
  2. Partial Class CarCode
  3.     Inherits System.Web.UI.Page
  4.     'Private Shared ReadOnly CacheKey As String = "CarCodeCacheKey"
  5.     Private ReadOnly Property CacheKey() As String
  6.         Get
  7.             'Test17
  8.             Return "CarCodeCacheKey" & strCarCode()
  9.         End Get
  10.     End Property
  11.  
  12.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  13.         If Not IsPostBack Then
  14.             grvCarCode.DataSource = GetCarCodeData()
  15.             grvCarCode.DataBind()
  16.         End If
  17.     End Sub
  18.     Private ReadOnly Property strCarCode() As String
  19.         Get
  20.             Return Request.QueryString("CarCode")
  21.         End Get
  22.     End Property
  23.  
  24.  
  25.     Private Function GetCarCodeData() As List(Of CarCodeItem)
  26.         Dim data As List(Of CarCodeItem) = DirectCast(Cache(CacheKey), List(Of CarCodeItem))
  27.  
  28.         If data Is Nothing Then
  29.             Using db_MoTypeUsage_MoVehSizeData_MoCompPrem As New CompulWeb_J_MoTypeUsage_MoVehSizeData_MoCompPremContext
  30.                 Dim IqueryX = From MO_VEH_SIZE_NotUsed In db_MoTypeUsage_MoVehSizeData_MoCompPrem.MO_VEH_SIZE_NotUsed_JTVCs _
  31.                                   Order By MO_VEH_SIZE_NotUsed.VD_Usage_Code, MO_VEH_SIZE_NotUsed.VD_Type_Code, MO_VEH_SIZE_NotUsed.VD_Size_Code _
  32.                                   Select MO_VEH_SIZE_NotUsed.VD_Usage_Code.Trim & MO_VEH_SIZE_NotUsed.VD_Type_Code.Trim & MO_VEH_SIZE_NotUsed.VD_Size_Code
  33.  
  34.                 Dim resu = (From MO_VEH_SIZE In db_MoTypeUsage_MoVehSizeData_MoCompPrem.MO_VEH_SIZE_JTVCs _
  35.                              Join MO_TYPE_USAGE In db_MoTypeUsage_MoVehSizeData_MoCompPrem.MO_TYPE_USAGE_JTVCs _
  36.                              On MO_VEH_SIZE.VD_Usage_Code Equals MO_TYPE_USAGE.TU_Usage_Code And MO_VEH_SIZE.VD_Type_Code Equals MO_TYPE_USAGE.TU_Type_Code _
  37.                              Order By MO_VEH_SIZE.VD_Usage_Code, MO_VEH_SIZE.VD_Type_Code, MO_VEH_SIZE.VD_Size_Code _
  38.                              Where Not IqueryX.ToList.Contains(MO_VEH_SIZE.VD_Usage_Code.Trim & MO_VEH_SIZE.VD_Type_Code.Trim & MO_VEH_SIZE.VD_Size_Code) And (MO_TYPE_USAGE.s_type = CChar(strCarCode)) _
  39.                              Select New CarCodeItem With {.ValueField = MO_VEH_SIZE.VD_Usage_Code.Trim & "." & MO_VEH_SIZE.VD_Type_Code.Trim & MO_VEH_SIZE.VD_Size_Code, _
  40.                                                           .TextField = MO_VEH_SIZE.VD_Usage_Code.Trim & "." & MO_VEH_SIZE.VD_Type_Code.Trim & MO_VEH_SIZE.VD_Size_Code, _
  41.                                                           .TextField2 = MO_VEH_SIZE.VD_Desc, _
  42.                                                           .VD_Usage_Code = MO_VEH_SIZE.VD_Usage_Code, _
  43.                                                           .VD_Type_Code = MO_VEH_SIZE.VD_Type_Code, _
  44.                                                           .VD_Size_Code = MO_VEH_SIZE.VD_Size_Code})
  45.                 Dim sql = DirectCast(db_MoTypeUsage_MoVehSizeData_MoCompPrem, System.Data.Linq.DataContext).GetCommand(resu)
  46.                 Dim result As String = ""
  47.                 For index As Integer = 0 To sql.Parameters.Count - 1
  48.                     result &= String.Format("{0}:{1}, ", index, sql.Parameters(index).Value.ToString)
  49.                 Next
  50.  
  51.  
  52.                 data = resu.ToList
  53.                 Cache.Add(CacheKey, data, Nothing, DateTime.Now.AddDays(10), TimeSpan.Zero, CacheItemPriority.High, Nothing)
  54.             End Using
  55.         End If
  56.  
  57.         Return data
  58.     End Function
  59.  
  60.     Protected Sub grvCarCode_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grvCarCode.RowDataBound
  61.         If e.Row.RowType = DataControlRowType.DataRow Then
  62.             e.Row.Attributes.Add("onmouseover", "javascript:setMouseOverColor(this);")
  63.             e.Row.Attributes.Add("onmouseout", "javascript:setMouseOutColor(this);")
  64.             e.Row.Attributes.Add("onclick", String.Format("javascript:selectValue('{0}','{1}');", e.Row.Cells(0).Text, e.Row.Cells(1).Text))
  65.         End If
  66.     End Sub
  67. End Class
  68.