public int GenPurchaseOrderNum()
{
Random random = new Random();
_uniqueNum = random.Next(13287, 21439);
return UniqueNum;
}
I removed unique constraint from the PONumber column in the db because an employee should only generate P.O. # when the deal is set. Otherwise, P.O. # would have 0.
P.O. Number used to have unique constraint, this forces employee to generate P.O. in all cases so the db doesn't throw unique constraint error.
Since i removed the unique constraint, any quote doesn't have P.O. will carry 0 value. Otherwise, a unique value is generated for P.O. #. However, i don't have a unique constraint in db which makes it hard for me to know whether the application generated P.O. # is unique or not.
What should i do?
I hope my question is clear enough
In a column, use =RAND() formula to generate a set of random numbers between 0 and 1.
In this program we call the srand () function with the system clock, to initiate the process of generating random numbers. And the rand () function is called with module 10 operator to generate the random numbers between 1 to 10. srand(time(0)); // Initialize random number generator.
The rand() function in C++ is used to generate random numbers; it will generate the same number every time we run the program. In order to seed the rand() function, srand(unsigned int seed) is used. The srand() function sets the initial point for generating the pseudo-random numbers.
A GUID is a bit high in the way of overhead. Specifically, it sounds like you need a human readable number for the PO#, which makes a GUID impractical. I'd be more inclined to use the following scenario.
That's the 20k foot view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With