예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //加载页面商品
                eShopDatabaseEntities eShop = new eShopDatabaseEntities();

                var query = from info in eShop.GoodsInfo
                            join img in eShop.GoodsImg on info.Id equals img.GoodId
                            where img.ImgLevel == 0
                            select new
                {
                    Id        = info.Id,
                    GoodName  = info.GoodName,
                    GoodPrice = info.GoodPrice,
                    ImgUrl    = img.ImgUrl
                };


                this.lvGoodList.DataSource = query.ToList();
                this.lvGoodList.DataBind();
            }
            if (Session["User"] != null)
            {
                this.lbtnAdminLogin.Visible = false;
                this.lbtnLogin.Visible      = false;
                this.lbtnRegister.Visible   = false;
                this.lbtnUserOrder.Visible  = true;
                this.lbtnAddress.Visible    = true;
                this.btnCart.Visible        = true;

                this.labHello.Text = "你好!用户 " + ((Users)Session["User"]).UserName;
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    int goodId = Int32.Parse(Request.QueryString["id"].ToString());

                    eShopDatabaseEntities eShop = new eShopDatabaseEntities();

                    var query = from info in eShop.GoodsInfo
                                join img in eShop.GoodsImg on info.Id equals img.GoodId
                                join seller in eShop.Sellers on info.AdderId equals seller.Id
                                where img.ImgLevel == 0 && info.Id == goodId
                                select new
                    {
                        GoodName  = info.GoodName,
                        GoodPrice = info.GoodPrice,
                        AddedDate = info.AddedDate,
                        GoodImg   = img.ImgUrl,
                        Adder     = seller.SellerName,
                        Remark    = info.Remark
                    };

                    this.FormViewItem.DataSource = query.ToList();
                    this.FormViewItem.DataBind();
                }
            }
        }