<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ExhibitorMaster.Master" Inherits="System.Web.Mvc.ViewPage<FamousFurnitureExpo.Models.Activity>" %>


<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Scripts/CheckInfo.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#CurrentPosition").html("我的活动");
            $("#menu41").css("visibility", "visible");

            var atyType = $("#AtyType").val();
            $("input[name='rdoType'][value='" + atyType + "']").attr("checked", true);

            var atyDate = $("#AtyDate").val();
            if (atyDate != "") {
                $("input[name='rdoDate'][value='" + atyDate + "']").attr("checked", true);
            }
        });

        function Save() {
            
            if (checkInfo()) {
                var rdoType = $("input[name='rdoType']:checked").val();
                $("#AtyType").val(rdoType);
                $("#f1").submit();
            }
        }
        function checkInfo() {
            var theme = $("#AtyTheme").val();
            if ($.trim(theme) == "") {
                $("#AtyTheme").focus().select();
                showMsg("请输入活动主题！");
                return false;
            }
            var content = $("#AtyContent").val();
            if ($.trim(content) == "") {
                $("#AtyContent").focus().select();
                showMsg("请输入活动内容！");
                return false;
            }
            var rdoDate = $("input[name='rdoDate']:checked").val();
            $("#AtyDate").val(rdoDate);
            var date = $("#AtyDate").val();
            if ($.trim(date) == "") {
                $("#rdoDate1").focus().select();
                showMsg("请选择活动日期！");
                return false;
            }

            $("#AtyBTime").val($("#selBTHour").val() + ":" + $("#selBTMinute").val());
            var btime = $("#AtyBTime").val();
            if ($.trim(btime) == "") {
                $("#AtyBTime").focus().select();
                showMsg("请输入活动开始时间！");
                return false;
            } else {
                if (!checkTime($.trim(btime))) {
                    $("#AtyBTime").focus().select();
                    showMsg("活动开始时间格式不正确！");
                    return false;
                }
            }
            $("#AtyETime").val($("#selETHour").val() + ":" + $("#selETMinute").val());
            var etime = $("#AtyETime").val();
            if ($.trim(etime) == "") {
                $("#AtyETime").focus().select();
                showMsg("请输入活动结束时间！");
                return false;
            } else {
                if (!checkTime($.trim(etime))) {
                    $("#AtyETime").focus().select();
                    showMsg("活动结束时间格式不正确！");
                    return false;
                }
            }
            var place = $("#AtyPlace").val();
            if ($.trim(place) == "") {
                $("#AtyPlace").focus().select();
                showMsg("请输入活动地点！");
                return false;
            }
            var url = $("#AtyUrl").val();
            if ($.trim(url) != "") {
                if (!checkUrl($.trim(url))) {
                    $("#AtyUrl").focus().select();
                    showMsg("请正确输入活动网址！以“http://”开头！");
                    return false;
                }
            }
            var quota = $("#AtyQuoTa").val();
            if ($.trim(quota) != "") {
                if (!checkNum(quota)) {
                    $("#AtyQuoTa").focus().select();
                    showMsg("名额必须为数字！");
                    return false;
                }
            } else {
                $("#AtyQuoTa").val("0");
            }
            var price = $("#AtyPrice").val();
            if ($.trim(price) != "") {
                if (!checkPrice(price)) {
                    $("#AtyPrice").focus().select();
                    showMsg("价格格式不正确！");
                    return false;
                }
            } else {
                $("#AtyPrice").val("0");
            }
            return true;
        }
        function showMsg(msg) { 
            MsgTip.show({ msg: msg, ico: "warning", top: 340 });
        }
        function checkTime(time) {
            //var reg = /^(([0-1]{0,1}[0-9]{1})|([2]{1}[0-3]{1}))[:]{1}([0-5]{1}[0-9]{1})$/;
            var reg = /^(([0-1]{1}[0-9]{1})|([2]{1}[0-3]{1}))[:]{1}([0-5]{1}[0-9]{1})$/;
            if (reg.test(time)) {
                return true;
            } else {
                return false;
            }
        }
        function checkNum(num) {
            var reg = /^[0-9]{1,}$/;
            if (reg.test(num)) {
                return true;
            } else {
                return false;
            }
        }
        function checkPrice(price) {
            var reg = /^(([0-9]{1,}[.]{1}[0-9]{1,})|([0-9]{1,}))$/;
            if (reg.test(price)) {
                return true;
            } else {
                return false;
            }
        }

        function Back() {
            window.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/ActivityList";
        }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <center>
            <form id="f1" action="" method="post">
            <table width="100%" border="0" style="text-align: left" cellpadding="0" cellspacing="0" id="main">
                <tr>
                    <td align="left">
                         <table border="0" cellpadding="0" cellspacing="10" width="100%">
                            <tr>
                                <td width="100" align="right">活动类型：</td>
                                <td valign="top">
                                <% 
                                    List<FamousFurnitureExpo.Models.Dict> typeLi = FamousFurnitureExpo.Models.Activity.GetAtyTypeList();
                                    for (int i = 0; i < typeLi.Count; i++)
                                    {
                                        string check = "";
                                        if (i == 0)
                                        {
                                            check = " checked='checked' ";
                                        }
                                %>
                                    <input type="radio" <%=check %> id="rdo<%=i %>" name="rdoType" value="<%=typeLi[i].DctValue %>" /><%=Server.HtmlEncode(typeLi[i].DctName) %>&nbsp;
                                <%        
                                    }    
                                %>
                                    <input type="hidden" id="AtyType" name="AtyType" value="<%=Model.AtyType %>" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">活动主题：</td>
                                <td>
                                    <input type="text" class="text" id="AtyTheme" name="AtyTheme" value="<%=Server.HtmlEncode(Model.AtyTheme) %>" />
                                    <span id="checkTheme"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" valign="top">活动内容：</td>
                                <td valign="top">
                                    <textarea cols="40" rows="10" id="AtyContent" name="AtyContent"><%=Server.HtmlEncode(Model.AtyContent) %></textarea>
                                    <span id="checkContent" style="vertical-align:top"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">活动日期：</td>
                                <td>
                                    <%
                                        //预约日期
                                        List<DateTime> li = new List<DateTime>();
                                        DateTime exhBTime = Convert.ToDateTime(Session["ExhBTime"]);
                                        DateTime exhETime = Convert.ToDateTime(Session["ExhETime"]);
                                        if (exhBTime < exhETime)
                                        {
                                            DateTime currentDate = exhBTime;
                                            while (currentDate <= exhETime)
                                            {
                                                li.Add(currentDate);
                                                currentDate = currentDate.AddDays(1);
                                            }
                                        }
                                        int j = 0;
                                        foreach (DateTime date in li)
                                        {
                                            j++;
                                    %>
                                    <input type="radio" id="rdoDate<%=j %>" name="rdoDate" value="<%=date.ToShortDateString() %>" /><%=date.ToShortDateString() %>&nbsp;
                                    <%    
                                        }
                                        DateTime dt = Model.AtyDate;
                                        string atyDate="";
                                        if (dt.Year != 1)
                                        {
                                            atyDate = dt.ToShortDateString();
                                        }
                                    %>
                                    <input type="hidden" class="text" id="AtyDate" name="AtyDate" readonly="readonly" onkeydown="event.returnValue=false;" value="<%=atyDate %>" />
                                    <span id="checkDate"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">活动时间：</td>
                                <td>
                                    <script type="text/javascript">
                                        $(function () {
                                            var bTime = $("#AtyBTime").val();
                                            var eTime = $("#AtyETime").val();

                                            if (bTime != "") {
                                                var b = bTime.split(':');
                                                $("#selBTHour").val(b[0]);
                                                $("#selBTMinute").val(b[1]);
                                            }
                                            if (eTime != "") {
                                                var e = eTime.split(':');
                                                $("#selETHour").val(e[0]);
                                                $("#selETMinute").val(e[1]);
                                            }
                                        });

                                        var varOptionHour = "";
                                        for (var i = 0; i < 24; i++) {
                                            var hour = i + "";
                                            if (i < 10) {
                                                hour = "0" + hour;
                                            }
                                            varOptionHour += "<option value='" + hour + "'>" + hour + "</option>";
                                        }
                                        var varOptionMinute = "";
                                        for (var i = 0; i < 60; i++) {
                                            var minute = i + "";
                                            if (i < 10) {
                                                minute = "0" + minute;
                                            }
                                            varOptionMinute += "<option value='" + minute + "'>" + minute + "</option>";
                                        }
                                        var html = "";
                                        html += "<select id='selBTHour' name='selBTHour' style='width:40px;'>" + varOptionHour + "</select>";
                                        html += "时";
                                        html += "<select id='selBTMinute' name='selBTMinute' style='width:40px;'>" + varOptionMinute + "</select>";
                                        html += "分";
                                        html += "&nbsp;至&nbsp;";
                                        html += "<select id='selETHour' name='selETHour' style='width:40px;'>" + varOptionHour + "</select>";
                                        html += "时";
                                        html += "<select id='selETMinute' name='selETMinute' style='width:40px;'>" + varOptionMinute + "</select>";
                                        html += "分";
                                        document.write(html);
                                    </script>
                                    <%--<input type="text" class="text" id="AtyBTime" name="AtyBTime" value="<%=Server.HtmlEncode(Model.AtyBTime) %>" style="width:91px" />至
                                    <input type="text" class="text" id="AtyETime" name="AtyETime" value="<%=Server.HtmlEncode(Model.AtyETime) %>" style="width:91px" />--%>
                                    <span id="checkTime"><font color="red">※</font></span>
                                    <input type="hidden" id="AtyBTime" name="AtyBTime" value="<%=Server.HtmlEncode(Model.AtyBTime) %>" />
                                    <input type="hidden" id="AtyETime" name="AtyETime" value="<%=Server.HtmlEncode(Model.AtyETime) %>" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">活动地点：</td>
                                <td>
                                    <input type="text" class="text" id="AtyPlace" name="AtyPlace" value="<%=Server.HtmlEncode(Model.AtyPlace) %>" />
                                    <span id="checkPlace"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">活动链接：</td>
                                <td>
                                    <input type="text" class="text" id="AtyUrl" name="AtyUrl" value="<%=Server.HtmlEncode(Model.AtyUrl) %>" />（例：http://www.baidu.com）
                                </td>
                            </tr>
                            <tr>
                                <td align="right">主讲人：</td>
                                <td>
                                    <input type="text" class="text" id="AtySpeaker" name="AtySpeaker" value="<%=Server.HtmlEncode(Model.AtySpeaker) %>" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">名额：</td>
                                <td>
                                    <input type="text" class="text" id="AtyQuoTa" name="AtyQuoTa" onkeyup="value=$.trim(value)" value="<%=Model.AtyQuoTa %>" />（为0时不限）
                                </td>
                            </tr>
                            <tr>
                                <td align="right">价格：</td>
                                <td>
                                    <input type="text" class="text" id="AtyPrice" name="AtyPrice" onkeyup="value=$.trim(value)" value="<%=Model.AtyPrice %>" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <input type="hidden" id="Type" name="Type" value="<%=ViewData["Type"] %>" />
                                    <input type="hidden" id="AtyID" name="AtyID" value="<%=Model.AtyID %>" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <table border="0" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td><div class="button" onclick="Save()">保存</div></td>
                                            <td><div class="button" onclick="Back()">返回</div></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            </form>
        </center>
    </div>
</asp:Content>
