Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int       index = int.Parse(Request.Params["PageIndex"].ToString());
            int       size  = int.Parse(Request.Params["PageSize"].ToString());
            int       begin = (index - 1) * size;
            DataTable da    = Page.Selects(@"select * from goods order by id asc limit " + begin + "," + size + "");
            DataTable count = Page.Selects(@"select count(*) from goods");

            Response.Write(SqlHelper.DataTableToJSON(da));
            Response.End();
        }
Exemple #2
0
        public DataTable GetProductClass()
        {
            string strSql = "select id,className from goodsclass";

            SqlOper.SqlHelper sqlOper = new SqlOper.SqlHelper();
            return(sqlOper.Selects(strSql));
        }
Exemple #3
0
        /// <summary>
        /// 模糊查询
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public DataTable GetLikeSelect(string id, string name)
        {
            SqlOper.SqlHelper like = new SqlOper.SqlHelper();
            DataTable         dt   = like.Selects(@"select id,GoodsName,Price,Title,GoodsDetail,Photos from goods where id like '%" + id + "%' or GoodsName like '%" + name + "%'");

            return(dt);
        }
Exemple #4
0
        /// <summary>
        /// 显示评论列表+分页
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, object> SelComment(int index, int size)
        {
            int begin = (index - 1) * size;
            //根据最新日期排序
            string CommentStr   = @"select id,Name,Email,Phone,Message,Whetherread,deleted ,Created from messageboard where deleted=0 ORDER BY Created DESC limit " + begin + "," + size + "";
            string CommentCount = @"select count(*) from messageboard where deleted=0";

            SqlOper.SqlHelper Com = new SqlOper.SqlHelper();

            string Comstr   = SqlHelper.DataTableToJSON(Com.Selects(CommentStr));
            string ComCount = SqlHelper.DataTableToJSON(Com.Selects(CommentCount));
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("Comstr", Comstr);
            dic.Add("ComCount", ComCount);
            return(dic);
        }
Exemple #5
0
        public DataTable GetProductList()
        {
            string strSql = "select g.id,GoodsName,Price,Title,GoodsDetail,Photos,gc.className from goods g inner join goodsclass gc on gc.id=g.ClassID where Deleted=0";

            SqlOper.SqlHelper sh = new SqlOper.SqlHelper();
            DataTable         dt = sh.Selects(strSql);

            return(dt);
        }
Exemple #6
0
        /// <summary>
        /// 分页,模糊查询
        /// </summary>
        /// <param name="size">每页显示多少条数据</param>
        /// <param name="index">当前页</param>
        /// <param name="Goodno">按商品编号模糊查询</param>
        /// <param name="name">按商品名称模糊查询</param>
        /// <param name="Proclassify">按商品分类选中值查询</param>
        /// <param name="CheckBox1">首页推荐查询</param>
        /// <param name="CheckBox2">首页展示查询</param>
        /// <returns></returns>
        public Dictionary <string, object> GetProductPage(int size, int index, string Goodno, string name, string Proclassify, string CheckBox1, string CheckBox2)
        {
            int begin = (index - 1) * size;

            SqlOper.SqlHelper Page     = new SqlOper.SqlHelper();
            string            strWhere = "";

            if (Goodno.Trim() != "")
            {
                strWhere += " and ( GoodsNo like '%" + Goodno + "%')";
            }
            if (name.Trim() != "")
            {
                if (strWhere == "")
                {
                    strWhere += "and (";
                }
                else
                {
                    strWhere = strWhere.Substring(0, strWhere.Length - 1) + " or ";
                }
                strWhere += "  GoodsName like '%" + name + "%' )";
            }
            if (Proclassify != "")
            {
                strWhere += " and g.ClassID = '" + Proclassify + "' ";
            }
            if (CheckBox1 != null)
            {
                strWhere += " and HomeRecommend=1 ";
            }
            if (CheckBox2 != null)
            {
                strWhere += " and HomeShow=1 ";
            }
            DataTable da    = Page.Selects(@"select g.id,GoodsNo,GoodsName,c.className,Price,Title,GoodsDetail,HomeShow,HomeRecommend,Photos,Created from goods g inner join goodsclass c on c.id=g.ClassID where Deleted=0 " + strWhere + " order by id desc limit " + begin + "," + size + "");
            string    count = SqlHelper.DataTableToJSON(Page.Selects("select count(*) as count from goods g inner join goodsclass c on c.id=g.ClassID where Deleted=0 " + strWhere));
            string    data  = SqlHelper.DataTableToJSON(da);
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("data", data);
            dic.Add("count", count);
            return(dic);
        }
Exemple #7
0
        public DataTable GetProductListByClassID(string classID, string pageIndex, string searchText)
        {
            string w = "";

            if (!classID.Equals("0"))
            {
                w = " and g.classid=" + classID;
            }
            if (!"".Equals(searchText))
            {
                w = " and GoodsName like '%" + searchText + "%' ";
            }
            SqlOper.SqlHelper sqlOper   = new SqlOper.SqlHelper();
            string            pageCount = Utils.GetConfigByKey("PageCount");
            string            strSql    = "select g.id,GoodsName,c.id classid,c.className,Price,Title,GoodsDetail,Photos  from goods g inner join goodsclass c on c.id=g.classid where Deleted=0 " + w;

            strSql += " ORDER BY Created ASC limit " + ((Convert.ToInt32(pageIndex) - 1) * Convert.ToInt32(pageCount)) + "," + pageCount;

            return(sqlOper.Selects(strSql));
        }