<%@ page language="C#" masterpagefile="~/Member/MyShopMasterPage.master" autoeventwireup="true" inherits="Member_ClientRelation_ContacterManage, WebApp_deploy" title="联系人管理" %>

<asp:Content ID="contacter" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script src="../../Js/Function.js" type="text/javascript"></script>
    <script type="text/javascript">
        //切换选项卡                
        function setButtonActive(flags) {
            var _flag = parseInt(flags);
            var ulObj = document.getElementById("M1");
            for (var i = 0; i < ulObj.childNodes.length; i++) {
                ulObj.childNodes[i].className = "";
            }
            if (ulObj.childNodes.length > 2)
            { _flag = _flag * 2 + 1; }
            ulObj.childNodes[_flag].className = "active";

        }   
    </script>
    <div class="pageTitle" style="line-height: 30px; vertical-align: middle;">
        &nbsp;&nbsp;&nbsp;&nbsp;联系人管理</div>
    <div id="MainMenu">
        <div class="TabMenu">
            <!--一级导航-->
            <ul id="M1">
                <li class="active"><a href="ContacterManage.aspx?TabMenu=tabMnage">
                    <asp:Label ID="lblContacterManage" runat="server" Text="联系人管理" />
                </a></li>
                <li id="ContacterAddli"><a href="ContacterManage.aspx?TabMenu=tabAdd&action=addinfo">
                    <asp:Label ID="lblAddOrEditContacter" runat="server" Text="添加联系人" />
                </a></li>
            </ul>
        </div>
        <div class="TabText">
            <asp:HiddenField ID="hfClientID" Value="" runat="server" />
            <asp:HiddenField ID="hfContacterID" Value="" runat="server" />
            <%--联系人管理 begin--%>
            <asp:PlaceHolder ID="phContacterManage" runat="server">
                <table class="SearchTableStyle">
                    <tr>
                        <th colspan="3" style="float: left; text-align: left">
                            &nbsp;<b>高级查询：</b>
                        </th>
                    </tr>
                    <tr>
                        <td style="width: 30%">
                            &nbsp;类型：<asp:DropDownList ID="ddl_ClientType" runat="server" Width="100px" Height="20px">
                            </asp:DropDownList>
                        </td>
                        <td style="width: 30%">
                            &nbsp;客户名称：<asp:TextBox ID="txtSearchClientName" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td style="width: 30%">
                            &nbsp;姓名：<asp:TextBox ID="txtSearchTrueName" runat="server" Width="120px"></asp:TextBox>
                            &nbsp;
                            <asp:Button ID="SeachBut" runat="server" Text="查询" OnClick="SeachBut_Click" />
                        </td>
                    </tr>
                    <%--<tr>
                        <td>
                            &nbsp;
                            <asp:Button ID="SeachBut" runat="server" Text="查询" OnClick="SeachBut_Click" />
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>--%>
                </table>
                <asp:GridView ID="gvContacterManage" CssClass="tableHead" runat="server" AutoGenerateColumns="false"
                    AllowPaging="True" OnRowDataBound="gvContacterManage_RowDataBound" OnPageIndexChanging="gvContacterManage_PageIndexChanging"
                    PageSize="10">
                    <Columns>
                        <asp:TemplateField HeaderText="选择">
                            <ItemTemplate>
                                <input type="checkbox" id="contacterSelect" name="contacterSelect" value='<%# Eval("ContacterID") %>' />
                            </ItemTemplate>
                            <HeaderTemplate>
                                <input type="checkbox" id="chkAll" onclick="SelectAllCheckboxes(this,'contacterSelect')" />
                            </HeaderTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="ID" DataField="ContacterID" />
                        <asp:BoundField HeaderText="姓名" DataField="TrueName" />
                        <%-- <asp:BoundField HeaderText="称谓" DataField="Title" />--%>
                        <%--<asp:BoundField HeaderText="住宅电话" DataField="HomePhone" />
                        <asp:BoundField HeaderText="工作电话" DataField="OfficePhone" />
                        <asp:BoundField HeaderText="手机" DataField="Mobile" />--%>
                        <asp:TemplateField HeaderText="联系电话">
                            <ItemTemplate>
                                <%#GetContacPhone(Eval("HomePhone").ToString(), Eval("OfficePhone").ToString(), Eval("Mobile").ToString())%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="Email地址" DataField="Email" />
                        <asp:TemplateField HeaderText="类型">
                            <ItemTemplate>
                                <%#GetDictionaryTitle(Eval("ClientType").ToString().Trim())%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="对应客户" DataField="ClientName" />
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtnCheck" CommandName="CheckInfo" CommandArgument='<%# Eval("ContacterID")%>'
                                    OnCommand="Button_Command" runat="server">查看</asp:LinkButton>
                                <asp:LinkButton ID="lbtnUpdate" CommandName="EditInfo" CommandArgument='<%#Eval("ContacterID")%>'
                                    OnCommand="Button_Command" runat="server">修改</asp:LinkButton>
                                <asp:LinkButton ID="lbtnDelete" CommandName="DelInfo" CommandArgument='<%# Eval("ContacterID") %>'
                                    OnCommand="Button_Command" runat="server" OnClientClick="return confirm('确定要删除该信息吗？');">删除</asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <table class="tableHead" width="100%">
                            <tr>
                                <th>
                                    ID
                                </th>
                                <th>
                                    姓名
                                </th>
                                <%--<th>
                                    称谓
                                </th>
                                <th>
                                    住宅电话
                                </th>
                                <th>
                                    工作电话
                                </th>
                                <th>
                                    手机
                                </th>--%>
                                <th>
                                    联系电话
                                </th>
                                <th>
                                    Email地址
                                </th>
                                <th>
                                    类型
                                </th>
                                <th>
                                    对应客户
                                </th>
                                <th>
                                    操作
                                </th>
                            </tr>
                            <td colspan="8" style="text-align: center">
                                没有符合条件的联系人数据！
                            </td>
                        </table>
                    </EmptyDataTemplate>
                </asp:GridView>
                <div style="text-align: center;">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Literal ID="ltrPagePanel" runat="server"></asp:Literal>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                </div>
                <div>
                    &nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnMoreDelete" CommandName="MoreDelete" OnCommand="Button_Command"
                        runat="server" Text="删除所选中的联系人" />
                </div>
            </asp:PlaceHolder>
            <%--联系人管理 end--%>
            <br />
            <%--添加/修改联系人 begin--%>
            <asp:PlaceHolder ID="phContacterAddOrEdit" runat="server" Visible="false">
                <%--基本信息 begin--%>
                <table class="ShopOrderStyle">
                    <caption style="text-align: left">
                        &nbsp;&nbsp;基本信息</caption>
                    <tr>
                        <td class="OrderTitle">
                            对应客户：
                        </td>
                        <td>
                            <asp:TextBox ID="txtClient" runat="server" Enabled="false"></asp:TextBox>[<a onclick="javascript:void(0);"
                                id="showClient" style="cursor: pointer;" runat="server"><span style="color: Red">选择对应的客户</span></a>]<span
                                    style="color: Red">*</span>
                            <asp:HiddenField ID="hfDuiYingKeHu" runat="server" Value="0" />
                        </td>
                        <td class="OrderTitle">
                            称谓：
                        </td>
                        <td>
                            <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>
                        </td>
                        <%--<td class="OrderTitle">
                            上级联系人
                        </td>
                        <td>
                            <asp:TextBox ID="txtParent" runat="server" Enabled="false"></asp:TextBox>
                            [<a onclick="javascript:void(0)" id="showParentClient" runat="server"><span style="color: Red">选择上级联系人</span></a>]
                        </td>--%>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            真实姓名：
                        </td>
                        <td>
                            <asp:TextBox ID="txtTrueName" runat="server"></asp:TextBox>
                            <span style="color: Red">*</span>&nbsp;
                            <asp:RegularExpressionValidator ID="revTrueName" runat="server" ControlToValidate="txtTrueName"
                                ErrorMessage="真实姓名为中文！" ValidationExpression="^[\u4e00-\u9fa5]+$" Display="Dynamic" />
                        </td>
                        <td class="OrderTitle">
                            负责业务：
                        </td>
                        <td>
                            <asp:TextBox ID="txtOperation" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            所属部门：
                        </td>
                        <td>
                            <asp:TextBox ID="txtDepartment" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            职位：
                        </td>
                        <td>
                            <asp:TextBox ID="txtPosition" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <%--<tr>
                        <td class="OrderTitle">
                            类别：
                        </td>
                        <td>
                            <asp:RadioButtonList ID="rbl" runat="server">
                            </asp:RadioButtonList>
                        </td>
                    </tr>--%>
                    <%--<tr>
                        <td colspan="4" style="color: Blue;">
                            提示： 1.企业客户的主联系人有且只有一个，不能将主联系人直接修改为其他联系人。<br />
                            2.将客户的其他联系人设为主联系人，客户原主联系人会自动改为其他联系人。
                        </td>
                    </tr>--%>
                </table>
                <br />
                <%--基本信息 end--%>
                <%--联络信息 begin--%>
                <table class="ShopOrderStyle">
                    <caption style="text-align: left">
                        &nbsp;&nbsp;联络信息</caption>
                    <tr>
                        <td class="OrderTitle">
                            国家/地区：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlCountry" runat="server">
                                <asp:ListItem Text="中华人民共和国" Value="中华人民共和国"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="OrderTitle">
                            所在地：
                        </td>
                        <td>
                            <hl:HoWaveProvinceCity ID="HoWaveProvinceCity1" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            联系地址：
                        </td>
                        <td>
                            <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            邮政编码：
                        </td>
                        <td>
                            <asp:TextBox ID="txtZipCode" runat="server"></asp:TextBox>
                            <asp:RegularExpressionValidator ID="revZipCode" runat="server" ControlToValidate="txtZipCode"
                                ErrorMessage="邮政编码格式不对" ValidationExpression="\d{6}" Display="Dynamic" />
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            办公电话：
                        </td>
                        <td>
                            <asp:TextBox ID="txtOfficePhone" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            住宅电话：
                        </td>
                        <td>
                            <asp:TextBox ID="txtHomePhone" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            移动电话：
                        </td>
                        <td>
                            <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            传真号码
                        </td>
                        <td>
                            <asp:TextBox ID="txtFax" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            个人主页：
                        </td>
                        <td>
                            <asp:TextBox ID="txtHomepage" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            Email地址：
                        </td>
                        <td>
                            <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            QQ号码：
                        </td>
                        <td>
                            <asp:TextBox ID="txtQQ" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            MSN帐号：
                        </td>
                        <td>
                            <asp:TextBox ID="txtMSN" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            雅虎通帐号：
                        </td>
                        <td>
                            <asp:TextBox ID="txtYahoo" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            UC帐号：
                        </td>
                        <td>
                            <asp:TextBox ID="txtUC" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="color: Blue;">
                            &nbsp;&nbsp;注意：1.住宅电话、办公电话和移动电话至少填写一个!<br />
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.住宅电话、办公电话格式：<span
                                style="color: Gray;">(如：020-66693588或0771-2669288)</span>
                        </td>
                    </tr>
                </table>
                <br />
                <%--联络信息 end--%>
                <%--个人信息 begin--%>
                <table class="ShopOrderStyle">
                    <caption style="text-align: left">
                        &nbsp;&nbsp;个人信息</caption>
                    <tr>
                        <td class="OrderTitle">
                            出生日期：
                        </td>
                        <td>
                            <asp:TextBox ID="txtBirthday" runat="server" onfocus="SelectDate(this,'yyyy-MM-dd');"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            证件号码：
                        </td>
                        <td>
                            <asp:TextBox ID="txtIDCard" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            籍贯：
                        </td>
                        <td>
                            <asp:TextBox ID="txtNativePlace" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            民族：
                        </td>
                        <td>
                            <asp:TextBox ID="txtNation" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            性别：
                        </td>
                        <td>
                            <asp:RadioButtonList ID="rblSex" runat="server" RepeatDirection="Horizontal">
                            </asp:RadioButtonList>
                        </td>
                        <td class="OrderTitle">
                            婚姻状况：
                        </td>
                        <td>
                            <asp:RadioButtonList ID="rblMarriage" runat="server" RepeatDirection="Horizontal">
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            学历：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlEducation" runat="server">
                            </asp:DropDownList>
                        </td>
                        <td class="OrderTitle">
                            毕业学校：
                        </td>
                        <td>
                            <asp:TextBox ID="txtGraduateFrom" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            生活爱好：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfLife" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            文化爱好：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfCulture" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            娱乐休闲爱好：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfAmusement" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            体育爱好：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfSport" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            其它爱好：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfOther" runat="server"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            月收入：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlIncome" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            家庭状况：
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="txtFamily" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <%--个人信息 end--%>
                <div style="text-align: center;">
                    <br />
                    <asp:Button ID="btnSave" OnClick="btnSave_Click" OnClientClick="return checkPass();"
                        runat="server" Text="保存联系人信息" />
                </div>
            </asp:PlaceHolder>
            <br />
            <%--添加/修改联系人 end--%>
            <br />
        </div>
    </div>
    <script type="text/javascript">        setButtonActive('<%=m_flag %>');</script>
    <script type="text/javascript">
        //基本信息
        //对应客户
        function checkKehu() {
            var kehu = $("#<%=txtClient.ClientID %>"); //客户名称
            if (kehu.val().length == 0) {
                alert("请选择对应的客户!");
                kehu.focus();
                return false;
            }
            var duiyingkehu = $("#<%=hfDuiYingKeHu.ClientID %>"); //客户名称
            duiyingkehu.attr("value", kehu.val());
            return true;
        }
        //真实姓名
        function checkTrueName() {
            var trueName = $("#<%=txtTrueName.ClientID %>"); //客户名称
            if (trueName.val().length == 0) {
                alert("真实姓名不能为空!");
                trueName.focus();
                return false;
            }
            return true;
        }
        //移动电话、固定电话、办公电话
        function checkDianHua() {
            var mobile = $("#<%=txtMobile.ClientID %>"); //移动电话
            var homePhone = $("#<%=txtHomePhone.ClientID %>"); //固定电话(住宅电话)
            var officePhone = $("#<%=txtOfficePhone.ClientID %>"); //办公电话

            var word = /^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/; //电话号码格式

            //手机号码
            if (mobile.val().length == 0) {
                if (homePhone.val().length == 0) {
                    //办公电话
                    if (officePhone.val().length == 0) {
                        alert("住宅电话、办公电话和移动电话至少填写一个!");
                        homePhone.focus();
                        return false;
                    } else {
                        if ((word.test(officePhone.val())) == false) {
                            alert('办公电话号码为数字或格式不对！');
                            officePhone.focus();
                            return false;
                        }
                    }
                } else {
                    if ((word.test(homePhone.val())) == false) {
                        alert('住宅电话为数字或格式不对！');
                        homePhone.focus();
                        return false;
                    }
                }
            } else {
                var word1 = /\d{11}/; //手机号码格式/^1\d{10}$/;     
                if ((word1.test(mobile.val())) == false) {
                    alert('手机号码为数字或格式不对！');
                    mobile.focus();
                    return false;
                }
            }
            return true;
        }
        function checkPass() {
            if (checkKehu() && checkTrueName() && checkDianHua()) {
                return true;
            } else {
                return false;
            }
        }
    </script>
    <script type="text/javascript">
        //选择对应的客户（企业客户：ClientType_qy）
        function SelectClient(ctlName) {
            var arr = showModalDialog('ClientList.aspx?TypeSelect=ClientType_qy&ClientOwner=' +<%= user.UserID %> + '&DefaultValue=' + document.getElementById(ctlName).value, '', 'dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');
            if (arr != null) {
                var temparray = arr.split('|');
                if (temparray != null && temparray.length > 2) {
                document.getElementById(ctlName).value = temparray[0];
                }
            }
        }
        //选择上级联系人
        function SelectParent(ctlParentName) {
            var arr = showModalDialog('ClientList.aspx?DefaultValue=' + document.getElementById(ctlParentName).value, '', 'dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');
            if (arr != null) {
                document.getElementById(ctlParentName).value = arr;
            }
        }
    </script>
</asp:Content>
