How to achieve automatic increase of document number through C #.

Source: Internet
Author: User

Next, I'll give you a piece of code. It has a full annotation inside.

Using System;

Namespace Baselayer
{
///


The document number, which produces the DJ000002 number, such as: the entry parameter is "DJ000003" and returns "
///
public class Sheetnumber
{
///
The document number, which produces the DJ000002 number, such as: the entry parameter is "DJ000003" and returns "
///
///Original value
/// Next value
public string Nextnumber (string basenumber)
{
String newnumber = "";//New value
int innumber = 1;//rounding
int placevalue;//bit value
char[] No = Basenumber.tochararray ();

for (int i=basenumber.length-1;i>=0;i--)
{
if (no[i]== ' 9 ' && innumber==1)
{
Innumber=1;
Newnumber= "0" +newnumber;
}
Else
if (innumber==1 && no[i]>= ' 0 ' && no[i]< ' 9 ')
{
Placevalue=int32.parse (No[i]. ToString ());
Placevalue= (Innumber+placevalue);
innumber=0;
Newnumber=placevalue.tostring () +newnumber;
}
Else
{
innumber=0;
Newnumber=no[i]+newnumber;
}
}
if (Basenumber==newnumber)
Newnumber= "0000000001";
return newnumber;
}
}
}

Ok. If you ever have to append your own document number. This piece of code should probably fulfill your requirements, right? '





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.