예제 #1
0
        /// <summary>
        /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定对象的集合</returns>
        public override List <T> FindWithPager(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            PagerHelper helper = new PagerHelper(tableName, this.selectedFields, fieldToSort,
                                                 info.PageSize, info.CurrenetPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(DatabaseType.MySql, true);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string   dataSql = helper.GetPagingSql(DatabaseType.MySql, false);
            List <T> list    = GetList(dataSql, null, trans);

            return(list);
        }
예제 #2
0
        public ActionResult getBlogPageData()
        {
            int pageSize    = Request["pageSize"] == null ? 5 : int.Parse(Request["pageSize"]);
            int pageIndex   = Request["pageIndex"] == null ? 1 : int.Parse(Request["pageIndex"]);
            int totalCount  = _articleServer.GetList().Count();
            var getPageList = _articleServer.GetPageList(pageIndex, pageSize, u => true, a => true, true);

            //接受一个对像,内部把此对象使用javaScript序列化类对象志字符串,发送到前台
            var    data   = from u in getPageList select new { u.Id, u.ArticleTitle, u.AddedDate, u.IsTop, u.Category, u.ThumbPath };
            string strNav = PagerHelper.ShowPageNavigate(pageIndex, pageSize, totalCount);
            var    result = new { Data = data, NavStr = strNav };

            countNow = pageIndex;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public void SendPagerMessage()
        {
            List <string> pagerToList = new List <string> {
                "102", "103"
            };
            PagerHelper pagerHelper = new PagerHelper(pagerToList, "101", "Hello");
            var         jsonData    = "{\"to\": [{\"extensionNumber\": \"" + pagerHelper.to[0] + "\"}, {\"extensionNumber\": \"" + pagerHelper.to[1] + "\"}]," +
                                      "\"from\": {\"extensionNumber\": \"" + pagerHelper.from + "\"},\"text\": \"" + pagerHelper.text + "\"}";
            Request  request = new Request(PagerEndPoint, jsonData);
            Response result  = RingCentralClient.GetPlatform().Post(request);
            JToken   token   = result.GetJson();
            var      id      = (int)token.SelectToken("id");

            Assert.AreEqual(8, id);
        }
예제 #4
0
        /// <summary>
        /// 农机服务信息列表
        /// </summary>
        /// <param name="CatalogID"></param>
        /// <param name="Begin"></param>
        /// <param name="End"></param>
        /// <param name="Type"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public ActionResult Index(int?CatalogID, DateTime?Begin, DateTime?End, InformationType?Type, bool?Verify, int p = 0)
        {
            ViewBag.Level1 = (from c in DB.Catalogs
                              where c.Level == 0 &&
                              !c.Delete &&
                              c.Type == CatalogType.农机服务分类
                              select c).ToList();
            ViewBag.Level2 = (from c in DB.Catalogs
                              where c.Level == 1 &&
                              !c.Delete &&
                              c.Type == CatalogType.农机服务分类
                              select c).ToList();
            ViewBag.Level3 = (from c in DB.Catalogs
                              where c.Level == 2 &&
                              !c.Delete &&
                              c.Type == CatalogType.农机服务分类
                              select c).ToList();
            ViewBag.Level4 = (from c in DB.Catalogs
                              where c.Level == 3 &&
                              !c.Delete &&
                              c.Type == CatalogType.农机服务分类
                              select c).ToList();
            IEnumerable <Information> query = DB.Informations.Where(x => x.Type != InformationType.本地通信息 && x.Type != InformationType.农业信息).ToList();

            if (CatalogID.HasValue)
            {
                query = query.Where(x => x.CatalogID == CatalogID.Value).ToList();
            }
            if (Begin.HasValue)
            {
                query = query.Where(x => x.Time >= Begin.Value).ToList();
            }
            if (End.HasValue)
            {
                query = query.Where(x => x.Time <= End.Value).ToList();
            }
            if (Type.HasValue)
            {
                query = query.Where(x => x.Type == Type.Value).ToList();
            }
            if (Verify.HasValue)
            {
                query = query.Where(x => x.Verify == Verify.Value).ToList();
            }
            query            = query.OrderByDescending(x => x.Top).ThenByDescending(x => x.Time).ToList();
            ViewBag.PageInfo = PagerHelper.Do(ref query, 50, p);
            return(View(query));
        }
예제 #5
0
        private void BindData()
        {
            CheckStockBLL  bll       = null;
            DataPage       dp        = new DataPage();
            CheckStockBill condition = new CheckStockBill();

            try
            {
                bll = BLLFactory.CreateBLL <CheckStockBLL>();
                condition.StartDate = this.StartDate.Text;
                condition.EndDate   = this.EndDate.Text;
                condition.Warehouse = this.Warehouse.SelectedValue;
                condition.AreaID    = this.AreaID.SelectedValue;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <CheckStockBill> list = dp.Result as List <CheckStockBill>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    this.GvList.Rows[i].Cells[6].Text = this.GvList.Rows[i].Cells[6].Text == "0" ? "未确认" : "已确认";

                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["ID"].ToString());

                    LinkButton btEdit = (this.GvList.Rows[i].Cells[9].FindControl("lbtEdit") as LinkButton);
                    if (this.GvList.Rows[i].Cells[6].Text == "已确认")
                    {
                        btEdit.Visible = false;
                    }
                    else
                    {
                        //绑定编辑功能
                        btEdit.Attributes.Add("onclick", click);
                    }

                    //绑定查看功能
                    (this.GvList.Rows[i].Cells[8].FindControl("lbtView") as LinkButton)
                    .Attributes.Add("onclick", "return view('" + this.GvList.DataKeys[i]["ID"].ToString() + "');");
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        private void BindData()
        {
            StockBLL    bll       = null;
            DataPage    dp        = new DataPage();
            WHMatAmount condition = new WHMatAmount();

            try
            {
                bll = BLLFactory.CreateBLL <StockBLL>();
                condition.Warehouse   = this.Warehouse.SelectedValue;
                condition.ProductType = this.ProductType.SelectedValue;
                condition.MatID       = this.MatID.SelectedValue;
                condition.IsDetail    = this.CbxDetail.Checked;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                if (condition.IsDetail == false)
                {
                    this.GvList.Columns[1].Visible  = false;
                    this.GvList.Columns[2].Visible  = false;
                    this.GvList.Columns[8].Visible  = false;
                    this.GvList.Columns[9].Visible  = false;
                    this.GvList.Columns[10].Visible = false;
                    this.GvList.Columns[12].Visible = false;
                    this.GvList.Columns[13].Visible = false;
                }
                else
                {
                    this.GvList.Columns[1].Visible  = true;
                    this.GvList.Columns[2].Visible  = true;
                    this.GvList.Columns[8].Visible  = true;
                    this.GvList.Columns[9].Visible  = true;
                    this.GvList.Columns[10].Visible = true;
                    this.GvList.Columns[12].Visible = true;
                    this.GvList.Columns[13].Visible = true;
                }

                List <WHMatAmount> list = dp.Result as List <WHMatAmount>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
        public List <T> QueryNearBy(Expression <Func <T, bool> > where, int page, int pagesize,
                                    Expression <Func <T, object> > field, GeoInfo point,
                                    double?max_distance = null, double?min_distance = null)
        {
            var condition = Builders <T> .Filter.Empty;

            condition &= Builders <T> .Filter.Near(field, point.Lat, point.Lon, max_distance, min_distance);

            if (where != null)
            {
                condition &= Builders <T> .Filter.Where(where);
            }
            var range = PagerHelper.GetQueryRange(page, pagesize);

            return(this.Set().Find(condition).QueryPage(page, pagesize).ToList());
        }
예제 #8
0
        private void BindData()
        {
            ProcessInfoBLL bll = null;
            DataPage       dp  = new DataPage();

            Manage.Entity.MES.ProcessInfo condition = new Manage.Entity.MES.ProcessInfo();
            string eID = Request.QueryString["eID"];

            if (!string.IsNullOrEmpty(eID))
            {
                if (eID.Split('|')[1] == "F")
                {
                    condition.FACTORYPID = eID.Split('|')[0];
                }
                else
                {
                    condition.FLOWID = eID.Split('|')[0];
                }
            }
            this.HiFLOWID.Value = condition.FLOWID;
            try
            {
                bll             = BLLFactory.CreateBLL <ProcessInfoBLL>();
                condition.PCODE = this.PCODE.Text;
                condition.PNAME = this.PNAME.Text;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <Manage.Entity.MES.ProcessInfo> list = dp.Result as List <Manage.Entity.MES.ProcessInfo>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["PID"].ToString());

                    (this.GvList.Rows[i].Cells[4].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #9
0
        private void BindData()
        {
            UserManageBLL bll = null;
            DataPage      dp  = new DataPage();

            Manage.Entity.Sys.User condition = new Manage.Entity.Sys.User();

            try
            {
                bll = BLLFactory.CreateBLL <UserManageBLL>();
                condition.LoginUserID = this.LoginUserID.Text;
                condition.UserName    = this.UserName.Text;
                condition.OrganID     = this.OrganID.Value;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <Entity.Sys.User> list = dp.Result as List <Entity.Sys.User>;

                foreach (Entity.Sys.User user in list)
                {
                    if (string.IsNullOrEmpty(user.OrganID) == false && user.OrganID == "root")
                    {
                        user.OrganDESC = ConfigurationManager.AppSettings["rootOrgan"];
                    }
                }

                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["UserID"].ToString());

                    (this.GvList.Rows[i].Cells[8].Controls[0] as WebControl).Attributes.Add("onclick", click);

                    LinkButton btWHPowers = this.GvList.Rows[i].Cells[9].FindControl("btWHPowers") as LinkButton;

                    btWHPowers.OnClientClick = "setWHPowers('" + this.GvList.DataKeys[i]["UserID"].ToString() + "');return false;";
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
        public static string GetPagerHtml <T, EXT>(this PagerData <T, EXT> pager, Controller controller, string pageKey, int currentPage, int pageSize)
        {
            var p        = new Dictionary <string, string>();
            var _context = controller.HttpContext;

            var kv = _context.Request.Query.ToDict().Where(x => ValidateHelper.IsNotEmpty(x.Key) && x.Key.ToLower() != pageKey.ToLower()).ToDictionary(x => x.Key, x => ConvertHelper.GetString(x.Value));

            p.AddDict(kv);

            return(PagerHelper.GetPagerHtmlByData(
                       url: _context.Request.PathBase,
                       pageKey: pageKey,
                       urlParams: p,
                       itemCount: pager.ItemCount,
                       page: currentPage,
                       pageSize: pageSize));
        }
예제 #11
0
        public virtual List <T> FindWithPager(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Error(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }
            PagerHelper helper   = new PagerHelper(tableName, this.selectedFields, fieldToSort, info.PageSize, info.CurrentPageIndex, desc, condition);
            string      countSql = helper.GetPagingSql(true);
            string      strCount = SqlValueList(countSql);

            info.RecordCount = Convert.ToInt32(strCount);
            string   dataSql = helper.GetPagingSql(false);
            List <T> list    = GetList(dataSql, null, trans);

            return(list);
        }
예제 #12
0
        private void BindData()
        {
            InspectDeviceBLL    bll       = null;
            DataPage            dp        = new DataPage();
            InspectDeviceEntity condition = new InspectDeviceEntity();

            try
            {
                bll = BLLFactory.CreateBLL <InspectDeviceBLL>();
                condition.DeviceCode = this.DeviceCode.Text;
                condition.DeviceName = this.DeviceName.Text;
                condition.OrganID    = this.OrganID.Text;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <InspectDeviceEntity> list = dp.Result as List <InspectDeviceEntity>;

                CommonDropdown  commonDropdown = new CommonDropdown();
                List <DictInfo> typeList       = commonDropdown.getInspectDeviceType();
                foreach (InspectDeviceEntity ide in list)
                {
                    var temp = typeList.Find(p => p.ID == ide.DeviceType);
                    if (temp != null && temp.Des != null)
                    {
                        ide.DeviceTypeName = temp.Des;
                    }
                }

                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["Id"].ToString());

                    (this.GvList.Rows[i].Cells[14].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #13
0
        private static List <ProductListV2> LoadData(int page)
        {
            var client = new ElasticClient(new Uri("http://172.16.42.28:9200/"));
            var sd     = new SearchDescriptor <ProductListV2>();

            sd = sd.Index("productlist");
            int pagesize = 100;
            var range    = PagerHelper.GetQueryRange(page, pagesize);

            sd = sd.Skip(range[0]).Take(range[1]);
            var response = client.Search <ProductListV2>(x => sd);

            if (response.IsValid)
            {
                return(response?.Hits.Select(x => x.Source).Where(x => x != null).ToList());
            }
            return(null);
        }
예제 #14
0
        /// <summary>
        /// 1.0 HttpGet评论分页 采用递归的方法直接在后台拼接好Ajax评论内容及分页Html,再将json返回到前台
        /// </summary>
        /// <param name="id">博文id</param>
        /// <returns></returns>
        public JsonResult WrapComment(int id)
        {
            int pageIndex = Request["pageIndex"] == null ? 1 : int.Parse(Request["pageIndex"]);
            int pageSize  = Request["pageSize"] == null ? 4 : int.Parse(Request["pageSize"]);

            //1.1 选出当前博文的该页内的一级评论
            List <Comment> topCmtList = commentService.GetPagedList(pageIndex, pageSize, c => c.CmtArtId == id && c.Status == 1 && c.ParentId == 0, c => c.SubTime, true);

            //1.2 创建评论框区域的大容器
            StringBuilder cmtHtmlStr = new StringBuilder("<ol class=\"commentlist\">");

            //1.3 递归获取各级评论,并追加到cmtHtmlString中
            PackCmt(topCmtList, cmtHtmlStr);

            //1.4 合上评论框区域的大容器,评论区域HTML拼接完毕
            cmtHtmlStr.Append("</ol>");

            //1.5 评论总Html
            string cmtHtmlString = cmtHtmlStr.ToString();

            //1.6 评论分页Html
            string cmtPagerString = string.Empty;

            //1.7 该篇博文的所有评论(连带回复)
            int totalCount = commentService.GetDataListBy(c => c.CmtArtId == id && c.Status == 1 && c.ParentId == 0).Count;//分页插件用

            if (totalCount > 0)
            {
                cmtPagerString = PagerHelper.GeneratePagerString(pageIndex, pageSize, totalCount);
                cmtPagerString = "<div class='pagination'>" + "<ul>" + cmtPagerString + "</ul>" + "</div>";
            }

            //1.8 构造json数据
            JsonModel jsonData = new JsonModel()
            {
                CoreData   = cmtHtmlString,
                Status     = 1,
                Message    = "成功",
                GotoUrl    = HttpContext.Request.Url.AbsoluteUri,
                PageNavStr = cmtPagerString
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
예제 #15
0
        private void BindData()
        {
            UseMatBLL  bll       = null;
            DataPage   dp        = new DataPage();
            UseMatBill condition = new UseMatBill();

            try
            {
                bll = BLLFactory.CreateBLL <UseMatBLL>();
                condition.BatchNumber = this.BatchNumber.Text;


                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <UseMatBill> list = dp.Result as List <UseMatBill>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string pid = null;

                    if (this.GvList.DataKeys[i]["PID"] != null)
                    {
                        pid = this.GvList.DataKeys[i]["PID"].ToString();
                        string viewClick = string.Format("return view('{0}');", pid);

                        (this.GvList.Rows[i].Cells[6].FindControl("LinkView") as LinkButton).Attributes.Add("onclick", viewClick);
                        (this.GvList.Rows[i].Cells[6].FindControl("LinkView") as LinkButton).Text     = "查看";
                        (this.GvList.Rows[i].Cells[7].FindControl("LinkBuild") as LinkButton).Visible = false;
                    }
                    else
                    {
                        (this.GvList.Rows[i].Cells[6].FindControl("LinkView") as LinkButton).Enabled = false;
                    }
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #16
0
        private void BindData()
        {
            WorkStationBLL bll       = null;
            DataPage       dp        = new DataPage();
            WorkStation    condition = new WorkStation();
            string         wsID      = Request.QueryString["wsID"];

            if (!string.IsNullOrEmpty(wsID))
            {
                if (wsID.Split('|')[1] == "F")
                {
                    condition.FACTORYPID = wsID.Split('|')[0];
                }
                else
                {
                    condition.PRODUCTLINEPID = wsID.Split('|')[0];
                }
            }
            try
            {
                bll = BLLFactory.CreateBLL <WorkStationBLL>();
                condition.WSCODE = this.WSCODE.Text;
                condition.WSNAME = this.WSNAME.Text;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <WorkStation> list = dp.Result as List <WorkStation>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["PID"].ToString());

                    (this.GvList.Rows[i].Cells[8].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #17
0
        /// <summary>
        /// 根据条件查询数据库,并返回DataTable集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定DataTable的集合</returns>
        public override DataTable FindToDataTable(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Error(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }

            PagerHelper helper = new PagerHelper(tableName, this.selectedFields, fieldToSort,
                                                 info.PageSize, info.CurrentPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(DatabaseType.SqlServer, true);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string dataSql = helper.GetPagingSql(DatabaseType.SqlServer, false);

            return(GetDataTableBySql(dataSql, trans));
        }
예제 #18
0
        /// <summary>
        /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定对象的集合</returns>
        public override List <T> FindWithPager(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_ERR, string.Format("检测出SQL注入的恶意数据, {0}", condition), typeof(BaseDALSQLite <T>));
                throw new Exception("检测出SQL注入的恶意数据");
            }

            PagerHelper helper = new PagerHelper(tableName, this.selectedFields, fieldToSort,
                                                 info.PageSize, info.CurrenetPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(DatabaseType.SQLite, true);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string   dataSql = helper.GetPagingSql(DatabaseType.SQLite, false);
            List <T> list    = GetList(dataSql, null, trans);

            return(list);
        }
예제 #19
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int    pageindex, pagesize, pagecount, recordcount;
            string pIndex = context.Request.QueryString["pageindex"];
            string pSize  = context.Request.QueryString["pagesize"];

            pageindex = String.IsNullOrEmpty(pIndex) ? 1 : int.Parse(pIndex);
            pagesize  = String.IsNullOrEmpty(pSize) ? 3 : int.Parse(pSize);
            UserHandlerBLL bll      = new UserHandlerBLL();
            List <TblArea> list     = bll.GetData(pageindex, pagesize, out pagecount, out recordcount);
            string         strIndex = PagerHelper.strPage(recordcount, pagesize, pagecount, pageindex, "UsersHandler.ashx?pagesize=" + pagesize + "&pageindex=");
            var            sendData = new { _pageData = list, _pageIndex = strIndex };
            //序列化为json格式
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string strJson           = jss.Serialize(sendData);

            context.Response.Clear();
            context.Response.Write(strJson);
            context.Response.End();
        }
예제 #20
0
        private void BindData()
        {
            DataPage       dp        = new DataPage();
            ProducePlan    condition = new ProducePlan();
            ProducePlanBLL bll       = null;

            try
            {
                bll = BLLFactory.CreateBLL <ProducePlanBLL>();
                condition.FACTORYPID   = this.FACTORYPID.SelectedValue;
                condition.PRID         = this.PRID.SelectedValue;
                condition.PRODUCTIONID = this.PRODUCTIONID.SelectedValue;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);
                List <ProducePlan> list = dp.Result as List <ProducePlan>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    if (this.GvList.Rows[i].Cells[8].Text == "0")
                    {
                        this.GvList.Rows[i].Cells[8].Text = "未完成";
                    }
                    else
                    {
                        this.GvList.Rows[i].Cells[8].Text = "已完成";
                    }

                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["PID"].ToString());

                    (this.GvList.Rows[i].Cells[9].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #21
0
        public ActionResult Search(string q)
        {
            var       pageIndex  = Convert.ToInt32(Request["pageIndex"] ?? "1");
            var       pageSize   = 10;
            var       totalCount = 0;
            Stopwatch watch      = new Stopwatch();

            watch.Start();
            // 页码
            ViewBag.Index = pageIndex;
            if (string.IsNullOrWhiteSpace(q))
            {
                ViewBag.Count = 0;
                ViewBag.Time  = 0;
                ViewBag.Page  = 1;
                return(View());
            }

            List <SearchArticleResult> list = null;

            try
            {
                list = PanGuLuceneHelper.Instance.Search(q, pageIndex, pageSize, out totalCount);
            }
            catch (Exception e)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, e.Message);
            }

            // 结果数
            ViewBag.Count = totalCount;
            // 搜索词
            ViewBag.Query = q;
            // 总页数
            ViewBag.Page = PagerHelper.GetTotalPage(pageSize, totalCount);
            watch.Stop();
            // 搜索所需时间
            ViewBag.Time = watch.ElapsedMilliseconds;
            return(View(list));
        }
예제 #22
0
        private void BindData()
        {
            OutStockBLL  bll       = null;
            DataPage     dp        = new DataPage();
            OutStockBill condition = new OutStockBill();

            try
            {
                bll = BLLFactory.CreateBLL <OutStockBLL>();
                condition.StartDate    = this.StartDate.Text;
                condition.EndDate      = this.EndDate.Text;
                condition.OutStockMode = this.OutStockMode.SelectedValue;
                condition.Warehouse    = this.Warehouse.SelectedValue;
                condition.ProductType  = this.ProductType.SelectedValue;
                condition.MatID        = this.MatID.SelectedValue;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <OutStockBill> list = dp.Result as List <OutStockBill>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["ID"].ToString());

                    //绑定编辑功能
                    (this.GvList.Rows[i].Cells[10].Controls[0] as WebControl).Attributes.Add("onclick", click);

                    //绑定查看功能
                    (this.GvList.Rows[i].Cells[11].FindControl("lbtView") as LinkButton).PostBackUrl = "ViewOutStockBill.aspx?id=" + this.GvList.DataKeys[i]["ID"].ToString();
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #23
0
        private void BindData()
        {
            WHMatSpecBLL bll       = null;
            DataPage     dp        = new DataPage();
            WHMatSpec    condition = new WHMatSpec();
            string       matID     = Request.QueryString["matID"];

            try
            {
                bll = BLLFactory.CreateBLL <WHMatSpecBLL>();
                this.MatID.Value = matID;

                WHMat mat = BLLFactory.CreateBLL <WHMatBLL>().Get(new WHMat {
                    ID = matID
                });
                this.MatCode.Text = mat.MatCode;
                this.MatName.Text = mat.MatName;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                condition.MatID = matID;
                dp = bll.GetList(condition, dp);

                List <WHMatSpec> list = dp.Result as List <WHMatSpec>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["ID"].ToString());

                    (this.GvList.Rows[i].Cells[6].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #24
0
        private void BindData()
        {
            WHMatBLL bll       = null;
            DataPage dp        = new DataPage();
            WHMat    condition = new WHMat();

            try
            {
                bll = BLLFactory.CreateBLL <WHMatBLL>();
                condition.MatName = this.Description.Text;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <WHMat> list = dp.Result as List <WHMat>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["ID"].ToString());

                    (this.GvList.Rows[i].Cells[10].Controls[0] as WebControl).Attributes.Add("onclick", click);

                    LinkButton lbtBuildCode = this.GvList.Rows[i].Cells[11].FindControl("lbtBuildCode") as LinkButton;

                    lbtBuildCode.PostBackUrl = "BuildMatIDCode.aspx?matID=" + this.GvList.DataKeys[i]["ID"].ToString();

                    LinkButton lbtSetSpec = this.GvList.Rows[i].Cells[12].FindControl("lbtSetSpec") as LinkButton;

                    lbtSetSpec.PostBackUrl = "ManageMatSpec.aspx?matID=" + this.GvList.DataKeys[i]["ID"].ToString();
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #25
0
        private void BindData()
        {
            OutStockQueryBLL bll       = null;
            DataPage         dp        = new DataPage();
            OutStockBill     condition = new OutStockBill();

            try
            {
                bll = BLLFactory.CreateBLL <OutStockQueryBLL>();
                condition.StartDate = this.StartDate.Value;
                condition.EndDate   = this.EndDate.Value;
                condition.Warehouse = this.WarehouseID.Value;
                condition.MatID     = this.MatID.Value;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetOutMatDetails(condition, dp);

                List <OutStockQueryResult> list = dp.Result as List <OutStockQueryResult>;

                foreach (OutStockQueryResult detail in list)
                {
                    detail.UnitName = string.IsNullOrEmpty(detail.UnitName) == false ? detail.UnitName : detail.MainUnitName;
                    if (detail.Amount == 0)
                    {
                        detail.Amount   = detail.MainUnitAmount;
                        detail.UnitName = detail.MainUnitName;
                    }
                }

                this.GvList.DataSource = list;
                this.GvList.DataBind();

                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #26
0
        private void BindData()
        {
            QualityTraceQueryBLL  bll       = null;
            DataPage              dp        = new DataPage();
            QualityTraceCondition condition = new QualityTraceCondition();

            try
            {
                bll = BLLFactory.CreateBLL <QualityTraceQueryBLL>();
                condition.StartDate          = this.StartDate.Text;
                condition.EndDate            = this.EndDate.Text;
                condition.Factory            = this.Factory.SelectedValue;
                condition.ProductLine        = this.ProductLine.SelectedValue;
                condition.Product            = this.Product.SelectedValue;
                condition.ProductBatchNumber = this.ProductBatchNumber.Text;
                condition.MatIDCode          = this.MatIDCode.Text;
                condition.ProductIDCode      = this.ProductIDCode.Text;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <QualityTraceInfo> list = dp.Result as List <QualityTraceInfo>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    LinkButton lbtQualityTrace = this.GvList.Rows[i].Cells[7].FindControl("lbtQualityTrace") as LinkButton;

                    lbtQualityTrace.OnClientClick = "viewTraceDetail('" + this.GvList.DataKeys[i]["PID"].ToString() + "');return false;";
                }

                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #27
0
        private void BindData()
        {
            StockWarningBLL bll       = null;
            DataPage        dp        = new DataPage();
            WHMatAmount     condition = new WHMatAmount();

            try
            {
                bll = BLLFactory.CreateBLL <StockWarningBLL>();
                condition.Warehouse   = this.Warehouse.SelectedValue;
                condition.ProductType = this.ProductType.SelectedValue;
                condition.MatID       = this.MatID.SelectedValue;
                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <StockWarningResult> list = dp.Result as List <StockWarningResult>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    if (this.GvList.DataKeys[i]["WarningMode"].ToString() == "1")
                    {
                        this.GvList.Rows[i].BackColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        this.GvList.Rows[i].BackColor = System.Drawing.Color.Yellow;
                    }
                }

                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pInfo"></param>
        /// <param name="q"></param>
        /// <returns></returns>
        public static IList <Inpinke_User> GetUserByQueryModel(PageInfo pInfo, UserQueryModels query)
        {
            try
            {
                IList <Inpinke_User> list = new List <Inpinke_User>();
                string field = " U.* ";
                string table = " Inpinke_User U ";
                string where = FormatQModel.FormatQueryModel <UserQueryModels>(query);
                string orderby = " U.ID ";

                string countQ = PagerHelper.GetCountSQL(table, where);
                string qSql   = PagerHelper.GetPager(table, pInfo.Skip, pInfo.PageSize, field, orderby, where);
                pInfo.Total = InpinkeDataContext.Instance.ExecuteQuery <int>(countQ).FirstOrDefault();
                list        = InpinkeDataContext.Instance.ExecuteQuery <Inpinke_User>(qSql).ToList();

                return(list);
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("GetUserByQueryModel Error:{0}", ex.ToString()));
                return(null);
            }
        }
예제 #29
0
        /// <summary>
        /// 供应商列表
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="Phone"></param>
        /// <param name="Name"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public ActionResult Provider(string Title, string Phone, string Name, ProviderStatus?Status, int p = 1)
        {
            IEnumerable <Provider> query = DB.Providers.Where(x => !x.Delete).ToList();

            if (Status.HasValue)
            {
                query = query.Where(x => x.Status == Status.Value).ToList();
            }
            if (!string.IsNullOrEmpty(Title))
            {
                query = query.Where(x => x.Title.Contains(Title) || Title.Contains(x.Title)).ToList();
            }
            if (!string.IsNullOrEmpty(Phone))
            {
                query = query.Where(x => x.Phone == Phone).ToList();
            }
            if (!string.IsNullOrEmpty(Name))
            {
                query = query.Where(x => x.Name == Name).ToList();
            }
            ViewBag.PageInfo = PagerHelper.Do(ref query, 50, p);
            return(View(query));
        }
예제 #30
0
        /// <summary>
        /// 用户列表
        /// </summary>
        /// <param name="Username"></param>
        /// <param name="Role"></param>
        /// <param name="Name"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public ActionResult Index(string Username, UserRole?Role, string Name, int p = 0)
        {
            IEnumerable <User> query = DB.Users.Where(x => !x.Delete).ToList();

            if (!string.IsNullOrEmpty(Username))
            {
                query = query.Where(x => x.Username == Username).ToList();
            }
            if (!string.IsNullOrEmpty(Name))
            {
                query = query.Where(x => x.Name != null && x.Name.Contains(Name)).ToList();
            }
            if (Role.HasValue)
            {
                query = query.Where(x => x.Role == Role.Value).ToList();
            }
            if (CurrentUser.Role == UserRole.大区经理)
            {
                query = query.Where(x => x.ManagerID == CurrentUser.ID).ToList();
            }
            ViewBag.PageInfo = PagerHelper.Do(ref query, 50, p);
            return(View(query));
        }
예제 #31
0
        public static MvcHtmlString Pager(this HtmlHelper helper, int currentPage, int pageSize, int totalItemCount, object routeValues)
        {
            var pagerHelper = new PagerHelper(currentPage, pageSize, totalItemCount, 10);

            var urlHelper = new UrlHelper(helper.ViewContext.RequestContext, helper.RouteCollection);
            var query = helper.ViewContext.RequestContext.HttpContext.Request["q"];
            string queryString = !string.IsNullOrEmpty(query) ? "&q=" + query : string.Empty;
            var container = new TagBuilder("div");
            container.AddCssClass("pager");
            var actionName = helper.ViewContext.RouteData.GetRequiredString("Action");

            // if we are past the first page
            if (currentPage > 1)
            {
                var previous = new TagBuilder("a");
                previous.SetInnerText("<");
                previous.AddCssClass("previous");
                var routingValues = new RouteValueDictionary(routeValues);
                routingValues.Add("page", currentPage - 1);
                previous.MergeAttribute("href", urlHelper.Action(actionName, routingValues) + queryString);
                container.InnerHtml += previous.ToString();
            }

            // if we have past the first page group
            if (currentPage > pagerHelper.GroupSize)
            {
                var previousDots = new TagBuilder("a");
                previousDots.SetInnerText("...");
                previousDots.AddCssClass("previous-dots");
                var routingValues = new RouteValueDictionary(routeValues);
                routingValues.Add("page", pagerHelper.GroupStart - pagerHelper.GroupSize);
                previousDots.MergeAttribute("href", urlHelper.Action(actionName, routingValues) + queryString);
                container.InnerHtml += previousDots.ToString();
            }

            for (var i = pagerHelper.GroupStart; i <= pagerHelper.GroupEnd; i++)
            {
                var pageNumber = new TagBuilder("a");
                pageNumber.AddCssClass(((i == pagerHelper.CurrentPage)) ? "selected-page" : "page");
                pageNumber.SetInnerText((i).ToString());
                var routingValues = new RouteValueDictionary(routeValues);
                routingValues.Add("page", i);
                pageNumber.MergeAttribute("href", urlHelper.Action(actionName, routingValues) + queryString);
                container.InnerHtml += pageNumber.ToString();
            }

            // if there are still pages past the end of this page group
            if (pagerHelper.PageCount > pagerHelper.GroupEnd)
            {
                var nextDots = new TagBuilder("a");
                nextDots.SetInnerText("...");
                nextDots.AddCssClass("next-dots");
                var routingValues = new RouteValueDictionary(routeValues);
                routingValues.Add("page", pagerHelper.GroupEnd + 1);
                nextDots.MergeAttribute("href", urlHelper.Action(actionName, routingValues) + queryString);
                container.InnerHtml += nextDots.ToString();
            }

            // if we still have pages left to show
            if (pagerHelper.CurrentPage < pagerHelper.PageCount)
            {
                var next = new TagBuilder("a");
                next.SetInnerText(">");
                next.AddCssClass("next");
                var routingValues = new RouteValueDictionary(routeValues);
                routingValues.Add("page", currentPage + 1);
                next.MergeAttribute("href", urlHelper.Action(actionName, routingValues) + queryString);
                container.InnerHtml += next.ToString();
            }

            return MvcHtmlString.Create(container.ToString());
        }