Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to auto increment Request No in my application with Alphanumeric ID using mvc view

do anyone have any code or hint for it..

thanks in advance


What I have tried:

i tried to find code or logic from some of the well known sites, but i did not found any matching code...
Posted
Updated 5-Jan-18 20:08pm
Comments
Karthik_Mahalingam 6-Jan-18 1:32am    
like
REQ001
REQ002
.
.
REQ00N ?
Dheerajs975 6-Jan-18 1:34am    
yes exactly.. in mvc4
Karthik_Mahalingam 6-Jan-18 1:38am    
check this Auto generate auto incremented unique alphanumeric [^]
or handle it in the insert SP
Dheerajs975 6-Jan-18 1:43am    
i got one code, will you please tell me the correction if i ask you in that?
Karthik_Mahalingam 6-Jan-18 1:50am    
ok post it

1 solution

try

static void Main()
        {

            string a = GetAutoNumber("1"); // PR001
            string a1 = GetAutoNumber("11");// PR011
            string a2 = GetAutoNumber("111");// PR111
            string a3 = GetAutoNumber("1111");// PR1111

        }
        public static string GetAutoNumber(string lastPRNo)
        {
            string prefix = "PR";
            string number = lastPRNo;
            if (lastPRNo.Length < 3)
            {
                number = "000" + lastPRNo;
                number = number.Substring(number.Length - 3, 3);
            }

            return prefix + number;
        }
 
Share this answer
 
Comments
Dheerajs975 6-Jan-18 2:16am    
will it woek in MVC?
it is ASP.NET code ryt?
Dheerajs975 6-Jan-18 2:18am    
i want to code same as i posted in comments..
Karthik_Mahalingam 6-Jan-18 2:22am    
 public ActionResult AutoPRNo(string lastPRNo)
        {
            string prefix = "PR";
            string number = lastPRNo;
            if (lastPRNo.Length < 3)
            {
                number = "000" + lastPRNo;
                number = number.Substring(number.Length - 3, 3);
            }
            string final = prefix + number;
            ViewBag.request_number = final;
            return View();
        }

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