How Can I Generate Random Unqiue Numbers in C#
- by peace
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