<%@ Page Language="C#" AutoEventWireup="true"  EnableViewState="true"  MasterPageFile="~/Main.Master"  Theme="Default"  CodeBehind="AgentList.aspx.cs" Inherits="OAWeb.crm.Agent.AgentList" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="/UserControls/AgentLeft.ascx" TagName="TaskNav" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" runat="server">
<style>
.BtnList a
{
	margin-right:5px;
}
</style>
    <script language="javascript" type="text/javascript">
        //打开分配窗口
        function OpenAssignDialog() {
            if (document.getElementById('<% =hdfOwnerId.ClientID %>').value != "") {
                return true;
            }
            if (getCheckedValueList() == "") {
                alert("请选择要分配的数据！");
                return false;
            }
            var Url = "/Dialog/EmploySelectDialog.aspx?user=0";

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

            });
            return false;
        }
        //打开归还窗口
        function OpenBackCustomerDialog() {
            var values = getCheckedValueList();
            if (values == "") {
                alert("请选择要归还的数据！");
                return false;
            }


            var Url = "/Dialog/BackCustomer.aspx?IdArray=" + values;

            OpenDialog(Url, "");
            return false;


        }

        function MoveCustomer() {
            var values = getCheckedValueList();
            if (values == "") {
                alert("请选择要移动的客户！");
                return false;
            }

            var Url = "/Dialog/MoveCustomer.aspx?IdArray=" + values;

            OpenDialog(Url, "移动客户");
            return false;


        }

        function AddNewCustomer() {
            var values = getCheckedValueList();

            if (values == "") {
                alert("请选择需要合并的2条数据");
            }
            else {
                var v = values.split(",");
                if (v.length != 2) {
                    alert("目前只支持2条合并");
                }
                else {
                    var str = "";
                    for (var i = 0; i < v.length; i++) {
                        str += "'" + v[i] + "',";
                    }
                    str = str.substr(0, str.length - 1);

                    var Url = "CustomerNew.aspx?strIds=" + str;

                    OpenWindow(Url, "1000", "600");
                }
            }
        }

        function SendMessage() {
            var values = getCheckedValueList();
            if (values == "") {
                alert("请选择要操作的客户");
                return;
            }
            var url = "/Dialog/SendMessage.aspx?IdList=" + values;
            OpenDialog(url, "群发信息");
        }
    </script>
    <script type="text/javascript" language="javascript">
        //CallCity("ctl00_ContentPlaceHolder1_ddlProvince");
    </script>
    <!--搜索区域 开始-->
    <table id="plc_profile" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="main_left">
                <uc1:TaskNav ID="TaskNav1" runat="server" />
            </td>
            <td class="main_center">
                <div class="page_main">
                    <div class="page_content">
                        <table class="data_title" style="margin-top: 10px;">
                            <tr>
                                <td class="data_caption">
                                    <asp:Label ID="lblCaption" runat="server"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td class="data-field">
                                    <table width="60%">
                                        <tr>
                                            <td class="tb-label">
                                                &nbsp;<asp:DropDownList ID="ddlField" runat="server">
                                                    <asp:ListItem>客户名称</asp:ListItem>
                                                    <asp:ListItem>客户电话</asp:ListItem>
                                                    <asp:ListItem>联系人姓名</asp:ListItem>
                                                    <asp:ListItem>联系人电话</asp:ListItem>
                                                    <asp:ListItem>联系人手机</asp:ListItem>
                                                    <asp:ListItem>联系人QQ</asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td class="tb-editor" nowrap="nowrap">
                                                <asp:TextBox ID="txtCustomer" runat="server" Width="200px"></asp:TextBox>
                                                <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" TabIndex="1"
                                                    Text=" 查 询 " CssClass="btn_77px" />
                                                <asp:Button ID="btnAdvanceSearch" Visible="false" runat="server" Text="高级查询" CssClass="btn_77px" />
                                            </td>
                                            <td class="tb-label">
                                            </td>
                                            <td class="tb-editor" nowrap="nowrap">
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                        <div class="buttons-bar" style="margin-bottom: 10px;">
                            <table class="w100p" style="width: 100%">
                                <tr>
                                    <td align="left">
                                        <asp:Button ID="btnAddCustomer" runat="server" Text="新建客户" CssClass="btn_77px" />

                                        <asp:Button ID="btnAllot" runat="server" Text="分 配" OnClick="btnAllot_Click" CssClass="btn_77px" />
                                        <asp:Button ID="btnBack" runat="server" OnClick="btnBack_Click" Text="归 还" CssClass="btn_77px" />

                                        <asp:Button ID="btnDelCustomer" runat="server" OnClick="btnDelCustomer_Click" Text="删 除" Visible="false"
                                            CssClass="btn_77px" />

                                    </td>
                                    <td align="right">
                                        <asp:DropDownList ID="ddlSort" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlSort_SelectedIndexChanged">
                                            <asp:ListItem Value="Customer.CreateDate desc">创建时间</asp:ListItem>
                                            <asp:ListItem Value="Customer.last_login desc">活跃时间</asp:ListItem>
                                            <asp:ListItem Value="Customer.ModifyDate desc">修改时间</asp:ListItem>
                                            <asp:ListItem Value="Customer.NextContactTime desc">下次联系</asp:ListItem>
                                            <asp:ListItem Value="Customer.LastTradeDate desc">交易时间</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <asp:GridView ID="gvCustomerList" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"
                            OnRowCommand="gvCustomerList_RowCommand" OnRowDataBound="gvCustomerList_RowDataBound"
                            PageSize="20">
                            <HeaderStyle Wrap="False" />
                            <Columns>
                                <asp:TemplateField>
                                    <HeaderTemplate>
                                        <asp:CheckBox ID="chkAll" runat="server" onclick="SelectAll(this);" />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <input runat="server" id="chkItem" name="chkItem" type="checkbox" value='<%#Eval("CustomerID")%>' />
                                    </ItemTemplate>
                                    <ItemStyle Width="20px" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="CustomerID" HeaderText="编号" Visible="false">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" Width="30px" />
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="">
                                    <ItemStyle HorizontalAlign="Left" Width="30px" />
                                    <ItemTemplate>
                                        <span id="spLock" runat="server"></span><span id="spImg" runat="server"></span>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="会员相关信息">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <div style="margin-top: 0px; float: left; width: 100%; color: #666666; font-size: 14px;
                                            text-align: left; line-height:20px;">
                                            <asp:Image ID="Image1" runat="server" Width="16" Height="16" />
                                            <asp:LinkButton ID="lnkbtnView" runat="server" CausesValidation="false" CommandName="lbtView"
                                                CommandArgument='<%#DataBinder.Eval(Container.DataItem,"CustomerID").ToString()%>'><strong><%# Eval("CustomerName").ToString()%></strong></asp:LinkButton>
                                            <span style="font-size: 12px">
                                                <br />
                                                <strong>行业：</strong><asp:Label ID="lblIndustryName" runat="server" Text='<%# Eval("IndustryName") %>'></asp:Label>&nbsp;
                                                <strong>联系人：</strong><asp:Label ID="lblContactMan" runat="server" Text='<%# Eval("MainContactName") %>'></asp:Label>&nbsp;
                                                <strong>电话：</strong><asp:Label ID="lblTelephone" runat="server" ForeColor="blue"
                                                    Text='<%# DataBinder.Eval(Container.DataItem, "Telephone")%>'></asp:Label>
                                               
                                                
                                            </span>
                                        </div>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="CityName" HeaderText="城市" >
                                    <ItemStyle  />
                                </asp:BoundField>
                             
                           
                                <asp:TemplateField HeaderText="级别">
                                    <ItemStyle HorizontalAlign="Center"  />
                                    <ItemTemplate>
                                        <asp:Label ID="lblGrade" runat="server" Text=""></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="授权产品数">
                                    <ItemStyle HorizontalAlign="Center"  />
                                    <ItemTemplate>
                                        <asp:Label ID="lblCount" runat="server" Text="0"></asp:Label>   
                                        <a style=" margin-left:10px;" href="javascript:void(0)"  id="LinkView" runat="server">查看</a> 
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="余额">
                                    <ItemStyle HorizontalAlign="Center"  />
                                    <ItemTemplate>
                                        <asp:Label ID="lblBalance" runat="server" Text="Label"></asp:Label> 
                                        <a href="javascript:void(0)" id="LinkBalance" runat="server" style=" margin-left:5px">明细</a>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="业务负责">
                                    <HeaderStyle HorizontalAlign="Center" ></HeaderStyle>
                                    <ItemTemplate>
                                        <asp:Label ID="lblOwnerName" runat="server" Text='<%#Eval("OwnerName") %>'></asp:Label>
                                        <asp:Label ID="lblOwnerID" runat="server" Text='<%#Eval("OwnerID") %>' Visible="false"></asp:Label>
                                        <asp:LinkButton ID="lnkbtnTrack" runat="server" CausesValidation="false" CommandName="cmdTrack"
                                            CommandArgument='<%#DataBinder.Eval(Container.DataItem,"CustomerID").ToString()%>'>领用</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="CreateDate" HeaderText="创建日期" SortExpression="Customer.CreateDate"
                                    DataFormatString="{0:g}" HtmlEncode="false">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center"  />
                                </asp:BoundField>
                        
                                <asp:TemplateField HeaderText="操作" >
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" CssClass="BtnList"  />
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkbtnEdit" runat="server" CausesValidation="false" CommandName="cmdEdit"
                                            CommandArgument='<%#DataBinder.Eval(Container.DataItem,"CustomerID").ToString()%>'>编辑</asp:LinkButton>
                                            <asp:LinkButton ID="lbtnReceive" runat="server" CausesValidation="false" CommandName="Receive" OnClientClick="return confirm('确定要转为正式分销会员？')"
                                            CommandArgument='<%#DataBinder.Eval(Container.DataItem,"CustomerID").ToString()%>'>接受</asp:LinkButton>
                                            <asp:LinkButton ID="lbtnRefuse" runat="server" CausesValidation="false" CommandName="Refuse"  OnClientClick="return confirm('确定要拒绝此分销会员？')"
                                            CommandArgument='<%#DataBinder.Eval(Container.DataItem,"CustomerID").ToString()%>'>拒绝</asp:LinkButton>
                                        <asp:LinkButton ID="lnkbtnDelete" runat="server" CausesValidation="false" CommandName="cmdDelete"
                                            CommandArgument='<%#DataBinder.Eval(Container.DataItem,"CustomerID").ToString()%>'>删除</asp:LinkButton>

                                            <asp:LinkButton ID="lbtnAmount" runat="server"  CommandName="Amount"
                                            CommandArgument='<%#Eval("CustomerID")%>'>录款</asp:LinkButton>
                                            <asp:LinkButton ID="lbtnSet" runat="server"  CommandName="Set"
                                            CommandArgument='<%#Eval("CustomerID")%>'>设置</asp:LinkButton>
                                            <asp:LinkButton ID="lbtnEnable" runat="server" Visible="false"  CommandName="Disabled" OnClientClick="return comfirm('确认要冻结该用户？')"
                                            CommandArgument='<%#Eval("CustomerID")%>'>冻结</asp:LinkButton>
                                             <asp:LinkButton ID="lbtnBack" runat="server"  CommandName="Back"  OnClientClick="return comfirm('确认取消该用户的资格？')"
                                            CommandArgument='<%#Eval("CustomerID")%>'>取消资格</asp:LinkButton>

                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        <div class="pager-bar">
                            <webdiyer:AspNetPager ID="plCustomer" runat="server" OnPageChanged="plCustomer_PageChanged"
                                PageSize="20">
                            </webdiyer:AspNetPager>
                        </div>
                        <asp:HiddenField ID="hdfSql" runat="server" />
                        <asp:HiddenField ID="hdfOwnerId" runat="server" />
                    </div>
                </div>
            </td>
        </tr>
    </table>
</asp:Content>
