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

<!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>Jointure par fonction auxiliare</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id_compte"
            DataSourceID="ds_compte">
            <Columns>
                <asp:CommandField ShowEditButton="True" CancelText="Annuler" EditText="Modifier" UpdateText="Mettre &#224; jour" />
                <asp:BoundField DataField="titulaire" HeaderText="Titulaire" SortExpression="titulaire" />
                <asp:TemplateField HeaderText="Agence" SortExpression="id_agence">
                    <EditItemTemplate>
                        <asp:DropDownList ID="lst_edit_agence" runat="server"
                        DataSourceID="ds_agence"
                        DataTextField="nom_agence"
                        DataValueField="id_agence"
                        selectedvalue='<%# Bind("id_agence") %>'
                        ></asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" 
                        Text='<%# 
                        getNomAgence(
                            (int) Eval("id_agence")
                            ) %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <br />
        <asp:SqlDataSource ID="ds_compte" runat="server" ConnectionString="<%$ ConnectionStrings:bancaConnectionString %>"
            DeleteCommand="DELETE FROM [compte] WHERE [id_compte] = @id_compte" InsertCommand="INSERT INTO [compte] ([titulaire], [solde], [id_agence]) VALUES (@titulaire, @solde, @id_agence)"
            SelectCommand="SELECT * FROM [compte]" UpdateCommand="UPDATE [compte] SET [titulaire] = @titulaire, [solde] = @solde, [id_agence] = @id_agence WHERE [id_compte] = @id_compte">
            <DeleteParameters>
                <asp:Parameter Name="id_compte" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="titulaire" Type="String" />
                <asp:Parameter Name="solde" Type="Decimal" />
                <asp:Parameter Name="id_agence" Type="Int32" />
                <asp:Parameter Name="id_compte" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="titulaire" Type="String" />
                <asp:Parameter Name="solde" Type="Decimal" />
                <asp:Parameter Name="id_agence" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
        &nbsp;</div>
        <asp:SqlDataSource ID="ds_agence" runat="server" ConnectionString="<%$ ConnectionStrings:bancaConnectionString %>"
            SelectCommand="SELECT * FROM [agence]"></asp:SqlDataSource>
    </form>
</body>
</html>
