asp.net(c#)两时间段每天是星期几,周几(时间段日历显示)的问题解

简介:

asp.net(c#)两时间段每天是星期几,周几(时间段日历显示)的问题解决

string   temp="<table width=\"560\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"dddddd\" align=center height=\"100\"> ";

temp=temp+"<tr align=\"center\" bgcolor=\"#CCCCCC\"> ";
temp=temp+"<td width =\"14%\" height=\"19\"> 日</td> ";
temp=temp+"<td width=\"14%\"> 一</td> ";
temp=temp+"<td width=\"14%\"> 二</td> ";
temp=temp+"<td width=\"14%\"> 三</td> ";
temp=temp+"<td width=\"14%\"> 四</td> ";
temp=temp+"<td width=\"14%\"> 五</td> ";
temp=temp+"<td width=\"14%\"> 六</td> ";
temp=temp+"</tr> ";
temp = temp + "<tr align=center bgcolor=ffffff height=19> ";

DateTime dt1 = System.Convert.ToDateTime("2009-7-2");
DateTime dt2 = System.Convert.ToDateTime("2009-8-20");
TimeSpan ts = dt2 -dt1 ;

int countday = (int)ts.TotalDays;

int maxi = countday;
int i=1 ;
while (dt1 < dt2)
{

    if (i == 1)
    {
        int t = xingqi(dt1.ToString("yyyy-MM-dd").ToString()); //开始的第一天位置
     
        while (i < t+1)
        {
            temp = temp + "<td align=center></td>";
            i++;
        }
    }

        temp = temp + "<td align=center>" + dt1.ToString("yyyy-MM-dd").ToString() + "</td>";


        if (i % 7 == 0)
                {
                    temp = temp + "</tr><tr align=center bgcolor=ffffff height=19>";
                }

                i = i + 1;

                dt1 = dt1.AddDays(1);


}

temp = temp + "</table>";


Response.Write(temp);
    }
    public static int xingqi(string d)      //判断星期几
    {
        int reslut = 0;  //周日
        string xq = Convert.ToDateTime(d).DayOfWeek.ToString();
        switch (xq)
        {
            case "Monday":   //星期一;
                reslut = 1;
                break;
            case "Tuesday":
                reslut = 2;
                break;
            case "Wednesday":
                reslut = 3;
                break;
            case "Thursday":
                reslut = 4;
                break;
            case "Friday":
                reslut = 5;
                break;
            case "Saturday":  //星期六;
                reslut = 6;
                break;
            case "Sunday":
                reslut = 0;
                break;
            default:
                reslut = 0;
                break;
        }
        return reslut;
    }
 asp.net(c#)两时间段每天是星期几,周几(时间段日历显示)的问题解决



本文转自左正博客园博客,原文链接:http://www.cnblogs.com/soundcode/archive/2011/07/20/2112040.html,如需转载请自行联系原作者

目录
相关文章
|
10月前
|
Java 物联网 C#
C#/.NET/.NET Core学习路线集合,学习不迷路!
C#/.NET/.NET Core学习路线集合,学习不迷路!
394 0
|
5月前
|
SQL 小程序 API
如何运用C#.NET技术快速开发一套掌上医院系统?
本方案基于C#.NET技术快速构建掌上医院系统,结合模块化开发理念与医院信息化需求。核心功能涵盖用户端的预约挂号、在线问诊、报告查询等,以及管理端的排班管理和数据统计。采用.NET Core Web API与uni-app实现前后端分离,支持跨平台小程序开发。数据库选用SQL Server 2012,并通过读写分离与索引优化提升性能。部署方案包括Windows Server与负载均衡设计,确保高可用性。同时针对API差异、数据库老化及高并发等问题制定应对措施,保障系统稳定运行。推荐使用Postman、Redgate等工具辅助开发,提升效率与质量。
177 0
|
9月前
|
开发框架 搜索推荐 算法
一个包含了 50+ C#/.NET编程技巧实战练习教程
一个包含了 50+ C#/.NET编程技巧实战练习教程
250 18
|
9月前
|
缓存 算法 安全
精选10款C#/.NET开发必备类库(含使用教程),工作效率提升利器!
精选10款C#/.NET开发必备类库(含使用教程),工作效率提升利器!
254 12
|
9月前
|
开发框架 人工智能 .NET
C#/.NET/.NET Core拾遗补漏合集(24年12月更新)
C#/.NET/.NET Core拾遗补漏合集(24年12月更新)
125 6
|
9月前
|
开发框架 算法 .NET
C#/.NET/.NET Core技术前沿周刊 | 第 15 期(2024年11.25-11.30)
C#/.NET/.NET Core技术前沿周刊 | 第 15 期(2024年11.25-11.30)
123 6
|
9月前
|
开发框架 Cloud Native .NET
C#/.NET/.NET Core技术前沿周刊 | 第 16 期(2024年12.01-12.08)
C#/.NET/.NET Core技术前沿周刊 | 第 16 期(2024年12.01-12.08)
120 6
|
9月前
|
开发框架 监控 .NET
C#进阶-ASP.NET WebForms调用ASMX的WebService接口
通过本文的介绍,希望您能深入理解并掌握ASP.NET WebForms中调用ASMX WebService接口的方法和技巧,并在实际项目中灵活运用这些技术,提高开发效率和应用性能。
510 5
|
9月前
|
算法 Java 测试技术
Benchmark.NET:让 C# 测试程序性能变得既酷又简单
Benchmark.NET是一款专为 .NET 平台设计的性能基准测试框架,它可以帮助你测量代码的执行时间、内存使用情况等性能指标。它就像是你代码的 "健身教练",帮助你找到瓶颈,优化性能,让你的应用跑得更快、更稳!希望这个小教程能让你在追求高性能的路上越走越远,享受编程带来的无限乐趣!
407 13
|
10月前
|
Java 物联网 编译器
C#一分钟浅谈:.NET Core 与 .NET 5 区别
本文对比了 .NET Core 和 .NET 5,从历史背景、主要区别、常见问题及易错点等方面进行了详细分析。.NET Core 侧重跨平台支持和高性能,而 .NET 5 在此基础上统一了 .NET 生态系统,增加了更多新特性和优化。开发者可根据具体需求选择合适的版本。
344 7

热门文章

最新文章