Private string jia7 (datatable DT, int dd) // calculate the correct date after 7 days
{
String date = "";
Int riqi = 0, days = 0, Day = 0;
String date = DT. Rows [0] [0]. tostring ();
Int testdate = convert. toint32 (date. substring (); // year
Int testdate1 = convert. toint32 (date. substring (); // month
Int testdate2 = convert. toint32 (date. substring (6, 2); // obtain the date
Days = Yuefen (testdate1); // verify the month and give the correct number of days
Riqi = convert. toint32 (testdate2) + dd;
If (riqi> days) // if the date after 7 days is greater than the date of this month
{
If (testdate1 = 12) // if the current month is January 1, December
{
Day = Yuefen (1); // upload the day January back to calculate the day January
Testdate1 = 1; // change the month to February.
Testdate = testdate + 1; // and Add 1 to the current year
}
Else
{
Testdate1 = testdate1 + 1; // Add 1 to the current month
Day = Yuefen (testdate1 );
}
Day = riqi-days; // subtract the date of the new month from the date of the last seven days.
Date + = testdate; // Add the correct year
If (testdate1> 0 & testdate1 <10)
{
Date + = 0;
Date + = testdate1;
}
Else
{
Date + = testdate1; // Add the correct month
}
If (day> 0 & day <10)
{
Date + = 0;
Date + = Day;
}
Else
{
Date + = day; // Add the correct date
}
}
Else
{
Date + = testdate;
If (testdate1> 0 & testdate1 <10)
{
Date + = 0;
Date + = testdate1;
}
Else
{
Date + = testdate1; // Add the correct month
}
If (riqi> 0 & riqi <10)
{
Date + = 0;
Date + = riqi;
}
Else
{
Date + = riqi; // Add the correct date
}
}
Return date;
}
Private string jian7 (datatable DT, int dd) // calculate the correct date after 7 days
{
String date = "";
Int riqi = 0, days = 0, Day = 0;
String date = DT. Rows [0] [0]. tostring ();
Int testdate = convert. toint32 (date. substring (); // year
Int testdate1 = convert. toint32 (date. substring (); // month
Int testdate2 = convert. toint32 (date. substring (6, 2); // obtain the date
Days = Yuefen (testdate1); // verify the month and give the correct number of days
Riqi = convert. toint32 (testdate2)-dd; // subtract 7 days from the number of days obtained
If (riqi <1) // if the result is smaller than 1, reduce it by one month.
{
If (testdate1 = 1) // if the current month is January 1, January
{
Day = Yuefen (12); // The number of days passed for December 1, December
Testdate1 = 12; // change the month to January 1, December.
Testdate = testDate-1; // The Year of month rollback is also rolled back
}
Else
{
Testdate1 = testDate1-1; // subtract 1 from the retrieved month
Day = Yuefen (testdate1 );
}
Day = day + riqi; // calculate the correct date
Date + = testdate; // Add the correct year
If (testdate1> 0 & testdate1 <10)
{
Date + = 0;
Date + = testdate1;
}
Else
{
Date + = testdate1; // Add the correct month
}
If (day> 0 & day <10)
{
Date + = 0;
Date + = Day;
}
Else
{
Date + = day; // Add the correct date
}
}
Else
{
Date + = testdate;
If (testdate1> 0 & testdate1 <10)
{
Date + = 0;
Date + = testdate1;
}
Else
{
Date + = testdate1; // Add the correct month
}
If (riqi> 0 & riqi <10)
{
Date + = 0;
Date + = riqi;
}
Else
{
Date + = riqi; // Add the correct date
}
}
Return date;
}
Private int Yuefen (INT testdate1) // accept the month to calculate the correct number of days of the month
{
Int days = 0;
Switch (testdate1) // verify the month and give the correct number of days
{
Case 1:
Days = 31;
Break;
Case 2:
If (convert. toint32 (testdate1) % 4 = 0)
{
Days = 29;
}
Else
{
Days = 28;
}
Break;
Case 3:
Days = 31;
Break;
Case 4:
Days = 30;
Break;
Case 5:
Days = 31;
Break;
Case 6:
Days = 30;
Break;
Case 7:
Days = 31;
Break;
Case 8:
Days = 31;
Break;
Case 9:
Days = 30;
Break;
Case 0:
Days = 31;
Break;
Case 11:
Days = 30;
Break;
Case 12:
Days = 31;
Break;
}
Return days;
}