1 class Program2 {3 //The order Number data source, in the actual project, is read from the database .4 string[] Strlist = {"201512000001","201512000002","201512000003","201512000004", 5 "201512000008","201512000007","201512000006","201512000005", 6 "201512000009","201512000010","201512000011","201512000012",7 "201512000013","201512000014","201512000015" }; 8 Static voidMain (string[] args)9 {TenProgram P =NewProgram (); One Console.WriteLine (P.getordernum ()); A Console.readkey (); - } - the Public stringGetordernum () - { - stringresult =""; - stringYearmonth = DateTime.Now.ToString ("yyyymm"); + varCount = count (Yearmonth);//201512 5 -result = Yearmonth +"0000001"; + varDD =count. ToString (). Length; A Switch(DD) at { - Case 1: -result = Yearmonth +"00000"+ (Count +1); - Break; - Case 2: -result = Yearmonth +"0000"+ (Count +1); in Break; - Case 3: toresult = Yearmonth +" the"+ (Count +1); + Break; - Case 4: theresult = Yearmonth +"xx"+ (Count +1); * Break; $ Case 5:Panax Notoginsengresult = Yearmonth +"0"+ (Count +1); - Break; the default: +result = Yearmonth + (count +1); A Break; the } + returnresult; - } $ $ Public intCount (stringyearmonth) { - intresult =0; -result = Strlist.count (item=>item. Contains (Yearmonth)); the returnresult; - } Wuyi}
Who has a better build rule, might as well discuss the next
Order number generation rules, who knows with whom