Encoder system, characters, and numbers incremented sequence number of the formed solution

    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,
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.
None.gif private   string  getNextString( string  source)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif                
char[] temp=source.ToCharArray();
InBlock.gif            
InBlock.gif                
int h;
InBlock.gif            
InBlock.gif                h
=1;
InBlock.gif
InBlock.gif                
for(int i=temp.Length-1;i>=0;i--)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if(!char.IsDigit(temp[i]))
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif
InBlock.gif                        
int a;
InBlock.gif                        a
=Convert.ToInt16(temp[i]);
InBlock.gif                        
if (a==72||a==78||a==89||a==87)
InBlock.gif                            a
+=2;
InBlock.gif                        
else
InBlock.gif                            a
+=h;
InBlock.gif                        
if(a>90)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                        
InBlock.gif                            temp[i]
=Convert.ToChar(65);
InBlock.gif                            h
=1;
InBlock.gif                        
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            temp[i]
=Convert.ToChar(a);
InBlock.gif                            h
=0;
ExpandedSubBlockEnd.gif                        }

ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else  
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif
InBlock.gif                        
int a;
InBlock.gif                        a
=Convert.ToInt16(temp[i])+h;
InBlock.gif                        
if(a>57)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            
if(i!=0)
InBlock.gif                                temp[i]
=Convert.ToChar(48);
InBlock.gif                            
else
InBlock.gif                                temp[i]
=Convert.ToChar(65);
InBlock.gif                            h
=1;
InBlock.gif
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            temp[i]
=Convert.ToChar(a);
InBlock.gif                            h
=0;
ExpandedSubBlockEnd.gif                        }

InBlock.gif                     
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                
string w;
InBlock.gif                w
="";
InBlock.gif                
for(int i=0;i<temp.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif
InBlock.gif                    w
+=temp[i];
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif            
InBlock.gif
InBlock.gif                
return  w ;
ExpandedBlockEnd.gif        }

None.gif
This function of the number of bits of the parameters, i.e. the length of the string is not limited.
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

Guess you like

Origin blog.csdn.net/weixin_34413802/article/details/93710266