I have this application that automatically generates order ID. Now I want it to be like this 9999-99-9999, the first four numbers represents the Year. Now, the second one is the month and the last is auto-incremented.
I'm working now on the second one which is the month. So in my code I have to know whether it is a two digit number or one digit number so that I can add a zero. When I run the application there is an error which says input string was not in a correct format. What does it mean? Is there an error in my code?
private void btnOk_Click(object sender, EventArgs e)
{
string order_ID = DateTime.Now.Year.ToString();
order_ID += "-";
if (Convert.ToInt32(order_ID) < 10)
{
order_ID += "0";
}
order_ID += DateTime.Now.Month.ToString();
}
The error is in this line Convert.ToInt32(order_ID).
DateTime.Now.ToString("yyyy-MM")?