Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Friends:

I am creating a billing software in C#. I have a text box and a button . On the text box i want Bill Number and on button click i want to Print that .

But the problem is i want to auto generate bill no. every time +1 after print command .


like i give the print command for bill no 1 then after print it should be +1 on last bill number....






Please ingonre grammer mistake and help me regarding this...

thanks:
Posted

1 solution

Basically, you need a singleton which generates new number every time. (A simple hint: the current number should be a static field of the generator type.) As you might need to continue the same numbering after your application is terminated and executed again, you need to persist the last generated number: a database, a file. You need to keep last generated number in some persistent storage and restore at the beginning of runtime.

Please see:
http://en.wikipedia.org/wiki/Singleton_pattern[^],
implementation is C#: http://csharpindepth.com/Articles/General/Singleton.aspx[^].

—SA
 
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