仅将零件添加到订单一次 [英] Adding a part to an order only once

查看:159
本文介绍了仅将零件添加到订单一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何限制用户仅将每个零件添加一次,这样他们将无法再次添加它?这是我的代码.

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.

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

推荐答案

我可以限制用户只添加一次每个零件,以使他们将无法再次添加它
是的.

如何
维护已将其部分添加到订单中的用户列表(用户ID或用户名,这对您来说是唯一且容易的).
用户将其零件添加到订单后,将用户添加到该列表.将列表维护在跨多个用户的应用程序变量中.如果它基于一个会话,则在一个会话中进行维护.

对于应用程序变量: MSDN:应用程序状态 [ ^ ]

试试吧!
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!


这篇关于仅将零件添加到订单一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆