开发者

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.

I need some kind of timetable that allows the user to define different electric 开发者_Python百科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.

Where can I find such a control?


Does it need to be an ASP.NET control? Perhaps a clientside jQuery control populated via a JSON feed would be a suitable alternative? I can recommend 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, e.g., 0 is Sunday, 5 is Friday. 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. 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. It seems pretty lightweight to me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜