<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customerList.aspx.cs" Inherits="Czou2012.UI.Manager.Customer.customerList" %>

<!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>
    <title>信息列表</title>
    <link type="text/css" rel="stylesheet" href="../Styles/style.css" />
    <link type="text/css" rel="stylesheet" href="../Styles/pagination.css" />
    <link type="text/css" rel="stylesheet" href="../Styles/table.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/themes/icon.css" />
    <script type="text/javascript" src="../Scripts/publicjavascript.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.form.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.validate.field.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.fixedtableheader.min.js"></script>
    <link type="text/css" rel="stylesheet" href="../Scripts/Tips/tip-white/tip-white.css" />
    <script type="text/javascript" src="../Scripts/Tips/jquery.poshytip.js"></script>
    <script type="text/javascript">



        //Query查询事件--------------------------------------------------------------/
        function btnQuery() {
            document.forms[0].action = "customerList.aspx?type=query&CustomerType=<%=nCustomerType%>&ColumnCode=<%=nColumnCode%>&RowNumPerPage=<%=nRowNumPerPage%>";
            document.forms[0].submit();
        }

        //批量Modify事件--------------------------------------------------------------/
        function btnModify() {
            var ifSelected = "0";
            $("tbody input:checkbox[id^='check']").each(function (i) {
                if ($("tbody input:checkbox[id^='check']").eq(i).attr("checked") == true) {
                    ifSelected = "1";
                }
            });

            if (ifSelected == "1") {
                var options = {
                    target: '#lblInfo',
                    method: 'post',
                    url: 'customerList.aspx?type=modify&RowNumPerPage=<%=nRowNumPerPage%>',
                    beforeSubmit: function () {
                        //  $.messager.progress("close");
                    },
                    success: function (msg) {
                        if (msg == "1") {
                            $("#lblInfo").text("修改成功！");

                            $.messager.alert('系统提示', '修改成功', 'question', function () {
                                window.location.href = "<%=nCurrentRequestUrl%>";
                            });

                        }
                        else
                            $("#lblInfo").text("修改有误，请检查！");
                        return false;
                    },
                    error: function () { $.messager.alert("操作提示", "请求异常！", "warning"); }
                };
                $('#formmodify').ajaxSubmit(options);
            }
            else {
                $.messager.alert("操作提示", "您没有选择信息！", "warning");
            }
        }

        //单条信息Modify事件--------------------------------------------------------------/
        function btnSingleModify() {
            var ifSelected = "0";
            var numSelected = 0;
            var valSelected = "0";
            $("tbody input:checkbox[id^='check']").each(function (i) {
                if ($("tbody input:checkbox[id^='check']").eq(i).attr("checked") == true) {
                    valSelected = $.trim($("#CustomerID" + i).val());
                    ifSelected = "1";
                    numSelected = numSelected + 1;
                }
            });

            if (ifSelected == "1" && numSelected == 1) {
                window.parent.SubIframeAddTab('修改会员', 'Customer/customerModify.aspx?ColumnCode=<%=nColumnCode%>&CustomerID=' + valSelected, 'icon icon-ok', true);
            }
            else if (ifSelected == "0") {
                $.messager.alert("操作提示", "您没有选择信息！", "warning");
            }
            else {
                $.messager.alert("操作提示", "您选择了多条信息！", "warning");
            }
        }

        //delete按钮事件--------------------------------------------------------------/
        function btnDelete() {
            var ifSelected = "0";
            $("tbody input:checkbox[id^='check']").each(function (i) {
                if ($("tbody input:checkbox[id^='check']").eq(i).attr("checked") == true) {
                    ifSelected = "1";
                }
            });

            if (ifSelected == "1") {
                var options = {
                    //参数说明：
                    //1.用此方式提交时，form不能为runat="server"；
                    //2.必须在表单form中加method="post"，此参数中加的method:'post'不能提交含大量表单域的form；
                    //3.必须在cs文件中用Request["名称"]获取表单域的值，否则RequestString获取字符串长度有限制.
                    target: '#lblInfo',
                    method: 'post',
                    url: 'customerList.aspx?type=delete&RowNumPerPage=<%=nRowNumPerPage%>',
                    success: function (msg) {
                        if (msg == "1") {
                            $("#lblInfo").text("删除成功！");
                            $.messager.alert('系统提示', '删除成功', 'question', function () {
                                window.location.href = "<%=nCurrentRequestUrl%>";
                            });
                        }
                        else
                            $("#lblInfo").text("删除有误，请检查！");
                        return false;
                    },
                    error: function () { $.messager.alert("操作提示", "请求异常！", "warning"); }
                };
                $('#formmodify').ajaxSubmit(options);
            }
            else {
                $.messager.alert("操作提示", "您没有选择信息！", "warning");
            }

        }



        //reset复原按钮---------------------------------------------------------------------/
        function btnReset() {
            $("form").each(function () {
                this.reset(); //有效，其他无效
            });

            $('#btnForbid').linkbutton('disable');    // disable the button  
            $('#btnDelete').linkbutton('disable');    // disable the button  
            $('#btnAdd').linkbutton('<%=Czou2012.UI.Manager.CommonClass.OperatorRight.IsRightButton("enable","w")%>');    // enable the button  
            window.location.href = "<%=nCurrentRequestUrl%>";
            checkboxClick();

        }

        //checkbox全选事件--------------------------------------------------------------/
        function selectAll(o) {
            if (o.checked) {
                $("input:checkbox[id^='check']").attr("checked", true);

            } else {
                $("input:checkbox[id^='check']").attr("checked", false);
            }
            checkboxClick();
        }

        //checkbox点击事件--------------------------------------------------------------/
        function checkboxClick() {
            $("tbody input:checkbox[id^='check']").each(function (i) {
                if ($("tbody input:checkbox[id^='check']").eq(i).attr("checked") == true) {
                    $("tbody input:checkbox[id^='check']").eq(i).parent().parent().addClass("trSelected");
                } else {
                    $("tbody input:checkbox[id^='check']").eq(i).parent().parent().removeClass("trSelected");
                }
            });

        }

        //文本框改变事件--------------------------------------------------------------/
        function inputChange(obj, i) {
            var cc = "#check" + i;
            $(obj).addClass("inputChange");
            $(cc).attr('checked', true);
            checkboxClick()
        }

        //检查是否输入数字-----------------------------------------------------------/
        function inputNumber(obj) {
            var nNumTemp = obj.value;
            var msg = $.ValidateField.ValidateNumber(nNumTemp);
            if (msg != 'ok') {
                obj.value = "0";
            }
        }

        //全选审核-----------------------------------------------------------/
        function changeAllState(obj) {
            $("[id^='State']").each(function (i) {
                $("#State" + i + " option").each(function (n) {
                    var a = $("#State" + i + " option").eq(n);
                    if ($(obj).val() == a.val()) {
                        $(a).attr("selected", true);
                    }
                });
            });

            $("input:checkbox[id^='check']").attr("checked", true);
            $("tbody input:checkbox").parent().parent().addClass("trSelected");
        }

        //全选权限-----------------------------------------------------------/
        function checkAllAccess(o, nType) {
            if (o.checked) {
                $("input:checkbox[id^='AccessSign" + nType + "']").attr("checked", true);
                $("input:checkbox[id^='AllAccess" + nType + "']").attr("checked", true);
            } else {
                $("input:checkbox[id^='AccessSign" + nType + "']").attr("checked", false);
                $("input:checkbox[id^='AllAccess" + nType + "']").attr("checked", false);
            }

            $("input:checkbox[id^='check']").attr("checked", true);
            $("tbody input:checkbox").parent().parent().addClass("trSelected");
        }

        //打开信息浏览Tab-----------------------------------------------------------/
        function openHref(ColumnCode, CustomerID) {
            window.parent.SubIframeAddTab("会员详细信息", "Customer/customerItemShow.aspx?ColumnCode=" + ColumnCode + "&CustomerID=" + CustomerID, "icon icon-info", true);
        }

        //打开新增信息Tab-----------------------------------------------------------/
        function btnAdd() {

            window.parent.SubIframeAddTab("新增会员", "Customer/customerInput.aspx?CustomerType=<%=nCustomerType%>&ColumnCode=<%=nColumnCode%>", "icon icon-add", true);
        }


        //页面属性 Start--------------------------------------------------------------/
        $(function () {
            $("#tableContent table>tbody>tr input:text").addClass("inputText");
            $("#tableContent table>tbody>tr select").addClass("inputText");

            //linkbutton失效实例,增加权限控制       
            $('#btnAdd').linkbutton('<%=Czou2012.UI.Manager.CommonClass.OperatorRight.IsRightButton("enable","w")%>');
            $('#btnModify').linkbutton('<%=Czou2012.UI.Manager.CommonClass.OperatorRight.IsRightButton("enable","m")%>');
            $('#btnModifyMulti').linkbutton('<%=Czou2012.UI.Manager.CommonClass.OperatorRight.IsRightButton("enable","c")%>');
            $('#btnDelete').linkbutton('<%=Czou2012.UI.Manager.CommonClass.OperatorRight.IsRightButton("enable","d")%>');
            $('#btnQuery').linkbutton('<%=Czou2012.UI.Manager.CommonClass.OperatorRight.IsRightButton("enable","r")%>');
            // $('#btnForbid').linkbutton({ text: "可以" });
            $("#customerTable").fixedtableheader({ headerrowsize: 1 });

            $('span.icon-image,span.incoInfo').poshytip({
                className: 'tip-white',
                showOn: 'mouseover',
                alignTo: 'target',
                alignX: 'right',
                alignY: 'center',
                offsetX: 5,
                content: function () {
                    return "<img src=\"" + $(this).attr('inner') + "\" onload=\"DrawImage(this,90,120)\"/>";
                }
            });

        })
    
    </script>
</head>
<body>
    <div class="tableHeader">
        <span class="navImage">&nbsp;</span><asp:Label ID="lblNavigator" class="lblNavigator"
            runat="server"></asp:Label><span style="padding-left: 20px; padding-right: 5px;"><a
                id="btnAdd" class="easyui-linkbutton" icon="icon-add" href="javascript:btnAdd();"
                tabindex="8">新增</a></span>
    </div>
    <form id="formmodify" method="post" class="form" style="width: 100%;">
    <div id="tableContent" style="height: 75%; overflow: auto; border: 0px solid #ccc">
        <table class="commonTable" id="customerTable">
            <thead>
                <tr>
                    <th style="width: 15px; text-align: center;">
                        <input type="checkbox" id="allCheck" style="border: 0px;" onclick="selectAll(this)" />
                    </th>
                    <th style="width: 100px;">
                        会员编号
                    </th>
                    <th style="min-width: 100px;">
                        登录帐号
                    </th>
                    <th style="min-width: 150px;">
                        会员名称
                    </th>
                    <th style="width: 80px;">
                        会员类型
                    </th>
                    <th style="min-width: 100px;">注册时间</th>
                    <!--
                    <th style="width: 180px; text-align: left;">
                        <input type="checkbox" value="1" id="AllAccess" onclick="checkAllAccess(this,'');" />访问权限
                        (
                        <input type="checkbox" value="1" id="AllAccessL" onclick="checkAllAccess(this,'L');" />
                        &nbsp;<input type="checkbox" value="1" id="AllAccessE" onclick="checkAllAccess(this,'E');" />
                        &nbsp;<input type="checkbox" value="1" id="AllAccessO" onclick="checkAllAccess(this,'O');" />
                        )
                    </th>
                    -->
                    <th style="width: 50px; text-align: center;">
                        排序
                    </th>
                   
                    <th style="width: 60px;">
                        <select name="select0" onchange="changeAllState(this);">
                            <option value="0">未审</option>
                            <option value="1" style="background: #00cc00">已审</option>
                            <option value="2" style="background: red">暂停</option>
                        </select>
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Label ID="tbodyDiv" runat="server"></asp:Label>
                <asp:Repeater runat="server" ID="columnRepeater">
                    <ItemTemplate>
                        <tr style='cursor: pointer;' id='tr_'>
                            <td style="text-align: center; border-left: 0px; border-right: 0px;">
                                <input type="checkbox" value="1" id="<%#"check"+Container.ItemIndex %>" name="<%#"check"+Container.ItemIndex %>"
                                    onclick="checkboxClick();">
                            </td>
                            <td>
                                <a href="#" onclick="openHref('<%=nColumnCode%>','<%# Eval("CustomerID")%>')" title="<%# Eval("CustomerName")%>">
                                    <%# Czou.Common.ComStringHelper.IntParse(Eval("SysSign")) == 1 ? "<span class='fontSign'>" + Eval("CustomerNumber") + "<span>" : Eval("CustomerNumber")%></a>
                                <input type="hidden" value="<%# Eval("CustomerID")%>" id="<%#"CustomerID"+Container.ItemIndex %>"
                                    name="<%#"CustomerID"+Container.ItemIndex %>">
                                <input type="hidden" value="<%# Eval("SysSign")%>" id="<%#"SysSign"+Container.ItemIndex %>"
                                    name="<%#"SysSign"+Container.ItemIndex %>">
                                <input type="hidden" value="<%# Eval("CustomerName")%>" name="<%#"CustomerName"+Container.ItemIndex %>">
                                <input type="hidden" value="<%# Eval("CustomerNumber")%>" name="<%#"CustomerNumber"+Container.ItemIndex %>">
                                <%# (DataBinder.Eval(Container.DataItem, "CustomerPhoto").ToString() != "") ? "<span class='iconInfo icon-image' style='width:16px;height:16px' inner=\""+DataBinder.Eval(Container.DataItem, "CustomerPhoto").ToString()+"\">&nbsp;</span>" : ""%>
                            </td>
                            <td>
                                <%# Eval("CustomerAccount")%>
                            </td>
                            <td>
                                <%# Eval("CustomerName")%>
                            </td>
                            <td>
                                <%# Czou.Business.Dictionary.BusDicRule.GetNameListByCodeList(Eval("CustomerType").ToString(), "single", "1", "")%>&nbsp;
                            </td>
                              <td> <%# Eval("AddTime")%></td>
                        
                            <td>
                                <input value="<%# Eval("Sort")%>" name="<%#"Sort"+Container.ItemIndex %>" onchange="inputChange(this,<%#Container.ItemIndex%>);"
                                    onblur="inputNumber(this);" />
                            </td>

                
                            <td>
                                <select name="<%#"State"+Container.ItemIndex %>" id="<%#"State"+Container.ItemIndex %>"
                                    style="width: 50px;" onchange="inputChange(this,<%#Container.ItemIndex%>);">
                                    <option value='0' <%# (DataBinder.Eval(Container.DataItem, "State").ToString() == "0") ? "selected" : ""  %>
                                        style="background: white; height: 25px; line-height: 35px">未审</option>
                                    <option value='1' <%# (DataBinder.Eval(Container.DataItem, "State").ToString() == "1") ? "selected" : ""  %>
                                        style="background: #00cc00; height: 25px; line-height: 35px">正常</option>
                                    <option value='2' <%# (DataBinder.Eval(Container.DataItem, "State").ToString() == "2") ? "selected" : ""  %>
                                        style="background: red; height: 25px;">暂停</option>
                                </select>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
    <table style="border: 0px; width: 100%;" cellpadding="0" cellspacing="0">
        <tr>
            <td style="height: 28px; background: #eee;">
                <div style="float: left;">
                    <asp:Label ID="LblPageNavigator" runat="server"></asp:Label>
                </div>
            </td>
            <td style="height: 28px; background: #eee;">
                <a id="btnModify" class="easyui-linkbutton" href="javascript:btnSingleModify();"
                    tabindex="12">修改会员</a> &nbsp;&nbsp;<a id="btnDelete" class="easyui-linkbutton" href="#"
                        tabindex="14" onclick='{ $.messager.confirm("操作提示", "删除的信息将不能恢复!您确定要继续吗？\n", function (data) {if (data) {btnDelete();}else {return false;}});}'>
                        选择删除</a> &nbsp;&nbsp;&nbsp;<a id="btnModifyMulti" class="easyui-linkbutton" href="javascript:btnModify();"
                            tabindex="12">批量修改审核</a>
            </td>
        </tr>
        <tr>
            <td style="height: 28px;">
                <span id="lblInfo" style="line-height: 25px; color: #ff0000;" class="lblInfo"></span>
            </td>
        </tr>
    </table>
    <table class="pureTable" style="border: 1px solid #ccc; width: 100%;">
        <tr>
            <td class="bgGray" style="width: 100px; text-align: center;">
                关键字:
            </td>
            <td style="width: 200px">
                <input type="text" id="txtKeywords" name="txtKeywords" class="inputAdd input100"
                    style="width: 90%;" />
            </td>
            <td class="bgGray" style="width: 100px; text-align: center;">
                录入人:
            </td>
            <td style="width: 150px">
                <input type="text" id="txtInputBy" name="txtInputBy" class="inputAdd input100" style="width: 90%;" />
            </td>
            <td style="text-align: left; padding-left: 15px;">
                <a id="btnQuery" class="easyui-linkbutton" href="javascript:btnQuery();" tabindex="13">
                    查询</a>&nbsp;&nbsp;&nbsp;<a id="btnReset" class="easyui-linkbutton" href="javascript:btnReset();"
                        tabindex="15">复原</a>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
