IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 .NET Discussion :

Copie de ligne d'un gridview à l'autre et image


Sujet :

.NET

  1. #1
    Membre du Club
    Inscrit en
    Avril 2004
    Messages
    78
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : Avril 2004
    Messages : 78
    Points : 56
    Points
    56
    Par défaut Copie de ligne d'un gridview à l'autre et image
    Bonjour,

    J'ai un petit problème que je n'arrive pas à comprendre. Voilà, je développe une page dans laquelle, lorsque je sélectionne un élément dans un gridview, celui-ci est dupliqué dans un autre Gridview.

    Le code que j'utilise fonctionne bien. En effet, j'ai un lien "Sélectionner" (le link button natif du gridview), et lorsque je clique dessus, je bind le gridview
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    protected void GridViewListePrestations_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewListePrestations.DataBind();
        }
    Cela me permet de travailler avec l'évènement
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    protected void GridViewListePrestations_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    }
    Jusque là tout va bien, je ne sais pas si c'est la bonne méthode, mais elle a le mérite de fonctionner...Enfin presque

    En effet, je me suis mis en tête de remplacer le "link button" du gridview par un "image button" (c'est tellement plus fun ) mais là c'est la cata car du coup, l'évènement RowDataBound est lancé deux fois et du coup mes lignes sont copiées en double dans l'autre gridview et ça c'est moche.

    Quelqu'un aurait-il une idée ou pourrait peut-être m'expliquer pourquoi le fait de mettre une image rebind le gridview? C'est vraiment galère et je ne trouve pas de solution.

    Merci d'avance à ceux qui voudront bien m'aider.

    Fab

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Février 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : Royaume-Uni

    Informations forums :
    Inscription : Février 2007
    Messages : 62
    Points : 79
    Points
    79
    Par défaut
    Tu veux pas poster ton code ?

  3. #3
    Membre du Club
    Inscrit en
    Avril 2004
    Messages
    78
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : Avril 2004
    Messages : 78
    Points : 56
    Points
    56
    Par défaut
    Voici le code html

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
     
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ActionsAnimal.aspx.cs" Inherits="Ecrans_Gestion_de_la_boutique_ActionsAnimal" %>
     
    <!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>Page sans titre</title>
        <style type="text/css">
            .style1
            {
                width: 485px;
            }
            .style2
            {
                text-align: center;
            }
            .style3
            {
                width: 485px;
                text-align: center;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ObjectDataSource 
                ID="ODS_ANIMAL" 
                runat="server" 
                SelectMethod="GetAnimalByIDAnimal" 
                TypeName="AnimalBLL" 
                UpdateMethod="UpdateAnimal" 
                DeleteMethod="DeleteAnimal" 
                InsertMethod="InsertAnimal">
                <DeleteParameters>
                    <asp:Parameter Name="ID_ANIMAL" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="ID_CLIENT" Type="Int32" />
                    <asp:Parameter Name="ID_TYPE_ANIMAL" Type="Int32" />
                    <asp:Parameter Name="ID_RACE" Type="Int32" />
                    <asp:Parameter Name="ID_TAILLE" Type="Int32" />
                    <asp:Parameter Name="ID_LONGUEUR" Type="Int32" />
                    <asp:Parameter Name="ID_COULEUR" Type="Int32" />
                    <asp:Parameter Name="Nom" Type="String" />
                    <asp:Parameter Name="Sexe" Type="String" />
                    <asp:Parameter Name="Date_Naissance" Type="DateTime" />
                    <asp:Parameter Name="Type_Identification" Type="String" />
                    <asp:Parameter Name="Identification" Type="String" />
                    <asp:Parameter Name="Commentaire" Type="String" />
                    <asp:Parameter Name="ID_ANIMAL" Type="Int32" />
                </UpdateParameters>
                <SelectParameters>
                    <asp:QueryStringParameter 
                        Name="_IDAnimal" 
                        QueryStringField="ID" 
                        Type="Int32" />
                </SelectParameters>
                <InsertParameters>
                    <asp:Parameter Name="ID_CLIENT" Type="Int32" />
                    <asp:Parameter Name="ID_TYPE_ANIMAL" Type="Int32" />
                    <asp:Parameter Name="ID_RACE" Type="Int32" />
                    <asp:Parameter Name="ID_TAILLE" Type="Int32" />
                    <asp:Parameter Name="ID_LONGUEUR" Type="Int32" />
                    <asp:Parameter Name="ID_COULEUR" Type="Int32" />
                    <asp:Parameter Name="Nom" Type="String" />
                    <asp:Parameter Name="Sexe" Type="String" />
                    <asp:Parameter Name="Date_Naissance" Type="DateTime" />
                    <asp:Parameter Name="Type_Identification" Type="String" />
                    <asp:Parameter Name="Identification" Type="String" />
                    <asp:Parameter Name="Commentaire" Type="String" />
                </InsertParameters>
            </asp:ObjectDataSource>
     
                    <asp:FormView 
                        ID="FormViewAnimal" 
                        runat="server" 
                        DataKeyNames="ID_ANIMAL,ID_LONGUEUR,ID_TAILLE" 
                        DataSourceID="ODS_ANIMAL" 
                        ondatabound="FormViewAnimal_DataBound">
                        <EditItemTemplate>
                            Nom:
                            <asp:TextBox ID="NomTextBox" runat="server" Text='<%# Bind("Nom") %>' />
                            <br />
                            Sexe:
                            <asp:TextBox ID="SexeTextBox" runat="server" Text='<%# Bind("Sexe") %>' />
                            <br />
                            Type_Identification:
                            <asp:TextBox ID="Type_IdentificationTextBox" runat="server" 
                                Text='<%# Bind("Type_Identification") %>' />
                            <br />
                            Identification:
                            <asp:TextBox ID="IdentificationTextBox" runat="server" 
                                Text='<%# Bind("Identification") %>' />
                            <br />
                            Commentaire:
                            <asp:TextBox ID="CommentaireTextBox" runat="server" 
                                Text='<%# Bind("Commentaire") %>' />
                            <br />
                            MaitreAnimal:
                            <asp:TextBox ID="MaitreAnimalTextBox" runat="server" 
                                Text='<%# Bind("MaitreAnimal") %>' />
                            <br />
                            TypeAnimal:
                            <asp:TextBox ID="TypeAnimalTextBox" runat="server" 
                                Text='<%# Bind("TypeAnimal") %>' />
                            <br />
                            RaceAnimal:
                            <asp:TextBox ID="RaceAnimalTextBox" runat="server" 
                                Text='<%# Bind("RaceAnimal") %>' />
                            <br />
                            TailleAnimal:
                            <asp:TextBox ID="TailleAnimalTextBox" runat="server" 
                                Text='<%# Bind("TailleAnimal") %>' />
                            <br />
                            LongueurPoilAnimal:
                            <asp:TextBox ID="LongueurPoilAnimalTextBox" runat="server" 
                                Text='<%# Bind("LongueurPoilAnimal") %>' />
                            <br />
                            CouleurAnimal:
                            <asp:TextBox ID="CouleurAnimalTextBox" runat="server" 
                                Text='<%# Bind("CouleurAnimal") %>' />
                            <br />
                            Date_Naissance:
                            <asp:TextBox ID="Date_NaissanceTextBox" runat="server" 
                                Text='<%# Bind("Date_naissance") %>' />
                            <br />
                            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                                CommandName="Update" Text="Mettre à jour" />
                            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                                CausesValidation="False" CommandName="Cancel" Text="Annuler" />
                        </EditItemTemplate>
                        <ItemTemplate>
                        <div id="enteteFw">
                            Maitre:
                            <asp:Label ID="MaitreAnimalLabel" runat="server" Text='<%# Bind("MaitreAnimal") %>' />
                            <br />
                            Animal:
                            <asp:Label ID="NomLabel" runat="server" Text='<%# Bind("Nom") %>' />
                            (
                            <asp:Label ID="SexeLabel" runat="server" Text='<%# Bind("Sexe") %>' />
                            )
     
                        </div>
     
                            Type_Identification:
                            <asp:Label ID="Type_IdentificationLabel" runat="server" 
                                Text='<%# Bind("Type_Identification") %>' />
                            <br />
                            TypeAnimal:
                            <asp:Label ID="TypeAnimalLabel" runat="server" 
                                Text='<%# Bind("TypeAnimal") %>' />
                            <br />
                            RaceAnimal:
                            <asp:Label ID="RaceAnimalLabel" runat="server" 
                                Text='<%# Bind("RaceAnimal") %>' />
                            <br />
                            TailleAnimal:
                            <asp:Label ID="TailleAnimalLabel" runat="server" 
                                Text='<%# Bind("TailleAnimal") %>' />
                            <br />
                            LongueurPoilAnimal:
                            <asp:Label ID="LongueurPoilAnimalLabel" runat="server" 
                                Text='<%# Bind("LongueurPoilAnimal") %>' />
                            <br />
     
                            <br />
                            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                                CommandName="Edit" Text="Modifier" />
                         </ItemTemplate>
                    </asp:FormView>
            <br />
            <br />
        </div>
     
        <asp:ObjectDataSource 
            ID="ODS_ListeTarifsPrestations" 
            runat="server" 
            DeleteMethod="DeleteTarif" 
            InsertMethod="InsertTarif" 
            SelectMethod="GetTarifByTailleAndLongueur" 
            TypeName="TarifBLL" 
            UpdateMethod="UpdateTarif">
            <DeleteParameters>
                <asp:Parameter Name="ID_TARIF" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Code_Tarif" Type="String" />
                <asp:Parameter Name="ID_PRESTATION" Type="Int32" />
                <asp:Parameter Name="Prestation" Type="String" />
                <asp:Parameter Name="ID_Taille" Type="Int32" />
                <asp:Parameter Name="ID_LONGUEUR" Type="Int32" />
                <asp:Parameter Name="Temps_Minute" Type="Int32" />
                <asp:Parameter Name="Tarif" Type="double" />
                <asp:Parameter Name="TVA" Type="Double" />
                <asp:Parameter Name="ID_TARIF" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:Parameter Name="_IDLongeur" Type="Int32" />
                <asp:Parameter Name="_IDTaille" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="Code_Tarif" Type="String" />
                <asp:Parameter Name="ID_PRESTATION" Type="Int32" />
                <asp:Parameter Name="Prestation" Type="String" />
                <asp:Parameter Name="ID_Taille" Type="Int32" />
                <asp:Parameter Name="ID_LONGUEUR" Type="Int32" />
                <asp:Parameter Name="Temps_Minute" Type="Int32" />
                <asp:Parameter Name="Tarif" Type="double" />
                <asp:Parameter Name="TVA" Type="Double" />
            </InsertParameters>
        </asp:ObjectDataSource>
     
        <asp:ObjectDataSource 
            ID="ODS_PrestationsRDV" 
            runat="server" 
            DeleteMethod="DeleteVenteDetail" 
            InsertMethod="InsertVenteDetail" 
            SelectMethod="GetVenteDetailByIDVente" 
            TypeName="VenteDetailBLL" 
            UpdateMethod="UpdateVenteDetail" >
            <DeleteParameters>
                <asp:Parameter Name="ID_VENTEDETAIL" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="_IDVente" Type="Int32" />
                <asp:Parameter Name="_IDArticle" Type="Int32" />
                <asp:Parameter Name="_IDPrestation" Type="Int32" />
                <asp:Parameter Name="_CodeItem" Type="String" />
                <asp:Parameter Name="_Element" Type="String" />
                <asp:Parameter Name="_PrixUnitaireHT" Type="double" />
                <asp:Parameter Name="_TauxTVA" Type="Double" />
                <asp:Parameter Name="_PrixUnitaireTTC" Type="double" />
                <asp:Parameter Name="_Quantite" Type="Int32" />
                <asp:Parameter Name="_Remise" Type="Double" />
                <asp:Parameter Name="_TotalArticle" Type="double" />
                <asp:Parameter Name="_IDVenteDetail" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="DetailsViewVente" Name="_IDVente" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="_IDVente" Type="Int32" />
                <asp:Parameter Name="_IDArticle" Type="Int32" />
                <asp:Parameter Name="_IDPrestation" Type="Int32" />
                <asp:Parameter Name="_CodeItem" Type="String" />
                <asp:Parameter Name="_Element" Type="String" />
                <asp:Parameter Name="_PrixUnitaireHT" Type="double" />
                <asp:Parameter Name="_TauxTVA" Type="Double" />
                <asp:Parameter Name="_PrixUnitaireTTC" Type="double" />
                <asp:Parameter Name="_Quantite" Type="Int32" />
                <asp:Parameter Name="_Remise" Type="Double" />
                <asp:Parameter Name="_TotalArticle" Type="double" />
            </InsertParameters>
        </asp:ObjectDataSource>
     
        <asp:ObjectDataSource ID="ODS_VenteData" runat="server" 
            DeleteMethod="DeleteVente" InsertMethod="InsertVenteReturnIDVente" 
            SelectMethod="GetVenteByIDVENTE" 
            TypeName="VenteBLL" UpdateMethod="UpdateVente" 
            >
            <DeleteParameters>
                <asp:Parameter Name="_IDVente" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="_IDClient" Type="Int32" />
                <asp:Parameter Name="_IDEmploye" Type="Int32" />
                <asp:Parameter Name="_DateVente" Type="DateTime" />
                <asp:Parameter Name="_TotalVenteHT" Type="Double" />
                <asp:Parameter Name="_TotalVenteTTC" Type="Double" />
                <asp:Parameter Name="_IDVente" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:Parameter Name="_IDVente" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="_IDClient" Type="Int32" />
                <asp:Parameter Name="_IDEmploye" Type="Int32" />
                <asp:Parameter Name="_DateVente" Type="DateTime" />
                <asp:Parameter Name="_TotalVenteHT" Type="Double" />
                <asp:Parameter Name="_TotalVenteTTC" Type="Double" />
            </InsertParameters>
        </asp:ObjectDataSource>
     
        <table>
            <tr>
                <td class="style1">
     
                    &nbsp;</td>
                <td>
                    <asp:DetailsView ID="DetailsViewVente" runat="server" AutoGenerateRows="False" 
                        DataKeyNames="ID_VENTE" DataSourceID="ODS_VenteData">
                        <Fields>
                            <asp:BoundField DataField="Client" HeaderText="Client" 
                                SortExpression="Client" >
                                <HeaderStyle Width="50px" />
                                <ItemStyle Width="100px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Employe" HeaderText="Employé" 
                                SortExpression="Employe" />
                            <asp:BoundField DataField="Date_Vente" HeaderText="Date de la vente" 
                                SortExpression="Date_Vente"></asp:BoundField>
                            <asp:BoundField DataField="Total_Vente_HT" HeaderText="Total HT" 
                                SortExpression="Total_Vente_HT" DataFormatString="{0:c}"/>
                            <asp:BoundField DataField="Total_Vente_TTC" HeaderText="Total TTC" 
                                SortExpression="Total_Vente_TTC" DataFormatString="{0:c}">
                            </asp:BoundField>
                        </Fields>
                    </asp:DetailsView>
                </td>
            </tr>
            <tr>
                <td class="style1">
     
                    <asp:GridView 
                        ID="GridViewListePrestations" 
                        runat="server" 
                        DataSourceID="ODS_ListeTarifsPrestations" 
                        AutoGenerateColumns="False" 
                        DataKeyNames="ID_TARIF" 
                        onrowdatabound="GridViewListePrestations_RowDataBound" 
                        onselectedindexchanged="GridViewListePrestations_SelectedIndexChanged">
                        <HeaderStyle CssClass="HeaderStyle" />
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" 
                                SelectImageUrl="~/App_Themes/Vert/Images/Validate.gif" />
                            <asp:BoundField DataField="Code_Tarif" HeaderText="Code_Tarif" 
                                SortExpression="Code_Tarif" />
                            <asp:BoundField DataField="Prestation" HeaderText="Prestation" ReadOnly="True" 
                                SortExpression="Prestation" />
                            <asp:BoundField DataField="Taille" HeaderText="Taille" ReadOnly="True" 
                                SortExpression="Taille" >
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Temps_Minute" HeaderText="Temps_Minute" 
                                SortExpression="Temps_Minute" >
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="LongueurPoil" HeaderText="LongueurPoil" 
                                ReadOnly="True" SortExpression="LongueurPoil" >
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Tarif" HeaderText="Tarif" SortExpression="Tarif" 
                                DataFormatString="{0:c}" >
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                        </Columns>
                    </asp:GridView>
     
                </td>
                <td>
                    <asp:GridView 
                        ID="GridViewDetailVente" 
                        runat="server" 
                        AutoGenerateColumns="False" 
                        DataKeyNames="ID_VENTEDETAIL" 
                        DataSourceID="ODS_PrestationsRDV"
                        EmptyDataText="Ajoutez une prestation au ticket" 
                        onrowdatabound="GridViewDetailVente_RowDataBound" ShowFooter="True">
                        <FooterStyle CssClass="FooterStyle" />
                        <emptydatarowstyle BackColor="LightBlue" ForeColor="Red"/>
                        <Columns>
                            <asp:BoundField DataField="Code_Item" HeaderText="Code Prestation" 
                                SortExpression="Code_Item" />
                            <asp:BoundField DataField="Item" HeaderText="Prestation" 
                                SortExpression="Item" />
                            <asp:BoundField DataField="Prix_Unitaire_HT" HeaderText="Prix HT" 
                                SortExpression="Prix_Unitaire_HT" DataFormatString="{0:c}">
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Taux_TVA" HeaderText="Tx TVA" 
                                SortExpression="Taux_TVA" DataFormatString="{0:P2}">
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Prix_Unitaire_TTC" HeaderText="Prix TTC" 
                                SortExpression="Prix_Unitaire_TTC" DataFormatString="{0:c}">
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Remise" HeaderText="Remise" 
                                SortExpression="Remise">
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Total_Article" HeaderText="Total TTC" 
                                SortExpression="Total_Article" DataFormatString="{0:c}" >
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:CommandField ShowDeleteButton="True" ButtonType="Image" 
                                DeleteImageUrl="~/App_Themes/Vert/Images/delete.gif" />
                        </Columns>
                        <HeaderStyle CssClass="HeaderStyle" />
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    <asp:ImageButton 
                        ID="BtnAnnuler" 
                        runat="server" 
                        ImageUrl="~/App_Themes/Vert/Images/dog2_back_32.gif" 
                        ToolTip="Annuler et revenir à l'écran précédent" 
                        onclick="BtnAnnuler_Click" />
                </td>
                <td class="style2">
                    <asp:ImageButton 
                        ID="BtnValider" 
                        runat="server" 
                        ToolTip="Enregistrer le ticket"  
                        ImageUrl="~/App_Themes/Vert/Images/dog5_ok_32.gif" 
                        onclick="BtnValider_Click" />
                </td>
            </tr>
        </table>
     
        </form>
    </body>
    </html>


    Si tu as une idée, je suis preneur

  4. #4
    Membre du Club
    Inscrit en
    Avril 2004
    Messages
    78
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : Avril 2004
    Messages : 78
    Points : 56
    Points
    56
    Par défaut
    et le code behind

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
     
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using VenteTableAdapters;
     
    //ATTENTION, LA DONNEE ID_EMPLOYE EST UTILISEE DANS CETTE PAGE, IL FAUDRA LA METTRE A JOUR QUAND LES ID_EMPLOYES SERONT GERES
     
    public partial class Ecrans_Gestion_de_la_boutique_ActionsAnimal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
     
        }
     
        protected void FormViewAnimal_DataBound(object sender, EventArgs e)
        {
            //******************************************************************************************************
            //Initialisation du Gridview de la liste des prestations en fonction des données de l'énimal sélectionné
            if (((System.Data.DataRowView)FormViewAnimal.DataItem) != null)
            {
                //**************************************************************************************************
                //Selection du dataitem contenu dans le formview
                Gestion.T_ANIMALRow _animal = (Gestion.T_ANIMALRow)((System.Data.DataRowView)FormViewAnimal.DataItem).Row;
     
                //**************************************************************************************************
                //Initialisation du GridView GridViewListePrestation en fonction des paramètres de l'animal sélectionné
                ODS_ListeTarifsPrestations.SelectParameters[0].DefaultValue = Convert.ToString(_animal.ID_LONGUEUR);
                ODS_ListeTarifsPrestations.SelectParameters[1].DefaultValue = Convert.ToString(_animal.ID_TAILLE);
                ODS_ListeTarifsPrestations.Select();
                ODS_ListeTarifsPrestations.DataBind();
     
                //**************************************************************************************************
                //Initialisation du Detailsview après création d'une nouvelle vente
     
                //Récupération de l'ID_CLIENT du maitre de l'animal sélectionné
                int _idClient = _animal.ID_CLIENT;
     
                //Récupération de l'ID_Animal de l'animal sélectionné
                int _idAnimal = _animal.ID_ANIMAL;
     
                //Récupération de la date
                DateTime _datevente = DateTime.Now;
     
                //Création d'une nouvelle vente avec récupération de l'ID de la vente
                VenteBLL _Vente = new VenteBLL();
     
                //Paramètres: @ID_CLIENT,@ID_EMPLOYE,@Date_Vente,@Total_Vente_HT,@Total_Vente_TTC
                //On récupère l'id de la dernière vente enregistrée pour initialiser le detailsview
                int _idVente = _Vente.InsertVenteReturnIDVente(_idClient, 1,_idAnimal, _datevente, 0, 0);
     
                //Affichage de la vente créée
                ODS_VenteData.SelectParameters[0].DefaultValue = Convert.ToString(_idVente);
                ODS_VenteData.Select();
                ODS_VenteData.DataBind();
     
                //Affichage des boutons en fonction du type d'animal
     
                switch (_animal.TypeAnimal)
                {
                    case "Chien":
                        BtnAnnuler.ImageUrl = "~/App_Themes/Vert/Images/dog2_back_32.gif";
                        BtnValider.ImageUrl = "~/App_Themes/Vert/Images/dog5_ok_32.gif";
                        break;
                    case "Chat":
                        BtnAnnuler.ImageUrl = "~/App_Themes/Vert/Images/russianblu_32_Annuler.gif";
                        BtnValider.ImageUrl = "~/App_Themes/Vert/Images/birman2_32_OK.gif";
                        break;
                    default:
                        BtnAnnuler.ImageUrl = "~/App_Themes/Vert/Images/dog2_back_32.gif";
                        BtnValider.ImageUrl = "~/App_Themes/Vert/Images/dog5_ok_32.gif";
                        break;
                }
     
            }
     
     
     
     
            //******************************************************************************************************
            //Récupérer l'id de l'animal envoyé dans la page
                            //int Param = Request.QueryString["ID"];
     
            //FormView Fw = (FormView)FormViewAnimal;
            //TextBox _TxtbxidClient = (TextBox)Fw.FindControl("MaitreAnimalTextBox");
            //String _Client = _TxtbxidClient.Text;
     
            ////@ID_CLIENT
            //ODS_VenteData.InsertParameters[0].DefaultValue = "1";
            ////@ID_EMPLOYE
            //ODS_VenteData.InsertParameters[1].DefaultValue = "1";
            ////@Date_Vente
            //ODS_VenteData.InsertParameters[2].DefaultValue = _datevente.ToString();
            ////@Total_Vente_HT
            //ODS_VenteData.InsertParameters[3].DefaultValue = "0";
            ////
            //ODS_VenteData.InsertParameters[4].DefaultValue = "0";
     
        }
     
     
        protected void GridViewListePrestations_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //Si un élément est sélectionné (y compris si c'est un alternate) on récupère les valeurs dont
            //on a besoin pour ajouter au ticket
            if ((e.Row.RowState & DataControlRowState.Selected) == DataControlRowState.Selected)
            {
                DataRowView _rowview = (DataRowView)e.Row.DataItem;
     
                //Récupération des valeurs de la sélection à ajouter à la vente
                string _codeitem = _rowview.Row.ItemArray[1].ToString();
                int _idPrestation =(int)_rowview.Row.ItemArray[2];
                string _prestation = _rowview.Row.ItemArray[3].ToString();
                double _tarif = (double)_rowview.Row.ItemArray[9];
                double _tva = (double)_rowview.Row.ItemArray[10];
     
                //Calcul de la valeur Hors TVA
                double _tarif_ht;
     
                if (_tva == 0 || _tva == null)
                    _tarif_ht = 0;
                else
                    _tarif_ht = _tarif / (1+_tva);
     
                //Calcul de la valeur remisée
                double _val_remisee;
     
                _val_remisee = _tarif;
     
     
                //Récupération de l'ID_VENTE du détailsview
                DetailsView Dv = (DetailsView)DetailsViewVente;
                int _idVente = (int)Dv.DataKey.Value;
     
                //Insertion d'une ligne dans la table T_VENTE_DETAIL
                VenteDetailBLL _DetailVente = new VenteDetailBLL();
     
                //Paramètres: @ID_VENTE,@ID_ARTICLE,@ID_PRESTATION,@Code_Item,@Item,@Prix_Unitaire_HT,@Taux_TVA
                //            @Prix_Unitaire_TTC,@Quantite,@Remise,@Total_Article
                _DetailVente.InsertVenteDetail(_idVente, 0, _idPrestation, _codeitem, _prestation, _tarif_ht, _tva, _tarif, 1, 0, _val_remisee);
     
                //Mise à jour de l'affichage dans le gridview
                ODS_PrestationsRDV.Select();
                ODS_PrestationsRDV.DataBind();
                GridViewDetailVente.DataBind();
            }
     
        }
     
        protected void GridViewListePrestations_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewListePrestations.DataBind();
        }
     
     
        protected void BtnAnnuler_Click(object sender, ImageClickEventArgs e)
        {
     
     
     
            //************************************************************************************
            //****  Annulation de la vente *******************************************************
            //************************************************************************************
     
            VenteDetailBLL _DetailVente = new VenteDetailBLL();
            VenteBLL _Vente = new VenteBLL();
     
            //Récupération de l'ID_VENTE du détailsview
            DetailsView Dv = (DetailsView)DetailsViewVente;
            int _idVente = (int)Dv.DataKey.Value;
     
            //Suppression des prestations ajoutées
            //_DetailVente..DeleteVenteDetailByIDVente(_idVente);(ne fonctionne pas, je ne sais pas pourquoi)
     
            // Iterate through the Products.Rows property
            foreach (GridViewRow row in GridViewDetailVente.Rows)
            {
            // Access the CheckBox
                {
                // Delete row! (Well, not really...)
                // First, get the ProductID for the selected row
                    int _IDDetailVente = Convert.ToInt32(GridViewDetailVente.DataKeys[row.RowIndex].Value);
                // "Delete" the row
                _DetailVente.DeleteVenteDetail(_IDDetailVente);
                //............................................
                }
            }
     
     
            //Suppression de la vente
            _Vente.DeleteVente(_idVente);
     
     
            //retour à l'écran de recherche
            Response.Redirect("RechercheClient.aspx");
        }
     
     
        protected void BtnValider_Click(object sender, ImageClickEventArgs e)
        {
            //Retour à l'écran de recherche
            Response.Redirect("RechercheClient.aspx");
     
        }
     
        //Création de variables de niveau page pour le calcul de totaux dans le GridViewDetailVente
        double _totalTTC = 0;
        double _totalHT = 0;
        double _totalGeneral = 0;
        int _NbreElements = 0;
     
        protected void GridViewDetailVente_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType==DataControlRowType.DataRow)
            {
                // Reference the DetailVenteRow via the e.Row.DataItem property
                Vente.T_VENTE_DETAILRow _detailVente=(Vente.T_VENTE_DETAILRow)
                                                    ((System.Data.DataRowView)e.Row.DataItem).Row;
                // Increment the running totals (if they're not NULL!)
                if (!_detailVente.IsPrix_Unitaire_HTNull())
                {
                    _totalHT += _detailVente.Prix_Unitaire_HT;
                    _totalTTC += _detailVente.Prix_Unitaire_TTC;
                    _totalGeneral += _detailVente.Total_Article;
                }
     
                //incrémente le nombre d'élément même si la valeur est NULL
                _NbreElements++;
            }
            else if(e.Row.RowType==DataControlRowType.Footer)
            {
                e.Row.Cells[0].Text = "Nbre d'élts:" + _NbreElements.ToString();
                e.Row.Cells[1].Text = "Total:";
                e.Row.Cells[2].Text = _totalHT.ToString("c");
                e.Row.Cells[4].Text = _totalTTC.ToString("c");
                e.Row.Cells[6].Text = _totalGeneral.ToString("c");
            }
     
            //Récupération de l'ID_VENTE du détailsview
            VenteBLL _Vente = new VenteBLL();
            DetailsView Dv = (DetailsView)DetailsViewVente;
            int _idVente = (int)Dv.DataKey.Value;
            _Vente.UpdateTotalByIDVente(_totalHT, _totalTTC, _idVente);
            Dv.DataBind();
     
        }
    }

  5. #5
    Membre du Club
    Inscrit en
    Avril 2004
    Messages
    78
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : Avril 2004
    Messages : 78
    Points : 56
    Points
    56
    Par défaut
    Bon, je me suis débrouillé autrement.

    Pour éviter des databindings à tout va, je passe par l'évènement rowcommand au lieu de rowdatabound.

    Ainsi, j'ai tout mon code de récupération de données au même endroit. ça fait un peu plus propre.

    Merci à ceux qui ont essayé de m'aider

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2007] Copie de ligne en fonction de couleur de cellule dans d'autre feuille
    Par stephadm dans le forum Macros et VBA Excel
    Réponses: 23
    Dernier message: 30/09/2011, 07h43
  2. copie de rows d'un gridview à un autre
    Par Hepil dans le forum Windows Forms
    Réponses: 6
    Dernier message: 23/08/2010, 10h52
  3. copié une ligne d'une table dans une autre
    Par Invité dans le forum Requêtes
    Réponses: 1
    Dernier message: 21/11/2009, 20h48
  4. copie les ligne visible dans un autre onglet
    Par calvi2002 dans le forum Excel
    Réponses: 4
    Dernier message: 16/07/2009, 09h09
  5. [DOS] copie de ligne d'un fichier vers un autre
    Par Ted37 dans le forum Scripts/Batch
    Réponses: 5
    Dernier message: 23/01/2009, 18h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo