ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

DateTime Use in Library SystemManagement

this extension method is Used in Library System Management for return Recive book Date if you use this method this add to Date.Now 14 Days with change the Year and Month Day

Source

System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();   //object of System.Globalization.PersianCalendar class
textBox1.Text = pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now) + "/" + pc.GetDayOfMonth(DateTime.Now);   //date of today in textbox1 without change
textBox2.Text = pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now) + "/" + pc.GetDayOfMonth(DateTime.Now.AddDays(14));   //date today+14days just wiht change of day in textbox2
if (pc.GetDayOfMonth(DateTime.Now) + 14 > pc.GetDaysInMonth(pc.GetYear(DateTime.Now), pc.GetMonth(DateTime.Now)))   //condition for control month change
{
    textBox2.Text = pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now.AddMonths(1)) + "/" + pc.GetDayOfMonth(DateTime.Now.AddDays(14));   //date today+14days when month and day are changed in textbox2
    if (pc.GetMonth(DateTime.Now) + 1 > pc.GetMonthsInYear(pc.GetYear(DateTime.Now))) //condition for control year change
    {
        textBox2.Text = pc.GetYear(DateTime.Now.AddYears(1)) + "/" + pc.GetMonth(DateTime.Now.AddMonths(1)) + "/" + pc.GetDayOfMonth(DateTime.Now.AddDays(14));   //date today+14days when month,day and year are changed in textbox2
    }
}

Example

1394/2/9 ===>Date.Now


OutPut:   1394/2/23 ===> Date with increase 14 Days

Author: EbrahimKarimi

Submitted on: 29 apr. 2015

Language: C#

Type: DateTime

Views: 4439