购物网第三阶段总结笔记4:新品上架页面和特价商品页面

【一】建立页面:newpro.aspx

(1):把数据库中新品上市的商品显示到页面中:

aspx代码:

               <table width="100%" border="0">
                    <tr>
                        <td height="35" bgcolor="#CCCCCC" style="font-weight: bold; padding-left: 10px;">
                            <img src="images/dot_03.gif" width="9" height="9" />
                            新品上架
                        </td>
                    </tr>
                    <tr>
                        <td height="35" align="right" style="padding-right: 20px; border-bottom: 1px #999999 solid;">
                            选择查看方式:
                            <select name="select">
                                <option>按商品关注度排序</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Repeater ID="rep" runat="server">
                            <ItemTemplate>
                             <div class="proitem">
                                <div class="proitem_img">
                                    <a href='pro.aspx?id=<%#Eval("id") %>' title='<%#Eval("proname") %>'>
                                        <img src='upload/<%#Eval("proimg") %>' width="85" height="105" /></a>
                                </div>
                                <div class="proitem_right">
                                    <div>
                                        市场价:<span class="delfont">¥<%#Eval("marketprice") %></span></div>
                                    <div>
                                        会员价:<span class="redfont">¥<%#Eval("memberprice") %></span></div>
                                    <div>
                                        <a href="#">
                                            <img src="images/gm.gif" /></a></div>
                                    <div>
                                        <a href="#">
                                            <img src="images/shc.gif" /></a></div>
                                </div>
                            </div>
                            </ItemTemplate>
                            </asp:Repeater>
                           

                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                           <webdiyer:AspNetPager ID="anp" runat="server"  FirstPageText="首页" 
                                LastPageText="尾页" NextPageText="下一页" NumericButtonCount="5" 
                                PrevPageText="上一页" 
                                CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条" 
                                PageSize="5" ShowCustomInfoSection="Left" AlwaysShow="true" onpagechanged="anp_PageChanged">
                            </webdiyer:AspNetPager>
                        </td>
                    </tr>
                </table>


cs代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class newpro : System.Web.UI.Page
    {
        MyShop.DAL.ProductDAO dao = new MyShop.DAL.ProductDAO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                anp.RecordCount = dao.CalcCount(GetCond());
                BindRep();
            }
        }

        //绑定数据
        private void BindRep()
        {
            rep.DataSource = dao.GetList("*", "createDate", "desc", anp.PageSize, anp.CurrentPageIndex, GetCond());
            rep.DataBind();
        }

        //获取条件
        private string GetCond()
        {
            string cond = "isxp=1";

            return cond;
        }
        //分页
        protected void anp_PageChanged(object sender, EventArgs e)
        {

            BindRep();
        }
    }
}



(2):商品排序
aspx代码:

注意添加: AutoPostBack="true"

                    <tr>
                        <td height="35" align="right" style="padding-right: 20px; border-bottom: 1px #999999 solid;">
                            选择查看方式:
                            <asp:DropDownList ID="ddlorder" runat="server">
                            <asp:ListItem Text="↓按上架时间降序排列" Value="0"></asp:ListItem>
                            <asp:ListItem Text="↑按上架时间升序排列" Value="1"></asp:ListItem>
                            <asp:ListItem Text="↓按商品会员价格降序排列" Value="2"></asp:ListItem>
                            <asp:ListItem Text="↑按商品会员价格升序排列" Value="3"></asp:ListItem>                           
                            </asp:DropDownList>
                        </td>
                    </tr>

cs代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class newpro : System.Web.UI.Page
    {
        MyShop.DAL.ProductDAO dao = new MyShop.DAL.ProductDAO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                anp.RecordCount = dao.CalcCount(GetCond());
                BindRep();
            }
        }

        //绑定数据
        private void BindRep()
        {
            string order = "createDate";
            string ordertype = "desc";
            switch (ddlorder.SelectedValue)
            {
                case "0":
                    order = "createDate";
                    ordertype = "desc";
                    break;
                case "1":
                    order = "createDate";
                    ordertype = "asc";
                    break;
                case "2":
                    order = "memberprice";
                    ordertype = "desc";
                    break;
                case "3":
                    order = "memberprice";
                    ordertype = "asc";
                    break;
                default:
                    break;
            }
            rep.DataSource = dao.GetList("*", order, ordertype, anp.PageSize, anp.CurrentPageIndex, GetCond());
            rep.DataBind();
        }

        //获取条件
        private string GetCond()
        {
            string cond = "isxp=1";

            return cond;
        }
        //分页
        protected void anp_PageChanged(object sender, EventArgs e)
        {

            BindRep();
        }

        //选择排序方式
        protected void ddlorder_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindRep();
        }
    }
}


(3):实现加入收藏按钮【结合购物网第三阶段总结笔记6】

aspx代码:

 <asp:LinkButton ID="LinkButton1" OnClick="Favorite" CommandArgument='<%#Eval("id") %>' runat="server">
<img src="images/shc.gif" />
</asp:LinkButton>

cs代码:

  //加入收藏
        protected void Favorite(object sender, EventArgs e)
        {
            string proid = (sender as LinkButton).CommandArgument;
            MyShop.DAL.FavoriteDAO dao = new MyShop.DAL.FavoriteDAO();
            int y = dao.CalcCount("username='"+User.Identity.Name+"' and proid="+proid);
            if (y!=0)
            {
                 Page.ClientScript.RegisterStartupScript(Page.GetType(), "MsgBox", "<script>alert('该商品您已经收藏过!')</script>");
                 return;
            }
            int x = dao.CalcCount("username='"+User.Identity.Name+"'");
            if (x==10)
            {
                 Page.ClientScript.RegisterStartupScript(Page.GetType(), "MsgBox", "<script>alert('您的收藏夹已满!')</script>");
                 return;
            }
            else
            {
                dao.Add(new MyShop.Model.Favorite() { 
                proid=int.Parse(proid),
                createDate=DateTime.Now,
                username=User.Identity.Name
                });


                Page.ClientScript.RegisterStartupScript(Page.GetType(), "MsgBox", "<script>alert('收藏商品成功!')</script>");
            }
                
        }


 【二】:特价商品页面:tejiapro.aspx,和新品上架一摸一样,这部分视频不用看,笔记省略。




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
购物网站的首页设计是非常重要的,因为它是用户进入网站的第一印象。在设计首页时,我们应该考虑以下几个方面: 1. 页面布局:首页的布局应该简洁明了,使用户能够快速找到他们感兴趣的商品或相关信息。通常使用网站的标志和导航菜单作为页面的主要元素,方便用户浏览网站的不同部分。 2. 高品质图片:购物网站通常会显示商品的图片,所以我们应该选择高品质的图片。这将有助于提升网站的专业性和吸引力,同时也可以帮助用户更好地了解商品的外观和特性。 3. 搜索功能:在首页上添加搜索框是一个好的设计选择。这样用户可以直接在首页上进行商品的搜索,提高用户的搜索效率和体验。 4. 推荐商品和促销信息:首页上可以展示一些热门或推荐的商品,以吸引用户的注意力。同时,我们还可以在首页上宣传一些促销活动或优惠信息,以刺激用户的购买欲望。 登录页面是用户进行购物网站登录和注册的重要界面,设计时需要注意以下几个方面: 1. 界面简洁:登录页面应该尽量简洁,减少冗余内容。只需要展示用户名和密码输入框,同时提供一个登录按钮和注册链接即可。 2. 用户友好的交互:登录页面应该具备友好的用户交互,给用户提供简单明了的登录流程。在输入框中添加合适的提示信息,如"请输入用户名"和"请输入密码",以帮助用户正确地输入信息。 3. 注册选项:登录页面一般都提供注册选项,用户可以通过点击注册链接跳转到注册页面进行注册。在登录页面上,可以添加一个用户注册的链接,方便用户进行注册。 4. 安全性:购物网站登录页面需要保证用户信息的安全性。所以,我们需要使用合适的安全技术,如SSL加密和用户验证等,来保护用户的账号和密码。 总之,购物网站的首页和登录页面设计需要兼顾美观和用户体验。通过简洁清晰的布局、高品质的图片和友好的交互方式,能够吸引用户的访问,并提供便捷的登录和注册流程,增强购物网站的功能和用户体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值