public string GetTableHtml(string roomId, DateTime sDate, DateTime eDate, bool isNetPrice)
{
StringBuilder sb = new StringBuilder();
int dLength = int.Parse(DateDiff(sDate, eDate));
DateTime theDate = sDate;
List<DateTime> li = new List<DateTime>();
for (int i = 0; i < dLength; i++)
{
if (i > 0) theDate = theDate.AddDays(1);
li.Add(theDate);
}
//判断是否跨周
int iWeek = 1;
for (int i = 1; i < li.Count; i++)
{
if ((GetWeekIndex(li[i]) - GetWeekIndex(li[i - 1])) > 0) iWeek++;
}
//循环生成表格
for (int tr = 0; tr < iWeek; tr++)
{
//生成行
sb.Append("<tr>");
//生成列
for (int td = 0; td < 7; td++)
{
string tdCss = " class='pingshi'";
if (td == 5 || td == 6) tdCss = " class='week'";
sb.Append("<td" + tdCss + ">");
if (li.Count > 0)
{
for (int n = 0; n < li.Count; n++)
{
if (Convert.ToInt32(li[n].DayOfWeek) == td)
{
//输入当前日期和价格
DateTime dt = li[n];
string cDt = dt.Month.ToString() + "月" + dt.Day.ToString() + "日";
int price = (isNetPrice) ? GetNetPrice(roomId, dt) : GetPrice(roomId, dt);
string strOut = cDt + "<br />" + price.ToString() + "元";
sb.Append(strOut);
li.Remove(li[n]);
break;
}
else
{
sb.Append(" "); break;
}
}
}
else
{
sb.Append(" ");
}
sb.Append("</td>");
}
sb.Append("</tr>");
}
return sb.ToString();
}