I have a function which gives me 12 digit strings.
For eg.
AA 01 201 210 22
AA 02 201 210 22
.
.
AA 99 201 210 22
AB 01 201 210 22
& so on. . .
public string GetPersonalId(int n)
{
char letter1 = (char)('A' + ((n / 10 / 26 / 26) % 26));
char letter2 = (char)('A' + ((n / 10 / 10 ) % 26));
char digit1 = (char)('0' + ((n / 10) % 10));
char digit2 = (char)('0' + ((n) % 10));
string dateString = string.Format("{0:yyyyMMdd}", DateTime.Today)
.Insert(6, " ")
.Insert(3, " ");
return string.Format("{0}{1} {2}{3} {4}",
letter1, letter2, digit1, digit2, dateString);
}
now the problem is that for next day this sequence should start again from AA 01 201 210 23.
can anyone help me.
n, store a DateTimedtnext to it.n, check ifdtequalsDatetime.Todaynas before.nto zero (or maybe one) and setdttoDateTime.Today.(I’d also pass
dtintoGetPersonalIdrather than usingDateTime.Todayinside the function, just in case the date chnages between the two usages ofDateTime.today.)e.g. if you have
change to something like