<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mycalendarsmanager.aspx.cs" Inherits="Us.Web.admin.calendars.mycalendarsmanager" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>修改日程详细</title>
    <link href="Theme/Default/main.css" rel="stylesheet" type="text/css" />
    <link href="Theme/Default/dp.css" rel="stylesheet" />
    <link href="Theme/Default/dropdown.css" rel="stylesheet" />
    <link href="Theme/Default/colorselect.css" rel="stylesheet" />


    <link href="Theme/Default/dailog.css" rel="stylesheet" type="text/css" />
    <link href="Theme/Default/calendar.css" rel="stylesheet" type="text/css" />
    <link href="Theme/Default/dp.css" rel="stylesheet" type="text/css" />
    <link href="Theme/Default/alert.css" rel="stylesheet" type="text/css" />
    <link href="Theme/Shared/blackbird.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .calpick
        {
            width: 25px;
            border: none;
            cursor: pointer;
            background: url("Images/icons/cal.gif") no-repeat center 2px;
            margin-left: -22px;
        }
    </style>
</head>
<body>
    <div>
        <div class="toolBotton">
            <a id="Savebtn"  runat="server" class="imgbtn" href="javascript:void(0);"><span class="Save" title="保存">
                保存(<u>S</u>)</span> </a><a id="Closebtn" class="imgbtn"
                        href="javascript:void(0);"><span class="Close" title="关闭窗口">关闭</span></a>
        </div>
        <div style="clear: both">
        </div>
        <div class="infocontainer">
            <form class="fform" id="fmEdit" runat="server">
            <label>
                <span>*主题： </span>
                <div id="calendarcolor">
                </div>
                <asp:TextBox MaxLength="200" class="required safe" ID="txtSubject" name="txtSubject"
                    Style="width: 85%;" runat="server"></asp:TextBox>
                <asp:HiddenField ID="colorvalue" runat="server" />
            </label>
            <label>
                <span>*时间： </span>
                <div>
                    <asp:TextBox MaxLength="10" class="required date" ID="stpartdate" Style="padding-left: 2px;
                        width: 90px;" runat="server"></asp:TextBox>
                    <asp:TextBox MaxLength="5" class="required time" ID="stparttime" name="stparttime"
                        Style="width: 40px;" runat="server"></asp:TextBox>
                    到
                    <asp:TextBox class="required date" ID="etpartdate" name="etpartdate" Style="padding-left: 2px;
                        width: 90px;" runat="server"></asp:TextBox>
                    <asp:TextBox MaxLength="50" class="required time" ID="etparttime" name="etparttime"
                        Style="width: 40px;" runat="server"></asp:TextBox>
                    <label class="checkp">
                         全天日程：
                        <asp:CheckBox ID="IsAllDayEvent"  runat="server" Checked="false"/>
                    </label>
                </div>
            </label>
            <label>
                <span>地点： </span>
                <asp:TextBox MaxLength="200" ID="txtLocation" name="txtLocation" Style="width: 95%;"
                    type="text" runat="server"></asp:TextBox>
            </label>
            <label>
                <span>参加人员： </span>
                <asp:TextBox MaxLength="200" ID="txtAttendeeNames" name="txtAttendeeNames" Style="width: 95%;"
                    type="text" runat="server"></asp:TextBox>
            </label>
            <label>
                <span>备注： </span>
                <asp:TextBox cols="20" ID="txtDescription" name="txtDescription" Style="width: 95%;
                    height: 70px" runat="server" TextMode="MultiLine" Rows="5"></asp:TextBox>
            </label>
            <input id="timezone" name="timezone" type="hidden" value="" />
            <asp:HiddenField ID="hidID" runat="server" />
            </form>
        </div>
        <script src="Javascripts/jquery.min.js" type="text/javascript"></script>
        <script src="Javascripts/Common.js" type="text/javascript"></script>
        <script src="Javascripts/Plugins/jquery.form.js" type="text/javascript"></script>
        <script src="Javascripts/Plugins/jquery.validate.js" type="text/javascript"></script>
        <script src="Javascripts/Plugins/datepicker_lang_zh_CN.js" type="text/javascript"></script>
        <script src="Javascripts/Plugins/jquery.datepicker.js" type="text/javascript"></script>
        <script src="Javascripts/Plugins/jquery.dropdown.js" type="text/javascript"></script>
        <script src="Javascripts/Plugins/jquery.colorselect.js" type="text/javascript"></script>


         
    <script src="Javascripts/Plugins/jquery.alert.js" type="text/javascript"></script>
        <script type="text/javascript">
            if (!DateAdd || typeof (DateDiff) != "function") {
                var DateAdd = function (interval, number, idate) {
                    number = parseInt(number);
                    var date;
                    if (typeof (idate) == "string") {
                        date = idate.split(/\D/);
                        eval("var date = new Date(" + date.join(",") + ")");
                    }
                    if (typeof (idate) == "object") {
                        date = new Date(idate.toString());
                    }
                    switch (interval) {
                        case "y": date.setFullYear(date.getFullYear() + number); break;
                        case "m": date.setMonth(date.getMonth() + number); break;
                        case "d": date.setDate(date.getDate() + number); break;
                        case "w": date.setDate(date.getDate() + 7 * number); break;
                        case "h": date.setHours(date.getHours() + number); break;
                        case "n": date.setMinutes(date.getMinutes() + number); break;
                        case "s": date.setSeconds(date.getSeconds() + number); break;
                        case "l": date.setMilliseconds(date.getMilliseconds() + number); break;
                    }
                    return date;
                }
            }
            function getHM(date) {
                var hour = date.getHours();
                var minute = date.getMinutes();
                var ret = (hour > 9 ? hour : "0" + hour) + ":" + (minute > 9 ? minute : "0" + minute);
                return ret;
            }
            $(document).ready(function () {
                //debugger;

                $.alerts.okButton = "确定";
                $.alerts.cancelButton = "取消";




                var arrT = [];
                var tt = "{0}:{1}";
                for (var i = 0; i < 24; i++) {
                    arrT.push({ text: StrFormat(tt, [i >= 10 ? i : "0" + i, "00"]) }, { text: StrFormat(tt, [i >= 10 ? i : "0" + i, "30"]) });
                }
                $("#timezone").val(new Date().getTimezoneOffset() / 60 * -1);
                $("#stparttime").dropdown({
                    dropheight: 200,
                    dropwidth: 60,
                    selectedchange: function () { },
                    items: arrT
                });
                $("#etparttime").dropdown({
                    dropheight: 200,
                    dropwidth: 60,
                    selectedchange: function () { },
                    items: arrT
                });
                var check = $("#IsAllDayEvent").click(function (e) {
                    if (this.checked) {
                        $("#stparttime").val("00:00").hide();
                        $("#etparttime").val("00:00").hide();
                    }
                    else {
                        var d = new Date();
                        var p = 60 - d.getMinutes();
                        if (p > 30) p = p - 30;
                        d = DateAdd("n", p, d);
                        $("#stparttime").val(getHM(d)).show();
                        $("#etparttime").val(getHM(DateAdd("h", 1, d))).show();
                    }
                });
                if (check[0].checked) {
                    $("#stparttime").val("00:00").hide();
                    $("#etparttime").val("00:00").hide();
                }
                $("#Savebtn").click(function () {

                    if (/^\s*$/.test($("#txtSubject").val())) {
                        //alert("主题不能为空!");
                        hiAlert("主题不能为空!", "确认", "");
                        return;
                    }
                    else {
                        if (!/^[^$\<\>]+$/.test($("#txtSubject").val())) {
                            //alert("不能包含以下符号: $<>!");
                            hiAlert("不能包含以下符号: $<>!", "确认", "");
                            return;
                        }
                    }

                    var isalldayevent = 0;
                    if ($("#IsAllDayEvent").attr("checked") == true) {
                        isalldayevent = "1";
                    }

                    var param = [{ "name": "calendarId", value: $("#hidID").val() }
                                    , { "name": "CalendarStartTime", value: $("#stpartdate").val() + " " + $("#stparttime").val() }
                                    , { "name": "CalendarEndTime", value: $("#etpartdate").val() + " " + $("#etparttime").val() }
                                    , { "name": "CalendarTitle", value: $("#txtSubject").val() }
                                    , { "name": "Location", value: $("#txtLocation").val() }
                                    , { "name": "timezone", value: $("#timezone").val() }
                                    , { "name": "Description", value: $("#txtDescription").val() }
                                    , { "name": "IsAllDayEvent", value: isalldayevent }
                                    , { "name": "AttendeeNames", value: $("#txtAttendeeNames").val() }
                                    , { "name": "ColorValue", value: $("#colorvalue").val() }
                    ];

                    $.post("mycalendarsajax.aspx?careffid=SaveCalendar",
                        param,
                        function (data) {
                            if (data.IsSuccess) {
                                //alert(data.Msg);
                                hiAlert(data.Msg, "确认", "");
                                CloseModelWindow(null, true);
                            }
                            else {
                                //alert("操作失败：\r\n" + data.Msg);
                                hiAlert("操作失败：\r\n" + data.Msg, "确认", "");
                            }
                        }
                    , "json");

                });

                $("#Closebtn").click(function () { CloseModelWindow(); });
                $("#Deletebtn").click(function () {
                    if (confirm("你确定要取消该日程吗？")) {
                        var param = [{ "name": "calendarId", value: $("#hidID").val() }];
                        $.post("mycalendarsajax.aspx?careffid=QuickDelete",
                        param,
                        function (data) {
                            if (data.IsSuccess) {
                                hiAlert(data.Msg, "确认", "");
                                CloseModelWindow(null, true);
                            }
                            else {
                                hiAlert("操作失败：\r\n" + data.Msg, "确认", "");
                            }
                        }
                    , "json");
                    }
                });

                $("#stpartdate,#etpartdate").datepicker({ picker: "<button class='calpick'></button>" });
                var cv = $("#colorvalue").val();
                if (cv == "") {
                    cv = "-1";
                }
                $("#calendarcolor").colorselect({ title: "颜色分类", index: cv, hiddenid: "colorvalue" });
                //定义ajaxform的调用参数
                var options = {
                    beforeSubmit: function () {
                        return true;
                    },
                    dataType: "json",
                    success: function (data) {
                        alert(data.Msg);
                        if (data.IsSuccess) {
                            CloseModelWindow(null, true);
                        }
                    }
                };
            });
        </script>
    </div>
    
</body>
</html>

