In the encoder system, the coding is formed according to predefined encoding rules good. A variety of business rules coded in the coding sequence of numbers formed generally divided into several such rules:
1, all formed from 0-9; 000-999
2. entirely of uppercase and lowercase letters; AAA- ZZZ
. 3, with the composition of letters and numbers; A00-Z99
for the above types can also be formed in other embodiment variants;
if the segment sequence number is 3, when all of the digits 0-9 is formed, so that relatively simple procedures to achieve as numerical data plus 1 to get the next sequential code. Here the sequence number for all types of strings gives a solution formed by the characters or letters and numbers, this solution also solves all reaches the maximum sequence number is 999, the numeral formed by a sequence number to prevent it becomes the case 000; a
database system in the encoder, encoding is formed will be stored, encoding 1CB11200A01, the sequence number is three, he would be stored in the database tables in the code field code_h,
Not coded storage method discussed here, so there will no longer deeply. Want to say here is that we can get the current maximum sequence number A01 categories from a database table. The following write a function to achieve change from A01 to A02, the A01 as a parameter, the return value is what we need to A02.
It is generated from the encoding A01-Z99, will obtain the next number A00 999.
This is after I joined the company, to improve the coding system made some contribution.
1, all formed from 0-9; 000-999
2. entirely of uppercase and lowercase letters; AAA- ZZZ
. 3, with the composition of letters and numbers; A00-Z99
for the above types can also be formed in other embodiment variants;
if the segment sequence number is 3, when all of the digits 0-9 is formed, so that relatively simple procedures to achieve as numerical data plus 1 to get the next sequential code. Here the sequence number for all types of strings gives a solution formed by the characters or letters and numbers, this solution also solves all reaches the maximum sequence number is 999, the numeral formed by a sequence number to prevent it becomes the case 000; a
database system in the encoder, encoding is formed will be stored, encoding 1CB11200A01, the sequence number is three, he would be stored in the database tables in the code field code_h,
code_h | |
1CB11200A01 |
Not coded storage method discussed here, so there will no longer deeply. Want to say here is that we can get the current maximum sequence number A01 categories from a database table. The following write a function to achieve change from A01 to A02, the A01 as a parameter, the return value is what we need to A02.
private
string
getNextString(
string
source)
{
char[] temp=source.ToCharArray();
int h;
h=1;
for(int i=temp.Length-1;i>=0;i--)
{
if(!char.IsDigit(temp[i]))
{
int a;
a=Convert.ToInt16(temp[i]);
if (a==72||a==78||a==89||a==87)
a+=2;
else
a+=h;
if(a>90)
{
temp[i]=Convert.ToChar(65);
h=1;
}
else
{
temp[i]=Convert.ToChar(a);
h=0;
}
}
else
{
int a;
a=Convert.ToInt16(temp[i])+h;
if(a>57)
{
if(i!=0)
temp[i]=Convert.ToChar(48);
else
temp[i]=Convert.ToChar(65);
h=1;
}
else
{
temp[i]=Convert.ToChar(a);
h=0;
}
}
}
string w;
w="";
for(int i=0;i<temp.Length;i++)
{
w+=temp[i];
}
return w ;
}
This function of the number of bits of the parameters, i.e. the length of the string is not limited.
{
char[] temp=source.ToCharArray();
int h;
h=1;
for(int i=temp.Length-1;i>=0;i--)
{
if(!char.IsDigit(temp[i]))
{
int a;
a=Convert.ToInt16(temp[i]);
if (a==72||a==78||a==89||a==87)
a+=2;
else
a+=h;
if(a>90)
{
temp[i]=Convert.ToChar(65);
h=1;
}
else
{
temp[i]=Convert.ToChar(a);
h=0;
}
}
else
{
int a;
a=Convert.ToInt16(temp[i])+h;
if(a>57)
{
if(i!=0)
temp[i]=Convert.ToChar(48);
else
temp[i]=Convert.ToChar(65);
h=1;
}
else
{
temp[i]=Convert.ToChar(a);
h=0;
}
}
}
string w;
w="";
for(int i=0;i<temp.Length;i++)
{
w+=temp[i];
}
return w ;
}
It is generated from the encoding A01-Z99, will obtain the next number A00 999.
This is after I joined the company, to improve the coding system made some contribution.
Reproduced in: https: //www.cnblogs.com/yitian/articles/809575.html