Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
How can I limit the user to only adding each part only once so they will not be able to add it again? Here is the code that I have.

VB
Protected Sub btnAddPartToOrder_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim o As Order
        o = Session("CurrentOrder")
        Dim p As New PartOrdered

        'does not allow the user to add a part to their order if the same part has already been ordered
        'If p Is Nothing Then
        p.PartNum = lstPart.SelectedValue
        p.Description = lstPart.SelectedItem.Text
        p.NumOrdered = txtQuantity.Text
        p.QuotedPrice = txtPrice.Text
        o.PartsOrdered.Add(p)

        'End If


        'Session("CurrentOrder") = o

        gvPartsOrdered.DataSource = o.PartsOrdered
        gvPartsOrdered.DataBind()

    End Sub
Posted
Updated 29-Apr-12 19:10pm
v3
Comments
Lakamraju Raghuram 29-Apr-12 23:50pm    
what is your question ?

1 solution

can I limit the user to only adding each part only once so they will not be able to add it again
Yes.

How
Maintain a list of users (userid or username whatever is unique and easy for you) that has already added their part to order.
Once a user adds his part to the order, add the user to that list. Maintain the list in an application variable as it looks like spanned across multiuser. In case it's based on one session then maintain it in a session.

For Application variable: MSDN: Application State[^]

Try!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900