<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin.Master" CodeBehind="SegmentList.aspx.vb" Inherits="Superbowl.SegmentList" 
    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">
            Segment List</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td width="25%">&nbsp;</td>
    </tr>
    <tr>		 
        <td align="right">Segment:</td>
        <td  align="left"><asp:TextBox ID="txtSegment" runat="server"></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="gvSegment" runat="server" Width="100%" CellPadding="2" 
				  AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
				  DataSourceID="sdsSegment" PageSize="25" HeaderStyle-CssClass="gvHeader" 
				  DataKeyNames="SegmentID,strSegment">	  	
					<Columns>
						<asp:BoundField DataField="#" HeaderText="#" ReadOnly="True" >
							<HeaderStyle Width="1%" />
							<ItemStyle Font-Size="Smaller" HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:HyperLinkField DataNavigateUrlFields="SegmentID"	SortExpression="strSegment"
							DataNavigateUrlFormatString="SegmentDetails.aspx?SID={0}" 
							DataTextField="strSegment" HeaderText="Segment" />	
						<asp:BoundField DataField="strLastUser" HeaderText="Last User" 
							SortExpression="strLastUser" />
						<asp:BoundField DataField="dtStamp" HeaderText="Last Edit" 
							SortExpression="dtStamp" >
							<ItemStyle HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:CommandField HeaderText="Delete" ShowDeleteButton="True">
							<ItemStyle HorizontalAlign="Center" />
						</asp:CommandField>
					</Columns>
					<HeaderStyle CssClass="gvHeader"/>				  
				  <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="sdsSegment" AutoGenerateColumns="False" DataKeyNames="SegmentID">
				   <Columns>
						<asp:BoundField DataField="SegmentID" HeaderText="Segment ID" InsertVisible="False" 
							ReadOnly="True" />
						<asp:BoundField DataField="strSegment" HeaderText="Segment"  />  						
						<asp:BoundField DataField="strLastUser" HeaderText="Last User" 
							SortExpression="strLastUser" />
						<asp:BoundField DataField="dtStamp" HeaderText="Stamp" 
							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="sdsSegment" runat="server" ConnectionString="<%$ ConnectionStrings:csStockControl %>"		 
SelectCommand="SELECT '' AS #, mstSegment.SegmentID, mstSegment.strSegment, COUNT(mstCustomer.strCustomerNo) AS intCustomer, mstSegment.strLastUser, mstSegment.dtStamp FROM mstCustomer RIGHT OUTER JOIN mstChannel ON mstCustomer.refChannelID = mstChannel.ChannelID RIGHT OUTER JOIN mstSegment ON mstChannel.refSegmentID = mstSegment.SegmentID GROUP BY mstSegment.SegmentID, mstSegment.strSegment, mstSegment.strLastUser, mstSegment.dtStamp ORDER BY strSegment"
DeleteCommand="DELETE FROM [mstSegment] WHERE [SegmentID] = @SegmentID"	  />
<DeleteParameters>
	<asp:Parameter Name="SegmentID" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
			  <br />			 
</asp:Content>
