Hi, again about DateTime method I get to some conclusionns and build a class of my problem that solve the last expired day of some product I get a day od today and number of month when product can used without any problem and the day when product was made
and compare these two days...
i want to here your opinion about this clas and usinf the Datetime method
Thanks Sergey
class Date
{
//data memebers
private DateTime today = DateTime.Now; // variable for todays data
private DateTime published=new DateTime(1900,1,1);//variable for date when product made
private int month; // the number of month that product can used
private DateTime ExDay;// the day when product is expired
//constructors
public Date(DateTime today, DateTime published, int month)
{
this.today = today;
this.published = published;
this.month = month;
}
//properties
public DateTime Publish
{
get { return published; }
set
{
Console.Write(" enter a date when a product was made in format(yy/mm/dd) :");
published = value;
}
}
public int MonthEx
{
get { return month; }
set
{
Console.Write(" Enter a number of month user can used a product :");
do
{
month = value;
if (month <= 0) Console.WriteLine(" Wrong number Please Re-Enter!!");
} while (month <= 0);
}
}
//Methods
//function that solve the expired day
private DateTime Expired()
{
ExDay=published.AddDays(month * 30);
return ExDay;
}
//function that solve if it already over the last expired day or not
public void Condition()
{
int cond = DateTime.Compare(today, ExDay);
if (cond >= 0) Console.WriteLine(" You can use the product !!!");
Console.WriteLine(" You can't use the product!!!");
}
// bool todayEqualsToday = DateTime.Equals(today1, today2);
// Console.WriteLine(todayEqualsToday);
// // todayEqualsTomorrow gets false.
// bool todayEqualsTomorrow = DateTime.Equals(today1, tomorrow);
// Console.WriteLine(todayEqualsTomorrow);
// DateTime today = DateTime.Now;
//DateTime answer = today.AddDays(1);
//Console.WriteLine("{0}", answer);
// DateTime today1 =
// new System.DateTime(DateTime.Today.Ticks);
// DateTime today2 =
// new DateTime(DateTime.Today.Ticks);
//DateTime tomorrow =
// new System.DateTime(
// DateTime.Today.AddDays(1).Ticks);
// // todayEqualsToday gets true.
// bool todayEqualsToday = DateTime.Equals(today1, today2);
// Console.WriteLine(todayEqualsToday);
// // todayEqualsTomorrow gets false.
// bool todayEqualsTomorrow = DateTime.Equals(today1, tomorrow);
// Console.WriteLine(todayEqualsTomorrow);
}