If a database is being used to store orders, use an order-ID identity column - for example:
CREATE TABLE dbo.Orders
(
OrderID into IDENTITY(1,1),
-- other columns
)
If not (which seems unlikely), use a singleton or static order-number generator that returns the max order number returned previously plus one.
You could implement this max-plus-one logic in the button-click event handler too of course, but I would just plan on order-number generation as a responsibility to encapsulate in a distinct type.