Let's use a piece of code to talk about how I generate the document number. I wrote a class, as shown in the following code:
public class BillNo { public static object _lock = new object(); public static int count = 1; public static string GetBillNo() { lock(_lock) { if(count >= 10000) { count = 1; } var number = "P" + DateTime.Now.ToString("yyMMddHHmmss") + count.ToString("0000"); count++; return number; } } }
When using it, call it directly as follows:
BillNo.GetBillNo ();