public const string EmployeePrefix="EMP";
For Sql Server
Select Top(1) EmployeeId from Employees OrderBy EmployeeId Desc
here you are getting EMP010
Then
string returnEmployeeid = from query(EMP010);
returnemployeeId = returnemployeeid.substring(3,5).ToString();
so you got 010 the convertt into int
int count = convert.toint32(returnemployeeid);
count=count+1;
if(count.length >=3)
{
returnemployeeid = EmployeePrefix + count;
}
else if(count.length == 2)
{
returnemployeeid = EmployeePrefix + "0" + count;
}
else
{
returnemployeeid = EmployeePrefix + "00" + count;
}
then save the returnemployeeid to database for a new record.
MuthuKumaran.R
Senior Software Engineer
Techcello
India.
reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator