<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin.Master" CodeBehind="AuditLog.aspx.vb" Inherits="Superbowl.AuditLog" 
    title="Untitled Page" EnableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<link href='calendar_control/scripts/CalendarControl.css' rel='stylesheet' type='text/css' />
	<script src='calendar_control/scripts/CalendarControl.js' language='javascript'></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
  <table width="100%" cellpadding="2">
    <tr>
        <td align="center" class="headings" colspan="4">Audit Change Log</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td width="30%">&nbsp;</td>
    </tr>
    <tr>		 
        <td align="right">Entity:</td>
        <td align="left">
          <asp:DropDownList ID="ddlEntity" runat="server" DataSourceID="sdsEntity" 
            DataTextField="strEntity" DataValueField="strEntity" Width="200px">
          </asp:DropDownList></td>		 
        <td align="right">Start Date:</td>
        <td align="left"><asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox></td>
                
    </tr>	
    <tr>
        <td align="right">Entity ID:</td>
        <td  align="left">
          <asp:DropDownList ID="ddlEntityID" runat="server" DataSourceID="sdsEntityID" 
            DataTextField="ID" DataValueField="ID" Width="200px">
          </asp:DropDownList></td> 
        <td align="right">End Date:</td>
        <td  align="left"><asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox></td>       
    </tr>	
    <tr>		 
        <td align="right">User:</td>
        <td  align="left">
          <asp:DropDownList ID="ddlUser" runat="server" DataSourceID="sdsUser" 
            DataTextField="strLastUser" DataValueField="strLastUser" Width="200px">
          </asp:DropDownList></td>
        <td align="right"><asp:Button ID="btnSearch" runat="server" Text="Search" /></td>
        <td  align="left"><asp:Button ID="btnExport" runat="server" Text="Export" /></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="gvLog" runat="server" Width="100%" CellPadding="2" 
				  AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
				  DataSourceID="sdsLog" PageSize="25" HeaderStyle-CssClass="gvHeader" 
				  DataKeyNames="dtStamp">	  	
					<Columns>
						
            <asp:BoundField DataField="refStamp" HeaderText="Date Time" 
              SortExpression="refStamp"  ItemStyle-Wrap="False">
            <ItemStyle HorizontalAlign="Left" Wrap="False" Width="5%" />
            </asp:BoundField>
            <asp:BoundField DataField="strEntity" HeaderText="Entity" 
              SortExpression="strEntity"  ItemStyle-Wrap="False">
            <ItemStyle HorizontalAlign="Left" Wrap="False" Width="10%" />
            </asp:BoundField>
            <asp:BoundField DataField="ID" HeaderText="Entity ID" SortExpression="ID" >
            <ItemStyle Width="5%" />
            </asp:BoundField>
            <asp:BoundField DataField="Field" HeaderText="Field" 
              SortExpression="Field" >
            <ItemStyle HorizontalAlign="Left" Width="20%" Wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="Old Value" HeaderText="Old Value" 
              SortExpression="Old Value" ItemStyle-HorizontalAlign="Center" >
            <ItemStyle HorizontalAlign="Left" Width="20%" />
            </asp:BoundField>
             <asp:BoundField DataField="New Value" HeaderText="New Value" 
               SortExpression="New Value" >						
					  <ItemStyle HorizontalAlign="Left" Width="20%" />
            </asp:BoundField>
						
					  <asp:BoundField DataField="strLastUser" HeaderText="Last User" 
              SortExpression="strLastUser" >
						
					  <ItemStyle HorizontalAlign="Left" Width="10%" />
            </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:SqlDataSource ID="sdsLog" runat="server" 
            ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
            
            SelectCommand="SELECT dtStamp, refStamp, strEntity, ID, strField AS Field, valueOld AS [Old Value], valueNew AS [New Value], strLastUser FROM logAudit ORDER BY refStamp DESC, dtStamp">
          </asp:SqlDataSource>
			  <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="sdsLog" AutoGenerateColumns="False" DataKeyNames="dtStamp">
				   <Columns>
						
					   <asp:BoundField DataField="dtStamp" HeaderText="dtStamp" ReadOnly="True" 
               SortExpression="dtStamp" />
             <asp:BoundField DataField="refStamp" HeaderText="refStamp" 
               SortExpression="refStamp" />
             <asp:BoundField DataField="strEntity" HeaderText="Entity" 
               SortExpression="strEntity" />
             <asp:BoundField DataField="ID" HeaderText="ID" 
               SortExpression="ID" />
             <asp:BoundField DataField="Field" HeaderText="Field" 
               SortExpression="Field" />
             <asp:BoundField DataField="Old Value" HeaderText="Old Value" 
               SortExpression="Old Value" ItemStyle-HorizontalAlign="Center" />
             <asp:BoundField DataField="New Value" HeaderText="New Value" 
               SortExpression="New Value" />
						
					   <asp:BoundField DataField="strLastUser" HeaderText="Last User" 
               SortExpression="strLastUser" />
						
					</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>
</table>

<asp:SqlDataSource ID="sdsEntity" runat="server" 
  ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
  SelectCommand="SELECT '- All -' as strEntity UNION SELECT DISTINCT strEntity FROM logAudit ORDER BY strEntity">
</asp:SqlDataSource>

<asp:SqlDataSource ID="sdsEntityID" runat="server" 
  ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
  SelectCommand="SELECT '- All -' as ID UNION SELECT DISTINCT ID FROM logAudit ORDER BY ID">
</asp:SqlDataSource>

<asp:SqlDataSource ID="sdsUser" runat="server" 
  ConnectionString="<%$ ConnectionStrings:csStockControl %>" 
  SelectCommand="SELECT '- All -' as strLastUser UNION SELECT DISTINCT strLastUser FROM logAudit ORDER BY strLastUser">
</asp:SqlDataSource>

</asp:Content>
