Mercurial > pub > bltoolkit
comparison Demo/Asp.Net/Web/Controls/WishListControl.ascx.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.Web.UI.WebControls; | |
4 | |
5 using PetShop.ObjectModel; | |
6 | |
7 namespace PetShop.Web | |
8 { | |
9 public partial class WishListControl : System.Web.UI.UserControl | |
10 { | |
11 /// <summary> | |
12 /// Handle Page load event | |
13 /// </summary> | |
14 protected void Page_PreRender(object sender, EventArgs e) | |
15 { | |
16 if (!IsPostBack) | |
17 BindCart(); | |
18 } | |
19 | |
20 /// <summary> | |
21 /// Bind repeater to Cart object in Profile | |
22 /// </summary> | |
23 private void BindCart() | |
24 { | |
25 ICollection<CartItem> wishList = Profile.WishList.Items; | |
26 | |
27 if (wishList.Count > 0) | |
28 { | |
29 repWishList.DataSource = wishList; | |
30 repWishList.DataBind(); | |
31 } | |
32 else | |
33 { | |
34 repWishList.Visible = false; | |
35 lblMsg.Text = "Your wish list is empty."; | |
36 } | |
37 } | |
38 | |
39 /// <summary> | |
40 /// Handler for Delete/Move buttons | |
41 /// </summary> | |
42 protected void CartItem_Command(object sender, CommandEventArgs e) | |
43 { | |
44 switch (e.CommandName.ToString()) | |
45 { | |
46 case "Del": | |
47 Profile.WishList.Remove(e.CommandArgument.ToString()); | |
48 break; | |
49 | |
50 case "Move": | |
51 Profile.WishList.Remove(e.CommandArgument.ToString()); | |
52 Profile.ShoppingCart.Add(e.CommandArgument.ToString()); | |
53 break; | |
54 } | |
55 | |
56 Profile.Save(); | |
57 BindCart(); | |
58 } | |
59 } | |
60 } |