zoukankan      html  css  js  c++  java
  • 牛腩购物网31:产品搜索的制作,投票的制作,投票的div的长度

    搜索前台:

    关键字:<asp:TextBox ID="txtKey" runat="server"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                 <asp:LinkButton ID="lbtnSearch" runat="server" OnClick="lbtnSearch_Click">搜索</asp:LinkButton>

     

    后台:

    //搜索,记得要对搜索的字符进行转码
            protected void lbtnSearch_Click(object sender, EventArgs e)
            {
                string key = txtKey.Text.Trim();
                if (key.Length == 0)
                {
                    Utility.Tool.alert("关键字不能为空", this.Page);
                    return;
                }
                else
                {
                   key=Server.UrlEncode(key);
                   Response.Redirect("/prolist.aspx?key=" + key);
                }
            }

     

    搜索的页面:

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    string caid = Request.QueryString["caid"];
                    int x;
                    if (int.TryParse(caid, out x))
                    {
                        anp.RecordCount = ptdao.CalcCount(getCond());
                        BindRep();
                    }
                    string key = Request.QueryString["key"];
                    if (!string.IsNullOrEmpty(key))
                    {
                        anp.RecordCount = ptdao.CalcCount(getCond());
                        BindRep();
                    }
                    //else
                    //{
                    //    Response.Write("参数传入错误");
                    //    Response.End();
                    //}
                }
            }

     

    private void BindRep()
            {
                string order = "createdate";
                string ordertype = "desc";
    
                switch (ddlOrder.SelectedValue)
                {
                    case "0":
                        order = "createdate"; ordertype = "asc";  //升序,从小到大  
                        break;
                    case "1":
                        order = "createdate"; ordertype = "desc"; //降序
                        break;
                    case "2":
                        order = "memberprice"; ordertype = "asc";
                        break;
                    case "3":
                        order = "memberprice"; ordertype = "desc";
                        break;
                    default:
                        break;
                }
                rep.DataSource = ptdao.GetList("*", order, ordertype, anp.PageSize, anp.CurrentPageIndex, getCond());
                rep.DataBind();
            }
            //获取条件
            private string getCond()
            {
                string cond = "";
    
                //这里要先判断传过来的关键字查询
                string key = Request.QueryString["key"];
                if (!string.IsNullOrEmpty(key))
                {
                    key = Server.UrlDecode(key);
                    key = Utility.Tool.GetSafeSQL(key);
                    cond = "proname like '%"+key+"%'";
                    return cond;
                }
    
                string caid = Request.QueryString["caid"];
                    int x;
                if (int.TryParse(caid, out x))
                {
                    cond += "caid=" + x; //这里还是有错的,因为只是求出了一个类别的,但是假如这是个大类的,那么大类以下的没有显示出来
                }
                return cond;
            }

    投票表:

    shop_vote:id,create,ip,vote

    投票的长度,假设我们把投票用2个 div 来显示, 完整的长度是250 ,满意的部分我们用 绿色,不满意就用蓝色

    满意票为4票:      那么 满意票的DIV的长度就为 250*(4/5)

    不满意票数为1票:  不满意的div的长度为    250*(1/5)

  • 相关阅读:
    svn搭建多版本共存记录
    python中使用redis
    小程序之使用腾讯地图获取经纬度
    vue路由元之进入路由需要用户登录权限功能
    input type="tel" 数字输入框显示圆点
    input在IOS中的聚焦问题
    JS实现手机号码中间4位变星号
    CSS实现div填充剩余高度
    小程序之地图导航
    小程序之点击图片放大预览
  • 原文地址:https://www.cnblogs.com/iceicebaby/p/2469797.html
Copyright © 2011-2022 走看看