<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin.Master" CodeBehind="SalesRepQF.aspx.vb" Inherits="Superbowl.SalesRepQF" 
    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">
            Sales QF</td>
    </tr>
    <tr>
        <td width="15%">&nbsp;</td>
        <td width="25%">&nbsp;</td>
        <td >&nbsp;</td>
        <td >&nbsp;</td>
    </tr>
    <tr>		 
        <td align="right">Principal:</td>
        <td  align="left"><asp:DropDownList ID="ddlPrincipal" runat="server" AutoPostBack="True" 
				  DataSourceID="sdsPrincipal" DataTextField="strPrincipal" 
				  DataValueField="PrincipalID" Width="200px">
			  </asp:DropDownList>
		  </td>
        <td align="right">Branch:</td>
        <td  align="left"><asp:DropDownList ID="ddlBranch" runat="server" AutoPostBack="True" Width="200px"
				  DataSourceID="sdsBranch" DataTextField="strBranch" DataValueField="BranchID">
			  </asp:DropDownList>
			
		  </td>
    </tr>	
    <tr>		 
        <td align="right">Brand:</td>
        <td  align="left">
			  <asp:DropDownList ID="ddlBrand" runat="server" DataSourceID="sdsBrand" 
				  DataTextField="strBrand" DataValueField="BrandID" Width="200px">
			  </asp:DropDownList>
		  </td>
        <td align="right">Sales Rep:</td>
        <td  align="left"> <asp:DropDownList ID="ddlRep" runat="server" DataSourceID="sdsRep" 
				  DataTextField="strRepName" DataValueField="RepID" Width="200px">
			  </asp:DropDownList>	  
			  
		  </td>
    </tr>	
    <tr >		 
        <td align="right" >Start Period:</td>
        <td  align="left" ><asp:DropDownList ID="ddlStartDate" runat="server" AutoPostBack="True" Width="100px"
				  DataSourceID="sdsPeriod" DataTextField="strPeriod" DataValueField="strPeriod">
			  </asp:DropDownList>		
		  </td>
        <td align="right" nowrap>End Period:</td>
        <td  align="left" ><asp:DropDownList ID="ddlEndDate" runat="server" DataSourceID="sdsPeriod" 
				  DataTextField="strPeriod" DataValueField="strPeriod" Width="100px" 
				  AutoPostBack="True">
			  </asp:DropDownList>
		  </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="2">
				<table width="70%" cellpadding="0" border="0"><tr>
						<td align="left" nowrap width="1%">Show:</td>
						<td align="left" nowrap><asp:CheckBox ID="chkPeriod" Checked="true" runat="server" Text="Period*" CssClass="red" /></td>
						<td align="left" nowrap><asp:CheckBox ID="chkBrand" Checked="true" runat="server" Text="Brand" CssClass="red" /></td>
						<td align="left" nowrap><asp:CheckBox ID="chkPrincipal" Checked="true" runat="server" Text="Principal" CssClass="red" /></td>
						<td align="left" nowrap><asp:CheckBox ID="chkBranch" Checked="true" runat="server" Text="Branch" CssClass="red" /></td>
						<td align="left" nowrap><asp:CheckBox ID="chkRep" Checked="true" runat="server" Text="Rep" CssClass="red" /></td>
						<td align="left" nowrap><asp:CheckBox ID="chkZero" Checked="true" runat="server" Text="Suppress Zeros" CssClass="red" /></td>
				</tr></table></td>
			<td align="right"><asp:Button ID="btnSearch" runat="server" Text="Search" /></td>
        <td  align="left">&nbsp;</td>
    </tr>
    <tr>		 
        <td align="left" colspan="4" style="border: 1px solid maroon">
			  <asp:GridView ID="gvRepQF" runat="server" Width="100%" CellPadding="2" 
				  AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
				 PageSize="25" HeaderStyle-CssClass="gvHeader" ShowFooter="True">	  					
					<HeaderStyle CssClass="gvHeader"/>				  
				  <AlternatingRowStyle CssClass="lightergrey" />
				   <PagerSettings PageButtonCount="20" Mode="NumericFirstLast" FirstPageText="<B>&lt;&lt;</B>" LastPageText="<B>&gt;&gt;</B>" />
				   <FooterStyle CssClass="gvHeader" />
				  <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" AutoGenerateColumns="False">
				   <RowStyle CssClass="gvItem" />
					<HeaderStyle CssClass="gvHeader" />
					<AlternatingRowStyle CssClass="lightergrey" />	  							
			  </asp:GridView>	  		  
		  	
		  </td>
    </tr>
    <tr>		 
        <td align="left" nowrap><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">&nbsp;</td>
    </tr>
</table>
<br />
<asp:SqlDataSource ID="sdsRepQF" runat="server" 
	ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
	SelectCommand="">
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsPrincipal" runat="server" 
	ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
	SelectCommand="SELECT 0 AS PrincipalID, '- All -' AS strPrincipal
							UNION SELECT [PrincipalID], [strPrincipal] FROM [mstPrincipal] ORDER BY [strPrincipal]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsBrand" runat="server" 
	ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
	SelectCommand="SELECT 0 AS BrandID, 0 as refPrincipalID, '- All -' AS strBrand, 1 AS blnActive
							UNION SELECT [BrandID], [refPrincipalID], [strBrand], [blnActive] FROM [mstBrand] WHERE ([blnActive] = 1) ORDER BY [strBrand]">
</asp:SqlDataSource>				 
<asp:SqlDataSource ID="sdsBranch" runat="server" 
	ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
	SelectCommand="SELECT 0 AS BranchID, '- All -' AS strBranch 
			UNION SELECT BranchID, strBranch +' '+ strCode + CASE WHEN [strBranch] = [strSalesOffice] THEN '' ELSE ' : ' + [strSalesOffice] END AS strBranch FROM mstBranch ORDER BY strBranch">
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsRep" runat="server" 
	ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
	SelectCommand="SELECT '0' AS RepID, '- All -' AS strRepName, 0 as refBranchID
							UNION SELECT [RepID], [strRepName] + ' - ' + [RepID] AS strRepName, [refBranchID] FROM [mstRep] WHERE [blnGenerateQF] = 1 ORDER BY [strRepName]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsPeriod" runat="server" 
	ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
	SelectCommand="SELECT [strPeriod] FROM [mstPeriod] WHERE ([strPeriod] >= '200808') ORDER BY [strPeriod]">
</asp:SqlDataSource>			  
<br />
 <asp:GridView ID="gvColumns" runat="server" Width="100%" CellPadding="2" 
				  AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
		PageSize="25" HeaderStyle-CssClass="gvHeader" Visible="False" ShowFooter="True">	  	
					<Columns>
						<asp:BoundField DataField="#" HeaderText="#" ReadOnly="True" >
							<HeaderStyle Width="1%" />
							<ItemStyle Font-Size="Smaller" HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:BoundField DataField="strPeriod" HeaderText="Period" 
							SortExpression="strPeriod" ReadOnly="True">
							<FooterStyle HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:BoundField DataField="strBrand" HeaderText="Brand" 
							SortExpression="strBrand" >
							<FooterStyle HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:BoundField DataField="strPrincipal" HeaderText="Principal" 
							SortExpression="strPrincipal">
							<FooterStyle HorizontalAlign="Right" />
						</asp:BoundField>	 						
						<asp:BoundField DataField="strBranch" HeaderText="Branch" 
							SortExpression="strBranch" >
							<FooterStyle HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:BoundField DataField="strRepName" HeaderText="Rep" 
							SortExpression="strRepName" >
							<FooterStyle HorizontalAlign="Right" />
						</asp:BoundField>
						<asp:BoundField DataField="dblBudget9l" HeaderText="Budget (9L)" 
							ReadOnly="True" SortExpression="dblBudget9l" ItemStyle-HorizontalAlign="Right" >
							<FooterStyle HorizontalAlign="Right" />
<ItemStyle HorizontalAlign="Right"></ItemStyle>
						</asp:BoundField>
						<asp:BoundField DataField="dblPercentage" HeaderText="%" 
							ReadOnly="True" SortExpression="dblPercentage" ItemStyle-HorizontalAlign="Right" >
							<FooterStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Right"></ItemStyle>
						</asp:BoundField>
						<asp:BoundField DataField="strLastUser" HeaderText="Last User" 
							SortExpression="strLastUser" >
							<FooterStyle HorizontalAlign="Left" />
						</asp:BoundField>
						<asp:BoundField DataField="dtStamp" HeaderText="Last Edit" 
							SortExpression="dtStamp" >
							<FooterStyle HorizontalAlign="Left" />
							<ItemStyle HorizontalAlign="Right" />
						</asp:BoundField>
					</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:Content>
