如何合并listview内容

时间:2014-07-24 23:17:40

标签: mysql vb.net listview visual-studio-2013

我目前正在开发销售点应用程序,它工作正常,但只有一个问题。我想在这里添加图片,但我的声誉太低,无法附加一个,所以我给了链接。

http://oi60.tinypic.com/212fyvo.jpg

我使用的代码是:

 Try
    connectDB()

    Dim sqlQuery As String = "select * from tbl_product where product_code='" & txtItemCode.Text & "'"
    Dim da As New MySqlDataAdapter
    Dim myCommand As New MySqlCommand
    Dim dt As New DataTable
    Dim i As Integer

    With myCommand
        .Connection = conn
        .CommandText = sqlQuery

    End With

    With da
        .SelectCommand = myCommand
        .Fill(dt)

    End With

    Dim quantity As Integer = Integer.Parse(txtQuantity.Text)
    Dim price As Integer = Integer.Parse(txtPrice.Text)
    Dim total_price As Integer = quantity * price

    For i = 0 To dt.Rows.Count - 1
        With lvlItems
            .Items.Add(dt.Rows(i)("product_code"))
            With .Items(.Items.Count - 1).SubItems
                .Add(dt.Rows(i)("product_name"))
                .Add(quantity)
                .Add(dt.Rows(i)("product_price"))
                .Add(total_price)

            End With
            Dim TotalSum As Double = 0
            Dim TempNode As ListViewItem
            For Each TempNode In lvlItems.Items
                TotalSum += CDbl(TempNode.SubItems.Item(4).Text)
            Next
            txtTotalPrice.Text = TotalSum
        End With
    Next
Catch ex As Exception
    MsgBox(ex.Message)
End Try
disconnectDB()

我希望有人可以帮我这个,我真的想让我的应用更好。

感谢。

0 个答案:

没有答案