public void ProcessRequest(HttpContext context) { BLL.HKSJ_Main mainService = new BLL.HKSJ_Main(); context.Response.ContentType = "text/plain"; Model.HKSJ_Main newsInfo = new Model.HKSJ_Main(); newsInfo.ID = context.Request["ID"] == null ? 0 : Convert.ToInt32(context.Request["ID"]); newsInfo.title = context.Request["title"]; newsInfo.content = context.Request["content"]; newsInfo.Date = Convert.ToDateTime(context.Request["Date"]); newsInfo.type = context.Request["type"]; newsInfo.people = context.Request["people"]; newsInfo.picUrl = context.Request["picUrl"]; if (mainService.Update(newsInfo)) { context.Response.Write("OK"); } else { context.Response.Write("error"); } }
public void ProcessRequest(HttpContext context) { BLL.HKSJ_Main mainService = new BLL.HKSJ_Main(); context.Response.ContentType = "text/plain"; Model.HKSJ_Main newsInfo = new Model.HKSJ_Main(); newsInfo.title = context.Request["title"] == null ? string.Empty : context.Request["title"]; newsInfo.content = context.Request["content"] == null ? string.Empty : context.Request["content"]; newsInfo.Date = Convert.ToDateTime(context.Request["Date"]); //这里不能限制读取的值 newsInfo.type = string.Format("{0}", "1 "); newsInfo.people = context.Request["people"] == null?string.Format("{0}", "Unknow") : context.Request["people"]; newsInfo.picUrl = context.Request["picUrl"] == null ? string.Empty : context.Request["picUrl"]; if (mainService.Add(newsInfo) > 0) { context.Response.Write("OK"); } else { context.Response.Write("error"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //判断用户是否登录 if (context.Session["user"] == null) { context.Response.Write("请您正常操作"); return; } //取出新闻列表 BLL.HKSJ_Main mainService = new BLL.HKSJ_Main(); //获取分页的参数 int pageIndex = context.Request["page"] == null ? 1 : int.Parse(context.Request["page"]); int pageSize = context.Request["rows"] == null ? 10 : int.Parse(context.Request["rows"]); //计算出总数量 int totalCount = mainService.GetRecordCount(string.Empty); var newsList = mainService.GetNavPageData(pageSize, pageIndex, out totalCount); //将得到的数据转换成json格式字符串 var data = new { total = totalCount, rows = newsList }; JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string json = javaScriptSerializer.Serialize(data); context.Response.Write(json); }
protected void Page_Load(object sender, EventArgs e) { BLL.HKSJ_Main mainBLL = new BLL.HKSJ_Main(); #region 无分页获取数据 ////获取数据 //NewsList = mainBLL.GetModelList(string.Empty); #endregion #region 分页获取数据 int totalListCount = mainBLL.GetRecordCount(string.Empty); //注意为空处理 int pageIndex = int.Parse(Context.Request["pageIndex"] ?? "1"); //每页显示的数量 int pageSize = 5; //获得要前端要显示的页数连接的数量,注意totalListCount数量过小处理 pageCount = Math.Max((totalListCount + pageSize - 1) / pageSize, 1); #region 代码生成器做法 //DataSet set = mainBLL.GetListByPage(string.Empty, "id", (pageIndex - 1) * pageSize + 1, pageIndex * pageSize); //NewsList = mainBLL.DataTableToList(set.Tables[0]); #endregion #region 自行编写存储过程及其对应三层代码做法 NewsList = mainBLL.MyGetListByPage(pageSize, pageIndex, out totalListCount); #endregion //处理链接导航栏,用一个静态类 PageNav = Pager.ShowPageNavigate(pageSize, pageIndex, totalListCount); #endregion }
protected void Page_Load(object sender, EventArgs e) { int ID = Request["ID"] == null ? 0 : Convert.ToInt32(Request["ID"]); //获取ID的新闻显示在页面上面 BLL.HKSJ_Main mainServices = new BLL.HKSJ_Main(); mainShowInfo = mainServices.GetModel(ID); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { BLL.HKSJ_Main mainBll = new BLL.HKSJ_Main(); Model.HKSJ_Main newsModel = new Model.HKSJ_Main(); //获得新闻数据 newsModel.title = Context.Request["title"]; newsModel.picUrl = ""; newsModel.people = ""; newsModel.Date = DateTime.Now; newsModel.type = ""; newsModel.content = Context.Request["content"]; //保存到数据库 mainBll.Add(newsModel); //重定向 Context.Response.Redirect("ShowListForm.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { //输出所有的信息 BLL.HKSJ_Main mainService = new BLL.HKSJ_Main(); //mainShowo = mainService.GetModelList(string.Empty); //分页每页显示13个记录 int pageIndex = Request["pageIndex"] == null ? 1 : Convert.ToInt32(Request["pageIndex"]); int pageSize = Request["pageSize"] == null ? 13 : Convert.ToInt32(Request["pageSize"]); //获取总数totalCount int totalCount = mainService.GetRecordCount(string.Empty); DataSet ds = mainService.GetListByPage(string.Empty, "ID", pageSize * (pageIndex - 1) + 1, pageSize * pageIndex); mainShowo = mainService.DataTableToList(ds.Tables[0]); NavPager = Common.LaomaPager.ShowPageNavigate(pageSize, pageIndex, totalCount); }
protected void Page_Load(object sender, EventArgs e) { //获取网站Main表中的数据 BLL.HKSJ_Main mainServices = new BLL.HKSJ_Main(); // mainShow = mainServices.GetModelList(string.Empty); //首先获取分页参数 int pageSize = Request["pageSize"] == null ? 10 : Convert.ToInt32(Request["pageSize"]); int pageIndex = Request["pageIndex"] == null ? 1 : Convert.ToInt32(Request["pageIndex"]); //获取到totalCount的数据 int totalCount = mainServices.GetRecordCount(string.Empty); //计算在页面上面显示的分页的数量 DataSet ds = mainServices.GetListByPage(string.Empty, "ID", pageSize * (pageIndex - 1) + 1, pageIndex * pageSize); mainShow = mainServices.DataTableToList(ds.Tables[0]); NavPager = Common.LaomaPager.ShowPageNavigate(pageSize, pageIndex, totalCount); }
protected void Page_Load(object sender, EventArgs e) { int id = int.Parse(Context.Request["id"]??"0"); BLL.HKSJ_Main mainBll = new BLL.HKSJ_Main(); NewsDeatail=mainBll.GetModel(id); }