<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ARList.aspx.vb" Inherits="VS4WebApp.ARList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="Scripts/Site2.css" rel="stylesheet" type="text/css" />


    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <link href="Content/bootstrap/bootstrap.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/jquery.cookie.js"></script>
    <style type="text/css">
        .selected
        {
            background-color: Yellow;
            color: Green;
        }
    </style>
    <script type="text/javascript">

        

        $(document).ready(function () {
            //$("#txtARSearch").keyup(function (event) {
            //    if (event.keyCode == 13) {
            //        //$("#btnSearchAR").click();
            //        alert(event.keyCode);
            //    }
            //});
            //$('#txtARSearch').keyup(function (event) {
            //    alert(event.keyCode);
            //    if (event.keyCode == '13') {
            //        alert(event.keyCode);
            //        //$('#btnSearchAR').click();
            //    }
            //});

            $("#<%=GridView1.ClientID%> tr:has(td)").hover(function (e) {
                $(this).css("cursor", "pointer");
            });

            $("#<%=GridView1.ClientID%> tr:has(td)").click(function (e) {
                var selTD = $(e.target).closest("td");
                var cell0 = $(this).closest('tr').find('td:eq(0)').text();
                var cell1 = $(this).closest('tr').find('td:eq(1)').text();
                var cell2 = $(this).closest('tr').find('td:eq(2)').text();
                var cell3 = $(this).closest('tr').find('td:eq(3)').text();
                var cell4 = $(this).closest('tr').find('td:eq(4)').text();

                $("#<%=GridView1.ClientID%> td").removeClass("selected");
                selTD.addClass("selected");

                $("#<%=lblSelectCode.ClientID%>").html(cell0);
                $("#<%=lblSelectName.ClientID%>").html(cell1);


                cell0 = $.trim(cell0);
                cell1 = $.trim(cell1);
                cell2 = $.trim(cell2);
                cell3 = $.trim(cell3);
                cell4 = $.trim(cell4);
  
                $("#HlblSelectCode").val(cell0);
                $("#HlblSelectName").val(cell1);
                $("#HlblSelectAddress").val(cell2);
                $("#HlblSelectPhone").val(cell3);
                $("#HlblSelectMobile").val(cell4);
                $.cookie("chkReloadCus", 1);
                $.cookie("CusCode", cell0);
                $.cookie("CusName", cell1);
                $.cookie("CusAddress", cell2);
                $.cookie("CusPhone", cell3);
                $.cookie("CusMobile", cell4);
            });

            $("#GotoNew").click(function () {
                //var sPageURL = window.location.search.substring(1);
                var url = 'NewCus.aspx';
                window.location = url;
            });

        });
    </script>

</head>
<body>
    <form id="form1" runat="server">

        <div class="panel panel-default">
            <div class="panel-heading">
                <button type="button" id="GotoNew" class="btn btn-warning" style="background-color: #4671D5">
                    <span class="glyphicon glyphicon-plus glyphicon glyphicon-user">ไปหน้าเพิ่มลูกค้าใหม่</span>
                </button>
                &nbsp;&nbsp;
                <asp:Button ID="Button4" runat="server" Text="ตกลง" CssClass="btn btn-primary" />
            </div>
            <div class="panel-body">
                <div style="display: table; margin-right: auto; margin-left: auto;">
                    <span>ผู้ดูแล</span> <asp:TextBox ID="txtSales" runat="server" Width="50px"></asp:TextBox>
                    <span>ค้นหา</span> <asp:TextBox ID="txtARSearch" runat="server" Width="200px"></asp:TextBox>
                    <asp:DropDownList ID="DRJOINAR" runat="server">
                        <asp:ListItem Selected="True" Value="0">ALL</asp:ListItem>
                        <asp:ListItem Value="1">ANY</asp:ListItem>
                    </asp:DropDownList>
                    <asp:Button ID="btnSearchAR" runat="server" Text="ค้นหา" />
                    <br />

                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" PageSize="15" OnPageIndexChanging="ShowPageCommand" AllowPaging="True">
                        <AlternatingRowStyle BackColor="#F0F0F0" />
                        <Columns>

                            <asp:TemplateField HeaderText="รหัส">
                                <ItemTemplate>
                                    <asp:Label ID="lblCode" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="ชื่อลูกค้า">
                                <ItemTemplate>
                                    <asp:Label ID="lblName" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="ที่อยู่">
                                <ItemTemplate>
                                    <asp:Label ID="lblAddress" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="โทร">
                                <ItemTemplate>
                                    <asp:Label ID="lblPhone" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                             <asp:TemplateField HeaderText="มือถือ">
                                <ItemTemplate>
                                    <asp:Label ID="lblMobile" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <HeaderStyle BackColor="#2D3E5B" ForeColor="White" />
                    </asp:GridView>

                    <asp:Label ID="lblSelectCode" runat="server"></asp:Label>
                    <asp:Label ID="lblSelectName" runat="server"></asp:Label>
                    <asp:HiddenField ID="HlblSelectCode" runat="server" />
                    <asp:HiddenField ID="HlblSelectName" runat="server" />
                    <asp:HiddenField ID="HlblSelectAddress" runat="server" />
                    <asp:HiddenField ID="HlblSelectPhone" runat="server" />
                    <asp:HiddenField ID="HlblSelectMobile" runat="server" />
                </div>
            </div>
        </div>
    </form>
</body>
</html>
