我想在单击组合框项目时添加百分比金额。有什么办法吗?

时间:2019-01-27 16:57:10

标签: vb.net-2010

我创建了帐单系统。它想要当我单击组合框的项目时,它应该添加百分比数量并添加到总价格中。 示例表单有两个单选按钮,分别为现金= 2%和信用卡= 5%卡。如果单击现金按钮和组合框项目,则应在项目中添加百分比金额。

公开课表格1     将Dim ds作为数据集     Dim dr As DataRow     昏暗的dt作为数据表

Private Sub btnaddnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddnew.Click
    dr = dt.NewRow

    dr(0) = txtcode.Text
    dr(1) = CmbCategory.Text
    dr(2) = txtname.Text
    dr(3) = txtqty.Text
    dr(4) = txtprice.Text
    dt.Rows.Add(dr)

    txtsubtotal.Text = Val(txtsubtotal.Text) + Val(txtqty.Text) * Val(txtprice.Text)

    txtcode.Clear()

    txtname.Clear()
    txtqty.Clear()
    txtprice.Clear()
    txtcode.Focus()
    txtdiscount.Text = 0

    txttotal.Text = Val(txtsubtotal.Text) - Val(txtdiscount.Text)


End Sub

Private Sub txtcode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcode.KeyPress
    If Asc(e.KeyChar) = 13 Then
        txtname.Focus()
    End If
End Sub

Private Sub txtcode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcode.TextChanged

End Sub

Private Sub txtname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtname.KeyPress
    If Asc(e.KeyChar) = 13 Then
        txtqty.Focus()
    End If
End Sub

Private Sub txtname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtname.TextChanged

End Sub

Private Sub txtqty_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtqty.KeyPress
    If Asc(e.KeyChar) = 13 Then
        txtprice.Focus()
    End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    dt = New DataTable("Items")

    dt.Columns.add("Code")
    dt.Columns.Add("Category")
    dt.Columns.Add("Name")
    dt.Columns.add("Qty")
    dt.Columns.add("Price")
    ds = New DataSet()
    ds.Tables.add(dt)
    DataGridView1.DataMember = "Items"
    DataGridView1.DataSource = ds
End Sub

Private Sub CmbCategory_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbCategory.SelectedIndexChanged

End Sub

结束班级

enter image description here

0 个答案:

没有答案