System.DateTime today = DateTime.Now.Date;
string str = string.Empty;
foreach (System.Data.DataRow dr in data.Rows)
{
string status = dr["Risk"].ToString();
if (status != "Open")
{
continue;
}
string dateStr = dr["逾期"].ToString().Substring(0, 10);
int year = 0;
int month = 0;
int day = 0;
int.TryParse(dateStr.Substring(6, 4), out year);
int.TryParse(dateStr.Substring(3, 2), out month);
int.TryParse(dateStr.Substring(0, 2), out day);
System.DateTime date = new DateTime(year, month, day);
int days = (date - today).Days;
int dlDays = 4;
switch (today.DayOfWeek)
{
case DayOfWeek.Monday:
case DayOfWeek.Tuesday:
case DayOfWeek.Friday:
dlDays = 4; break;
case DayOfWeek.Wednesday:
case DayOfWeek.Thursday:
dlDays = 5; break;
case DayOfWeek.Saturday:
dlDays = 3; break;
case DayOfWeek.Sunday:
dlDays = 2; break;
}
if (days <= dlDays)
{
str += "<tr>";
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">" + dr["ID"].ToString() + "</td>";
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">" + dr["主题"].ToString() + "</td>";
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">" + dr["Name"].ToString() + "</td>";
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">" + dr["Date"].ToString() + "</td>";
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">" + days.ToString() + "</td>";
if (days == 0)
{
if ((date - today).Hours > 0)
{
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap;background-color:#d15b47;color:#fff"">" + (date - today).Hours + "</td>";
}
else
{
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap;background-color:#d15b47;color:#fff"">" + (date - today).Minutes + "</td>";
}
}
else if (days == 1)
{
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap;background-color:#d15b47;color:#fff""></td>";
}
else if (date.DayOfWeek == DayOfWeek.Monday)
{
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap;background-color:#d15b47;color:#fff""></td>";
}
else
{
str += @"<td style=""border:inset #CCCCCC 1.0pt;border-top:none;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap""></td>";
}
str += "</tr>";
}
}
if (!string.IsNullOrWhiteSpace(str))
{
content = string.Format(@"
<h3>请求</h3>
<table>
<thead>
<tr>
<th style=""border:inset #CCCCCC 1.0pt;background:#CCCCCC;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">ID</th>
<th style=""border:inset #CCCCCC 1.0pt;background:#CCCCCC;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">主题</th>
<th style=""border:inset #CCCCCC 1.0pt;background:#CCCCCC;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">Name</th>
<th style=""border:inset #CCCCCC 1.0pt;background:#CCCCCC;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">Date</th>
<th style=""border:inset #CCCCCC 1.0pt;background:#CCCCCC;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">Remark</th>
<th style=""border:inset #CCCCCC 1.0pt;background:#CCCCCC;padding:1.5pt 1.5pt 1.5pt 1.5pt;white-space:nowrap"">risk</th>
</tr>
</thead>
<tbody>
{0}
</tbody>
</table>", str);
}