//管理员管理 public ActionResult Manage(string search) { //分页设置 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 10;//页面记录数 List <Admin> mlist = new List <Admin>(); int adminId = Convert.ToInt32(Session["AdminId"]); //查询记录 if (string.IsNullOrEmpty(search)) { mlist = Entity.Admin.Where(a => true && a.Id != adminId).OrderByDescending(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <Admin>(); } else { mlist = Entity.Admin.Where(a => a.Id != adminId && (a.AdminName.Contains(search) || a.Name.Contains(search) || a.Tel.Contains(search))).OrderByDescending(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <Admin>(); } int listCount = Entity.Admin.Where(a => true && a.Id != adminId).Count(); //生成导航条 string strBar = PageBarHelper.GetPagaBar(pageIndex, listCount, pageSize); ViewData["List"] = mlist; ViewData["Bar"] = strBar; return(View()); }
//用户管理 public ActionResult UserInfoManage(string search) { //分页设置 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 10;//页面记录数 List <UserInfo> mlist = new List <UserInfo>(); //查询记录 if (string.IsNullOrEmpty(search)) { mlist = Entity.UserInfo.Where(a => true).OrderByDescending(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <UserInfo>(); } else { mlist = Entity.UserInfo.Where(a => a.StuNo.Contains(search) || a.Name.Contains(search) || a.Tel.Contains(search)).OrderByDescending(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <UserInfo>(); } int listCount = Entity.UserInfo.Where(a => true).Count(); //生成导航条 string strBar = PageBarHelper.GetPagaBar(pageIndex, listCount, pageSize); ViewData["List"] = mlist; ViewData["Bar"] = strBar; return(View()); }
//自习室管理 public ActionResult Manage(string search) { //计算空余座位 SetEmptySeat(); //分页设置 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 6;//页面记录数 List <StuRoom> mlist = new List <StuRoom>(); //查询记录 if (string.IsNullOrEmpty(search)) { mlist = Entity.StuRoom.Where(a => true).OrderBy(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <StuRoom>(); } else { mlist = Entity.StuRoom.Where(a => a.Name.Contains(search)).OrderBy(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <StuRoom>(); } int listCount = Entity.StuRoom.Where(a => true).Count(); //生成导航条 string strBar = PageBarHelper.GetPagaBar(pageIndex, listCount, pageSize); ViewData["List"] = mlist; ViewData["Bar"] = strBar; return(View()); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Bll.UserInfoBll userInfoBll = new Bll.UserInfoBll(); int pageIndex; if (!int.TryParse(context.Request["pageIndex"], out pageIndex)) { pageIndex = 1; } int pageSize = 3; int pageCount = userInfoBll.GetPageCount(pageSize);//获取总页数 //判断当前页码值的取值范围 pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; //获取分页数据 List <UserInfo> list = userInfoBll.GetPageList(pageIndex, pageSize); //获取页码条 string pageBar = PageBarHelper.GetPageBar(pageIndex, pageCount); //用微软提供的 JavaScriptSerializer 类将数据序列化成Json字符串 System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); string str = js.Serialize(new { UList = list, MyPageBar = pageBar });//用匿名类把分页数据和页码条写到一起 context.Response.Write(str); }
/// <summary> /// 搜索内容 /// </summary> /// <returns></returns> public ActionResult SearchContent() { List <ViewModelContent> list = ShowSearchContent(); //实现分页功能 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 10;//页面记录数 int listCount = list.Count; list = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();//分页 //生成导航条 string search = Request["txtSearch"].Trim(); string strBar = PageBarHelper.GetPageBar(pageIndex, listCount, pageSize, 5, search); ViewData["mPageBar"] = strBar; ViewData["list"] = list; return(View("Index")); //if (!string.IsNullOrEmpty(Request["btnSearch"])) //{ // List<ViewModelContent> list = ShowSearchContent(); // ViewData["list"] = list; // return View("Index"); //} //else //{ // CreateSerachContent(); //} //return Content("ok"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; string effectId = context.Request.QueryString["effect"]; int pageSize = 8; int pageIndex; if (!int.TryParse(context.Request.QueryString["pageIndex"], out pageIndex)) { pageIndex = 1; } int pageCount = GoodsBLL.GetGoodsPageCount(pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; List <GoodModel> GoodsList = GoodsBLL.GetGoodsList(pageIndex, pageSize); //string sqlText = GoodsBLL.getPaginationSql(0, pageSize, "goods", "*", "Goods_is_delete = 0", "goods_id"); string temp = File.ReadAllText(context.Server.MapPath("drugstore_all.html")); StringBuilder sb = new StringBuilder(); if (GoodsList == null) { temp = temp.Replace("@content", "该类型的商品还未上架,敬请期待."); } else { foreach (GoodModel item in GoodsList) { sb.AppendFormat(@"<div class='col-lg-3' ><div class='thumbnail'><img src='{4}' style='height: 300px' alt='...'><div class='caption'><h3>{0}</h3><p>{1}元</p><p>总销量:{2}</p><p><a href='ProcessDrugDetails.ashx?goods_id={3}' class='btn btn-primary' role='button'>查看详情</a> <a href='../ShopCartInfo/ProcessAddCart.ashx?goods_id={3}' class='btn btn-default' role='button'>加入购物车</a></p></div></div></div>", item.GoodsName, item.GoodsPrice, item.GoodsSalesVolume, item.GoodsId, "../Images/product_img/" + item.GoodsPicture); } } temp = temp.Replace("@page", PageBarHelper.GetPageBar(pageIndex, pageCount)); temp = temp.Replace("@content", sb.ToString()); if (context.Session["users_id"] != null) { temp = temp.Replace("@user_name", context.Session["user_name"].ToString()); } else { temp = temp.Replace("@user_name", "游客"); } context.Response.Write(temp); }
//计算第一名 private void CalculationRank() { //统计学习记录 List <Study> studyList = new List <Study>(); //设置分页 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 2;//页面记录数 //获取所有用户 var userList = Entity.UserInfo.Where(a => true).ToList(); UserInfo user = new UserInfo(); TimeSpan maxTimeSpan = new TimeSpan(); Study study = null; //查询第一名 foreach (var item in userList) { study = new Study(); study.UserInfo = item; if (item.SeatDetail != null && item.SeatDetail.Count > 0) { TimeSpan span = CommonTool.CalculationStudyTime(item.SeatDetail.ToList());//获取学习时间 if (span > maxTimeSpan) { maxTimeSpan = span; user = item; } study.Count = item.SeatDetail.Count; study.TimeSpan = span; study.FormartTimeSpan = CommonTool.SetStudyTimeFormat(span).ToString(); } studyList.Add(study); } ViewData["UserName"] = user.Name; StringBuilder sb = CommonTool.SetStudyTimeFormat(maxTimeSpan); ViewData["MaxTimeSpan"] = sb.ToString(); ViewData["MaxCount"] = user.SeatDetail.Count; //生成导航条 string strBar = PageBarHelper.GetPagaBar(pageIndex, studyList.Count, pageSize); //设置每页展示指定的记录 studyList = studyList.Where(a => true).OrderBy(a => a.UserInfo.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <Study>(); ViewData["List"] = studyList; ViewData["Bar"] = strBar; }
public ActionResult ShowUserInfo() { if (Session["UserLogin"] == null) { return(RedirectToAction("Login")); } //将查询到的数据记录分页显示代码 int totalCount; int pageIndex = Convert.ToInt32(Request.QueryString["pageIndex"]); var userInfoList = iUserDal.LoadPageEntity <string>(pageIndex, 10, out totalCount, s => true, ss => ss.UserID, true); ViewBag.PageList = PageBarHelper.GetPagaBar(pageIndex, totalCount); return(View(userInfoList)); }
/// <summary> /// 搜索记录 /// </summary> /// <returns></returns> public ActionResult SearchDetail() { //分页设置 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 5;//页面记录数 List <SearchDetail> mlist = new List <SearchDetail>(); mlist = DB.SearchDetail.Where(a => true).OrderByDescending(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); int listCount = DB.SearchDetail.Where(a => true).Count(); //生成导航条 string strBar = PageBarHelper.GetPageBar(pageIndex, listCount, pageSize); ViewData["List"] = mlist; ViewData["PageBar"] = strBar; return(View()); }
public ActionResult ShowEmployee() { if (Session["UserLogin"] == null) { return(RedirectToAction("Login")); } var boolEmployee = iEmpDal.LoadEntity(u => true); if (boolEmployee == null) { return(RedirectToAction("Index")); } int Count; int pageIndex = Convert.ToInt32(Request.QueryString["pageIndex"]); var userInfoList = iEmpDal.LoadPageEntity <int>(pageIndex, 10, out Count, s => true, sb => sb.EmpoloyeeID, true); ViewBag.PageList = PageBarHelper.GetPagaBar(pageIndex, Count); return(View(userInfoList)); }
//查看所有座位 public ActionResult Manage(string search) { //设置保留座位的状态 SetSeatState(); //分页设置 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; search = Request.QueryString["search"] != null ? Request.QueryString["search"].ToString() : search; int pageSize = 15;//页面记录数 List <Seat> mlist = new List <Seat>(); var roomList = Entity.StuRoom.Where(a => true).OrderBy(a => a.Id).ToList(); //查询默认值 if (string.IsNullOrEmpty(search)) { if (roomList != null && roomList.Count > 0) { search = roomList[0].Name; } } //查询记录 if (string.IsNullOrEmpty(search)) { mlist = Entity.Seat.Where(a => true).OrderBy(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <Seat>(); } else { mlist = Entity.Seat.Where(a => a.StuRoom.Name.Contains(search)).OrderBy(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <Seat>(); } int listCount = Entity.Seat.Where(a => a.StuRoom.Name.Contains(search)).Count(); //生成导航条 string strBar = PageBarHelper.GetPagaBar(pageIndex, listCount, pageSize, search); ViewData["List"] = mlist; ViewData["Bar"] = strBar; ViewData["roomList"] = roomList; ViewData["search"] = search; return(View()); }
///// <summary> ///// 网站首页信息的创建(其实网站完成以后) ///// </summary> ///// <returns></returns> //public ActionResult CreateHomeCor() //{ // if (Session["UserLogin"] == null) // { // return RedirectToAction("Login"); // } // return View(); //} //[HttpPost] //public ActionResult CreateHomeCor(HomeCor homeCor, HttpPostedFileBase image) //{ // if (Session["UserLogin"] == null) // { // return RedirectToAction("Login"); // } // homeCor.Companylogo = UpLogo(image); // if (iHomeDal.AddEntity(homeCor)) // { // return RedirectToAction("HomeCor"); // } // else // { // return Content("添加失败,请重试!"); // } //} /// <summary> /// 网站首页信息的管理页(数据查询) /// </summary> /// <returns></returns> public ActionResult HomeCor() { if (Session["UserLogin"] == null) { return(RedirectToAction("Login")); } //将查询到的数据记录分页显示代码 int totalCount; int pageIndex = Convert.ToInt32(Request.QueryString["pageIndex"]); var homeInfoList = iHomeDal.LoadPageEntity <int>(pageIndex, 10, out totalCount, s => true, ss => ss.IndexID, true); if (homeInfoList == null) { return(RedirectToAction("CreateHomeCor")); } ViewBag.PageList = PageBarHelper.GetPagaBar(pageIndex, totalCount); return(View(homeInfoList)); }
//查看就坐记录 public ActionResult OrderHistory() { int userId = Convert.ToInt32(Session["UserId"]); //分页设置 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 6;//页面记录数 List <SeatDetail> mlist = new List <SeatDetail>(); //查询记录 mlist = Entity.SeatDetail.Where(a => a.UserId == userId).OrderByDescending(a => a.StartTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList <SeatDetail>(); int listCount = Entity.SeatDetail.Where(a => a.UserId == userId).Count(); //生成导航条 string strBar = PageBarHelper.GetPagaBar(pageIndex, listCount, pageSize); ViewData["List"] = mlist; ViewData["Bar"] = strBar; return(View()); }
public ActionResult ShowSubpageProduct() { if (Session["UserLogin"] == null) { return(RedirectToAction("Login")); } var boolProduct = iSubDal.LoadEntity(u => true); if (boolProduct == null) { return(RedirectToAction("Index")); } //将查询到的数据记录分页显示代码 int totalCount; int pageIndex = Convert.ToInt32(Request.QueryString["pageIndex"]); var userInfoList = iSubDal.LoadPageEntity <string>(pageIndex, 10, out totalCount, s => true, sb => sb.ProductID.ToString(), true); ViewBag.PageList = PageBarHelper.GetPagaBar(pageIndex, totalCount); return(View(userInfoList)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int pageIndex; if (!int.TryParse(context.Request["pageIndex"], out pageIndex)) { pageIndex = 1; } int pageSize = 5; UserInfoService userInfoService = new UserInfoService(); // 01_获取总页数 int pageCount = userInfoService.GetPageCount(pageSize); // 02_获取当前页的范围 pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; // 03_获取分页数据 List <UserInfoEntity> userInfoList = userInfoService.GetPageList(pageIndex, pageSize); // 04_获取页码条 string pageBar = PageBarHelper.GetPageBar(pageIndex, pageCount); // 05_利用匿名类在实体类的基础上添加一个属性,往客户端多传一些信息 var m = new //匿名类,在实体类的基础上又添加了一个属性 { myUserInfoList = userInfoList, //匿名类中的属性01_ m_UserInfoList myPageBar = pageBar //匿名类中的属性02_ m_PageBar }; // 06_创建JavaScript序列化对象 JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); // 07_将匿名类“m”序列化成json字符串 string strSerialize = javaScriptSerializer.Serialize(m); context.Response.Write(strSerialize); //不分页: //List<UserInfoEntity> userInfoList =userInfoService.GetUserInfoList(); //JavaScriptSerializer javaScriptSerializer=new JavaScriptSerializer();//进行序列化 //string strSerialize = javaScriptSerializer.Serialize(userInfoList); //将数据序列化成json字符串 //context.Response.Write(strSerialize); }
public ActionResult Index(string search) { if (string.IsNullOrEmpty(search)) { search = ""; } //分页设置 int pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1; int pageSize = 5;//页面记录数 List <Books> mlist = new List <Books>(); mlist = DB.Books.Where(a => a.Title.Contains(search)).OrderBy(a => a.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); int listCount = DB.Books.Where(a => a.Title.Contains(search)).Count(); //生成导航条 string strBar = PageBarHelper.GetPageBar(pageIndex, listCount, pageSize); ViewData["List"] = mlist; ViewData["PageBar"] = strBar; return(View()); }