向库存管理系统(vb.net)添加新的模块或功能

时间:2019-02-18 19:29:02

标签: vb.net vb.net-2010

enter image description here

上面的屏幕截图来自库存管理系统。

您看到上面的形式有两个ListView(ListVIewTransaction,ListViewTransactionItems)。

ListViewTransaction:包含所有事务。
ListViewTransactionItems:包含事务中的所有项目。

我的问题是,有什么方法可以向我的系统添加支持退货项的功能或撤消交易。如果是,则以下是表和查询。

Public Sub AddTransaction()
    Try
        sqL = "INSERT INTO [Transaction](InvoiceNo, TransactionDate, TransactionTime, Amount, VatAmount, TotalAmount, EmployeeID) VALUES('" & lblInvoice.Text & "', '" & Date.Now.ToString("MM/dd/yyyy") & "', '" & Date.Now.ToString("hh:mm:ss tt") & "', '" & lblSubTotal.Text.Replace(",", "") & "', '" & lblVAT.Text.Replace(",", "") & "', '" & Val(lblTotalAmount.Text.Replace(",", "")) & "', '" & Val(frmMain.lblUser.Tag) & "')"
        ConnDB()
        cmd = New SqlCommand(sqL, conn)
        cmd.ExecuteNonQuery()
    Catch ex As Exception
        MsgBox(ex.ToString)
    Finally
        cmd.Dispose()
        conn.Close()
    End Try
End Sub



Public Sub AddTransactionDetails()
    For i As Integer = 0 To dgw.Rows.Count - 1
        Try
            sqL = "INSERT INTO TransactionLineItem(InvoiceNo, ProductId, ItemPrice, Quantity, Discount, ExtendedPrice, TotalAmount) VALUES(@InvoiceNo, @ProductId, @ItemPrice, @Quantity, @Discount, @ExtendedPrice, @TotalAmount)"
            ConnDB()
            cmd = New SqlCommand(sqL, conn)
            cmd.Parameters.AddWithValue("@InvoiceNo", lblInvoice.Text)
            cmd.Parameters.AddWithValue("@ProductId", dgw.Rows(i).Cells(0).Value)
            cmd.Parameters.AddWithValue("@ItemPrice", CDbl(dgw.Rows(i).Cells(3).Value.ToString.Replace(",", "")))
            cmd.Parameters.AddWithValue("@Quantity", dgw.Rows(i).Cells(4).Value)
            cmd.Parameters.AddWithValue("@Discount", CDbl(dgw.Rows(i).Cells(6).Value.ToString.Replace(",", "")))
            cmd.Parameters.AddWithValue("@ExtendedPrice", CDbl(dgw.Rows(i).Cells(5).Value.ToString.Replace(",", "")))
            cmd.Parameters.AddWithValue("@TotalAmount", CDbl(dgw.Rows(i).Cells(7).Value.ToString.Replace(",", "")))

            cmd.ExecuteNonQuery()

        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            cmd.Dispose()
            conn.Close()
        End Try
    Next
End Sub

0 个答案:

没有答案