Click here to Skip to main content
15,881,877 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can you explain me how to auto increment the value like LG/SALES/1000,LG/SALES/1001, LG/SALES/1002.............LG/SALES/1030

i Had a Form With a label When I Load The Form The label will be fill with Alphanumeric number, THEN it will be stored into sq.

2.after that when i load the form max value comes from database and it will be incremented

my table name is sales and column name is sales_invoice(auto incremented values).
Posted

1 solution

Split on the / character using string.split[^].
Take the last value i.e. the number and the increment it by 1.
 
Share this answer
 
Comments
Being The Sharan Kumar 9-Aug-14 6:59am    
@Abhinav sir i had tried this code. The problem is that the final result doesn't appear in lable18


private void AutoIncrement()
{
var str = label18.Text;
var tempArray = str.Split('/');
string tempId = tempArray[2];
int id = Convert.ToInt32(tempId);
id = id + 1;
string autoId = "LG/SALES/" + String.Format("{0:0000000}", id);
label18.Text = autoId;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900