<%@ Page Language="C#"  AutoEventWireup="true"
    CodeBehind="CustomerNew.aspx.cs" Inherits="OAWeb.crm.customer.CustomerNew" Title=""
    EnableEventValidation="false" Theme="Default" ValidateRequest="false" EnableViewStateMac="false"  EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>合并客户</title>
    <link href="../../App_Themes/Default/default.css" rel="stylesheet" type="text/css" />
    <link href="../../Css/global.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
    <script src="/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/js/artDialog/artDialog.js?skin=default" type="text/javascript"></script>
    <script src="/js/artDialog/plugins/iframeTools.source.js" type="text/javascript"></script>
    
    </head>
<style>
.divOut
{
	 float:left;border-left: 1px solid #81B3EC; width:250px;
}

.divIn
{
	border-bottom:1px solid #81B3EC; height:26px; line-height:26px;
}

.divLeft
{
	float:left; width:100px; text-align:left;
}

.divLeft div
{
	border-bottom:1px solid #81B3EC; height:26px; line-height:26px;
}

.divOut div
{
	border-bottom:1px solid #81B3EC; height:26px; line-height:26px; padding-left:2px;
}

#divForm div
{
 padding-top:2px;
 height:24px;
 line-height:24px;
 padding-left:2px;
	
}

#DivContain .HeightDiv
{
	height:50px;
	
}

#DivContain div
{
 overflow:hidden;
	
}
</style>

<script>
function ChangeValue(v,Id)
{

    if(Id=="ProvinceID")
    {
       var strV=v.split(',');
       document.getElementById("ddlProvinceID").value=strV[0];
       CallCity('ddlCityID');
       document.getElementById("ddlCityID").value=strV[1];
       return;
    }
    if(document.getElementById("txt"+Id)!=null)
    document.getElementById("txt"+Id).value=v;
    if(document.getElementById("ddl"+Id)!=null)
    document.getElementById("ddl"+Id).value=v;
    if(document.getElementById("rbl"+Id+"_"+v)!=null)
    document.getElementById("rbl"+Id+"_"+v).checked=true;
    if(document.getElementById("cbb"+Id)!=null)
    {
    document.getElementById("cbb"+Id).checked=v;
    if(v=="False")
    document.getElementById("cbb"+Id).checked=false;
    }
}
</script>

 <script language="javascript" type="text/javascript">
var xmlHttp = false;
try 
{
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e) 
{
  try 
  {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch (e2) 
  {
    xmlHttp = false;
  }
}
var type = "",IsSucceed = false;
function CallCity(objID)
{
    var url = "";
    if(objID == "ddlProvinceID")
    {
        url = "../City.aspx?ID=0";//省
        type = "First";
    }
    else if(objID == "ddlCityID")
    {
        url = "../City.aspx?ID=" + document.getElementById("ddlProvinceID").value;//市
        type = "Second";
    }else if(objID == "txtTelephone")
    {
       if(document.getElementById(objID).value == "")
       {
          IsSucceed = false;
          return false;
       }
        url = "../City.aspx?state=1&tel="+document.getElementById(objID).value;
        
    }else if(objID == "txtMobilePhone"&&!IsSucceed)
    {
        url = "../City.aspx?state=2&mobile="+document.getElementById(objID).value;
    }
 
    if(objID == "txtTelephone" || (objID == "txtMobilePhone"&&!IsSucceed))
    {
      xmlHttp.open("GET", url, false);
      xmlHttp.onreadystatechange = SetProvinceCity;
      xmlHttp.send(null);
      if(objID == "txtMobilePhone")
      {
         IsSucceed = false;
      }
    }
    else if(objID == "ddlProvinceID" || objID == "ddlCityID")
    {
      xmlHttp.open("GET", url, false);
      xmlHttp.onreadystatechange = SetRespond;
      xmlHttp.send(null);
    }
    
}

function SetRespond()
{
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      var _List = response.split(",");
      var obj = null;
      if(type == "First")
      {
        obj = document.getElementById("ddlProvinceID");
      }
      else if(type == "Second")
      {
        obj = document.getElementById("ddlCityID");
      }
     
      for(var i=obj.options.length-1;i>=0;--i)   //撤消原来的列表项
      {
        obj.options.remove(i)
      }
      for(var i=0;i<_List.length;i++)   
      {
        var TypeID_Value = _List[i].split("#");
        var oOption = document.createElement('OPTION');
        oOption.text = TypeID_Value[1];
        oOption.value = TypeID_Value[0];
        obj.options.add(oOption); 
      }
   }
}

function SetProvinceCity()
{
    if (xmlHttp.readyState == 4)
    {
      var response = xmlHttp.responseText;
      var _List = response.split(",");
      var obj = document.getElementById("ddlProvinceID");
      if(_List.length > 1)
      {
         bindOptions(obj,_List[0]);
      }
   
      obj = document.getElementById("ddlCityID");
      if(_List.length >= 2&&obj.value != _List[1])
      {
         CallCity("ddlCityID");
         bindOptions(obj,_List[1]);
      }
      if(obj.value == _List[1])
        IsSucceed = true;
      else
        IsSucceed = false;
   }
}

function bindOptions(obj,value)
{
   for(var i=0;i<obj.options.length;i++)   
   {
    if(obj.options[i].value == value)
       {obj.options.selectedIndex = i;break;}
   }
}

  /*打开员工窗口*/
     function OpenEmployeeDialog() {

         var Url = "/Dialog/EmploySelectDialog.aspx?user=0";

         OpenRadioDialog(Url, "选择员工", function (text, value) {
             document.getElementById('<% =HiddenOwnerID.ClientID %>').value = value;
             document.getElementById('txtOwnerName').value = text;

         });

     }  
    </script>

<body>
    <form id="form1" runat="server">
    <div style="float:left; width:100%; padding:10px; padding-bottom:0px;">
        <asp:Button ID="btnAdd" runat="server" Text="保存合并" onclick="btnAdd_Click" />   <asp:Button ID="btnCacel" runat="server" Text="取消" OnClientClick="javascript:window.close();" />
    </div>
    <div id="DivContain" style="border: 1px solid #81B3EC;  float:left; margin:10px; border-bottom:none;">
        <div  class="divLeft" style="background-color:#DFE8F6">
            <div >字段名</div>
            <div >客户名称</div>
            <div >负责人</div>
            <div >重要程度</div>
           
            <div >助记简称</div>
            <div >行业</div>
            <div >商业种类</div>
           
            <div >代理商名称</div>
            <div >来源</div>
            <div >来源补充</div>
            <div >是否公司资源</div>
            <div >省份</div>

            <div >其他城市</div>
 
            <div >邮编</div>
            <div >网址</div>
            <div >地址</div>
            <div >电子邮件</div>
            
            <div >来源域名</div>
            <div >来源关键字</div>
            <div >跟踪代码</div>
            <div >是否个人客户</div>
            <div >是否公开</div>
            <div >是否已购买</div>
            
            <div >设置主联系人</div>
            <div >性别</div>
            <div >QQ</div>
            <div >手机</div>
            <div >电话</div>
            <div >传真</div>
            <div class="HeightDiv" >备注</div>
            <div class="HeightDiv" >公司介绍</div>
            
        </div>
        <asp:Repeater ID="rpCustomer" runat="server" 
            onitemdatabound="rpCustomer_ItemDataBound"  >
        <ItemTemplate>
          <div  class="divOut divRdo" style="width:50px;background-color:#DFE8F6">
           <div >保留</div>
            <div ><input  type="radio" name="rdo1" onclick="ChangeValue(this.value,'CustomerName')" value="<%# Eval("CustomerName") %>"  /></div>
            <div ><input  type="radio" name="rdo26" onclick="ChangeValue(this.value,'OwnerName')" value="<%# OACore.Caches.UsersCache.Instance.GetNickName(ObjToInt( Eval("OwnerID")))%>"  /></div>
            <div ><input  type="radio" name="rdo2" onclick="ChangeValue(this.value,'HotLevel')" value="<%# Eval("HotLevel") %>"  /></div>
            
            <div ><input  type="radio" name="rdo4" onclick="ChangeValue(this.value,'ShortName')" value="<%# Eval("ShortName") %>"  /></div>
            <div ><input  type="radio" name="rdo5" onclick="ChangeValue(this.value,'IndustryID')" value="<%# Eval("IndustryID") %>"  /></div>
            <div ><input  type="radio" name="rdo6" onclick="ChangeValue(this.value,'BizTypeID')" value="<%# Eval("BizTypeId") %>"  /></div>
            <div ><input  type="radio" name="rdo8" onclick="ChangeValue(this.value,'AgentUserName')" value="<%# Eval("AgentUserName") %>"  /></div>
            <div ><input  type="radio" name="rdo9" onclick="ChangeValue(this.value,'SourceID')" value="<%# Eval("SourceID") %>"  /></div>
            <div ><input  type="radio" name="rdo10" onclick="ChangeValue(this.value,'OtherSource')" value="<%# Eval("OtherSource") %>"  /></div>
            <div ><input  type="radio" name="rdo11" onclick="ChangeValue(this.value,'IsCorporateResources')" value="<%# Eval("IsCorporateResources") %>"  /></div>
            <div ><input  type="radio" name="rdo12" onclick="ChangeValue(this.value,'ProvinceID')" value="<%# Eval("ProvinceId") %>,<%# Eval("CityId") %>"  /></div>
            

            <div ><input  type="radio" name="rdo14" onclick="ChangeValue(this.value,'City')" value="<%# Eval("City") %>"  /></div>

            <div ><input  type="radio" name="rdo16" onclick="ChangeValue(this.value,'PostCode')" value="<%# Eval("PostCode") %>"  /></div>
            <div ><input  type="radio" name="rdo17" onclick="ChangeValue(this.value,'Web')" value="<%# Eval("Web") %>"  /></div>
            <div ><input  type="radio" name="rdo18" onclick="ChangeValue(this.value,'Address')" value="<%# Eval("Address") %>"  /></div>
            <div ><input  type="radio" name="rdo19" onclick="ChangeValue(this.value,'Email')" value="<%# Eval("Email") %>"  /></div>
            
            <div ><input  type="radio" name="rdo27" onclick="ChangeValue(this.value,'FromHost')" value="<%# Eval("FromHost") %>"  /></div>
            <div ><input  type="radio" name="rdo28" onclick="ChangeValue(this.value,'FromKey')" value="<%# Eval("FromKey") %>"  /></div>
            <div ><input  type="radio" name="rdo29" onclick="ChangeValue(this.value,'FromName')" value="<%# Eval("FromName") %>"  /></div>
            <div ><input  type="radio" name="rdo30" onclick="ChangeValue(this.value,'IsPersonal')" value="<%# Eval("IsPersonal") %>"  /></div>
            <div ><input  type="radio" name="rdo31" onclick="ChangeValue(this.value,'IsPublic')" value="<%# Eval("IsPublic") %>"  /></div>
            <div ><input  type="radio" name="rdo32" onclick="ChangeValue(this.value,'IsPurchase')" value="<%# Eval("IsPurchase") %>"  /></div>
            
              <asp:Repeater ID="RpContact" runat="server">
              <ItemTemplate>
              <div >
              <input  type="radio" name="rdo20" onclick="ChangeValue(this.value,'ContactId')"  value="<%# Eval("ContactId") %>"  />
              
              </div>
              <div></div>
              <div></div>
              <div></div>
              <div></div>
              <div></div>
              </ItemTemplate>
              </asp:Repeater>
            
            <div class="HeightDiv" ><input  type="radio" name="rdo24" onclick="ChangeValue(this.value,'Remark')" value="<%# Eval("Remark") %>"  /></div>
           <div class="HeightDiv" ><input  type="radio" name="rdo25" onclick="ChangeValue(this.value,'CustomerInfo')" value="<%# Eval("CustomerInfo") %>"  /></div>
        </div>
        <div  class="divOut">
        <div style="background-color:#DFE8F6;" >客户数据</div>
            <div ><%# Eval("CustomerName") %></div>
            <div ><%# OACore.Caches.UsersCache.Instance.GetNickName(ObjToInt(Eval("OwnerID")))%></div>
            <div ><%# ObjToInt(Eval("HotLevel")) == 0 ? "普通" : ObjToInt(Eval("HotLevel")) == 1 ? "重要" : "很重要"%></div>
            
            <div ><%# Eval("ShortName") %></div>
            
            <div ><%# OACore.DALFactory.DataCache.GetDictName(OACore.DictType.Industry, ObjToInt(Eval("IndustryID")))%></div>
            <div ><%# Eval("BizTypeName")%></div>
            
            <div ><%# Eval("AgentUserName") %></div>
            <div ><%# OACore.DALFactory.DataCache.GetDictName(OACore.DictType.Source, ObjToInt(Eval("SourceID")))%></div>
            <div ><%# Eval("OtherSource") %></div>
            <div ><%# Convert.ToBoolean(Eval("IsCorporateResources"))==true?"是":"否"%></div>
            <div ><%# Eval("ProvinceName")%> <%# Eval("CityName") %></div>

            <div ><%# Eval("City") %></div>

            <div ><%# Eval("PostCode") %></div>
            <div ><%# Eval("Web") %></div>
            <div ><%# Eval("Address") %></div>
            <div ><%# Eval("Email") %><asp:Label ID="lblCustomerId" runat="server" Text='<%# Eval("CustomerId") %>' Visible="false"></asp:Label></div>
            
            <div ><%# Eval("FromHost")%></div>
            <div ><%# Eval("FromKey")%></div>
            <div ><%# Eval("FromName")%></div>
            <div ><%# Convert.ToBoolean(Eval("IsPersonal")) == true ? "是" : "否"%></div>
            <div ><%# Convert.ToBoolean(Eval("IsPublic")) == true ? "是" : "否"%></div>
            <div ><%# Convert.ToBoolean(Eval("IsPurchase")) == true ? "是" : "否"%></div>
            
            <div ><asp:Label ID="lblName" runat="server" Text="Label"></asp:Label></div>
            <div ><asp:Label ID="lblSexName" runat="server" Text="Label"></asp:Label></div>
            <div ><asp:Label ID="lblQQ" runat="server" Text="Label"></asp:Label></div>
            <div ><asp:Label ID="lblMobilPhone" runat="server" Text="Label"></asp:Label></div>
            <div ><asp:Label ID="lblTelphone" runat="server" Text="Label"></asp:Label></div>
            <div ><asp:Label ID="lblFax" runat="server" Text="Label"></asp:Label></div>
            <div class="HeightDiv" ><%# Eval("Remark") %></div>
            <div class="HeightDiv" ><%# Eval("CustomerInfo") %></div>
            
        </div>
        </ItemTemplate>
        </asp:Repeater>
        
         <div  class="divOut" id="divForm" >
         <div style="background-color:#DFE8F6;" >合并结果</div>
            <div  ><asp:TextBox ID="txtCustomerName" runat="server" Width="90%"></asp:TextBox></div>
            <div  ><asp:TextBox ID="txtOwnerName" runat="server" Width="50%" ></asp:TextBox>
           <input id="Button2" type="button" value="..." onclick="OpenEmployeeDialog()" /><asp:HiddenField
                    ID="HiddenOwnerID" runat="server" />
            </div>
            <div ><asp:RadioButtonList ID="rblHotLevel" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal"
                    Width="231px">
                    <asp:ListItem Selected="True" Value="0">普通</asp:ListItem>
                    <asp:ListItem Value="1">重要</asp:ListItem>
                    <asp:ListItem Value="2">很重要</asp:ListItem>
                </asp:RadioButtonList>
            </div>

            <div ><asp:TextBox ID="txtShortName" runat="server"  MaxLength="50" Width="90%"></asp:TextBox></div>
            <div ><asp:DropDownList ID="ddlIndustryID" runat="server">
                  </asp:DropDownList>
            </div>
            <div ><asp:DropDownList ID="ddlBizTypeID" runat="server" onchange="selectBizTypeID()">
                  </asp:DropDownList>
            </div>
           
            <div ><asp:TextBox ID="txtAgentUserName" runat="server" Width="90%" ></asp:TextBox></div>
            <div ><asp:DropDownList ID="ddlSourceID" runat="server">
                </asp:DropDownList>
            </div>
            <div ><asp:TextBox ID="txtOtherSource" runat="server"  Width="90%"></asp:TextBox></div>
            <div ><asp:CheckBox ID="cbbIsCorporateResources" runat="server" Text="是否公司资源" Checked="True" /></div>
            <div > <asp:DropDownList ID="ddlProvinceID" runat="server">
                 </asp:DropDownList>
                <asp:DropDownList ID="ddlCityID" runat="server">
                </asp:DropDownList>
            </div>
            <div ><asp:TextBox ID="txtCity" runat="server" Width="90%" MaxLength="20"></asp:TextBox></div>
            <div ><asp:TextBox ID="txtPostCode" runat="server" Width="90%" MaxLength="6"></asp:TextBox></div>
            <div ><asp:TextBox ID="txtWeb" runat="server" Width="90%" MaxLength="100">http://</asp:TextBox></div>
            <div ><asp:TextBox ID="txtAddress" runat="server" Width="90%" MaxLength="100"></asp:TextBox></div>
            <div ><asp:TextBox ID="txtEmail" runat="server" Width="90%" MaxLength="50"></asp:TextBox></div>
            
            <div ><asp:TextBox ID="txtFromHost" runat="server" Width="90%" MaxLength="50"></asp:TextBox></div>
            <div ><asp:TextBox ID="txtFromKey" runat="server" Width="90%" MaxLength="50"></asp:TextBox></div>
            <div ><asp:TextBox ID="txtFromName" runat="server" Width="90%" MaxLength="50"></asp:TextBox></div>
            <div ><asp:CheckBox ID="cbbIsPersonal" runat="server" Text="是否个人客户" Checked="True" /></div>
            <div ><asp:CheckBox ID="cbbIsPublic" runat="server" Text="是否公开" Checked="True" /></div>
            <div ><asp:CheckBox ID="cbbIsPurchase" runat="server" Text="是否已购买" Checked="True" /></div>
            
            <div ><input id="txtContactId"  type="hidden" runat="server"/></div>
            <div ></div>
            <div ></div>
            <div ></div>
            <div ></div>
            <div ></div>
            <div class="HeightDiv" style="padding-top:0px;" ><asp:TextBox ID="txtRemark" 
                    runat="server" Width="90%" TextMode="MultiLine" Height="45px"></asp:TextBox></div>
            <div class="HeightDiv" style="padding-top:0px;"  ><asp:TextBox ID="txtCustomerInfo" runat="server" Width="90%" TextMode="MultiLine" Height="45px"></asp:TextBox></div>
            
        </div>
     
        
    </div>
</form>
<script>
var divRdo=$(".divRdo")[1] ;
$(divRdo).find(":radio").each(function(i)
{ 

     if(this.value!=""&&this.value!=null&&this.value!="00000000-0000-0000-0000-000000000000")
     {
      this.checked=true;
      this.click();
      }
      else
      {
          var rdo=document.getElementsByName(this.name);
          if(rdo[0].value!=""&&rdo[0].value!=null)
          {
          rdo[0].checked=true;
          rdo[0].click();
          }
      }
});




</script>
</body>
</html>