<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin.Master" CodeBehind="ChannelList.aspx.vb" Inherits="Superbowl.ChannelList" 
    title="Untitled Page" EnableEventValidation="false"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
  <table width="100%" cellpadding="2">
    <tr>
        <td align="center" class="headings" colspan="4">
            Channel Segment List</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td width="35%">&nbsp;</td>
    </tr>
    <tr>		 
        <td align="right">Channel Segment:</td>
        <td  align="left"><asp:TextBox ID="txtChannelSegment" runat="server" 
            Width="200px"></asp:TextBox></td>
        <td align="right">&nbsp;</td>
        <td  align="left">&nbsp;</td>
    </tr>
    <tr>		 
        <td align="right">&nbsp;</td>
        <td  align="left">&nbsp;</td>
        <td align="right"><asp:Button ID="btnSearch" runat="server" Text="Search" /></td>
        <td  align="left"><asp:Button ID="btnAdd1" runat="server" Text="Add" /></td>
    </tr>
    <tr>		 
        <td align="right">&nbsp;</td>
        <td  align="left">&nbsp;</td>
        <td align="right">&nbsp;</td>
        <td  align="left">&nbsp;</td>
    </tr>
    <tr>		 
        <td align="left" colspan="4" style="border: 1px solid maroon">
			  <asp:GridView ID="gvChannelSegment" runat="server" Width="100%" CellPadding="2" 
				  AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
				  DataSourceID="sdsChannelSegment" PageSize="25" HeaderStyle-CssClass="gvHeader" 
				  
            DataKeyNames="ChannelSegmentID,strChannelPrimary,strChannel,strSegmentPrimary,strSegment">	  	
					<Columns>
						<asp:BoundField DataField="#" HeaderText="#" ReadOnly="True" >
							<HeaderStyle Width="1%" />
							<ItemStyle Font-Size="Smaller" HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:HyperLinkField DataNavigateUrlFields="ChannelSegmentID" 
              DataNavigateUrlFormatString="ChannelDetails.aspx?CID={0}" 
              DataTextField="strSegmentPrimary" HeaderText="Segment Primary" 
              SortExpression="strSegmentPrimary" />
            <asp:BoundField DataField="strSegment" HeaderText="Segment" 
              SortExpression="strSegment" />
            <asp:BoundField DataField="strChannelPrimary" HeaderText="Channel Primary" 
              SortExpression="strChannelPrimary" />
            <asp:BoundField DataField="strChannel" HeaderText="Channel" 
              SortExpression="strChannel" />
						<asp:HyperLinkField DataNavigateUrlFields="ChannelSegmentID" 
              DataNavigateUrlFormatString="CustomerList.aspx?CID={0}" 
              DataTextField="intCustomer" HeaderText="Customer Count" 
              SortExpression="intCustomer" Target="_blank">
            <ItemStyle HorizontalAlign="Right" Width="5%" />
            </asp:HyperLinkField>
						<asp:BoundField DataField="strLastUser" HeaderText="Last User" 
							SortExpression="strLastUser" />
						<asp:BoundField DataField="dtStamp" HeaderText="Last Edit" 
							SortExpression="dtStamp" >
							<ItemStyle HorizontalAlign="Right" Wrap="False" Width="5%" />
						</asp:BoundField>
						<asp:CommandField HeaderText="Delete" ShowDeleteButton="True">
							<ItemStyle HorizontalAlign="Center" />
						</asp:CommandField>
					</Columns>
					<HeaderStyle CssClass="gvHeader" Wrap="False"/>				  
				  <AlternatingRowStyle CssClass="lightergrey" />
				   <PagerSettings PageButtonCount="20" Mode="NumericFirstLast" FirstPageText="<B>&lt;&lt;</B>" LastPageText="<B>&gt;&gt;</B>" />
				  <RowStyle CssClass="gvItem" />		
			  </asp:GridView>
			  <asp:Label ID="lblMessage" CssClass="redBold" runat="server" Text=""></asp:Label>
			  <asp:GridView ID="gvExport" runat="server" 
				  AlternatingRowStyle-CssClass="lightergrey"  HeaderStyle-CssClass="gvHeader" 
						SelectedRowStyle-CssClass="gvItem" CellPadding="0" visible="False" 
				  DataSourceID="sdsChannelSegment" AutoGenerateColumns="False" DataKeyNames="ChannelSegmentID">
				   <Columns>
						<asp:BoundField DataField="ChannelSegmentID" HeaderText="ChannelSegmentID" 
               InsertVisible="False" ReadOnly="True" SortExpression="ChannelSegmentID"  />									
						<asp:BoundField DataField="strSegmentPrimary" HeaderText="strSegmentPrimary" 
               SortExpression="strSegmentPrimary" />
						<asp:BoundField DataField="strSegment" HeaderText="strSegment" 
               SortExpression="strSegment">
						</asp:BoundField>
						<asp:BoundField DataField="strChannelPrimary" HeaderText="strChannelPrimary" 
							SortExpression="strChannelPrimary" />
						<asp:BoundField DataField="strChannel" HeaderText="strChannel" 
							SortExpression="strChannel"/>
					   <asp:BoundField DataField="intCustomer" HeaderText="intCustomer" 
               ReadOnly="True" SortExpression="intCustomer" />
             <asp:BoundField DataField="strLastUser" HeaderText="strLastUser" 
               SortExpression="strLastUser" />
             <asp:BoundField DataField="dtStamp" HeaderText="dtStamp" 
               SortExpression="dtStamp" />
					</Columns>
				   <SelectedRowStyle CssClass="gvItem" />
					<HeaderStyle CssClass="gvHeader" />
					<AlternatingRowStyle CssClass="lightergrey" />	  						
			  </asp:GridView>	  		  
		  	
		  </td>
    </tr>
    <tr>		 
        <td align="left"><asp:CheckBox ID="chkResize" runat="server" AutoPostBack="True" CssClass="red" Text="Show 1000" /></td>
        <td  align="left">&nbsp;</td>
        <td align="right">&nbsp;</td>
        <td  align="left">&nbsp;</td>
    </tr>
    <tr>		 
        <td align="right">&nbsp;</td>
        <td  align="left">&nbsp;</td>
        <td align="right"><asp:Button ID="btnExport" runat="server" Text="Export" /></td>
        <td  align="left"><asp:Button ID="btnAdd2" runat="server" Text="Add" /></td>
    </tr>
</table>	  
			  <asp:SqlDataSource ID="sdsChannelSegment" runat="server" 
				  ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
				  DeleteCommand="DELETE FROM [mstChannelSegment] WHERE [ChannelSegmentID] = @ChannelSegmentID" 				  
				  
  SelectCommand="SELECT '' AS '#', mstChannelSegment.ChannelSegmentID, mstChannelSegment.strSegmentPrimary, mstChannelSegment.strSegment, mstChannelSegment.strChannelPrimary, mstChannelSegment.strChannel, COUNT(mstCustomer.strCustomerNo) AS intCustomer, mstChannelSegment.strLastUser, mstChannelSegment.dtStamp FROM mstChannelSegment LEFT OUTER JOIN mstCustomer ON mstChannelSegment.ChannelSegmentID = mstCustomer.refChannelSegmentID GROUP BY mstChannelSegment.ChannelSegmentID, mstChannelSegment.strLastUser, mstChannelSegment.dtStamp, mstChannelSegment.strSegmentPrimary, mstChannelSegment.strSegment, mstChannelSegment.strChannelPrimary, mstChannelSegment.strChannel ORDER BY mstChannelSegment.strSegmentPrimary, mstChannelSegment.strSegment, mstChannelSegment.strChannelPrimary, mstChannelSegment.strChannel" 				  >
				  <DeleteParameters>
					  <asp:Parameter Name="ChannelSegmentID" Type="Int32" />
				  </DeleteParameters>		  				  
			  </asp:SqlDataSource>
			  
			  <asp:SqlDataSource ID="sdsSegment" runat="server" 
				  ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
				  SelectCommand="SELECT 0 AS segmentID, '- All -' AS strSegment
											UNION SELECT [SegmentID], [strSegment] FROM [mstSegment] ORDER BY [strSegment]">
			  </asp:SqlDataSource>
			  
</asp:Content>
