none
Adding items if the product is the same...

    Frage

  • Hi Everyone. I am new to vb.net. Can someone help me please?

    The GUI below shows the same product I inputted. If I inputted the same product and a new Quantity inputted, it will add to the current Quantity inputted. Same goes to the Total Amount will change..

    Thanks Everyone! Have a Good Day!

    Freitag, 9. März 2012 11:40

Antworten

  • This is the code in my "ADD" button

    Dim lv As ListViewItem = lvTransaction.Items.Add(txtItemNum.Text)
            With lv
                .SubItems.Add(txtProdType.Text)
                .SubItems.Add(txtItemID.Text)
                .SubItems.Add(txtQTY.Text)
                .SubItems.Add(txtPrice.Text)
                .SubItems.Add(txtTAmount.Text)
            End With

    This is the code in my "UPDATE" button

    If lvTransaction.SelectedItems.Count > 0 Then
                'lvTransaction.SelectedItems(0).Text = txtItemNum.Text
                'lvTransaction.SelectedItems(0).SubItems(1).Text = txtProdType.Text
                'lvTransaction.SelectedItems(0).SubItems(2).Text = txtItemID.Text
                lvTransaction.SelectedItems(0).SubItems(3).Text = txtQTY.Text
                'lvTransaction.SelectedItems(0).SubItems(4).Text = txtPrice.Text
                'lvTransaction.SelectedItems(0).SubItems(5).Text = txtTAmount.Text
            End If

    Thats what I coded. In clicking the "ADD" button, If the item inputted is already existed, the quantity and the amount will change..

    I also posted this problem here..

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/311bb057-1cac-4189-bfd2-36b63195586d

    • Als Antwort markiert Helen Zhou Montag, 19. März 2012 09:49
    Dienstag, 13. März 2012 15:31

Alle Antworten

  • Post your code where you are adding the item to the DGV.

    Although, you can loop through the DGV and check if the Item entered exist in the DGV, simple update that selected row else insert a new row.


    Amit Govil | Email

    "Weeks of coding can save you hours of planning"

    Freitag, 9. März 2012 17:54
  • I am using ListView. For now, i don't know what to do in my problem. I am newbie in vb.net. I don't know how to code it. If you can help me in my problem, Ill appreciate it
    Sonntag, 11. März 2012 11:23
  • I don't know how to code it. If you can help me in my problem, Ill appreciate it.

    OK, but how did you already code it? Show us what you've got ... then maybe we can help.


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    Montag, 12. März 2012 01:58
  • This is the code in my "ADD" button

    Dim lv As ListViewItem = lvTransaction.Items.Add(txtItemNum.Text)
            With lv
                .SubItems.Add(txtProdType.Text)
                .SubItems.Add(txtItemID.Text)
                .SubItems.Add(txtQTY.Text)
                .SubItems.Add(txtPrice.Text)
                .SubItems.Add(txtTAmount.Text)
            End With

    This is the code in my "UPDATE" button

    If lvTransaction.SelectedItems.Count > 0 Then
                'lvTransaction.SelectedItems(0).Text = txtItemNum.Text
                'lvTransaction.SelectedItems(0).SubItems(1).Text = txtProdType.Text
                'lvTransaction.SelectedItems(0).SubItems(2).Text = txtItemID.Text
                lvTransaction.SelectedItems(0).SubItems(3).Text = txtQTY.Text
                'lvTransaction.SelectedItems(0).SubItems(4).Text = txtPrice.Text
                'lvTransaction.SelectedItems(0).SubItems(5).Text = txtTAmount.Text
            End If

    Thats what I coded. In clicking the "ADD" button, If the item inputted is already existed, the quantity and the amount will change..

    I also posted this problem here..

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/311bb057-1cac-4189-bfd2-36b63195586d

    • Als Antwort markiert Helen Zhou Montag, 19. März 2012 09:49
    Dienstag, 13. März 2012 15:31
  • In looking at the other thread, it appears you have found an answer to your problem. That other thread actually points to a third thread ... and it is in this third thread where you have an answer!!!

    You really should NOT post your question in several different places in these forums. I understand the desire to get an answer quickly and thus crosspost like that, but it's hard to follow everything that way (hard for you, for those who are trying to help and for lurkers trying to find a solution to their own problems ).


    ~~Bonnie Berent DeWitt [C# MVP]

    geek-goddess-bonnie.blogspot.com

    • Als Antwort vorgeschlagen Helen Zhou Montag, 19. März 2012 09:49
    Mittwoch, 14. März 2012 15:19