Click here to Skip to main content
15,881,877 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more: , +
Hi guys,

I have created one asp.net page for invoice,
where i have to generate invoice no# before insertion.

for eg, creating invoice form:
Date:__________ Invoice# 10012

Item:__________ Description:__________ Qty:__________Remarks:__________

'Save'


on every new invoice, i have to auto increment the 'invoice#'.
how to do that,

plzzz help/suggest me.

thanks.
Posted
Updated 8-Apr-14 7:37am
v5
Comments
Richard C Bishop 8-Apr-14 11:49am    
Generate a number where?
abdul subhan mohammed 8-Apr-14 13:35pm    
i hv updated my question
[no name] 8-Apr-14 12:04pm    
We would have no idea what the business rules are for your invoice number. We would also have no idea what you have tried and why this is a problem.
abdul subhan mohammed 8-Apr-14 13:35pm    
i hv updated my question
abdul subhan mohammed 8-Apr-14 12:10pm    
i have update my question, plz check.

Solution:
Like if your table name is InvoiceTbl
than do this

1. Make InvioceNo column identical like identity(1, 1)

2. Run this query to get next number:
SQL
SELECT Max(InvoiceNo) FROM  InvoiceTbl


This will return you max invoice number.

2. Add One (+1) to the returned number.

3. ave the new record
 
Share this answer
 
Define the field for invoice no in the SQL as auto-increment:
http://www.w3schools.com/sql/sql_autoincrement.asp[^]
 
Share this answer
 
Comments
abdul subhan mohammed 8-Apr-14 12:16pm    
before insertion i have to show the invoice# would be this....
[no name] 8-Apr-14 12:20pm    
So get the last one inserted and increment it.
Kornfeld Eliyahu Peter 8-Apr-14 12:23pm    
That can't work if he has more than one user...
[no name] 8-Apr-14 14:05pm    
Sure it can. At no time is a user needed at all.
Kornfeld Eliyahu Peter 8-Apr-14 14:06pm    
You didn't got me. What if two or more end users are to fill the invoice form?
for adding a invoice no for your invoice form you can add it to top-left or top-right of your form(for example). for generating new invoice no for your new invoice you can create a string that has numbers and letters that with every click on create invoice button you can generate new invoice no that has a letter that show invoice type(buy,sell or other) and a number that can created randomly or with order.
 
Share this answer
 

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