private void GetInfo(int id) { Product product = _productBLL.Select(id); if (product != null) { txtProductName.Text = product.ProductName; txtNormalPrice.Text = product.NormalPrice.ToString("#"); txtMemberPrice.Text = product.MemberPrice.ToString("#"); } }
private void BindRepeater() { PagerItem pagerItem = new PagerItem(); pagerItem.CurrentPage = _currentPage; pagerItem.PageSize = 15; pagerItem.Keywords = ""; IProductBLL productBLL = (IProductBLL)SpringContext.Context.CreateSecurityProxyInstance("ProductBLL"); rpt.DataSource = productBLL.Select(pagerItem); rpt.DataBind(); }
private void List() { int currentPage = 1; int.TryParse(Request.QueryString["page"], out currentPage); if (currentPage <= 0) { currentPage = 1; } PagerItem pagerItem = new PagerItem(); pagerItem.CurrentPage = currentPage; pagerItem.PageSize = 15; pagerItem.Keywords = ""; IProductBLL productBLL = (IProductBLL)SpringContext.Context.CreateInstance("ProductBLL"); IList list = productBLL.Select(pagerItem); int count = list.Count; StringBuilder result = new StringBuilder(); result.Append("{result:["); if (count > 0) { for (int i = 0; i < count; i++) { Model.Product product = (Model.Product)list[i]; result.Append("{ID:").Append(product.ID).Append(","); result.Append("ProductName:\"").Append(product.ProductName).Append("\","); result.Append("NormalPrice:").Append(product.NormalPrice).Append(","); result.Append("MemberPrice:").Append(product.MemberPrice).Append("}"); if (i < count - 1) { result.Append(","); } } } result.Append("]}"); Response.Write(result.ToString()); Response.End(); }
protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e) { int productId = int.Parse(e.CommandArgument.ToString()); IProductBLL productBLL = (IProductBLL)SpringContext.Context.CreateSecurityProxyInstance("ProductBLL"); switch (e.CommandName.ToLower()) { case "delete": productBLL.Delete(productId); Response.Redirect("ProductList.aspx", true); break; case "putcar":; Product product = productBLL.Select(productId); OrderProduct orderProduct = new OrderProduct(); orderProduct.Num = 1; orderProduct.ProductID = productId; orderProduct.ProductName = product.ProductName; IUserBLL userBLL = (IUserBLL)SpringContext.Context.CreateSecurityProxyInstance("UserBLL"); ICustomBLL customBLL = (ICustomBLL)SpringContext.Context.CreateSecurityProxyInstance("CustomBLL"); if (customBLL.Select(userBLL.UserID).IsMember) { orderProduct.Price = product.MemberPrice; } else { orderProduct.Price = product.NormalPrice; } IShopCarBLL shopCarBLL = (IShopCarBLL)SpringContext.Context.CreateSecurityProxyInstance("ShopCarBLL"); shopCarBLL.Add(orderProduct); Response.Redirect("ShopCar.aspx", true); break; default: break; } }
/// <summary> /// 向购物车添加产品 /// </summary> private void Add() { string id = Request.QueryString["productId"]; if (!string.IsNullOrEmpty(id)) { int productId = 0; int.TryParse(id, out productId); IProductBLL productBLL = (IProductBLL)SpringContext.Context.CreateInstance("ProductBLL"); Model.Product product = productBLL.Select(productId); OrderProduct orderProduct = new OrderProduct(); orderProduct.Num = 1; orderProduct.ProductID = productId; orderProduct.ProductName = product.ProductName; IUserBLL userBLL = (IUserBLL)SpringContext.Context.CreateInstance("UserBLL"); ICustomBLL customBLL = (ICustomBLL)SpringContext.Context.CreateInstance("CustomBLL"); if (customBLL.Select(userBLL.UserID).IsMember) { orderProduct.Price = product.MemberPrice; } else { orderProduct.Price = product.NormalPrice; } shopCarBLL.Add(orderProduct); Response.Write("{success:true}"); } else { Response.Write("{success:false}"); } Response.End(); }