当前位置:编程学习 > C#/ASP.NET >>

求VB高手帮忙修改下实现功能

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strField As String
        Dim strValue As String
        If RadioButton1.Checked Then
            strField = "商品名称"
            strValue = "'" & TextBox1.Text & "'"
        Else
            strField = "类型编号"
            'strValue = "'" & TextBox1.Text & "'"

            strValue = " (select 编号 from Type where 名称='" & TextBox1.Text & "')"
        End If

        Dim SQLString As String = "SELECT * FROM sale where " & strField & "=" & strValue & ""
        ListView1.Items.Clear()
        Dim SQLString1 As String = "SELECT * FROM sale where 日期 Between '" & DTP1.Value & "' and '" & DTP2.Value & "'"[img=http://][/img]
        Dim SqlString2 As String = "SELECT sum(利润总计) FROM sale where 日期 Between '" & DTP1.Value & "' and '" & DTP2.Value & "'"
        Dim dt As DB数据表 = New DB数据表(ConnStr)
        Dim table As DataTable = dt.CreateDataTable(SQLString, "sale")
        Dim UserRow As DataRow
        Dim LItem As ListViewItem
        For Each UserRow In table.Rows
            LItem = New ListViewItem(UserRow(0).ToString())
            Dim i As Integer
            For i = 1 To ListView1.Columns.Count - 1
                LItem.SubItems.Add(CStr(UserRow(i) & ""))
            Next
            ListView1.Items.Add(LItem)
        Next

        Dim table2 As DataTable = dt.CreateDataTable(SqlString2, "sale")
        For Each UserRow In table2.Rows
            LblSum.Text = "总利润:" & (UserRow(0) & "")
        Next

        table2 = dt.CreateDataTable("select 商品名称,sum(利润总计) from Sale GROUP BY 商品名称", "sale")
        For Each UserRow In table2.Rows

            Debug.Print(Double.Parse(UserRow(1)))
        Next
    End Sub
我还想要实现按商品名查找商品的利润统计 --------------------编程问答-------------------- 就是要实现最下面的这两个功能
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,