<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultHashTable.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div>
      <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        DeleteCommand="DELETE FROM [Customers] WHERE [CustomerID] = @CustomerID" InsertCommand="INSERT INTO [Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (@CustomerID, @CompanyName, @ContactName, @ContactTitle, @Address, @City, @Region, @PostalCode, @Country, @Phone, @Fax)"
        SelectCommand="SELECT * FROM [Customers]" UpdateCommand="UPDATE [Customers] SET [CustomerID]=@CustomerID, [CompanyName] = @CompanyName, [ContactName] = @ContactName, [ContactTitle] = @ContactTitle, [Address] = @Address, [City] = @City, [Region] = @Region, [PostalCode] = @PostalCode, [Country] = @Country, [Phone] = @Phone, [Fax] = @Fax WHERE [CustomerID] = @CustomerID">
        <DeleteParameters>
          <asp:Parameter Name="CustomerID" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
          <asp:Parameter Name="CompanyName" Type="String" />
          <asp:Parameter Name="ContactName" Type="String" />
          <asp:Parameter Name="ContactTitle" Type="String" />
          <asp:Parameter Name="Address" Type="String" />
          <asp:Parameter Name="City" Type="String" />
          <asp:Parameter Name="Region" Type="String" />
          <asp:Parameter Name="PostalCode" Type="String" />
          <asp:Parameter Name="Country" Type="String" />
          <asp:Parameter Name="Phone" Type="String" />
          <asp:Parameter Name="Fax" Type="String" />
          <asp:Parameter Name="CustomerID" Type="String" />
        </UpdateParameters>
        <InsertParameters>
          <asp:Parameter Name="CustomerID" Type="String" />
          <asp:Parameter Name="CompanyName" Type="String" />
          <asp:Parameter Name="ContactName" Type="String" />
          <asp:Parameter Name="ContactTitle" Type="String" />
          <asp:Parameter Name="Address" Type="String" />
          <asp:Parameter Name="City" Type="String" />
          <asp:Parameter Name="Region" Type="String" />
          <asp:Parameter Name="PostalCode" Type="String" />
          <asp:Parameter Name="Country" Type="String" />
          <asp:Parameter Name="Phone" Type="String" />
          <asp:Parameter Name="Fax" Type="String" />
        </InsertParameters>
      </asp:SqlDataSource>
    </div>
    <asp:UpdatePanel ID="panel" runat="server">
      <ContentTemplate>
        <telerik:RadGrid AllowMultiRowSelection="true" AllowMultiRowEdit="true" ID="RadGrid1"
          AllowAutomaticDeletes="true" OnItemCommand="RadGrid1_ItemCommand" OnDataBound="RadGrid1_DataBound"
          runat="server" DataSourceID="SqlDataSource1" GridLines="None" OnItemDeleted="RadGrid1_ItemDeleted">
          <MasterTableView AutoGenerateColumns="False" CellSpacing="-1" AllowPaging="true"
            AllowAutomaticDeletes="true" HierarchyLoadMode="ServerOnDemand" CommandItemDisplay="top"
            EditMode="EditForms" Name="Customers" AllowAutomaticUpdates="true" DataKeyNames="CustomerID"
            DataSourceID="SqlDataSource1">
            <Columns>
              <telerik:GridButtonColumn CommandName="Delete" ButtonType="imageButton">
              </telerik:GridButtonColumn>
              <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID"
                UniqueName="CustomerID" Visible="false">
              </telerik:GridBoundColumn>
              <telerik:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"
                UniqueName="CompanyName">
              </telerik:GridBoundColumn>
              <telerik:GridBoundColumn DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName"
                UniqueName="ContactName">
              </telerik:GridBoundColumn>
              <telerik:GridBoundColumn DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle"
                UniqueName="ContactTitle">
              </telerik:GridBoundColumn>
              <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City"
                UniqueName="City">
              </telerik:GridBoundColumn>
              <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country"
                UniqueName="Country">
              </telerik:GridBoundColumn>
            </Columns>
            <DetailTables>
              <telerik:GridTableView Name="Orders" DataSourceID="SqlDataSource2" EditMode="EditForms"
                AllowAutomaticDeletes="true" AutoGenerateColumns="false" CommandItemDisplay="top"
                DataKeyNames="OrderID">
                <ParentTableRelation>
                  <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
                </ParentTableRelation>
                <Columns>
                  <telerik:GridButtonColumn CommandName="Delete" ButtonType="imageButton">
                  </telerik:GridButtonColumn>
                  <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" HeaderText="OrderID"
                    ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" SortExpression="ShipCity"
                    UniqueName="ShipCity">
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="ShipCountry" SortExpression="ShipCountry"
                    UniqueName="ShipCountry">
                  </telerik:GridBoundColumn>
                </Columns>
                <DetailTables>
                  <telerik:GridTableView Name="OrderDetails" DataSourceID="SqlDataSource3" AutoGenerateColumns="false"
                    AllowAutomaticDeletes="true" DataKeyNames="OrderID,ProductID">
                    <ParentTableRelation>
                      <telerik:GridRelationFields DetailKeyField="OrderID" MasterKeyField="OrderID" />
                    </ParentTableRelation>
                    <Columns>
                      <telerik:GridButtonColumn CommandName="Delete" ButtonType="imageButton">
                      </telerik:GridButtonColumn>
                      <telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton"
                        DataField="OrderID" UniqueName="OrderID">
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn SortExpression="ProductID" HeaderText="ProductID" HeaderButtonType="TextButton"
                        DataField="ProductID" UniqueName="ProductID">
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn SortExpression="UnitPrice" HeaderText="Unit Price" HeaderButtonType="TextButton"
                        DataField="UnitPrice" UniqueName="UnitPrice">
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn SortExpression="Quantity" HeaderText="Quantity" HeaderButtonType="TextButton"
                        DataField="Quantity" UniqueName="Quantity">
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn SortExpression="Discount" HeaderText="Discount" HeaderButtonType="TextButton"
                        DataField="Discount" UniqueName="Discount">
                      </telerik:GridBoundColumn>
                    </Columns>
                  </telerik:GridTableView>
                </DetailTables>
              </telerik:GridTableView>
            </DetailTables>
          </MasterTableView>
          <ClientSettings Selecting-AllowRowSelect="true">
          </ClientSettings>
        </telerik:RadGrid>
      </ContentTemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
      SelectCommand="SELECT * FROM [Orders] Where CustomerID = @CustomerID" DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"
      InsertCommand="INSERT INTO [Orders] ([CustomerID], [EmployeeID], [OrderDate], [RequiredDate], [ShippedDate], [ShipVia], [Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode], [ShipCountry]) VALUES (@CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShippedDate, @ShipVia, @Freight, @ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry)"
      UpdateCommand="UPDATE [Orders] SET [CustomerID] = @CustomerID, [EmployeeID] = @EmployeeID, [OrderDate] = @OrderDate, [RequiredDate] = @RequiredDate, [ShippedDate] = @ShippedDate, [ShipVia] = @ShipVia, [Freight] = @Freight, [ShipName] = @ShipName, [ShipAddress] = @ShipAddress, [ShipCity] = @ShipCity, [ShipRegion] = @ShipRegion, [ShipPostalCode] = @ShipPostalCode, [ShipCountry] = @ShipCountry WHERE [OrderID] = @OrderID">
      <DeleteParameters>
        <asp:Parameter Name="OrderID" Type="Int32" />
      </DeleteParameters>
      <SelectParameters>
        <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" />
      </SelectParameters>
      <UpdateParameters>
        <asp:Parameter Name="CustomerID" Type="String" />
        <asp:Parameter Name="EmployeeID" Type="Int32" />
        <asp:Parameter DbType="Date" Name="OrderDate" />
        <asp:Parameter DbType="Date" Name="RequiredDate" />
        <asp:Parameter DbType="Date" Name="ShippedDate" />
        <asp:Parameter Name="ShipVia" Type="Int32" />
        <asp:Parameter Name="Freight" Type="Decimal" />
        <asp:Parameter Name="ShipName" Type="String" />
        <asp:Parameter Name="ShipAddress" Type="String" />
        <asp:Parameter Name="ShipCity" Type="String" />
        <asp:Parameter Name="ShipRegion" Type="String" />
        <asp:Parameter Name="ShipPostalCode" Type="String" />
        <asp:Parameter Name="ShipCountry" Type="String" />
        <asp:Parameter Name="OrderID" Type="Int32" />
      </UpdateParameters>
      <InsertParameters>
        <asp:Parameter Name="CustomerID" Type="String" />
        <asp:Parameter Name="EmployeeID" Type="Int32" />
        <asp:Parameter DbType="Date" Name="OrderDate" />
        <asp:Parameter DbType="Date" Name="RequiredDate" />
        <asp:Parameter DbType="Date" Name="ShippedDate" />
        <asp:Parameter Name="ShipVia" Type="Int32" />
        <asp:Parameter Name="Freight" Type="Decimal" />
        <asp:Parameter Name="ShipName" Type="String" />
        <asp:Parameter Name="ShipAddress" Type="String" />
        <asp:Parameter Name="ShipCity" Type="String" />
        <asp:Parameter Name="ShipRegion" Type="String" />
        <asp:Parameter Name="ShipPostalCode" Type="String" />
        <asp:Parameter Name="ShipCountry" Type="String" />
      </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
      SelectCommand="SELECT * FROM [Order Details] Where OrderID = @OrderID" DeleteCommand="DELETE FROM [Order Details] WHERE [OrderID] = @OrderID AND [ProductID] = @ProductID"
      InsertCommand="INSERT INTO [Order Details] ([OrderID], [ProductID], [UnitPrice], [Quantity], [Discount]) VALUES (@OrderID, @ProductID, @UnitPrice, @Quantity, @Discount)"
      UpdateCommand="UPDATE [Order Details] SET [UnitPrice] = @UnitPrice, [Quantity] = @Quantity, [Discount] = @Discount WHERE [OrderID] = @OrderID AND [ProductID] = @ProductID">
      <SelectParameters>
        <asp:SessionParameter Name="OrderID" SessionField="OrderID" />
      </SelectParameters>
      <DeleteParameters>
        <asp:Parameter Name="OrderID" Type="Int32" />
        <asp:Parameter Name="ProductID" Type="Int32" />
      </DeleteParameters>
      <UpdateParameters>
        <asp:Parameter Name="UnitPrice" Type="Decimal" />
        <asp:Parameter Name="Quantity" Type="Int16" />
        <asp:Parameter Name="Discount" Type="Single" />
        <asp:Parameter Name="OrderID" Type="Int32" />
        <asp:Parameter Name="ProductID" Type="Int32" />
      </UpdateParameters>
      <InsertParameters>
        <asp:Parameter Name="OrderID" Type="Int32" />
        <asp:Parameter Name="ProductID" Type="Int32" />
        <asp:Parameter Name="UnitPrice" Type="Decimal" />
        <asp:Parameter Name="Quantity" Type="Int16" />
        <asp:Parameter Name="Discount" Type="Single" />
      </InsertParameters>
    </asp:SqlDataSource>
  </form>
</body>
</html>
