예제 #1
0
        private void get_pro_list(HttpContext context)
        {
            int    page     = DTRequest.GetInt("page", 1);
            int    category = DTRequest.GetInt("category", 0);
            int    uid      = DTRequest.GetInt("uid", 0);
            string keywords = DTRequest.GetString("keywords");
            string city     = DTRequest.GetString("city");

            int count    = 0;
            int pageSize = 8;

            int sum = 0;

            if (uid == 0)
            {
                sum = new BLL.product().GetCount("status=2 and city=" + (city == "未知" ? "city" : "'" + city + "'") + " and category=" + (category == 0 ? "category" : category.ToString()));
            }
            else
            {
                sum = new BLL.product().GetCount("status=2 and user_id=" + uid);
            }


            if ((page - 1) * pageSize >= sum)
            {
                //没有更多数据
                context.Response.Write("{\"status\":0,\"msg\":\"没有更多数据\"}");
                return;
            }
            DataSet ds = new DataSet();

            if (uid == 0)
            {
                ds = new BLL.product().GetList(pageSize, page, "status=2 and city=" + (city == "未知" ? "city" : "'" + city + "'") + " and category=" + (category == 0 ? "category" : category.ToString()) + " and title like '%" + keywords + "%'", "pass_time desc", out count);
            }
            else
            {
                ds = new BLL.product().GetList(pageSize, page, "status=2 and user_id=" + uid, "pass_time desc", out count);
            }

            DataTable dt = ds.Tables[0];

            dt.Columns.Add("zan", typeof(int));
            dt.Columns.Add("collect", typeof(int));
            dt.Columns.Add("view", typeof(int));

            foreach (DataRow dr in dt.Rows)
            {
                dr["view"]    = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=1 and type=1");
                dr["collect"] = new BLL.news_commend().GetCount("news_id=" + dr["id"].ToString());
                dr["zan"]     = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=1 and type=2");
            }


            string strJson = DTcms.Common.JsonHelper.DataTableToJSON(ds.Tables[0]);


            context.Response.Write(strJson);
        }
예제 #2
0
        private void get_news_list(HttpContext context)
        {
            int    page     = DTRequest.GetInt("page", 1);
            string keywords = DTRequest.GetString("keywords");

            int count    = 0;
            int pageSize = 4;
            int sum      = new BLL.news().GetCount("");

            if ((page - 1) * pageSize > sum)
            {
                //没有更多数据
                context.Response.Write("{\"status\":0,\"msg\":\"没有更多数据\"}");
                return;
            }

            DataSet   ds = new BLL.news().GetList(pageSize, page, "title like '%" + keywords + "%'", "sort,time desc", out count);
            DataTable dt = ds.Tables[0];

            dt.Columns.Add("zan", typeof(int));
            dt.Columns.Add("collect", typeof(int));
            dt.Columns.Add("view", typeof(int));
            string[] arr = new string[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                arr[i] = Convert.ToDateTime(dt.Rows[i]["time"].ToString()).ToString("yyyy-MM-dd HH:mm");
            }
            dt.Columns.Remove("time");
            dt.Columns.Add("time", typeof(string));

            foreach (DataRow dr in dt.Rows)
            {
                dr["view"]    = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=2 and type=1");
                dr["collect"] = new BLL.news_commend().GetCount("news_id=" + dr["id"].ToString());
                dr["zan"]     = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=2 and type=2");
                dr["time"]    = arr[dt.Rows.IndexOf(dr)];
            }


            string strJson = DTcms.Common.JsonHelper.DataTableToJSON(ds.Tables[0]);


            context.Response.Write(strJson);
        }
예제 #3
0
        private void get_news_commend(HttpContext context)
        {
            int       news_id = DTRequest.GetInt("id", 0);
            DataTable dt      = new BLL.news_commend().GetList(0, "news_id=" + news_id, "time").Tables[0];

            string[] arr = new string[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                arr[i] = Convert.ToDateTime(dt.Rows[i]["time"].ToString()).ToString("yyyy-MM-dd HH:mm");
            }
            dt.Columns.Remove("time");
            dt.Columns.Add("time");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["time"] = arr[i];
            }

            context.Response.Write(JsonHelper.DataTableToJSON(dt));
        }