我在做购物车,大虾们快帮我看看这段代码什么意思啊,不胜感激!!
If Not Object.Equals(Session("ProductInCart"), Nothing) Then
Dim oHT As Hashtable = DirectCast(Session("ProductInCart"), Hashtable)
Dim oIDE As IDictionaryEnumerator = oHT.GetEnumerator()
Dim oDR As DataRow
While oIDE.MoveNext()
oDR = oDT.NewRow()
'定义一个sql查询语句
Dim sSql As String = "Select ProductId,PName,PMemberPrice from product where ProductId=" + oIDE.Key.ToString()
'调用类中的方法
Dim oDS As DataSet = OleBase.ExecuteSql4Ds(sSql)
oDR("ProductId") = oDS.Tables(0).Rows(0).ItemArray(0).ToString()
oDR("PName") = oDS.Tables(0).Rows(0).ItemArray(1).ToString()
oDR("PMemberPrice") = oDS.Tables(0).Rows(0).ItemArray(2).ToString()
oDR("PNumber") = oIDE.Value.ToString()
'获得商品的总额
dSum += Double.Parse(oDR("PMemberPrice").ToString()) * Integer.Parse(oDR("PNumber").ToString())
oDT.Rows.Add(oDR)
End While
End If
尤其是这个什么哈希表和IDictionaryEnumerator 是做什么的
If Not Object.Equals(Session("ProductInCart"), Nothing) Then
Dim oHT As Hashtable = DirectCast(Session("ProductInCart"), Hashtable)
Dim oIDE As IDictionaryEnumerator = oHT.GetEnumerator()
Dim oDR As DataRow
While oIDE.MoveNext()
oDR = oDT.NewRow()
'定义一个sql查询语句
Dim sSql As String = "Select ProductId,PName,PMemberPrice from product where ProductId=" + oIDE.Key.ToString()
'调用类中的方法
Dim oDS As DataSet = OleBase.ExecuteSql4Ds(sSql)
oDR("ProductId") = oDS.Tables(0).Rows(0).ItemArray(0).ToString()
oDR("PName") = oDS.Tables(0).Rows(0).ItemArray(1).ToString()
oDR("PMemberPrice") = oDS.Tables(0).Rows(0).ItemArray(2).ToString()
oDR("PNumber") = oIDE.Value.ToString()
'获得商品的总额
dSum += Double.Parse(oDR("PMemberPrice").ToString()) * Integer.Parse(oDR("PNumber").ToString())
oDT.Rows.Add(oDR)
End While
End If
尤其是这个什么哈希表和IDictionaryEnumerator 是做什么的
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货