예제 #1
0
    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("#");
        }
    }
예제 #2
0
    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();
    }
예제 #3
0
    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();
    }
예제 #4
0
    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;
        }
    }
예제 #5
0
    /// <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();
    }