Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to generate Invoice Number on each Bill

Tags:

c#

I have generated a Bill Generator application without using a database. This application generates bills and saves them with a file name in a folder as an HTML file. Right now I am using a timestamp to generate a unique ID for each bill. Now I want to reduce the length of my ID; I want to use serial number.

Problem: I am using an integer variable and on click I increment the value by one, but when I restart my application, the counter is reset...

How can I save last generated value and pick up where I left off when the application restarts?

like image 789
Sahil Ali Avatar asked Dec 07 '25 01:12

Sahil Ali


1 Answers

Here are some options, depending on your application and needs:

  • Use a text file.
  • Store the value in a user-scoped Setting.
  • Save the value somewhere in the registry.
  • Parse the value from the last generated bill and resume where you left off.
  • Save the value on your web server and retrieve it when necessary.
  • Have your web server or something else persistent always generate the values instead of creating them locally.
  • Ask the user to remember the number and enter it the next time.
like image 159
lc. Avatar answered Dec 08 '25 16:12

lc.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!