Hai,
I have one doubt.I am doing billing software. In this project the bill number want to generate automatically from database and also it should be unique like bill_01,bill_02....., and I want to display it to one textbox. After that I want to saved all details to database.
Please help me for how to generate bill number automatically from form loading.....
Thanks in advance
Loading
leathu rajPosted Apr 16, 2014, 7:22 AM
Anupam SinghPosted Apr 16, 2014, 6:32 AM
or you can mark this method as static
so you can use TextBox1.Text=GenerateNumber(your_Max_bill_no);
leathu rajPosted Apr 16, 2014, 6:25 AM
Anupam SinghPosted Apr 16, 2014, 6:01 AM
find the method to generate number in sequence. I am using the silar pattern in one of my project.
public string GenerateNumber(string ReceivedId)
{
// OR0000 // pattern
if (string.IsNullOrEmpty(ReceivedId))
{
ReceivedId = "BILL_000001";
}
string nextId = string.Empty;
int len = ReceivedId.Length;
string splitNo = ReceivedId.Substring(5, len - 5);//This line will ignore the string values and read only the numeric values
int num = Convert.ToInt32(splitNo);
num++;// Increment the numeric value
nextId = ReceivedId.Substring(0, 5) + num.ToString("000000");//Concatenate the string value and the numeric value after the increment
return nextId;
// return null;
}
in input parameter use MAX(YOUR_DB_FIELD) .