Click here to Skip to main content
15,119,954 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How I do this , I want to expire User that have joining date If he not visited our company in 7 days then he will be expired.....
PLZ tell me .... thanks in advance

C#
public bool CheckExpireUser(int UserId)
{
DateTime joingDte= MRB.get_JoingDate(UserId);
DateTime expireUsr = joingDte.AddDays(7);

if (expireUsr<=DateTime.Now)
{
    return true;
}
else
{
    MRB.Expire_Reg_Code(UserId); //EXPIRE USER ID CODE
    return false;

}
Posted
Updated 20-Nov-13 0:32am
v2
Comments
adityasahver 20-Nov-13 5:33am
   
what is meant by expire over here.. are you deleting the user from the database, or setting some Expire flag to True or something?
kashifjaat 20-Nov-13 5:44am
   
No, Just want to Expire his status

It's unlikely that you want to check for the "joiningDate" as this is a value that should probably never change.

I'd probably add another field in the database like "lastVisitDate" and update this field each time the user loggs in. You can then modify that piece of code to check if the lastVisitDate is older than 1 week ago.
   
Comments
kashifjaat 20-Nov-13 5:46am
   
I don't want to change the value of joining date I want jo add 7 days in joing days in local variable and if return false then change his status
kashifjaat 20-Nov-13 5:49am
   
and I don't want create New field in DB.
Nicholas Marty 20-Nov-13 5:57am
   
I'm not sure if I understand correctly. You want every user to expire after 7 days? If so where are you experiencing any issues? (I was probably more focussed on the "If he not visited our company in 7 days" part. you need to store when his last visit was otherwise it will be a bit difficult to know when his last visit was ;) )
Here at CodeProject you may find many articles on making 'trial version'[^] of your software.
   
Exactly, as Nicholas has already suggested.
Create a new column, say UserLastLogin, and every time the user logs in Update that column's value.
And then you can create a batch job where you will be checking the UserLastLogin with the current date, if the difference is more then 7 days(in this case) we can delete the UserRecord from the table or set the Expire flag as True.
   

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