Bonjour à tous, je viens à vous aujourd'hui parce que j'ai un souci avec un objet ListView contenu dans un Contrôle (System.Web.UI.UserControl).
Ce contrôle (LignesControl.ascx) doit afficher une liste d'articles contenant des boutons d'édition, suppression, déplacement, etc...
Il faut savoir que je n'ai pas programmé ce contrôle, je ne fais qu'apporter des améliorations au programme existant que je découvre peu à peu.
Bref, normalement, ce contrôle est fait pour fonctionner dans un autre contrôle (GroupLignesControl.ascx) qui est une ListView contenant des LignesControl (voir figure suivante)
Lorsqu'un utilisateur clique sur "ajouter un article", une modale s'ouvre pour sélectionner des articles à ajouter au groupe de lignes (LignesControl).
Je cherche donc à afficher uniquement le groupe de lignes concerné dans ma modale (voir figure suivante), la ViewList est chargée à partir d'un ObjectDataSource, les items sont chargés correctement, tout à l'air de fonctionner correctement mais lorsque je clique sur mon "ImageButton", le clic déclenche bien un évènement postback mais côté serveur, la méthode fournie à la listview pour intercepter les commandes (attribut "OnItemCommand" de la liste) ne se déclenche pas (le point d'arrêt du mode débug posé sur le premier "if" n'est jamais atteint, pourtant, cette méthode se trouve bien dans le codebehind du controleur, de plus, je ne reçois aucune erreur dans la console.
Ce qui rend la chose floue pour moi, c'est que ce même contrôleur est appelé dans GroupLignesControl et qu'il y fonctionne parfaitement...
Est-ce que quelqu'un a déjà eu la même problème?
Est-ce que ce problème vient de l'appel du contrôleur?
Est-ce qu'il faut encapsuler le contrôle dans une balise particulière pour que cela fonctionne?
Voici mon code :
LignesControl.ascx
LignesControl.ascx.cs
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485 <%@ Control Language="C#" AutoEventWireup="true" Inherits="PecV2.WebApp.Intervention.LignesControl" Codebehind="LignesControl.ascx.cs" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <link href="/Intervention/Facture.css" rel="stylesheet" type="text/css" /> <style type="text/css"> span.Label { font-size: 8pt; } .modalBackground { background-color: Black; filter: alpha(opacity=90); opacity: 0.8; } .modalPopup { background-color: #FFFFFF; border-width: 3px; border-style: solid; border-color: black; padding: 10px; width: 60%; height: 90%; align-items:center; text-align:center; } .modalPopup iframe{ width: 90%; height: 90%; margin-left:auto; margin-right:auto; border:none; } .modalPopup input{ display:inline-block; } </style> <asp:ObjectDataSource ID="odsLigne" runat="server" DataObjectTypeName="PecV2.BL.Ligne" InsertMethod="InsertLigne" SelectMethod="GetLignesByIDGroupe" UpdateMethod="UpdateLigne" TypeName="PecV2.BL.Ligne" OnSelecting="odsLigne_Selecting" DeleteMethod="DeleteLigne" OnDeleting="odsLigne_Deleting"> <SelectParameters> <asp:Parameter Name="IDGroupe" Type="Int64" /> </SelectParameters> <DeleteParameters> <asp:Parameter Name="IDLigne" Type="Int64" /> </DeleteParameters> </asp:ObjectDataSource> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div> <asp:ListView ID="lcvLigne" runat="server" DataSourceID="odsLigne" OnItemInserting="lcvLigne_ItemInserting" OnItemUpdating="lcvLigne_ItemUpdating" OnItemCanceling="lcvLigne_ItemCanceling" OnItemInserted="lcvLigne_ItemInserted" DataKeyNames="IDLigne" OnDataBound="lcvLigne_DataBound" OnItemCommand="lcvLigne_ItemCommand" OnItemDeleted="lcvLigne_ItemDeleted" OnItemUpdated="lcvLigne_ItemUpdated"> <LayoutTemplate> <table id="itemPlaceholderContainer" runat="server" cellpadding="2" cellspacing="0"> <tr class="TitreTableauLigne"> <th class="TitreTableauLigne"> </th> <th class="TitreTableauLigne" width="80" style="text-align: left"> Ref </th> <th class="TitreTableauLigne" width="200" style="text-align: left"> Denomination </th> <th class="TitreTableauLigne" width="30"> U </th> <th class="TitreTableauLigne" width="60"> PU </th> <th class="TitreTableauLigne" width="30"> TU </th> <th class="TitreTableauLigne" width="40"> Rab. </th> <th class="TitreTableauLigne" width="40"> Haus. </th> <th class="TitreTableauLigne" width="70"> Qté </th> <th class="TitreTableauLigne" width="80"> Mt HT </th> <th class="TitreTableauLigne" width="50"> Tx Tva </th> <th class="TitreTableauLigne" width="80"> Mt TVA </th> <th class="TitreTableauLigne" width="80"> Mt TTC </th> <th> </th> </tr> <tr> <td colspan="16" class="SeparateurTitreTableauLigne"> </td> </tr> <tr id="itemPlaceholder" runat="server"> </tr> <tr style="background-color: #DFDFDF"> <td colspan="12" align="right" style=""> Sous total HT : </td> <td style="font-weight: bold" colspan="4"> <asp:Label ID="lblTotal" runat="server" Text=""></asp:Label> </td> </tr> <tr> <td colspan="16" class="SeparateurItemTableauLigne"> </td> </tr> </table> </LayoutTemplate> <ItemTemplate> <tr> <td class="ItemTableauLigne"> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="EditButton" runat="server" CommandName="Edit" ImageUrl="~/_images/edit.png" /> <%} %> <asp:HiddenField ID="IDGroupe" runat="server" Value='<%# Eval("IDGroupe") %>' /> <asp:HiddenField ID="IDLigne" runat="server" Value='<%# Bind("IDLigne") %>' /> <asp:HiddenField ID="IDArticle" runat="server" Value='<%# Eval("IDArticle") %>' /> </td> <td class="ItemTableauLigne" style="text-align: left"> <asp:Label ID="CodeClientLabel" runat="server" Text='<%# ""+Eval("CodeClient") %>' /> </td> <td class="ItemTableauLigne" style="text-align: left"> <asp:Label ID="DenominationLabel" runat="server" Text='<%# Eval("Denomination") %>' Width="200px" /> </td> <td class="ItemTableauLigne"> <asp:Label ID="UniteLabel" runat="server" Text='<%# Eval("Unite") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="PrixUnitaireLabel" runat="server" Text='<%# Eval("PrixUnitaire") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="TempsUnitaireLabel" runat="server" Text='<%# Eval("TempsUnitaire") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="RabaisLabel" runat="server" Text='<%# Eval("Rabais","{0:g}") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="HausseLabel" runat="server" Text='<%# Eval("Hausse") %>' /> </td> <td class="ItemTableauLigne"> <table border="0" cellpadding="0" cellspacing="0" style="padding: 0px; margin: 0px"> <tr> <td> <asp:Label ID="QuantiteLabel" runat="server" Text='<%# Eval("Quantite") %>' /> </td> <td style="width: 4px"> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <table border="0" cellpadding="0" cellspacing="0"> <tr style="height: 0px; padding: 0px; margin: 0px"> <td style="height: 0px; padding: 0px; margin: 0px"> <asp:ImageButton ID="ibPlus" runat="server" CommandArgument='<%# Bind("IDLigne") %>' CommandName="Plus1" ImageUrl="~/_images/miniPlus.gif" ToolTip="Ajouter 1 à la quantité" /> </td> </tr> <tr style="height: 0px; padding: 0px; margin: 0px"> <td style="height: 0px; padding: 0px; margin: 0px"> <asp:ImageButton ID="ibMoins" runat="server" CommandArgument='<%# Bind("IDLigne") %>' CommandName="Moins1" ImageUrl="~/_images/miniMoins.gif" ToolTip="Soustraire 1 à la quantité" /> </td> </tr> </table> <%} %> </td> </tr> </table> </td> <td class="ItemTableauLigne"> <asp:Label ID="MontantHTLabel" runat="server" Text='<%# Eval("MontantHT") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="IDTauxTvaLabel" runat="server" Text='<%# Eval("TauxTva.Taux") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="MontantTVALabel" runat="server" Text='<%# Eval("MontantTVA") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="MontantTTCLabel" runat="server" Text='<%# Eval("MontantTTC") %>' /> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="btnMUpLigne" ImageUrl="~/_images/16/arrow_up_blue.png" ToolTip="Monter cette ligne" CommandName="mupLigne" runat="server" CommandArgument='<%#Bind("IDLigne")%>' /> <%} %> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="btnMDnLigne" ImageUrl="~/_images/16/arrow_down_blue.png" ToolTip="Descendre cette ligne" CommandName="mdnLigne" runat="server" CommandArgument='<%#Bind("IDLigne")%>' /> <%} %> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="DeleteLigne" runat="server" CommandName="Delete" ImageUrl="~/_images/DeleteHS.png" /> <cc1:ConfirmButtonExtender ID="ImageButton2_ConfirmButtonExtender" runat="server" ConfirmText="Etes vous sûr de vouloir supprimer cet article ?" Enabled="True" TargetControlID="DeleteLigne"> </cc1:ConfirmButtonExtender> <%} %> </td> </tr> <tr> <td colspan="16" class="SeparateurItemTableauLigne"> </td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr style="background-color: #F7F7F7"> <td class="ItemTableauLigne"> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="EditButton" runat="server" CommandName="Edit" ImageUrl="~/_images/edit.png" /> <%} %> <asp:HiddenField ID="IDGroupe" runat="server" Value='<%# Eval("IDGroupe") %>' /> <asp:HiddenField ID="IDLigne" runat="server" Value='<%# Bind("IDLigne") %>' /> <asp:HiddenField ID="IDArticle" runat="server" Value='<%# Eval("IDArticle") %>' /> </td> <td class="ItemTableauLigne" style="text-align: left"> <asp:Label ID="CodeClientLabel" runat="server" Text='<%# ""+Eval("CodeClient") %>' /> </td> <td class="ItemTableauLigne" style="text-align: left"> <asp:Label ID="DenominationLabel" runat="server" Text='<%# Eval("Denomination") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="UniteLabel" runat="server" Text='<%# Eval("Unite") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="PrixUnitaireLabel" runat="server" Text='<%# Eval("PrixUnitaire") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="TempsUnitaireLabel" runat="server" Text='<%# Eval("TempsUnitaire") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="RabaisLabel" runat="server" Text='<%# Eval("Rabais","{0:g}") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="HausseLabel" runat="server" Text='<%# Eval("Hausse") %>' /> </td> <td class="ItemTableauLigne"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td> <asp:Label ID="QuantiteLabel" runat="server" Text='<%# Eval("Quantite") %>' /> </td> <td style="width: 4px"> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <table border="0" cellpadding="0" cellspacing="0"> <tr style="height: 0px"> <td style="height: 0px"> <asp:ImageButton ID="ibPlus" runat="server" CommandArgument='<%# Bind("IDLigne") %>' CommandName="Plus1" ImageUrl="~/_images/miniPlus.gif" ToolTip="Ajouter 1 à la quantité" /> </td> </tr> <tr style="height: 0px"> <td style="height: 0px"> <asp:ImageButton ID="ibMoins" runat="server" CommandArgument='<%# Bind("IDLigne") %>' CommandName="Moins1" ImageUrl="~/_images/miniMoins.gif" ToolTip="Soustraire 1 à la quantité" /> </td> </tr> </table> <%} %> </td> </tr> </table> </td> <td class="ItemTableauLigne"> <asp:Label ID="MontantHTLabel" runat="server" Text='<%# Eval("MontantHT") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="IDTauxTvaLabel" runat="server" Text='<%# Eval("TauxTva.Taux") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="MontantTVALabel" runat="server" Text='<%# Eval("MontantTVA") %>' /> </td> <td class="ItemTableauLigne"> <asp:Label ID="MontantTTCLabel" runat="server" Text='<%# Eval("MontantTTC") %>' /> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="btnMUpLigne" ImageUrl="~/_images/16/arrow_up_blue.png" ToolTip="Monter cette ligne" CommandName="mupLigne" runat="server" CommandArgument='<%#Bind("IDLigne")%>' /> <%} %> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="btnMDnLigne" ImageUrl="~/_images/16/arrow_down_blue.png" ToolTip="Descendre cette ligne" CommandName="mdnLigne" runat="server" CommandArgument='<%#Bind("IDLigne")%>' /> <%} %> </td> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="DeleteLigne" runat="server" CommandName="Delete" ImageUrl="~/_images/DeleteHS.png" /> <cc1:ConfirmButtonExtender ID="ImageButton2_ConfirmButtonExtender" runat="server" ConfirmText="Etes vous sûr de vouloir supprimer cet article ?" Enabled="True" TargetControlID="DeleteLigne"> </cc1:ConfirmButtonExtender> <%} %> </td> </tr> <tr> <td colspan="16" class="SeparateurItemTableauLigne"> </td> </tr> </AlternatingItemTemplate> <InsertItemTemplate> <tr style=""> <td> <asp:HiddenField ID="IDGroupe" runat="server" Value='<%# Bind("IDGroupe") %>' /> <asp:HiddenField ID="IDLigne" runat="server" Value='<%# Bind("IDLigne") %>' /> <asp:HiddenField ID="IDArticle" runat="server" Value='<%# Bind("IDArticle") %>' /> <asp:HiddenField ID="Ordre" runat="server" Value='<%# Bind("NumeroOrdre") %>' /> </td> <td> <asp:TextBox ID="CodeClient" runat="server" Text='<%# Bind("CodeClient") %>' Width="50" /> </td> <td> <asp:TextBox ID="Denomination" runat="server" Text='<%# Bind("Denomination") %>' Width="150" MaxLength="5000" /> </td> <td> <asp:TextBox ID="Unite" runat="server" Text='<%# Bind("Unite") %>' Width="30" /> </td> <td> <asp:TextBox ID="PrixUnitaireTextBox" runat="server" Text='<%# Bind("PrixUnitaire") %>' Width="40" /> </td> <td> <asp:TextBox ID="TempsUnitaireTextBox" runat="server" Text='<%# Bind("TempsUnitaire") %>' Width="30" /> </td> <td> <asp:TextBox ID="Rabais" runat="server" Text='<%# Bind("Rabais") %>' Width="30" /> </td> <td> <asp:TextBox ID="Hausse" runat="server" Text='<%# Bind("Hausse") %>' Width="30" /> </td> <td> <asp:TextBox ID="Quantite" runat="server" Text='<%# Bind("Quantite") %>' Width="30" /> </td> <td> </td> <td> <asp:ObjectDataSource ID="odsTauxTva" runat="server" SelectMethod="GetTauxTVAs" TypeName="PecV2.BL.TauxTVA"> </asp:ObjectDataSource> <asp:DropDownList ID="IDTauxTVA" runat="server" DataSourceID="odsTauxTva" DataTextField="Taux" DataValueField="IDTauxTva" /> </td> <td colspan="3" align="right"> <asp:ImageButton ID="InsertButton" runat="server" CommandName="Insert" ImageUrl="~/_images/Check.gif" /> <asp:ImageButton ID="CancelButton" runat="server" CommandName="Cancel" ImageUrl="~/_images/Undo.gif" /> </td> </tr> <tr> <td colspan="16" class="SeparateurItemTableauLigne"> </td> </tr> </InsertItemTemplate> <EditItemTemplate> <tr> <td> <asp:HiddenField ID="IDGroupe" runat="server" Value='<%# Bind("IDGroupe") %>' /> <asp:HiddenField ID="IDLigne" runat="server" Value='<%# Bind("IDLigne") %>' /> <asp:HiddenField ID="IDArticle" runat="server" Value='<%# Bind("IDArticle") %>' /> <asp:HiddenField ID="Ordre" runat="server" Value='<%# Bind("NumeroOrdre") %>' /> </td> <td> <asp:TextBox ID="CodeClient" runat="server" Text='<%# Bind("CodeClient") %>' Width="60" /> </td> <td> <asp:TextBox ID="Denomination" runat="server" Text='<%# Bind("Denomination") %>' Width="200" MaxLength="5000" /> </td> <td> <asp:TextBox ID="Unite" runat="server" Text='<%# Bind("Unite") %>' Width="30" /> </td> <td> <asp:TextBox ID="PrixUnitaireTextBox" runat="server" Text='<%# Bind("PrixUnitaire") %>' Width="40" /> </td> <td> <asp:TextBox ID="TempsUnitaireTextBox" runat="server" Text='<%# Bind("TempsUnitaire") %>' Width="30" /> </td> <td> <asp:TextBox ID="Rabais" runat="server" Text='<%# Bind("Rabais") %>' Width="30" /> </td> <td> <asp:TextBox ID="Hausse" runat="server" Text='<%# Bind("Hausse") %>' Width="30" /> </td> <td> <asp:TextBox ID="Quantite" runat="server" Text='<%# Bind("Quantite") %>' Width="30" /> </td> <td> </td> <td> <asp:ObjectDataSource ID="odsTauxTva" runat="server" SelectMethod="GetTauxTVAs" TypeName="PecV2.BL.TauxTVA"> </asp:ObjectDataSource> <asp:DropDownList ID="IDTauxTVA" runat="server" DataSourceID="odsTauxTva" DataTextField="Taux" DataValueField="IDTauxTva" SelectedValue='<%# Bind("IDTauxTva") %>'> </asp:DropDownList> </td> <td colspan="3" align="right"> <asp:Panel runat="server" DefaultButton="UpdateButton"> <asp:ImageButton ID="UpdateButton" runat="server" CommandName="Update" ImageUrl="~/_images/Check.gif" /> <asp:ImageButton ID="CancelButton" runat="server" CommandName="Cancel" ImageUrl="~/_images/Undo.gif" /> </asp:Panel> </td> </tr> <tr> <td colspan="16" class="SeparateurItemTableauLigne"> </td> </tr> </EditItemTemplate> </asp:ListView> </div> <% if (HttpContext.Current.User.IsInRole("Modification") && Request.QueryString["IsReadOnly"] != "true") { %> <div style="margin-top: 10px"> <table border="0" cellpadding="0px" cellspacing="0px"> <tr> <td align="left"> <asp:Image runat="server" ImageUrl="~/_images/16/nut_and_bolt.png" Style="width: 16px; height: 16px" /> <asp:LinkButton ID="btnInsererArticles" runat="server" CssClass="Label" Visible="true"><span class="Label">Ajouter un article</span></asp:LinkButton> <cc1:ModalPopupExtender ID="ModalAjoutArticle" runat="server" PopupControlID="addArticlePanel" TargetControlID="btnInsererArticles" BackgroundCssClass="modalBackground"> </cc1:ModalPopupExtender> <asp:Panel ID="addArticlePanel" runat="server" style="display:none;" CssClass="modalPopup"> <iframe id="addArticleFrame" runat="server" ></iframe> <br/> <asp:Button ID="btnCloseModalAjoutArticle" runat="server" Text="Fermer" OnClick="btnCloseModalAjoutArticle_Click"/> </asp:Panel> <asp:HiddenField ID="Articles" runat="server" OnValueChanged="Articles_ValueChanged"> </asp:HiddenField> <asp:ImageButton ID="Image1" runat="server" ImageUrl="~/_images/16/row_add_after.png" OnClick="btnAjouterLigne_Click" /> <asp:LinkButton ID="btnAjouterLigne" runat="server" OnClick="btnAjouterLigne_Click" CssClass="Label" Visible="true"> <span class="Label">Ajouter une ligne vide</span></asp:LinkButton> </td> <td style="width: 20px"> </td> <td align="left"> <span class="Label"> <img src="../_images/16/percent.png" style="width: 16px; height: 16px" />Taux de TVA par défaut : </span><asp:ObjectDataSource ID="odsTauxTva" runat="server" SelectMethod="GetTauxTVAs" TypeName="PecV2.BL.TauxTVA"></asp:ObjectDataSource> <asp:DropDownList ID="IDTauxTVA" runat="server" DataSourceID="odsTauxTva" DataTextField="Taux" DataValueField="IDTauxTva" AutoPostBack="true" /> </td> </tr> </table> </div> <%} %> </ContentTemplate> </asp:UpdatePanel>
GroupLignesControl.ascx
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 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Text; using PecV2.BL; using PecV2.BL.utils; namespace PecV2.WebApp.Intervention { public partial class LignesControl : System.Web.UI.UserControl, IPostBackEventHandler { // IMPORTANT : indiquer que la classe implémente l'insterface IPostBackEventHandler // pour recevoir l'événement postback !!!!! public Int64 IDGroupe { get { object o = ViewState[this.ID.ToString() + "IDGroupe"]; if (o == null) { return 0; } else { return (Int64)o; } } set { ViewState[this.ID.ToString() + "IDGroupe"] = value; } } public delegate void LignesControlUpdate_Handler(object sender, EventArgs e); public event LignesControlUpdate_Handler LignesControlUpdate; protected virtual void OnLignesControlUpdate(object sender, EventArgs e) { LignesControlUpdate(this, e); } protected void Page_Load(object sender, EventArgs e) { //IDTauxTVA.DataBind(); // POPUP de recherche d'intervenants (ouverte en modal) /* PopupUtil.DefineStringPopupButton ( PecV2.BL.utils.UrlUtil.GetClientUrl(this.Request, "~/Articles/Articles.aspx?IDGroupe=" + IDGroupe.ToString() + "&IDTauxTVA=" + IDTauxTVA.SelectedValue.ToString()), "dialogWidth:890px;dialogHeight:730px;edge:sunken;status:no;scroll:no;", Articles, btnInsererArticles ); btnInsererArticles.CausesValidation = false;*/ //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertisreadonly", "alert('isreadonly : " + Request.QueryString["IsReadOnly"] + "')", true); } protected void Page_Prerender(object sender, EventArgs e) { addArticleFrame.Attributes.Add("src", "../Articles/ArticlesIntervention.aspx?IDGroupe=" + IDGroupe.ToString() + "&IDTauxTVA=" + IDTauxTVA.SelectedValue.ToString() + "&IsReadOnly=true"); } protected void btnCloseModalAjoutArticle_Click(object sender, EventArgs e) { LignesControlUpdate(this, e); } protected void lcvLigne_ItemUpdating(object sender, ListViewUpdateEventArgs e) { // modification des virgules e.NewValues["PrixUnitaire"] = Convert.ToDecimal(e.NewValues["PrixUnitaire"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.NewValues["TempsUnitaire"] = Convert.ToDecimal(e.NewValues["TempsUnitaire"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.NewValues["Rabais"] = Convert.ToDecimal(e.NewValues["Rabais"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.NewValues["Hausse"] = Convert.ToDecimal(e.NewValues["Hausse"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.NewValues["Quantite"] = Convert.ToDecimal(e.NewValues["Quantite"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.NewValues["MontantHT"] = Convert.ToDecimal(e.NewValues["MontantHT"], System.Globalization.DateTimeFormatInfo.CurrentInfo); e.NewValues["MontantTTC"] = Convert.ToDecimal(e.NewValues["MontantTTC"], System.Globalization.DateTimeFormatInfo.CurrentInfo); e.NewValues["MontantTVA"] = Convert.ToDecimal(e.NewValues["MontantTVA"], System.Globalization.DateTimeFormatInfo.CurrentInfo); } protected void lcvLigne_ItemInserting(object sender, ListViewInsertEventArgs e) { // modification des virgules e.Values["PrixUnitaire"] = Convert.ToDecimal(e.Values["PrixUnitaire"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.Values["TempsUnitaire"] = Convert.ToDecimal(e.Values["TempsUnitaire"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.Values["Rabais"] = Convert.ToDecimal(e.Values["Rabais"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.Values["Hausse"] = Convert.ToDecimal(e.Values["Hausse"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.Values["Quantite"] = Convert.ToDecimal(e.Values["Quantite"].ToString().Replace(".", ","), System.Globalization.DateTimeFormatInfo.CurrentInfo); e.Values["MontantHT"] = Convert.ToDecimal(e.Values["MontantHT"], System.Globalization.DateTimeFormatInfo.CurrentInfo); e.Values["MontantTTC"] = Convert.ToDecimal(e.Values["MontantTTC"], System.Globalization.DateTimeFormatInfo.CurrentInfo); e.Values["MontantTVA"] = Convert.ToDecimal(e.Values["MontantTVA"], System.Globalization.DateTimeFormatInfo.CurrentInfo); // insertion du taux de tva DropDownList ddl = e.Item.FindControl("IDTauxTVA") as DropDownList; if (ddl != null) { e.Values["IDTauxTva"] = (Convert.ToInt32(ddl.SelectedValue)); } // ajout du numéro de groupe e.Values["IDGroupe"] = IDGroupe; // forçage du numéro deligne à 0 e.Values["IDLigne"] = 0; } protected void odsLigne_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["IDGroupe"] = IDGroupe; } protected void btnAjouterLigne_Click(object sender, EventArgs e) { lcvLigne.InsertItemPosition = InsertItemPosition.LastItem; btnAjouterLigne.Visible = false; } protected void lcvLigne_ItemCanceling(object sender, ListViewCancelEventArgs e) { if (e.CancelMode == ListViewCancelMode.CancelingInsert) { lcvLigne.InsertItemPosition = InsertItemPosition.None; btnAjouterLigne.Visible = true; } } protected void lcvLigne_ItemInserted(object sender, ListViewInsertedEventArgs e) { // on masque la ligne d'insertion et on affiche le boutton ajouter une ligne lcvLigne.InsertItemPosition = InsertItemPosition.None; btnAjouterLigne.Visible = true; OnLignesControlUpdate(sender, e); } protected void odsLigne_Deleting(object sender, ObjectDataSourceMethodEventArgs e) { } protected void Articles_ValueChanged(object sender, EventArgs e) { //on ajoute les lignes au groupe string[] lesIDArticles = Articles.Value.Split(new Char[] { ';' }); // on récupère le nombre d'articles Decimal nbArticles = Convert.ToDecimal(lesIDArticles[0].Replace(".", ",")); for (int i = 1; i < lesIDArticles.Length; i++) { Article lArticle = Article.GetArticleByID(Convert.ToInt64(lesIDArticles[i])); Ligne maLigne = new Ligne(); maLigne.IDGroupe = IDGroupe; maLigne.IDArticle = lArticle.IDArticle; maLigne.IDTauxTva = Convert.ToInt64(IDTauxTVA.SelectedValue); maLigne.PrixUnitaire = lArticle.PrixUnitaire; maLigne.Hausse = lArticle.Hausse; maLigne.Rabais = lArticle.Rabais; maLigne.CodeClient = lArticle.CodeClient; maLigne.TempsUnitaire = lArticle.TempsUnitaire; maLigne.Unite = lArticle.Unite; maLigne.Denomination = lArticle.Denomination; maLigne.Quantite = nbArticles; Ligne.InsertLigne(maLigne); } Articles.Value = ""; lcvLigne.DataBind(); // on notifie la mise à jour OnLignesControlUpdate(sender, e); } protected void lcvLigne_DataBound(object sender, EventArgs e) { Label lblSoustotal = (Label)lcvLigne.FindControl("lblTotal"); if (lblSoustotal != null) { lblSoustotal.Text = PecV2.BL.GroupeLigne.GetTotalHT(IDGroupe).ToString("c"); } } protected void lcvLigne_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName.ToString() == "mupLigne") { Int64 IDLigne; if (Int64.TryParse(e.CommandArgument.ToString(), out IDLigne)) if (PecV2.BL.Ligne.UpLigne(IDGroupe, IDLigne)) lcvLigne.DataBind(); } else if (e.CommandName.ToString() == "mdnLigne") { Int64 IDLigne; if (Int64.TryParse(e.CommandArgument.ToString(), out IDLigne)) if (PecV2.BL.Ligne.DownLigne(IDGroupe, IDLigne)) lcvLigne.DataBind(); } else if (e.CommandName.ToString() == "Plus1") { Int64 IDLigne; if (Int64.TryParse(e.CommandArgument.ToString(), out IDLigne)) { //if (PecV2.BL.Ligne.Ajouter1_ToQuantite(IDLigne)) // lcvLigne.DataBind(); PecV2.BL.Ligne mLigne = PecV2.BL.Ligne.GetLigneByID(IDLigne); if (mLigne != null) { mLigne.Quantite += 1; if (PecV2.BL.Ligne.UpdateLigne(mLigne) > 0) lcvLigne.DataBind(); } } OnLignesControlUpdate(sender, e); } else if (e.CommandName.ToString() == "Moins1") { Int64 IDLigne; if (Int64.TryParse(e.CommandArgument.ToString(), out IDLigne)) { //if (PecV2.BL.Ligne.Soustraire1_ToQuantite(IDLigne)) // lcvLigne.DataBind(); PecV2.BL.Ligne mLigne = PecV2.BL.Ligne.GetLigneByID(IDLigne); if (mLigne != null && mLigne.Quantite > 0) { mLigne.Quantite += -1; if (PecV2.BL.Ligne.UpdateLigne(mLigne) > 0) lcvLigne.DataBind(); } } OnLignesControlUpdate(sender, e); } } protected void lcvLigne_ItemUpdated(object sender, ListViewUpdatedEventArgs e) { OnLignesControlUpdate(sender, e); } protected void lcvLigne_ItemDeleted(object sender, ListViewDeletedEventArgs e) { OnLignesControlUpdate(sender, e); } public void RaisePostBackEvent(string eventArgument) { // fermeture de la popup, on fait le databind if (eventArgument == "AjoutArticles") { lcvLigne.DataBind(); OnLignesControlUpdate(this, null); } } } }
GroupLignesControl.ascx.cs
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 <%@ Control Language="C#" AutoEventWireup="true" Inherits="PecV2.WebApp.Intervention.GroupeLigneControl" Codebehind="GroupeLigneControl.ascx.cs" %> <%@ Register Src="LignesControl.ascx" TagName="LignesControl" TagPrefix="uc1" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <link href="Facture.css" rel="stylesheet" type="text/css" /> <style type="text/css"> span.Label { font-size: 8pt; } </style> <asp:ObjectDataSource ID="odsGroupeLigne" runat="server" DataObjectTypeName="PecV2.BL.GroupeLigne" InsertMethod="InsertGroupeLigne" SelectMethod="GetGroupeLigneByIDFacture" TypeName="PecV2.BL.GroupeLigne" UpdateMethod="UpdateTitreGroupeLigne" DeleteMethod="DeleteGroupeLigne" OnSelecting="odsGroupeLigne_Selecting"> <SelectParameters> <asp:Parameter Name="IDFacture" Type="Int64" /> </SelectParameters> <DeleteParameters> <asp:Parameter Name="IDGroupe" Type="Int64" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="IDGroupe" Type="Int64" /> <asp:Parameter Name="Titre" Type="String" /> </UpdateParameters> </asp:ObjectDataSource> <asp:ListView ID="lsvGroupeLigne" runat="server" DataSourceID="odsGroupeLigne" DataKeyNames="IDGroupe" OnDataBound="lsvGroupeLigne_DataBound" OnItemCommand="lsvGroupeLigne_ItemCommand"> <ItemTemplate> <table cellpadding="0" cellspacing="0" class="TableauGroupeLigne"> <tr class="EnteteTableauGroupeLigne"> <td> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/_images/16/pencil.png" CommandName="Edit" /> <%} %> <asp:HiddenField ID="hfIdGroupe" Value='<%#Bind("IdGroupe")%>' runat="server" /> <asp:Label Width="150px" ID="Titre" Text='<%#Eval("Titre")%>' runat="server" /> </td> <td align="right"> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <a href="#" onclick='showDuplicateDialog(<%#Eval("IdGroupe")%>)'> <asp:Image ID="Image3" runat="server" ImageUrl="~/_images/16/copy.png" /></a> <asp:ImageButton ID="btnMUpGroupe" ImageUrl="~/_images/16/arrow_up_blue.png" ToolTip="Monter ce groupe" CommandName="mupGroupe" runat="server" CommandArgument='<%#Bind("IdGroupe")%>' /> <asp:ImageButton ID="btnMDnGroupe" ImageUrl="~/_images/16/arrow_down_blue.png" ToolTip="Descendre ce groupe" CommandName="mdnGroupe" runat="server" CommandArgument='<%#Bind("IdGroupe")%>' /> <asp:ImageButton ID="btnDelGroupe" ImageUrl="~/_images/DeleteHS.png" ToolTip="Supprimer ce groupe" CommandName="Delete" runat="server" /> <cc1:ConfirmButtonExtender ID="ImageButton2_ConfirmButtonExtender" runat="server" ConfirmText="Etes vous sûr de vouloir supprimer ce groupe?" Enabled="True" TargetControlID="btnDelGroupe"> </cc1:ConfirmButtonExtender> <%} %> </td> </tr> <tr> <td colspan="2"> <uc1:LignesControl ID="LignesControl1" runat="server" IDGroupe='<%# Eval("IDGroupe") %>' OnLignesControlUpdate="LignesControl1_OnLignesControlUpdate" /> </td> </tr> </table> </ItemTemplate> <EmptyDataTemplate> <table runat="server" style=""> <tr> <td>Aucune donnée n'a été retournée. </td> </tr> </table> </EmptyDataTemplate> <LayoutTemplate> <li id="itemPlaceholder" runat="server"></li> </LayoutTemplate> <EditItemTemplate> <table cellpadding="0" cellspacing="0" class="TableauGroupeLigne"> <tr class="EnteteTableauGroupeLigne"> <td> <asp:Panel runat="server" DefaultButton="ImageButton1"> <asp:HiddenField ID="hfIdGroupe" Value='<%#Bind("IdGroupe")%>' runat="server" /> <asp:TextBox Width="150px" ID="txtTitre" Text='<%#Bind("Titre")%>' runat="server" OnDataBinding="txtTitre_OnDataBinding" /> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/_images/16/check2.png" CommandName="Update" /> <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/_images/16/undo.png" CommandName="Cancel" /> </asp:Panel> </td> <td align="right"></td> </tr> <tr> <td colspan="2"> <uc1:LignesControl ID="LignesControl1" runat="server" IDGroupe='<%# Eval("IDGroupe") %>' /> </td> </tr> </table> </EditItemTemplate> </asp:ListView> <table style="width:100%"> <tr> <td valign="top"> <% if (HttpContext.Current.User.IsInRole("Modification")) { %> <asp:Image ID="Image2" runat="server" ImageUrl="~/_images/24/table_add.png" /><asp:LinkButton ID="btnAjouterGroupe" runat="server" OnClick="btnAjouterGroupe_Click"><span class="Label">Ajouter un groupe de ligne</span></asp:LinkButton> <%} %> </td> <td valign="top" align="right"> <div style="margin: 0px; text-align: right; font-weight: bold; width: 270px; vertical-align: middle; clip: rect(auto, 0px, auto, auto);"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table> <tr> <td valign="top" rowspan="3" width="30px" align="left"> <asp:Image ID="Image1" runat="server" ImageUrl="~/_images/24/money2.png" /> </td> <td align="left"> <span class="Label">Total HT : </span> </td> <td> <asp:Label ID="lblTotalHT" runat="server" /> </td> </tr> <tr> <td align="left"> <span class="Label">Total TVA : </span> </td> <td> <asp:Label ID="lblTotalTVA" runat="server" /> </td> </tr> <tr> <td align="left"> <span class="Label">Total TTC : </span> </td> <td> <asp:Label ID="lblTotalTTC" runat="server" /> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </div> </td> </tr> </table>
Le contenu de la popup est affiché dans une iframe pointant sur le fichier suivant :
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 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace PecV2.WebApp.Intervention { public partial class GroupeLigneControl : System.Web.UI.UserControl { public Int64 IDFacture { get { object o = ViewState[this.ID.ToString() + "IDFacture"]; if (o == null) { return 0; } else { return (Int64)o; } } set { ViewState[this.ID.ToString() + "IDFacture"] = value; } } public delegate void GroupeLignesControlUpdate_Handler(object sender, EventArgs e); public event GroupeLignesControlUpdate_Handler GroupeLignesControlUpdate; protected virtual void OnGroupeLignesControlUpdate(object sender, EventArgs e) { GroupeLignesControlUpdate(this, e); } protected void Page_Load(object sender, EventArgs e) { } protected void odsGroupeLigne_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["IDFacture"] = IDFacture; } protected void btnAjouterGroupe_Click(object sender, EventArgs e) { PecV2.BL.GroupeLigne monGroupe = new PecV2.BL.GroupeLigne(); monGroupe.IDFacture = IDFacture; PecV2.BL.GroupeLigne.InsertGroupeLigne(monGroupe); lsvGroupeLigne.DataBind(); } protected void lsvGroupeLigne_DataBound(object sender, EventArgs e) { lblTotalHT.Text = PecV2.BL.Facture.GetTotalHT(IDFacture).ToString("c"); lblTotalTVA.Text = PecV2.BL.Facture.GetTotalTVA(IDFacture).ToString("c"); lblTotalTTC.Text = PecV2.BL.Facture.GetTotalTTC(IDFacture).ToString("c"); GroupeLignesControlUpdate(sender, e); } protected void lsvGroupeLigne_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName.ToString() == "mupGroupe") { Int64 IDGrpe; if (Int64.TryParse(e.CommandArgument.ToString(), out IDGrpe)) if (PecV2.BL.GroupeLigne.UpGroup(IDFacture, IDGrpe)) lsvGroupeLigne.DataBind(); } else if (e.CommandName.ToString() == "mdnGroupe") { Int64 IDGrpe; if (Int64.TryParse(e.CommandArgument.ToString(), out IDGrpe)) if (PecV2.BL.GroupeLigne.DownGroup(IDFacture, IDGrpe)) lsvGroupeLigne.DataBind(); } else if (e.CommandName.ToString() == "Dupliquer") { Int64 IDGrpe; Int64 IDBTCible; TextBox txtIDBTCible = (TextBox)e.Item.FindControl("txtIDBTCible"); if (Int64.TryParse(e.CommandArgument.ToString(), out IDGrpe)) if (Int64.TryParse(txtIDBTCible.Text, out IDBTCible)) if (PecV2.BL.GroupeLigne.DupliquerGroupeLigne(IDGrpe, IDBTCible)) lsvGroupeLigne.DataBind(); } } protected void LignesControl1_OnLignesControlUpdate(object sender, EventArgs e) { lsvGroupeLigne.DataBind(); } protected void txtTitre_OnDataBinding(object sender, EventArgs e) { ((TextBox)sender).Focus(); } } }
ArticleIntervention.ascx
et ArticlesIntervention.ascx.cs
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 <%@ Page Title="" Language="C#" AutoEventWireup="true" Inherits="PecV2.WebApp.Articles.ArticlesIntervention" Codebehind="ArticlesIntervention.aspx.cs" %> <%@ Register Src="ArticlesControl.ascx" TagName="ArticlesControl" TagPrefix="uc1" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <%@ Register Src="../Intervention/LignesControl.ascx" TagName="LignesControl" TagPrefix="uc2" %> <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> <%@ Register Src="~/Intervention/GroupeLigneControl.ascx" TagName="GroupeLigneControl" TagPrefix="uc2" %> <!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 id="Head1" runat="server"> <link href="../_styles/pec.css" rel="stylesheet" type="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> div#LignesControl1_UpdatePanel1 { margin-left:auto; margin-right:auto; display:inline; width: 869px; height:150px; overflow-y: scroll; } </style> <title>Choix des articles</title> </head> <body> <form id="form1" runat="server"> <cc1:ToolkitScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"> </cc1:ToolkitScriptManager> <div style=" align-items:center; text-align:center; display:block; overflow:hidden; height:800px;"> <table border="0" cellpadding="0" cellspacing="0" style="margin-left:auto; margin-right:auto; text-align: center;"> <tr> <td valign="top" style="text-align: left"> <div class="DivTitreFamillesArticles"> Familles d'articles </div> <telerik:RadTreeView ID="RadTreeView1" runat="server" Height="615px" Width="220px" Style="border: 1px solid #CBE7F5; display:inline-block" OnNodeExpand="RadTreeView1_NodeExpand" OnNodeClick="TreeViewNodeSelect"> </telerik:RadTreeView> </td> <td> </td> <td> <uc1:ArticlesControl ID="ArticlesControl" runat="server" mMode="Consultation" style="display:inline-block" /> <table> <tr> <td> Nombre d'articles : </td> <td> <asp:TextBox ID="txtNbArticles" runat="server" Width="50px">1</asp:TextBox> <asp:RequiredFieldValidator ID="rfvNbArticles" runat="server" ErrorMessage="Nombre obligatoire" ControlToValidate="txtNbArticles" Display="Dynamic"></asp:RequiredFieldValidator> </td> <td> <asp:Button ID="btnAjouter" runat="server" Text="Ajouter" OnClick="btnAjouter_Click"> </asp:Button> </td> </tr> </table> </td> </tr> </table> <uc2:LignesControl ID="LignesControl" runat="server" IDGroupe='<%# IdGroupe %>' OnLignesControlUpdate="LignesControl_OnLignesControlUpdate" /> </div> </form> </body> </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 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using PecV2.BL; using System.Web.Services; using System.Web.Services.Protocols; using Telerik.Web.UI; namespace PecV2.WebApp.Articles { public partial class ArticlesIntervention : System.Web.UI.Page { protected Int64 IdGroupe = 0; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { getRootNodes(); } if (!(IdGroupe>0)) { IdGroupe = Convert.ToInt64(Request.QueryString["IDGroupe"]); LignesControl.DataBind(); } } protected void TreeViewNodeSelect(object sender, RadTreeNodeEventArgs nodeSelected) { ArticlesControl.IDFamilleArticle = Convert.ToInt64(nodeSelected.Node.Value); ArticlesControl.LibelleFamilleArticle = nodeSelected.Node.Text; ArticlesControl.DataBind(); } protected void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e) { getChildrenNodes(e.Node); } protected void getChildrenNodes(RadTreeNode parentNode) { List<FamilleArticle> mesFamilles = FamilleArticle.GetFamilleArticlesByIDFamilleArticleMere(Convert.ToInt64(parentNode.Value)); foreach (FamilleArticle famille in mesFamilles) { RadTreeNode node = new RadTreeNode(famille.Libelle); node.Value = famille.IDFamilleArticle.ToString(); node.ImageUrl = "../admin/articles/Img/Vista/folder.png"; node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; parentNode.Nodes.Add(node); } } private void getRootNodes() { RadTreeView1.Nodes.Clear(); RadTreeNode root = new RadTreeNode("Tous"); root.Value = "-1"; root.ImageUrl = "../admin/articles/Img/Vista/folder-open.png"; root.Selected = true; root.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; RadTreeView1.Nodes.Add(root); List<FamilleArticle> mesFamilles = FamilleArticle.GetFamilleArticlesRacine(); foreach (FamilleArticle famille in mesFamilles) { RadTreeNode rootNode = new RadTreeNode(famille.Libelle); rootNode.Value = famille.IDFamilleArticle.ToString(); rootNode.ImageUrl = "../admin/articles/Img/Vista/folder.png"; rootNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; RadTreeView1.Nodes.Add(rootNode); } } protected void btnAjouter_Click(object sender, EventArgs e) { List<Int64> maListe = ArticlesControl.ArticlesSelectionnés; // on regarde si on ajoute les articles à un groupe de ligne // groupe de ligne Int64 IdGroupe = Convert.ToInt64(Request.QueryString["IDGroupe"]); Int64 IDTauxTVA = Convert.ToInt64(Request.QueryString["IDTauxTVA"]); foreach (Int64 IdArticle in maListe) { Article lArticle = Article.GetArticleByID(IdArticle); Ligne maLigne = new Ligne(); maLigne.IDGroupe = IdGroupe; maLigne.IDArticle = lArticle.IDArticle; maLigne.IDTauxTva = IDTauxTVA; maLigne.PrixUnitaire = lArticle.PrixUnitaire; maLigne.Hausse = lArticle.Hausse; maLigne.Rabais = lArticle.Rabais; maLigne.CodeClient = lArticle.CodeClient; maLigne.TempsUnitaire = lArticle.TempsUnitaire; maLigne.Unite = lArticle.Unite; maLigne.Denomination = lArticle.Denomination; maLigne.Quantite = Convert.ToDecimal(txtNbArticles.Text.Replace(".", ",")); Ligne.InsertLigne(maLigne); } ArticlesControl.DataBind(); LignesControl.IDGroupe = Convert.ToInt64(Request.QueryString["IDGroupe"]); LignesControl.DataBind(); } public static int GetNexValue(int current, string tag) { return current++; } public static int GetPreviousValue(int current, string tag) { return current > 1 ? current++ : current; } protected void LignesControl_OnLignesControlUpdate(object sender, EventArgs e) { LignesControl.DataBind(); } } }
J'avoue que je suis un peu au bout de mes idées pour ce qui est du débug et je ne trouve pas de réponse à ma question sur internet.
Merci beaucoup de votre aide par avance et n'hésitez pas me demander des précisions sur le fonctionnement si ce n'est pas clair
Bonne soirée, Nico.
Partager