0

我有一个使用 Daypilot pro (7.9) 和 ajaxtoolkit:CalendarExtender 的网站 (.Net)。它用于在 Dynamics 中预订日期,它就像一个魅力,直到我选择 2016 年的日期......当我选择 2016 年的日期或周数时,日历会跳回到所选周的前一周。我使用的是瑞典语格式,我唯一的线索是 2015 年有 53 周,daypilot 可能会对此感到困惑?

这是代码(日期时间选择器来自 ajaxtoolkit)

<div id="divCalendar" runat="server" style="float: left; width: 90px; height:25px; margin-top: 2px;">
    <ajaxToolKit:CalendarExtender ID="calendar" runat="server" TargetControlID="dateTimeTextBox"
        Format="yyyy-MM-dd" PopupButtonID="popupButton" firstDayOfWeek="Monday" />
    <asp:TextBox ID="dateTimeTextBox" runat="server" CssClass="inputfields" Width="80px" AutoPostBack="true"
        OnTextChanged="DateTime_Changed" />
    <asp:CompareValidator ID="dateTimeTextBoxFormat" runat="server" ControlToValidate="dateTimeTextBox"
        Operator="DataTypeCheck" Type="Date" ErrorMessage="yyyy-mm-dd." Display="Dynamic"
        ValidationGroup="DateTime" />
    <asp:RequiredFieldValidator ID="dateTimeTextBoxRequired" runat="server" ControlToValidate="dateTimeTextBox"
        ErrorMessage="*" Display="Dynamic" ValidationGroup="DateTime" />
</div>
<div id="divCalendarButton" runat="server" style="float: left; width: 39px; margin-right: 12px;">
    <asp:Image ID="popupButton" runat="server" ImageUrl="/_imgs/btn_on_cal.gif" Style="cursor: pointer; height: 25px; padding-top: 3px;" />
</div>
<div id="divTime" runat="server" style="margin-left: 7px; padding-top: 3px;">
    <asp:DropDownList ID="dropDownHours" runat="server" AutoPostBack="true" />
    <asp:DropDownList ID="dropDownMinutes" runat="server" AutoPostBack="true" />
</div>

这是 DayPilot 部分:

<div style="float: left; padding: 5px;">

<DayPilot:DayPilotCalendar ID="dayPilotCalendar" runat="server" DataStartField="Start"
    DataEndField="End"  DataTextField="Name" DataValueField="Id" DataTagFields="ActivityTypeName, ColorCode, Status"
    BusinessBeginsHour="8" BusinessEndsHour="18" CellDuration="15" CellHeight="13"
    HeightSpec="BusinessHours" ShowAllDayEvents="true" AllDayEnd="Date" ShowAllDayEventStartEnd="false"
    EventClickHandling="JavaScript" EventClickJavaScript="viewEvent(e);" EventDoubleClickHandling="JavaScript"
    EventDoubleClickJavaScript="editEvent(e);" DataAllDayField="WholeDayActivity"
    TimeRangeSelectedHandling="JavaScript" TimeRangeSelectedJavaScript="createEvent(start, end, resource);"
     TimeRangeDoubleClickHandling="JavaScript" TimeRangeDoubleClickJavaScript="createEvent(start, end, resource);"
    ContextMenuID="DayPilotMenuActivity" OnBeforeEventRender="OnBeforeEventRender"
    BubbleID="ActivityCalendarBubble" ShowToolTip="false">
</DayPilot:DayPilotCalendar>

我希望有人可以帮助我找到解决方案。客户很生气,因为他们必须在日历中选择他们想要打开的那一周之后的那一周 =P

4

1 回答 1

0

谢谢丹,这就是问题所在。我从办公室的一位英雄那里得到了帮助,帮助我把正确的日期设置为.StartDate!

我们从这里改变了:

public static DateTime GetDateFromWeekNumber(int year, int weekNumber)
    {
        DateTime date = new DateTime(year, 1, 1);
        date = date.AddDays(7 * (weekNumber - 1));
        date = date.AddDays(-(int)date.DayOfWeek + 1);

        return date;
    }

对此:

public static DateTime GetFirstDayOfWeek(DateTime dayInWeek)
    {
        CultureInfo cultureInfo = CultureInfo.CurrentCulture;

        DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek;
        DateTime firstDayInWeek = dayInWeek.Date;
        while (firstDayInWeek.DayOfWeek != firstDay)
            firstDayInWeek = firstDayInWeek.AddDays(-1);

        return firstDayInWeek;
    }

现在它就像一个魅力!不是 Daypilot,只是旧代码 =D

于 2015-10-12T07:20:42.893 回答