zoukankan      html  css  js  c++  java
  • 在页面上打印日历


    @helper SignInCalender(DateTime argDate)
    {
        DateTime vFirstDay = new DateTime(argDate.Year, argDate.Month, 1);
        int vLastday = argDate.AddMonths(1).AddDays(-1).Day;//获取当月的最后一天
        int vWeek = (int)vFirstDay.DayOfWeek;//获取当年当月1号的星期

        int vMaxCells = 28;//页面上最多显示的单元格数
        int vPrdictDays = vLastday + vWeek;
        if (vPrdictDays > 35)
        {
            vMaxCells = 42;
        }
        else if (vPrdictDays > 28)
        {
            vMaxCells = 35;
        }
       
        System.Web.Mvc.TagBuilder tagTable = new System.Web.Mvc.TagBuilder("table");
        tagTable.InnerHtml = "<tr><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>";
       
        int vDay = 1;
        System.Web.Mvc.TagBuilder tagFirsTR = new System.Web.Mvc.TagBuilder("tr");
        for (int j = 0; j < vMaxCells; j++)
        {
            System.Web.Mvc.TagBuilder tagTd = new System.Web.Mvc.TagBuilder("td");
            string vDays = string.Empty;

            if (j >= vWeek && vDay <= vLastday)
            {
                vDays = vDay.ToString();
                vDay++; 
            }
           
            tagTd.SetInnerText(vDays);

            tagFirsTR.InnerHtml += tagTd.ToString();
            if ((j+1) % 7 == 0)
            {
                tagTable.InnerHtml += tagFirsTR.ToString();
                tagFirsTR.InnerHtml = string.Empty;
            }
        }

        @System.Web.Mvc.MvcHtmlString.Create(tagTable.ToString());
    }

  • 相关阅读:
    十天冲刺开发第六天个人工作总结
    十天冲刺开发第五天个人工作总结
    人月神话阅读笔记1
    第六周进度条
    构建之法阅读笔记6
    连通数组的最大子数组和
    团队项目成员和题目
    第五周进度条
    四则运算———安卓版
    构建执法阅读笔记5
  • 原文地址:https://www.cnblogs.com/xuxu-dragon/p/4137093.html
Copyright © 2011-2022 走看看