简体   繁体   English

如何找到ASP.NET时间表控件?

[英]how do I find an ASP.NET Timetable control?

I am developing a Web Application that shows the cost of energy based on the electric tariffs. 我正在开发一个Web应用程序,该应用程序根据电价显示能源成本。

I need some kind of timetable that allows the user to define different electric tariffs with different intervals of hours for every day of the week. 我需要某种时间表,允许用户在一周中的每一天以不同的小时间隔定义不同的电费。

I need something flexible, but only for a week. 我需要一些灵活的东西,但是只需要一个星期。 I do not need a calendar or a scheduler. 我不需要日历或调度程序。 I didn't find any control that is simple, flexible, and integrates with .NET. 我没有找到任何简单,灵活且与.NET集成的控件。

Where can I find such a control? 在哪里可以找到这样的控件?

Does it need to be an ASP.NET control? 它需要是一个ASP.NET控件吗? Perhaps a clientside jQuery control populated via a JSON feed would be a suitable alternative? 也许通过JSON feed填充的客户端jQuery控件将是合适的选择? I can recommend jQuery Week Calendar . 我可以推荐jQuery Week Calendar

I think you can define it pretty flexibly with the following table structure: 我认为您可以使用以下表结构非常灵活地定义它:

CREATE TABLE [dbo].[TarrifWindows](
    [Id] [int] NOT NULL,
    [StartTime] [datetime] NOT NULL,
    [EndTime] [datetime] NOT NULL,
    [StartDay] [int] NOT NULL,
    [EndDay] [int] NOT NULL,
    [TarriffAmount] [money] NOT NULL,
 CONSTRAINT [PK_TarrifWindows] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

The "Day" fields are day ordinals rather than datetime values, eg, 0 is Sunday, 5 is Friday. “日”字段是日序号,而不是日期时间值,例如0是星期日,5是星期五。 This should allow you to specify any crazy window you want, whether it's Monday - Friday, or 2:37 AM - 2:38 AM on a Tuesday morning. 这应该使您可以指定所需的任何疯狂窗口,无论是星期一-星期五,还是星期二早上的2:37 AM-2:38 AM。 To determine what window you're in, you just take query the table such that the current date ordinal is between the start and end day, and the current time is between the start and end time. 要确定您所在的窗口,只需查询表,以使当前日期序号在开始和结束日期之间,而当前时间在开始和结束时间之间。 You might have to do some fancy footwork with windows that span midnight...I haven't run all of the combinations in my head. 您可能需要使用跨午夜的窗户做一些花哨的步法...我还没有脑子里所有的组合。

You didn't specify a database platform, so if you're looking to avoid that, you could store this in a datatable and then serialize it to xml locally. 您没有指定数据库平台,因此,如果要避免这种情况,可以将其存储在数据表中,然后在本地将其序列化为xml。 It seems pretty lightweight to me. 对我来说似乎很轻巧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM