<%@ Page Language="VB" AutoEventWireup="false" CodeFile="EditConfigSettings.aspx.vb" Inherits="EditConfigSettings" ValidateRequest="false" %>
<%@ Register Src="../Controls/TopBanner.ascx" TagName="TopBanner" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Edit Config Settings</title>
</head>
<body>
    <form id="form1" runat="server">

            <asp:Table ID="Table1" runat="server" Width="100%" CellSpacing="0">
                <asp:TableRow BackColor="navy" >                     
                    <asp:TableCell>
                        <uc1:TopBanner ID="topMenuBanner" runat="server" />
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow >
                    <asp:TableCell>
                        <div>
                        &nbsp;Page:&nbsp;
                        <asp:TextBox ID="txtPage" runat="server" width="50"></asp:TextBox>
                        &nbsp;<asp:Button ID="btnPage" runat="server" Text="Go to Page" />
                        </div>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>
                        Filter on ConfigLocation:
                        <asp:TextBox ID="txtEnvironment" runat="server" width="100" Visible='false'></asp:TextBox>
                        <asp:DropDownList ID="ddlEnvironment" runat="server" 
                             DataTextField="configlocation"
                             DataSourceID="SqlDataSource2" DataValueField="configlocation"
                             />
                        &nbsp;Key:
                        <asp:TextBox ID="txtProvider" runat="server" width="100"></asp:TextBox>
                        &nbsp;XMLData:
                        <asp:TextBox ID="txtSetting" runat="server" Width="100"></asp:TextBox>
                        &nbsp;<asp:Button ID="btnFilter" runat="server" Text="Filter" />
                        <asp:Label ID="lblFilter" runat="server" Visible='false'></asp:Label>                        
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell HorizontalAlign="Center">
                        <div>
                            &nbsp;
                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                                CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
                                <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                                <Columns>
                                    <asp:CommandField  ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                                </Columns>
                                <RowStyle BackColor="#FFFBD6" ForeColor="#333333"  HorizontalAlign='Left'/>
                                <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                                <PagerSettings Position="TopAndBottom" />
                                <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Left" />
                                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" HorizontalAlign='Left'  />
                                <AlternatingRowStyle BackColor="White" />
                            </asp:GridView>
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Charter.Website.WS.CommerceEngineConnectionString %>"
                                DeleteCommand="DELETE FROM [ADMIN].[WebConfig] WHERE [ID] = @ID" 
                                InsertCommand="INSERT INTO [ADMIN].[WebConfig] ([ConfigLocation], [Key], [XMLData]) VALUES (@ConfigLocation, @Key, @XMLData)"
                                SelectCommand="SELECT * FROM [ADMIN].[WebConfig]" 
                                UpdateCommand="UPDATE [ADMIN].[WebConfig] SET [ConfigLocation] = @ConfigLocation, [Key] = @Key, [XMLData] = @XMLData WHERE [ID] = @ID">
                                <DeleteParameters>
                                    <asp:Parameter Name="ID" Type="Int32" />
                                </DeleteParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="ConfigLocation" Type="String" />
                                    <asp:Parameter Name="Key" Type="String" />
                                    <asp:Parameter Name="XMLData" Type="String" />
                                    <asp:Parameter Name="ID" Type="Int32" />
                                </UpdateParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="ConfigLocation" Type="String" />
                                    <asp:Parameter Name="Key" Type="String" />
                                    <asp:Parameter Name="XMLData" Type="String" />
                                </InsertParameters>
                            </asp:SqlDataSource>
                        </div>
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"  ConnectionString="<%$ ConnectionStrings:Charter.Website.WS.CommerceEngineConnectionString %>"
            SelectCommand="select '' as configlocation from admin.webconfig union select distinct configlocation FROM [ADMIN].[WebConfig] order by 1"
            DataSourceMode="DataReader"></asp:SqlDataSource>
    </form>
</body>
</html>
