คำตอบ Adding items if the product is the same...

  • 9 มีนาคม 2555 11:40
     
     

    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!

ตอบทั้งหมด

  • 9 มีนาคม 2555 17:54
     
     

    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"

  • 11 มีนาคม 2555 11:23
     
     
    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
  • 12 มีนาคม 2555 1:58
     
     
    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

  • 13 มีนาคม 2555 15:31
     
     คำตอบ

    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

    • ทำเครื่องหมายเป็นคำตอบโดย Helen ZhouModerator 19 มีนาคม 2555 9:49
    •  
  • 14 มีนาคม 2555 15:19
     
     คำตอบที่เสนอ

    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

    • เสนอเป็นคำตอบโดย Helen ZhouModerator 19 มีนาคม 2555 9:49
    •