<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin.Master" CodeBehind="MonthEnd.aspx.vb" Inherits="Superbowl.MonthEnd"  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">Month End Process</td>
    </tr>
    <tr>
        <td width="15%" align="right">&nbsp;</td>
        <td width="25%">&nbsp;</td>
        <td width="25%">&nbsp;</td>
        <td >&nbsp;</td>
    </tr>
    <tr>
        <td width="15%" align="right">Period:</td>
        <td width="25%">
          <asp:DropDownList ID="ddlPeriod" runat="server" DataSourceID="sdsPeriod" 
            DataTextField="refPeriod" DataValueField="refPeriod" Width="160px">
          </asp:DropDownList>
          
        </td>
        <td align="right" >
          <asp:Button ID="btnView" runat="server" Text="View" />
        </td>
        <td >
          <asp:Button ID="btnProcess" runat="server" Text="Process Month End" />
        </td>
    </tr>
    <tr>
        <td width="15%" align="right">&nbsp;</td>
        <td width="25%">&nbsp;</td>
        <td align="right" >
          &nbsp;</td>
        <td >files are available on &quot;\\Chandon\BFBE&quot;</td>
    </tr>
    <td align="left" colspan="4" style="border: 1px solid maroon">
			  <asp:GridView ID="gvZZ" runat="server" Width="100%" CellPadding="2" 
				  AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
				  DataSourceID="sdsZ" PageSize="32" HeaderStyle-CssClass="gvHeader">	  	
					<Columns>					  
						<asp:BoundField DataField="strDate" HeaderText="Date" 
              SortExpression="strDate" >
              <HeaderStyle Width="25px" Wrap="False" />
              <ItemStyle Wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="GSV" HeaderText="GSV" SortExpression="GSV" 
              DataFormatString="{0:#,##0.##}">
            <HeaderStyle Width="20%" />
            <ItemStyle HorizontalAlign="Right" />
            </asp:BoundField>
            <asp:BoundField DataField="9L" HeaderText="9L" SortExpression="9L" 
              DataFormatString="{0:#,##0.##}">
            <HeaderStyle Width="20%" />
            <ItemStyle HorizontalAlign="Right" />
            </asp:BoundField>
            <asp:BoundField DataField="Freestock" HeaderText="Freestock" 
              SortExpression="Freestock" DataFormatString="{0:#,##0.##}">
            <HeaderStyle Width="20%" />
            <ItemStyle HorizontalAlign="Right" />
            </asp:BoundField>
					</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:SqlDataSource ID="sdsZ" runat="server" 
            ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
            SelectCommand="SELECT strDate, ROUND(SUM(dblGSV), 4) AS GSV, ROUND(SUM(dbl9l), 4) AS [9L], ROUND(SUM(dbl9lFreeStock), 4) AS Freestock 
            FROM dwfSales INNER JOIN mstCustomer ON dwfSales.refCustomerNo = mstCustomer.strCustomerNo
            WHERE (refPeriod = @strPeriod) AND ((mstCustomer.blnPromotionalAccounts = 0) OR (dwfSales.dbl9lFreeStock = 0)) 
            GROUP BY strDate 
          UNION SELECT '' AS strDate, ROUND(SUM(dblGSV), 4) AS GSV, ROUND(SUM(dbl9l), 4) AS [9L], ROUND(SUM(dbl9lFreeStock), 4) AS Freestock 
            FROM dwfSales AS dwfSales_1 INNER JOIN mstCustomer AS mstCustomer_1 ON dwfSales_1.refCustomerNo = mstCustomer_1.strCustomerNo
            WHERE (refPeriod = @strPeriod) AND ((mstCustomer_1.blnPromotionalAccounts = 0) OR (dwfSales_1.dbl9lFreeStock = 0)) 
            ORDER BY strDate DESC">
            <SelectParameters>
              <asp:ControlParameter ControlID="ddlPeriod" DefaultValue="200901" 
                Name="strPeriod" PropertyName="SelectedValue" />
            </SelectParameters>
          </asp:SqlDataSource>
		      
    </td>
    <tr>
        <td width="15%" align="right">&nbsp;</td>
        <td width="25%">&nbsp;</td>
        <td align="right" >&nbsp;</td>
        <td >&nbsp;</td>
    </tr>
    <tr>
        <td width="15%" align="right">&nbsp;</td>
        <td width="25%">&nbsp;</td>
        <td align="right" >&nbsp;</td>
        <td >&nbsp;</td>
    </tr>
    </table>
  <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
    
<asp:SqlDataSource ID="sdsPeriod" runat="server" 
    ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
    SelectCommand="SELECT DISTINCT [refPeriod] FROM [dwfSales] WHERE ([refPeriod] &gt;= @refPeriod) ORDER BY [refPeriod] DESC">
    <SelectParameters>
      <asp:Parameter DefaultValue="200901" Name="refPeriod" Type="String" />
    </SelectParameters>
  </asp:SqlDataSource>
</asp:Content>
