I tried your proposition but it doesn't quite do what I want.
Indeed I have to increment with the max of the Id each time that the condition _currentYear == YearC is verified.
The code below make the job :
public string ECR {
get{
string _currentYear = DateTime.Today.Year.ToString();
int id ;
Id = DeveloperId
if (_currentYear == YearC)
{
id = Math.Max(Id,1) + 1;
}
else {id =1 ;}
string ecr = id.ToString() + '/' + YearC;
return ecr;
}
}
The result is eg :
I have always the question :
- The column ECR is not fill in table but it's rendering in UI. Why the value in column ECR is not write in the table?
- As you can see the result is 002/2022 which is the calculation of max(Id,1)+1. How can I start at 002/2022?
- I would like to add the format 001/2022 i.e. add zeros in front of the Id in the following way: Id takes the values 1 to 9 then the result will be 009/2022 if Id takes the values from 10 to 99 then the result will be 099/2022 ...
Thanks in advance to your help!!