<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin.Master" CodeBehind="SCReport.aspx.vb" Inherits="Stock_Control.SCReport" 
    title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
		
  </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
    <table class='red' border='0' style='border-style: none; border-width: 1px; ' background-color: #A02121; cellpadding=2 cellspacing=1 width='100%'>
		<tr>
			<td align="center" class="headings" colspan="4">Stock Control Report</td>
		</tr>
		<tr>
			<td colspan="4" class="style1"></td>
		</tr>
		<tr>
				<td align="right" width="15%" >&nbsp;Brand:</td>
				<td width="35%" >
        	  <asp:DropDownList ID="ddlBrand" runat="server" DataSourceID="sdsBrand" 
				  DataTextField="strBrand" DataValueField="BrandID" AutoPostBack="false" Width="90%">
			  </asp:DropDownList>			               
          </td>
       <td align="right" width="15%" >Period:</td>
       <td align="left" width="25%" nowrap="nowrap">
              <asp:DropDownList ID="ddlPeriod" runat="server" DataSourceID="sdsPeriod" 
                  DataTextField="strDisplay" DataValueField="strPeriod" Width="160px" 
							  AutoPostBack="false" CausesValidation="false">
              </asp:DropDownList>
          </td>
		</tr>
		<tr>	
			 <td align="right" nowrap>
              Brand Manager: </td>
          <td >
        	  <asp:DropDownList ID="ddlBM" runat="server" DataSourceID="sdsBM" 
							DataTextField="strUserName" DataValueField="strUserName" Width="90%">
						</asp:DropDownList>
          </td>						 			
			<td align="right">
				Display Field:</td>
			<td>
				<asp:DropDownList ID="ddlDisplayField" runat="server" Width="160px">
                    <asp:ListItem Value="dblOpening">Opening</asp:ListItem>
                    <asp:ListItem Value="dblQF">QF</asp:ListItem>
                    <asp:ListItem Value="dblBMA">BM Adjustment</asp:ListItem>
                    <asp:ListItem Value="dblActual">Actual</asp:ListItem>
                    <asp:ListItem Selected="True" Value="dblOrders">Orders</asp:ListItem>
                    <asp:ListItem Value="dblReceipts">Receipts</asp:ListItem>
                    <asp:ListItem Value="dblExports">Exports</asp:ListItem>
                    <asp:ListItem Value="dblDamages">Damages</asp:ListItem>
                    <asp:ListItem Value="dblRepack">Repack</asp:ListItem>
                    <asp:ListItem Value="dblClosing">Closing</asp:ListItem>
                    <asp:ListItem Value="dblMonths">Varience</asp:ListItem>
                </asp:DropDownList>
			 </td>
		</tr>
		<tr>	
			 <td align="right" >
                 &nbsp;</td>
          <td >
        	  &nbsp;</td>
			
			<td align="right">
				<asp:Button ID="btnView" runat="server" Text="View" />
			 </td>
			<td>
				<asp:Button ID="btnExport" runat="server" Enabled="False" Text="Export" />
			 </td>
		</tr>
		<tr>	
			 <td align="left" colspan="4">
              <asp:Label ID="lblReport" runat="server"></asp:Label>
			 </td>
		</tr>
		<tr>	
			 <td align="left" colspan="4">	              
			 			 <table style="border-style: solid; border-width: 2px; border-color: maroon; width:100%; vertical-align: middle;" cellspacing="0" cellpadding="0">
							 <tr>
								 <td><asp:GridView ID="gvReport" runat="server" 
								CellPadding="2" DataKeyNames="Code" Visible="False" BorderColor="Black" 
								BorderStyle="Solid" BorderWidth="1px">		
								<HeaderStyle CssClass="lightergrey" HorizontalAlign="Center" Wrap="True" />
								<AlternatingRowStyle CssClass="lightergrey" />
							</asp:GridView></td> 								 
							 </tr>																 
							</table>
			 </td>
		</tr>
		<tr>	
			 <td align="right" >
              &nbsp;</td>
          <td >
        	  &nbsp;</td>
			
			<td>
				&nbsp;</td>
			<td>
				&nbsp;</td>
		</tr>
	</table>
			
			  <asp:SqlDataSource ID="sdsBrand" runat="server" 
          ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
          SelectCommand="SELECT BrandID, strBrand FROM mstBrand WHERE blnActive = 1 ORDER BY strBrand">
      </asp:SqlDataSource>
      <asp:SqlDataSource ID="sdsPeriod" runat="server" 
          ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
          SelectCommand="SELECT DISTINCT strPeriod, intCalendarYear, strMonth, strMonth + ' ' + CAST(intCalendarYear AS varchar) AS strDisplay FROM mstPeriod WHERE strPeriod >= '200809' ORDER BY strPeriod">
      </asp:SqlDataSource>
      
	<asp:SqlDataSource ID="sdsReport" runat="server" 
		ConnectionString="<%$ ConnectionStrings:csStockControl %>"																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																			
		
		
		
    SelectCommand="SELECT '' AS '#', mstBrand.strBrand AS 'Brand', mstUser.strUserName AS 'Brand Manager', mstProduct.strLongProdDesc + ' x ' + CAST(mstProduct.intPack AS varchar(10)) AS Product, LEFT (mstProduct.strProdCode, 5) AS Code, 0.0 AS dblMC1, 0.0 AS dblMC2, 0.0 AS dblMC3, 0.0 AS dblMC4, 0.0 AS dblMC5, 0.0 AS dblMC6, 0.0 AS dblMC7, 0.0 AS dblMC8, 0.0 AS dblMC9, 0.0 AS dblMC10, 0.0 AS dblMC11, 0.0 AS dblMC12, 0.0 AS Total, 0.0 as Average FROM mstProduct INNER JOIN mstBrand INNER JOIN mstPrincipal ON mstBrand.refPrincipalID = mstPrincipal.PrincipalID ON mstProduct.refBrandID = mstBrand.BrandID INNER JOIN mstUser ON mstBrand.refBrandManagerID = mstUser.UserID WHERE (mstProduct.blnActive = 1) AND (mstBrand.blnActive = 1) AND (mstProduct.strProdCode LIKE N'%F%') GROUP BY mstBrand.strBrand, mstUser.strUserName, mstBrand.dblVariance, LEFT (mstProduct.strProdCode, 5), mstProduct.strLongProdDesc, mstProduct.intPack, mstProduct.strLongProdDesc + ' x ' + CAST(mstProduct.intPack AS varchar(10)), mstUser.strEmail ORDER BY 'Brand', mstProduct.strLongProdDesc" >

	</asp:SqlDataSource>
      
	<asp:SqlDataSource ID="sdsBM" runat="server" 
		ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
		
		SelectCommand="SELECT mstUser.UserID, mstUser.strUserName FROM mstUser INNER JOIN mstUserGroup ON mstUser.refUserGroupID = mstUserGroup.UserGroupID WHERE (mstUserGroup.strUserGroup LIKE N'%brand%') ORDER BY mstUser.strUserName">
	</asp:SqlDataSource>
</asp:Content>
