Automatic serial number generation

Source: Internet
Author: User

//serial number consists of: p+ month Day + number
//step:
//1, query the serial number, judging the current date there is no water
//2, the current date has a serial number
///3, find the maximum, intercept +1 and generate a new serial number
//4, no serial number, direct generation
string demo = "P" + DateTime.Now.ToString ("YyyyMMdd");
int num = 0;
var query = This._context.info.where (r = R.code.contains (demo));//query current date with no serial number
if (query. Count () >0)//Some cases
{
//Query results in descending order of maximum
string maxcode = query. OrderByDescending (r = r.code). First (). Code;
//intercept number last three digits, self-increment one
num = Convert.ToInt32 (maxcode.substring (maxcode.length-3)) + 1;
//Get new serial number
demo + = num. ToString ("the");
}
else//Current date no running water
{
demo + = (num + 1). ToString ("000");//serial number starting from 1
}
TextBox1.Text = demo;//assigns the serial number to the text box, preferably readonly=true the text box property;

Automatic serial number generation

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.