Ejemplo n.º 1
0
        private void Query(HttpContext context)
        {
            var name = context.Request["Name"].Trim();
            var description = context.Request["Description"].Trim();
            var area = context.Request["Area"].Trim();
            var type = context.Request["Type"].Trim();
            var ds = new DataSet();
            var classBll = new BLL.Class();
            var strWhere = "";
            if (!string.IsNullOrEmpty(name))
            {
                strWhere = string.Format(" Name like '%" + name + "%' ");
            }
            if (!string.IsNullOrEmpty(description))
            {
                if (!string.IsNullOrEmpty(strWhere))
                {
                    strWhere += string.Format(" and  Description  like '%" + description + "%' ");
                }
                else
                {
                    strWhere = string.Format(" Description like '%" + description + "%' ");
                }
            }
            if (!string.IsNullOrEmpty(area))
            {
                if (!string.IsNullOrEmpty(strWhere))
                {
                    strWhere += string.Format(" and  Area  like '%" + area + "%' ");
                }
                else
                {
                    strWhere = string.Format(" Area like '%" + area + "%' ");
                }
            }
            if (!string.IsNullOrEmpty(type))
            {
                if (!string.IsNullOrEmpty(strWhere))
                {
                    strWhere += string.Format(" and  Type  like '%" + type + "%' ");
                }
                else
                {
                    strWhere = string.Format(" Type like '%" + type + "%' ");
                }
            }

            var page = Convert.ToInt32(context.Request["page"]);
            var rows = Convert.ToInt32(context.Request["rows"]);

            var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "Name" : context.Request["sort"];
            var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"];

            var startIndex = (page - 1)*rows + 1;
            var endIndex = startIndex + rows - 1;

            var num = classBll.GetRecordCount(strWhere);
            ds = classBll.GetListByPage(strWhere, sort, startIndex, endIndex,order);

            var str = JsonConvert.SerializeObject(new {total = num, rows = ds.Tables[0]});
            context.Response.Write(str);
        }
Ejemplo n.º 2
0
        private string GetData(HttpContext context)
        {
            var ds = new DataSet();
            var classBll = new BLL.Class();

            var page = Convert.ToInt32(context.Request["page"]);
            var rows = Convert.ToInt32(context.Request["rows"]);

            var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "Name" : context.Request["sort"];
            var order = string.IsNullOrEmpty(context.Request["order"]) ? "desc" : context.Request["order"];

            var startIndex = (page - 1) * rows + 1;
            var endIndex = startIndex + rows - 1;

            var num = classBll.GetRecordCount("");
            ds = classBll.GetListByPage("", sort, startIndex, endIndex, order);

            var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] });
            return str;
        }