<%@ page language="C#" masterpagefile="../MyShopMasterPage.master" autoeventwireup="true" inherits="Member_ClientRelation_ClientManage, WebApp_deploy" enableeventvalidation="false" title="客户管理" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script src="../../Js/Function.js" type="text/javascript"></script>
    <%--    <script src="../../Skin/Index/js/jquery-1.4.4.min.js" type="text/javascript"></script>--%>
    <script src="../Js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
    <link href="../Js/jquery-ui-1.8.2.custom.css" rel="stylesheet" type="text/css" />
    <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 > 4)
            { _flag = _flag * 2 + 1; }
            ulObj.childNodes[_flag].className = "active";

        }
    </script>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <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="ClientManage.aspx?TabMenu=Myclient">
                    <asp:Label ID="lblMyClient" runat="server" Text="我的客户" />
                </a></li>
                <li><a href="ClientManage.aspx?TabMenu=Addpsn&action=addinfo">
                    <asp:Label ID="lblAddpsn" runat="server" Text="添加个人" />
                </a></li>
                <li><a href="ClientManage.aspx?TabMenu=Addcmp&action=addinfo">
                    <asp:Label ID="lblAddcmp" runat="server" Text="添加企业" />
                </a></li>
                <li><a href="ClientManage.aspx?TabMenu=Merge">
                    <asp:Label ID="Label2" runat="server" Text="合并客户" />
                </a></li>
            </ul>
        </div>
        <div class="TabText">
            <!--我的客户 begin -->
            <asp:PlaceHolder ID="PlaceHolder1" runat="server">
                <table class="SearchTableStyle">
                    <tr>
                        <th colspan="3" class="title" style="text-align: left;">
                            <b>&nbsp;高级查询：</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%">
                            客户组别：
                            <asp:DropDownList ID="ddl_GroupID" runat="server" Width="100px" Height="20px">
                            </asp:DropDownList>
                        </td>
                        <td style="width: 30%">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区域：
                            <asp:DropDownList ID="ddl_Area" runat="server" Width="100px" Height="20px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;阶段：
                            <asp:DropDownList ID="ddl_PeriodType" runat="server" Width="94px" Height="20px">
                            </asp:DropDownList>
                        </td>
                        <td>
                            客户类型：
                            <asp:DropDownList ID="ddl_IsBusiness" runat="server" Width="94px" Height="20px">
                            </asp:DropDownList>
                        </td>
                        <td>
                            &nbsp;客户名称：<asp:TextBox ID="txtSearchClientName" runat="server" Width="120px"></asp:TextBox>
                            &nbsp;
                            <asp:Button ID="SeachBut" runat="server" Text="查询" OnClick="SeachBut_Click" />
                        </td>
                    </tr>
                </table>
                <asp:GridView ID="gvClient" runat="server" AllowPaging="True" AutoGenerateColumns="false"
                    CssClass="tableHead" OnRowDataBound="gvClient_RowDataBound" OnPageIndexChanging="gvClient_PageIndexChanging"
                    PageSize="10">
                    <Columns>
                        <asp:TemplateField HeaderText="选择">
                            <ItemTemplate>
                                <input type="checkbox" id="IdSelect" name="IdSelect" value='<%# Eval("ClientID") %>' />
                            </ItemTemplate>
                            <HeaderTemplate>
                                <input type="checkbox" id="chkAll" onclick="SelectAllCheckboxes(this,'IdSelect')" />选择
                            </HeaderTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="ID" DataField="ClientID" />
                        <asp:BoundField DataField="ClientName" HeaderText="客户名称" />
                        <asp:TemplateField HeaderText="客户类型">
                            <ItemTemplate>
                                <%#GetDictionaryTitle(Eval("ClientType").ToString().Trim())%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="客户组别">
                            <ItemTemplate>
                                <%#GetDictionaryTitle(Eval("GroupID").ToString().Trim()) %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="区域">
                            <ItemTemplate>
                                <%#GetDictionaryTitle(Eval("Area").ToString().Trim())%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="阶段">
                            <ItemTemplate>
                                <%#GetDictionaryTitle(Eval("PeriodType").ToString().Trim())%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="用户类型">
                            <ItemTemplate>
                                <%#GetDictionaryTitle(Eval("IsBusiness").ToString().Trim())%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="最近联系时间" DataField="LastRelationTime" />
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtnCheck" CommandName="CheckInfo" CommandArgument='<%# string.Format("{0},{1}",GetDictionaryTitle(Eval("ClientType").ToString().Trim()),Eval("ClientID"))%>'
                                    OnCommand="Button_Command" runat="server">查看</asp:LinkButton>
                                <asp:LinkButton ID="lbtnUpdate" CommandName="EditInfo" CommandArgument='<%# string.Format("{0},{1}",GetDictionaryTitle(Eval("ClientType").ToString().Trim()),Eval("ClientID"))%>'
                                    OnCommand="Button_Command" runat="server">修改</asp:LinkButton>
                                <asp:LinkButton ID="lbtnDelete" CommandName="DelInfo" CommandArgument='<%# Eval("ClientID") %>'
                                    OnCommand="Button_Command" runat="server" OnClientClick="return confirm('确定要删除该信息吗？');">删除</asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <table style="width: 100%">
                            <tr>
                                <th>
                                    ID
                                </th>
                                <th>
                                    客户名称
                                </th>
                                <th>
                                    客户类型
                                </th>
                                <th>
                                    客户组别
                                </th>
                                <th>
                                    区域
                                </th>
                                <th>
                                    阶段
                                </th>
                                <th>
                                    用户类型
                                </th>
                                <th>
                                    最近联系时间
                                </th>
                                <th>
                                    操作
                                </th>
                            </tr>
                            <tr>
                                <td colspan="9">
                                    没有符合查询条件的记录！
                                </td>
                            </tr>
                        </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>
                <br />
            </asp:PlaceHolder>
            <!--我的客户 end -->
            <!--添加客户 begin -->
            <asp:PlaceHolder ID="PlaceHolder2" runat="server" Visible="false">
                <!--基本信息，就是客户信息表-->
                <table class="ShopOrderStyle">
                    <caption style="text-align: left">
                        <asp:HiddenField ID="hfIsRepeatKhName" Value="" runat="server" />
                        &nbsp;&nbsp;&nbsp;&nbsp;基本信息<asp:HiddenField ID="hfClientName" runat="server" />
                    </caption>
                    <tr>
                        <td class="OrderTitle">
                            客户姓名 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtClientName" runat="server" Width="120px" onblur="return khNameChange()"></asp:TextBox>
                            <span style="color: Red;">*&nbsp;<asp:Label ID="lblErr" runat="server"></asp:Label></span>
                        </td>
                        <td class="OrderTitle">
                            客户编号 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtClientNum" runat="server" Width="160px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            简称 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtShortedForm" runat="server" Width="120px"></asp:TextBox><span
                                style="color: Red;">*</span>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtShortedForm"
                                ErrorMessage="简称不能为空！"></asp:RequiredFieldValidator>
                        </td>
                        <td class="OrderTitle">
                            客户类型 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_ClientType1" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            区域 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_Area1" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                        <td class="OrderTitle">
                            行业 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_ClientField1" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            价值评估 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_ValueLevel1" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                        <td class="OrderTitle">
                            信用等级 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_CreditLevel1" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            重要程度 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_Importance1" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                        <td class="OrderTitle">
                            关系等级 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_ConnectionLevel1" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            客户组别 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_GroupID1" runat="server" Width="120px">
                            </asp:DropDownList>
                            <span style="color: Red;">*</span>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="ddl_GroupID1"
                                runat="server" ErrorMessage="请选择客户组别！"></asp:RequiredFieldValidator>
                        </td>
                        <td class="OrderTitle">
                            客户来源 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_SourceType1" runat="server" Width="120px">
                            </asp:DropDownList>
                            <span style="color: Red;">*</span>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="ddl_SourceType1"
                                runat="server" ErrorMessage="请选择客户来源！"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            阶段 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_PeriodType1" runat="server" Width="120px">
                            </asp:DropDownList>
                            <span style="color: Red;">*</span>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="ddl_PeriodType1"
                                runat="server" ErrorMessage="请选择客户处在的阶段！"></asp:RequiredFieldValidator>
                        </td>
                        <td class="OrderTitle">
                            是否商业用户 ：
                        </td>
                        <td>
                            <asp:CheckBox ID="chkIsBusiness" Text="是" runat="server" Checked="False" />
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            备注 ：
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="txtRemark" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                    </tr>
                </table>
                <!--联络信息，就是联系人表-->
                <table class="ShopOrderStyle">
                    <caption style="text-align: left">
                        &nbsp;&nbsp;&nbsp;&nbsp;联络信息
                    </caption>
                    <tr>
                        <td class="OrderTitle">
                            国家 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_Country" runat="server" Width="120px">
                                <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" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            邮政编码 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtZipCode" runat="server" Width="120px"></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="txtHomePhone" runat="server" Width="120px"></asp:TextBox>
                            <span style="color: Red;">*</span>
                        </td>
                        <td class="OrderTitle">
                            传真号码 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtFax" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="color: Blue;">
                            &nbsp;&nbsp;注意：1.固定电话格式：<span style="color: Gray;">(如：020-66693588或0771-2669288)</span>
                        </td>
                    </tr>
                </table>
                <!--个人信息，就是联系人表-->
                <table class="ShopOrderStyle" id="tb_person" runat="server">
                    <tr>
                        <td colspan="4" class="titleLeftBg">
                            &nbsp;&nbsp;&nbsp;&nbsp;个人信息<asp:HiddenField ID="h_ContacterID" runat="server" />
                            <asp:HiddenField ID="h_ClientID" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            称谓 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtTitle" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            会员类别 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_UserType" runat="server" Width="120px">
                            </asp:DropDownList>
                        </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:TextBox ID="txtBirthday" runat="server" onfocus="SelectDate(this,'yyyy-MM-dd');"
                                Width="70px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            籍贯 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtNativePlace" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            民族 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtNation" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            证件号码 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtIDCard" runat="server" Width="130px"></asp:TextBox>
                        </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:TextBox ID="txtFamily" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            月收入 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_Income" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            学历 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_Education" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                        <td class="OrderTitle">
                            毕业学校 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtGraduateFrom" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            生活爱好 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfLife" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            文化爱好 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfCulture" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            娱乐休闲爱好 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfAmusement" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            体育爱好 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfSport" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            其他爱好 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtInterestsOfOther" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            单位名称 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompany" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            单位地址 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompanyAddress" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            所属部门 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtDepartment" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            职务 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtPosition" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            负责业务 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtOperation" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            办公电话 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtOfficePhone" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            移动电话 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtMobile" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            Email地址 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtEmail" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            QQ号码 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtQQ" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            MSN帐号 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtMSN" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            雅虎通帐号 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtYahoo" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            UC帐号 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtUC" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            相关网址 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtHomepage" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <!--企业信息，就是公司表-->
                <table class="ShopOrderStyle" id="tb_company" runat="server" visible="false">
                    <tr>
                        <td colspan="4" class="titleLeftBg">
                            &nbsp;&nbsp;&nbsp;&nbsp;公司信息<asp:HiddenField ID="h_CompanyID" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            公司名称 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompanyName" runat="server" Width="120px"></asp:TextBox>
                            <span style="color: Red;">*</span>
                        </td>
                        <td class="OrderTitle">
                            相关网址 ：
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox9" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            开户银行 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtBankOfDeposit" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            银行帐号 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtBankAccount" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            税号 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtTaxNum" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            行业地位 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_StatusInField" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            公司规模 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_CompanySize" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                        <td class="OrderTitle">
                            业务范围 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtBusinessScope" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            公司简介 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompanyIntro" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            公司照片 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompanyPic" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            注册资本 ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtRegisteredCapital" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td class="OrderTitle">
                            经营状态 ：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddl_ManagementForms" runat="server" Width="120px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle" style="width: 16%">
                            年销售额（万元） ：
                        </td>
                        <td>
                            <asp:TextBox ID="txtAnnualSales" runat="server" Width="120px"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <!--企业联系人-->
                <table class="SearchTableStyle" id="tb_company_contacter" runat="server" visible="false">
                    <tr>
                        <td class="titleLeftBg">
                            &nbsp;&nbsp;&nbsp;&nbsp;联系人<asp:HiddenField ID="HiddenField1" runat="server" />
                            <asp:HiddenField ID="HiddenField3" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%--<table class="SearchTableStyle" width="98%" id="tb_A8B8643D3D3F8B1C939F">--%>
                            <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                                <ContentTemplate>
                                    <asp:Repeater ID="RepeaterContacter" runat="server" OnItemCommand="RepeaterContacter_ItemCommand">
                                        <HeaderTemplate>
                                            <table class="SearchTableStyle" width="98%" id="tb_A8B8643D3D3F8B1C939F">
                                                <tr>
                                                    <td style="text-align: center; width: 18%;">
                                                        真实姓名
                                                    </td>
                                                    <td style="text-align: center; width: 18%;">
                                                        办公电话
                                                    </td>
                                                    <td style="text-align: center; width: 18%;">
                                                        移动电话
                                                    </td>
                                                    <td style="text-align: center; width: 18%;">
                                                        QQ号码
                                                    </td>
                                                    <td style="text-align: center; width: 18%;">
                                                        Email地址
                                                    </td>
                                                    <td style="text-align: center; width: 8%;">
                                                        操作
                                                    </td>
                                                </tr>
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <tr>
                                                <td style="text-align: center;">
                                                    <asp:Label ID="LabelContacterID" runat="server" Visible="false" Text='<%#Eval("ContacterID")%>'></asp:Label>
                                                    <asp:Label ID="LabelTrueName" runat="server" Text='<%#Eval("TrueName")%>'></asp:Label>
                                                </td>
                                                <td style="text-align: center;">
                                                    <asp:Label ID="LabelOfficePhone" runat="server" Text='<%#Eval("OfficePhone")%>'></asp:Label>
                                                </td>
                                                <td style="text-align: center;">
                                                    <asp:Label ID="LabelMobile" runat="server" Text='<%#Eval("Mobile")%>'></asp:Label>
                                                </td>
                                                <td style="text-align: center;">
                                                    <asp:Label ID="LabelQQ" runat="server" Text='<%#Eval("QQ")%>'></asp:Label>
                                                </td>
                                                <td style="text-align: center;">
                                                    <asp:Label ID="LabelEmail" runat="server" Text='<%#Eval("Email")%>'></asp:Label>
                                                </td>
                                                <td style="text-align: center; width: 8%;">
                                                    <asp:Button ID="btnDelete" runat="server" Text="删除" CommandName="del" CommandArgument='<%#Eval("ContacterID") %>'
                                                        CausesValidation="false" />
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <tr>
                                                <td style="text-align: center; width: 18%;">
                                                    <asp:TextBox ID="TextBoxTrueName" runat="server" Width="130px"></asp:TextBox>
                                                </td>
                                                <td style="text-align: center; width: 18%;">
                                                    <asp:TextBox ID="TextBoxOfficePhone" runat="server" Width="110px"></asp:TextBox>
                                                </td>
                                                <td style="text-align: center; width: 18%;">
                                                    <asp:TextBox ID="TextBoxMobile" runat="server" Width="110px"></asp:TextBox>
                                                </td>
                                                <td style="text-align: center; width: 18%;">
                                                    <asp:TextBox ID="TextBoxQQ" runat="server" Width="110px"></asp:TextBox>
                                                </td>
                                                <td style="text-align: center; width: 18%;">
                                                    <asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox>
                                                </td>
                                                <td style="text-align: center; width: 8%;">
                                                    <asp:Button ID="btnAdd" runat="server" Text="添加" OnClientClick="return checkPass();"
                                                        CommandName="add" CausesValidation="false" />
                                                </td>
                                            </tr>
                                            </table>
                                        </FooterTemplate>
                                    </asp:Repeater>
                                    <span style="color: Blue;">&nbsp;&nbsp;注意：1.联系方式至少填写一个；办公电话格式：<span style="color: Gray;">(如：020-66693588或0771-2669288)</span>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
                                    <br />
                                    <span style="color: Red">
                                        <asp:Label ID="lblRepeatErr" runat="server"></asp:Label></span>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="RepeaterContacter"></asp:AsyncPostBackTrigger>
                                </Triggers>
                            </asp:UpdatePanel>
                            <%-- </table>--%>
                        </td>
                    </tr>
                </table>
                <%--<table class="ShopOrderStyle">
                    <tr>
                        <td colspan="4" style="text-align: center; font-weight: bold; color: Red;">--%>
                <div style="text-align: center; line-height: 30px;">
                    &nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="ButtonAdd" OnClientClick="return checkPass();"
                        OnClick="ButtonAdd_Click" runat="server" Text="确认保存" />
                </div>
                <%-- </td>
                    </tr>
                </table>--%>
            </asp:PlaceHolder>
            <!--添加客户 end -->
            <!--合并客户 begin-->
            <asp:PlaceHolder ID="PlaceHolder3" runat="server" Visible="false">
                <table class="ShopOrderStyle">
                    <caption style="text-align: left">
                        &nbsp;&nbsp;&nbsp;&nbsp;合并客户
                    </caption>
                    <tr>
                        <td class="OrderTitle">
                            主客户名称：
                        </td>
                        <td>
                            <asp:TextBox ID="txtZhuKehu" runat="server" Enabled="false"></asp:TextBox>[<a onclick="javascript:void(0);"
                                id="showZhuClient" runat="server"><span style="color: Red; cursor: pointer;">选择主客户名称</span></a>]<span
                                    style="color: Red">*</span>
                            <asp:HiddenField ID="hfZhuKehu" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            从客户名称：
                        </td>
                        <td>
                            <asp:TextBox ID="txtCiKehu" runat="server" Enabled="false"></asp:TextBox>[<a onclick="javascript:void(0);"
                                id="showCiClient" runat="server"><span style="color: Red; cursor: pointer;">选择从客户名称</span></a>]<span
                                    style="color: Red">*</span>
                            <asp:HiddenField ID="hfCiKehu" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            合并原因：
                        </td>
                        <td>
                            <asp:TextBox ID="txtReason" runat="server" TextMode="MultiLine" Height="130px" Width="230px"></asp:TextBox>
                            <span style="color: Red">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button ID="ButtonMerge" runat="server" Text="合并" OnClientClick="return checkPass2();"
                                OnClick="ButtonMerge_Click" />&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnBack" runat="server" Text="返回" OnClick="btnBack_Click" />
                        </td>
                    </tr>
                </table>
            </asp:PlaceHolder>
            <!--合并客户 end-->
            <br />
        </div>
    </div>
    <script type="text/javascript">setButtonActive(<%=m_flag %>);</script>
    <script type="text/javascript">
        //基本信息
        function checkClientName() {
            var clientName = $("#<%=txtClientName.ClientID %>"); //客户名称
            if (clientName.val().length == 0) {
                alert("客户姓名不能为空!");
                var editac = "<%=ActionTab %>";
                if (editac == "addinfo") {
                    clientName.focus();
                }
                return false;
            }
            return true;
        }
        //简称
        function checkShortedForm() {
            var ShortedForm = $("#<%=txtShortedForm.ClientID %>"); //简称
            if (ShortedForm.val().length == 0) {
                alert("简称不能为空!");
                ShortedForm.focus();
                return false;
            }
            return true;
        }
        //客户组别
        function ChangeGroupID() {
            var GroupID = document.getElementById('<%=ddl_GroupID1.ClientID %>');
            var bojvalue = "";
            for (i = 0; i < GroupID.options.length; i++) {
                if (GroupID.options[i].selected)
                    bojvalue = GroupID.options[i].value;
            }
            if (bojvalue.length == 0) {
                alert("请选择客户组别！");
                GroupID.focus();
                return false;
            }
            return true;
        }
        //客户来源
        function ChangeSourceType() {
            var GroupID = document.getElementById('<%=ddl_SourceType1.ClientID %>');
            var bojvalue = "";
            for (i = 0; i < GroupID.options.length; i++) {
                if (GroupID.options[i].selected)
                    bojvalue = GroupID.options[i].value;
            }
            if (bojvalue.length == 0) {
                alert("请选择客户来源！");
                GroupID.focus();
                return false;
            }
            return true;
        }
        //阶段
        function ChangePeriodType() {
            var GroupID = document.getElementById('<%=ddl_PeriodType1.ClientID %>');
            var bojvalue = "";
            for (i = 0; i < GroupID.options.length; i++) {
                if (GroupID.options[i].selected)
                    bojvalue = GroupID.options[i].value;
            }
            if (bojvalue.length == 0) {
                alert("请选择阶段！");
                GroupID.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})?$/; //电话号码格式

            var clieneType = "<%=TabMenu %>";
            if (clieneType == "Addpsn") { //个人客户
                //手机号码
                if (mobile.val().length == 0) {
                    if (homePhone.val().length == 0) {
                        alert("固定电话和移动电话至少填写一个!");
                        homePhone.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;
                    }
                }
                //办公电话
                if (officePhone.val().length != 0) {
                    if ((word.test(officePhone.val())) == false) {
                        alert('办公电话号码为数字或格式不对！');
                        officePhone.focus();
                        return false;
                    }
                }
            } else if (clieneType == "Addcmp") {//企业客户
                if (homePhone.val().length == 0) {
                    alert("请填写固定电话!");
                    homePhone.focus();
                    return false;
                } else {
                    if ((word.test(homePhone.val())) == false) {
                        alert('固定电话为数字或格式不对！');
                        homePhone.focus();
                        return false;
                    }
                }
            }
            return true;
        }
        function checkPass() {
            if (checkClientName() && checkShortedForm() && ChangeGroupID() && ChangeSourceType() && ChangePeriodType() && checkDianHua()) {
                return true;
            } else {
                return false;
            }
        }
    </script>
    <script type="text/javascript">
        //        //个人客户
        //        function SelectGR(zhukh) {
        //            var arr = showModalDialog('UserListPart.aspx?TypeSelect=gr&DefaultValue=' + document.getElementById(zhukh).value, '', 'dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');
        //            if (arr != null) {
        //                document.getElementById(zhukh).value = arr;
        //                document.getElementById(zhukh).focus();
        //            }
        //        }
        //        //企业客户
        //        function SelectQY(cikh) {
        //            var arr = showModalDialog('UserListPart.aspx?TypeSelect=qy&DefaultValue=' + document.getElementById(cikh).value, '', 'dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');
        //            if (arr != null) {
        //                document.getElementById(cikh).value = arr;
        //                document.getElementById(cikh).focus();
        //            }
        //        }


        $(function () {
            var clieneType = "<%=TabMenu %>";
            var ct = "";
            if (clieneType == "Addpsn") { //个人客户
                ct = "gr";
            } else if (clieneType == "Addcmp") {//企业客户
                ct = "qy";
            }
            //用户名
            $("#<%=txtClientName.ClientID %>").autocomplete({
                source: '/WebService/ClientService.ashx?Action=GetUserName&CT=' + ct + '&currentUser='+<%= user.UserID %> +'&d1=' + new Date().getMilliseconds()
            });
        });

        //下拉列表
        function ChangeDDL(ddl, objvalue) {
            //alert(ddl + ":\n" + objvalue + "\n" + ddl.length);
            for (i = 0; i < ddl.length; i++) {
                if (objvalue == ddl[i].text) {
                    ddl[i].selected = true;
                    break;
                }
            }
        }
        //城市
        function getCity(ddlCity, pro, citys) {
            if (pro != "") {
                ddlCity.options.length = 0; //清空下拉列表值
                $.post("../../WebService/ClientService.ashx", { 'Action': 'GetCityByProvince', 'Province': pro }, function (data, state) {
                    if (state == "success") {
                        if (data.toString() != "") {
                            var da = eval(data);
                            $.each(da.table1, function (p) {
                                var strName = da.table1[p].City; //文本值
                                var objOption = new Option(strName, strName); // 建立Option对象
                                ddlCity.options.add(objOption);
                                if (citys == strName) {
                                    //   ddlCity.selected =  'selected';
                                    ChangeDDL(ddlCity, citys);
                                }
                            });
                        }
                    }
                });
            }
        }
        //县/区
        function getArea(ddlArea, citys, areas) {
            if (citys != "") {
                ddlArea.options.length = 0; //清空下拉列表值
                $.post("../../WebService/ClientService.ashx", { 'Action': 'GetAllAreaByCity', 'City': citys }, function (data, state) {
                    if (state == "success") {
                        if (data.toString() != "") {
                            var dat = eval(data);
                            $.each(dat.table1, function (c) {
                                var strName = dat.table1[c].Area; //文本值
                                var objOption = new Option(strName, strName); // 建立Option对象
                                ddlArea.options.add(objOption);
                                if (areas == strName) {
                                    //ddlArea.selected = 'selected';
                                    ChangeDDL(ddlArea, areas);
                                }
                            });
                        }
                    }
                });
            }
        }
        
        function khNameChange() {
            var hfIsRepeatKhName = $("#<%=hfIsRepeatKhName.ClientID %>"); //是否重复的客户名称
            var clientName = $("#<%=txtClientName.ClientID %>"); //客户名称
            var clieneType = "<%=TabMenu %>"; //个人客户：Addpsn、企业客户：Addcmp
            var txtShortedForm = $("#<%=txtShortedForm.ClientID %>"); //简称
            //联络信息
            var country = document.getElementById("<%=ddl_Country.ClientID %>"); //国家
            var province = document.getElementById("ctl00_ContentPlaceHolder1_HoWaveProvinceCity1_Province"); //省
            var city = document.getElementById("ctl00_ContentPlaceHolder1_HoWaveProvinceCity1_City"); //市
            var cmArea = document.getElementById("ctl00_ContentPlaceHolder1_HoWaveProvinceCity1_ddlArea"); //县/区
            var address = $("#<%=txtAddress.ClientID %>");  //详细地址
            var zipCode = $("#<%=txtZipCode.ClientID %>"); //邮政编码
            var pPhone = $("#<%=txtHomePhone.ClientID %>"); //固定电话
            var fax = $("#<%=txtFax.ClientID %>"); //传真号码
            //个人信息
           // var rblSex = document.getElementsByName("<%=rblSex.ClientID %>"); //性别——0：男、1：女、2、保密
            var txtTitle = $("#<%=txtTitle.ClientID %>"); //称谓(昵称)
            var txtNativePlace = $("#<%=txtNativePlace.ClientID %>"); //籍贯
            var txtNation = $("#<%=txtNation.ClientID %>"); //民族
            var txtBirthday = $("#<%=txtBirthday.ClientID %>"); //出生日期
            var txtIDCard = $("#<%=txtIDCard.ClientID %>"); //证件号码        
           // var rblMarriage =document.getElementById("<%=rblMarriage.ClientID %>"); //婚姻状况——3：保密、4：未婚、5：已婚、6：离异
            var txtFamily = $("#<%=txtFamily.ClientID %>"); //家庭状况
            var ddl_Income = document.getElementById("<%=ddl_Income.ClientID %>"); //收人情况
            var ddl_Education = document.getElementById("<%=ddl_Education.ClientID %>"); //教育
            var txtGraduateFrom = $("#<%=txtGraduateFrom.ClientID %>"); //毕业学校
            var txtInterestsOfOther = $("#<%=txtInterestsOfOther.ClientID %>"); //兴趣爱好
            var txtMobile = $("#<%=txtMobile.ClientID %>"); //移动电话
            var txtEmail = $("#<%=txtEmail.ClientID %>"); //Email地址
            var txtHomepage = $("#<%=txtHomepage.ClientID %>"); //相关网址
            var txtQQ = $("#<%=txtQQ.ClientID %>");
            var txtMSN = $("#<%=txtMSN.ClientID %>");
            var userid = 0;

            //企业
            
            var tb_A8B8643D3D3F8B1C939F=document.getElementById("tb_A8B8643D3D3F8B1C939F");
            //公司信息
            var txtCompanyName = $("#<%=txtCompanyName.ClientID %>"); //公司名称
            

            //客户名称是否重复
            $.post("../../WebService/ClientService.ashx", { 'Action': 'GetClientByClientNameOwner', 'ClientName': clientName.val() }, function (data, state) {
                if (state == "success") {
                    if (data.toString() != "") {
                        var dd = eval(data);
                        $.each(dd.table1, function (i,d) {                       
                            hfIsRepeatKhName.attr("value",d.ClientName);
                            return;
                        });
                    }
                }
            });

            $.post("../../WebService/ClientService.ashx", { 'Action': 'GetUsers', 'ClientName': clientName.val() }, function (data, state) {
                if (state == "success") {
                    if (data.toString() != "") {
                        var d = eval(data);
                        $.each(d.table1, function (i) {
                            userid = d.table1[i].UserID;
                            //alert(userid);  
                           if(hfIsRepeatKhName.val()==clientName.val()){
                               alert("客户名称不能重复！");
                               if (clieneType == "Addcmp") {
                                   txtCompanyName.attr("value", "");
                                   $("input[type=text]:eq(0)",tb_A8B8643D3D3F8B1C939F).val("");//姓名
                                   $("input[type=text]:eq(1)",tb_A8B8643D3D3F8B1C939F).val("");//办公电话
                                   $("input[type=text]:eq(2)",tb_A8B8643D3D3F8B1C939F).val("");//移动电话
                                   $("input[type=text]:eq(4)",tb_A8B8643D3D3F8B1C939F).val("");//Email地址
                               }
                               txtShortedForm.attr("value","");
                                address.attr("value","");
                                zipCode.attr("value","");
                                pPhone.attr("value","");
                                fax.attr("value","");
                                txtTitle.attr("value","");
                                txtNativePlace.attr("value","");
                                txtNation.attr("value","");
                                txtBirthday.attr("value","");
                                txtIDCard.attr("value","");
                                txtFamily.attr("value", "");
                                txtGraduateFrom.attr("value", "");
                                txtInterestsOfOther.attr("value", "");
                                txtMobile.attr("value", "");
                                txtEmail.attr("value", "");
                                txtHomepage.attr("value", "");
                                txtQQ.attr("value", "");
                                txtMSN.attr("value", "");
                               return;
                           }               
                            txtShortedForm.attr("value", d.table1[i].TrueName);
                            if (clieneType == "Addpsn") { //个人客户
                                ChangeDDL(country, d.table1[i].Country);
                                var pro = d.table1[i].Province;
                                var c = d.table1[i].City;
                                var a = d.table1[i].CMArea;
                                ChangeDDL(province, pro); //省
                                getCity(city, pro, c); //市
                                getArea(cmArea, c, a); //县/区
                                address.attr("value", d.table1[i].Address);
                                if (d.table1[i].ZipCode.toString() != "0") {
                                    zipCode.attr("value", d.table1[i].ZipCode);
                                }
                                pPhone.attr("value", d.table1[i].HomePhone);
                                fax.attr("value", d.table1[i].Fax);

                               //性别
                               $('[name="ctl00$ContentPlaceHolder1$rblSex"]:radio').each(function() {
                                    if (this.value == d.table1[i].Sex) { 
                                        this.checked = true;
                                    }
                                });
                                txtTitle.attr("value", d.table1[i].NickName);
                                txtNativePlace.attr("value", d.table1[i].ComeFrom);
                                txtNation.attr("value", d.table1[i].Nation);
                                txtBirthday.attr("value", d.table1[i].Birthday.toString("yyyy-MM-dd"));
                                txtIDCard.attr("value", d.table1[i].IDCard);
                               //婚姻状况
                               $('[name="ctl00$ContentPlaceHolder1$rblMarriage"]:radio').each(function() {
                                    if (this.value == d.table1[i].Marriage) { 
                                        this.checked = true;
                                    }
                                });
                                txtFamily.attr("value", d.table1[i].Family);
                                if (d.table1[i].InCome != "" && d.table1[i].InCome != null) {
                                    ChangeDDL(ddl_Income, d.table1[i].InCome);
                                }
                                ChangeDDL(ddl_Education, d.table1[i].Eductation);
                                txtGraduateFrom.attr("value", d.table1[i].GraduteSchool);
                                txtInterestsOfOther.attr("value", d.table1[i].Interests);
                                txtMobile.attr("value", d.table1[i].MobilePhone);
                                txtEmail.attr("value", d.table1[i].Email);
                                txtHomepage.attr("value", d.table1[i].HomePage);
                                txtQQ.attr("value", d.table1[i].OICQ);
                                txtMSN.attr("value", d.table1[i].MSN);
                            } else if (clieneType == "Addcmp") {//企业客户
                                app(2, userid);
                            }
                        });
                    }
                }
            });           
        }

        /*********************************************/
        //认证信息
        function app(IdentifyType, userid) {
            //联络信息
            var country = document.getElementById("<%=ddl_Country.ClientID %>"); //国家
            var province = document.getElementById("ctl00_ContentPlaceHolder1_HoWaveProvinceCity1_Province"); //省
            var city = document.getElementById("ctl00_ContentPlaceHolder1_HoWaveProvinceCity1_City"); //市
            var cmArea = document.getElementById("ctl00_ContentPlaceHolder1_HoWaveProvinceCity1_ddlArea"); //县/区
            var address = $("#<%=txtAddress.ClientID %>");  //详细地址
            var zipCode = $("#<%=txtZipCode.ClientID %>"); //邮政编码
            var pPhone = $("#<%=txtHomePhone.ClientID %>"); //固定电话
            var fax = $("#<%=txtFax.ClientID %>"); //传真号码

            var tb_A8B8643D3D3F8B1C939F=document.getElementById("tb_A8B8643D3D3F8B1C939F");
            //公司信息
            var txtCompanyName = $("#<%=txtCompanyName.ClientID %>"); //公司名称

            txtCompanyName.attr("value", "");
            $("input[type=text]:eq(0)",tb_A8B8643D3D3F8B1C939F).val("");//姓名
            $("input[type=text]:eq(1)",tb_A8B8643D3D3F8B1C939F).val("");//办公电话
            $("input[type=text]:eq(2)",tb_A8B8643D3D3F8B1C939F).val("");//移动电话
            $("input[type=text]:eq(4)",tb_A8B8643D3D3F8B1C939F).val("");//Email地址

            $.post("../../WebService/ClientService.ashx", { 'Action': 'GetApplication', 'IdentifyType': IdentifyType, 'userid': userid }, function (data, state) {
                if (state == "success") {
                    if (data.toString() != "") {
                        var dd = eval(data); 
                        $.each(dd.table1, function (a,d) {
                            var ApplicationDetail = d.IdentifyDetail.split('$'); //分割字符
                            var comProv = GetContentByName("CompanyProvince", ApplicationDetail); //注册所在省
                            var comCity = GetContentByName("CompanyCity", ApplicationDetail); //注册所在市
                            var comArea= GetContentByName("CompanyArea", ApplicationDetail); //注册所在县/区
                            var comAddress = GetContentByName("CompanyAddress", ApplicationDetail); //公司详细地址
                            var comFax = GetContentByName("ContacterFax", ApplicationDetail); //公司传真
                            var comName = GetContentByName("CompanyName", ApplicationDetail); //公司名称
                            var ContacterName = GetContentByName("ContacterName", ApplicationDetail);//联系人姓名
                            var ContacterPhone =GetContentByName("ContacterPhone", ApplicationDetail);//联系人固话
                            var ContacterMobilePhone = GetContentByName("ContacterMobile", ApplicationDetail);//联系人手机
                            var Email = GetContentByName("ContacterEmail", ApplicationDetail);//联系人EMAIL

                            ChangeDDL(province, comProv); //省
                            getCity(city, comProv, comCity); //市
                             getArea(cmArea, comCity, comArea); //县/区
                            address.attr("value", comAddress);
                            fax.attr("value", comFax);
                            txtCompanyName.attr("value", comName);
                            $("input[type=text]:eq(0)",tb_A8B8643D3D3F8B1C939F).val(ContacterName);//姓名
                            $("input[type=text]:eq(1)",tb_A8B8643D3D3F8B1C939F).val(ContacterPhone);//办公电话
                            $("input[type=text]:eq(2)",tb_A8B8643D3D3F8B1C939F).val(ContacterMobilePhone);//移动电话
                            $("input[type=text]:eq(4)",tb_A8B8643D3D3F8B1C939F).val(Email);//Email地址
                        });
                    }
                }
            });
        }
        //认证信息
        function GetContentByName(TitleName, ContentArray) {
            if (ContentArray != null && ContentArray.length > 0) {
                for (var i = 0; i < ContentArray.length; i++) {
                    var temparray = ContentArray[i].split('|');
                    if (temparray[0] == TitleName) {
                        return temparray[1];
                    }
                }
            }
            return "";
        }
        /*********************************************/
      
    </script>
    <%--合并客户--%>
    <script type="text/javascript">
        //主客户
        function SelectZhu(zhukh) {
            var arr = showModalDialog('ClientList.aspx?TypeSelectZhuCi=Zhu&ClientOwner=' +<%= user.UserID %> + '&DefaultValue=' + document.getElementById(zhukh).value, '', 'dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');
            if (arr != null) {
                //document.getElementById(zhukh).value = arr;
                var temparray = arr.split('|');
                if (temparray != null && temparray.length > 2) {
                    document.getElementById(zhukh).value = temparray[0];//客户名称
                     //客户名称、客户类型、客户ID——temparray[0],temparray[1],temparray[2]
                }
            }
        }
        //主客户
        function SelectCi(cikh) {
            var arr = showModalDialog('ClientList.aspx?TypeSelectZhuCi=Ci&ClientOwner=' +<%= user.UserID %> + '&DefaultValue=' + document.getElementById(cikh).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(cikh).value = temparray[0];
                }
            }
        }
        //合并客户
        function checkPass2() {
            var zhuClientName = $("#<%=txtZhuKehu.ClientID %>"); //主客户
            if (zhuClientName.val().length == 0) {
                alert("请选择主客户！");
                return false;
            }
            var ciClientName = $("#<%=txtCiKehu.ClientID %>"); //从客户
            if (ciClientName.val().length == 0) {
                alert("请选择从客户!");
                return false;
            }
            var reason = $("#<%=txtReason.ClientID %>"); //从客户
            if (reason.val().length == 0) {
                alert("请填写合并的原因!");
                reason.focus();
                return false;
            }
            var hfZhu = $("#<%=hfZhuKehu.ClientID %>"); //主客户
            var hfCi = $("#<%=hfCiKehu.ClientID %>"); //从客户
            hfZhu.attr("value", zhuClientName.val());
            hfCi.attr("value", ciClientName.val());
            //alert(hfZhu.val()+"\n"+hfCi.val());
            return true;
        }
    
    </script>
</asp:Content>
