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


<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("货车证");
            $("#mainmenu3").css("visibility", "visible");

            var ticketType = $("#TktType").val();
            $("input[name='TypeName'][value='" + ticketType + "']").attr("checked", true);


            var type = $("#Type").val();
            if (type == "Add") {

            }
            if (type == "Modify") {
                checkAll();
            }

            $("#TktComName").blur(function () {
                checkComName();
            });
            $("#tel1").blur(function () {
                checkTel();
            });
            $("#tel2").blur(function () {
                checkTel();
            });
            $("#tel3").blur(function () {
                checkTel();
            });
            $("#TktAddress").blur(function () {
                checkAddress();
            });
            $("#TktZipCode").blur(function () {
                checkZipCode();
            });
        });
        function checkAll() {
            checkTicketType(); checkComName(); checkAddress(); checkZipCode();
        }

        function isNum(num) {
            var reg = /\D/g;
            if (num != "") {
                if (reg.test(num)) {
                    return true;
                }
                else {
                    return false;
                }
            } else {
                return false;
            }
        }
        function checkPhoneNum(phoneNum) {
            //验证电话号码/传真号码合法性
            var reg = /^\d{7,}$/g;
            if (phoneNum != "") {
                if (reg.test(phoneNum)) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
        function showCheckTag(id, ispass, message) {
            if (ispass == true) {
                $("#" + id).html('<font color="green">√</font>');
            } else {
                if (message == null) {
                    message = "";
                }
                $("#" + id).html('<font color="red">※' + message + '</font>');
            }
        }
        function Save() {
            if (checkSaveInfo()) {
                $("#f1").submit();
            }
        }
        function checkSaveInfo() {
            if (!checkTicketType()) {
                MsgTip.show({ msg: "请选择车证类型！", ico: "warning", top: 340 });
                $("#TypeName").focus().select();
                return false;
            }
            if (!checkComName()) {
                MsgTip.show({ msg: "请输入公司名称！", ico: "warning", top: 340 });
                $("#TktComName").focus().select();
                return false;
            }
            if (!checkAddress()) {
                MsgTip.show({ msg: "请输入邮寄地址！", ico: "warning", top: 340 });
                $("#TktAddress").focus().select();
                return false;
            }
            if (!checkZipCode()) {
                MsgTip.show({ msg: "请输入邮编！", ico: "warning", top: 340 });
                $("#TktZipCode").focus().select();
                return false;
            }
            return true;
        }

        function checkTicketType() {
            var ticketType = $("input[name='TypeName']:checked").val();
            if (ticketType == null || ticketType == "") {
                showCheckTag("checkTypeName", false, "请选择车证类型！");
                return false;
            }
            $("#TktType").val(ticketType);
            showCheckTag("checkTypeName", true, "");
            return true;
        }
        
        function checkComName() {
            var comName = $.trim($("#TktComName").val());
            if (comName == "") {
                showCheckTag("checkComName", false, "请输入公司名称");
                return false;
            }
            showCheckTag("checkComName", true, "");
            return true;
        }
        function checkAddress() {
            var address = $.trim($("#TktAddress").val());
            var error = Address_Check("地址", address);
            if (error != "") {
                showCheckTag("checkAddress", false, error);
                return false;
            }
            showCheckTag("checkAddress", true, "");
            return true;
        }
        function checkZipCode() {
            var zipCode = $.trim($("#TktZipCode").val());
            var error = ZipCode_Check("邮编", zipCode);
            if (error != "") {
                showCheckTag("checkZipCode", false, error);
                return false;
            }
            showCheckTag("checkZipCode", true, "");
            return true;
        }

        function GoTo(str) {
            window.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/" + str;
        }
        function Back() {
            window.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/ExhiTrafficCard";
        }
    </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="0" width="100%" align="left">
                            <tr>
                                <td class="tdMenu" onclick="GoTo('ExhiActorCard')">
                                    展商胸卡
                                </td>
                                <td class="tdMenuWidth">&nbsp;</td>
                                <td class="tdMenu" onclick="GoTo('ExhiVisitCard')">
                                    客户胸卡
                                </td>
                                <td class="tdMenuWidth">&nbsp;</td>
                                <td class="tdMenuSelect" onclick="GoTo('ExhiTrafficCard')">
                                    货车证
                                </td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="tdMenuLine" colspan="6"></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <table border="0" cellpadding="0" cellspacing="10" width="100%">
                            <tr>
                                <td align="right">车证类型：</td>
                                <td>
                            <%
                                System.Data.DataTable dt = ViewData["TicketType"] as System.Data.DataTable;
                                foreach (System.Data.DataRow dr in dt.Rows)
                                {
                            %>
                                    <input type="radio" id="TypeName" name="TypeName" value="<%=dr["DctName"] %>" /><%=dr["DctName"] %>&nbsp;
                            <%        
                                }
                            %>    
                                    <input type="hidden" id="TktType" name="TktType" value="<%=Server.HtmlEncode(Model.TktType) %>" />
                                    <span id="checkTypeName"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">公司名称：</td>
                                <td>
                                    <input class="text" type="text" id="TktComName" name="TktComName" value="<%=Server.HtmlEncode(Model.TktComName) %>" />
                                    <span id="checkComName"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">地址：</td>
                                <td>
                                    <input class="text" type="text" id="TktAddress" name="TktAddress" value="<%=Server.HtmlEncode(Model.TktAddress) %>" />
                                    <span id="checkAddress"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">邮编：</td>
                                <td>
                                    <input class="text" type="text" id="TktZipCode" name="TktZipCode" value="<%=Server.HtmlEncode(Model.TktZipCode) %>" />
                                    <span id="checkZipCode"><font color="red">※</font></span>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <table border="0" cellpadding="0" cellspacing="10">
                                        <tr>
                                            <td><div class="button" onclick="Save()">保存</div></td>
                                            <td><div class="button" onclick="Back()">返回</div></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="hidden" id="Type" name="Type" value="<%=ViewData["Type"] %>" />
                                    <input type="hidden" id="TktID" name="TktID" value="<%=Model.TktID %>" />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            </form>
        </center>
    </div>
</asp:Content>
