|
2#
楼主 |
发表于 2006-8-19 08:55:00
|
只看该作者
逻辑代码:
Dim myconstr As String = ConfigurationSettings.AppSettings("constr") & Server.MapPath(".") & ConfigurationSettings.AppSettings("dbs")
Dim mycon As OleDb.OleDbConnection = New OleDb.OleDbConnection(myconstr)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Request.Cookies("uid") Is Nothing Then
Response.Redirect("onuser.aspx")
Else
viewstate("userid") = Request.Cookies("uid").Value
If Not IsPostBack Then
BindGrid()
End If
End If
End Sub
'为datagrid绑定数据的过程
Sub BindGrid()
Dim mysql As String
mysql = "SELECT tab_salerecord.uid, tab_Pinfo.pname, tab_Pinfo.pkinds, tab_Pinfo.price, " & _
"tab_Pinfo.lprice, tab_salerecord.pcount , [lprice]*tab_salerecord!pcount AS msum, tab_salerecord.ID, tab_salerecord.yn " & _
"FROM tab_Pinfo INNER JOIN tab_salerecord ON tab_Pinfo.id = tab_salerecord.pid " & _
"WHERE tab_salerecord.uid=" & viewstate("userid") & "and isnull(tab_salerecord.lid)"
Dim mycmd As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(mysql, mycon)
Dim dt As Data.DataSet = New Data.DataSet
mycmd.Fill(dt)
Dim ta As DataTable
ta = dt.Tables(0)
DataGrid1.DataSource = ta
DataGrid1.DataBind()
Label2.Text = ta.DefaultView.Count '计算商品条目
If ta.DefaultView.Count <> 0 Then
Label3.Text = ta.Compute("sum(pcount)", Nothing) '计算商品总数
Label4.Text = ta.Compute("sum(msum)", Nothing) '计算金额
End If
End Sub
'生成订单
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
updatered()
End Sub
'继续购物
Private Sub BUTTON1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUTTON1.Click
Response.Redirect("pearch.aspx")
End Sub
'清空购物车
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim mysql As String
mysql = "delete * from tab_salerecord where uid=" & viewstate("userid")
mycon.Open()
Dim mycmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(mysql, mycon)
mycmd.ExecuteNonQuery()
mycon.Close()
BindGrid()
End Sub
'修改数量
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myitem As DataGridItem
For Each myitem In DataGrid1.Items
Dim mybox As TextBox
Dim id As Integer
mybox = myitem.Cells(6).Controls(1)
id = myitem.Cells(0).Text
Dim mycount As Integer
mycount = mybox.Text
Dim mysql As String
mysql = "UPDATE tab_salerecord SET tab_salerecord.pcount =" & mycount & " WHERE id=" & id
mycon.Open()
Dim mycmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(mysql, mycon)
mycmd.ExecuteNonQuery()
mycon.Close()
Next
BindGrid()
End Sub
'生成订单第一步:生成订单号码
Function mylist()
Dim mysql As String
mysql = "select id from tab_salelist ORDER BY ID DESC"
mycon.Open()
Dim mycmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(mysql, mycon)
Dim myrs As OleDb.OleDbDataReader
myrs = mycmd.ExecuteReader()
myrs.Read()
mylist = my |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|