protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ad = new accessDatabase(); if (Request.QueryString["konu"] == null) { int SayfaNo = Convert.ToInt32(Request.QueryString["Sayfa"]); Pageing p = new Pageing(); Repeater1.DataSource = p.GetData(SayfaNo, 7, Request.Url.Segments.Last().Substring(0, Request.Url.Segments.Last().Length - 5), (int)Session["kategoriid"]); Repeater1.DataBind(); lblIlkYorumuYapin.Visible = false; } else { if ((string)Session["login"] != "admin" && (string)Session["giris"] != "uye") { Response.Redirect("uyeol.aspx"); } okunmaSayisi(); ad.gridViewDoldur(Repeater1, "makale", "select m.okunmasayisi ,m.icerik, m.baslik,m.tarih,k.kategori, m.id, m.yazar,m.kucukResim, m.anahtarKelimeler from makale as m inner join kategoriler as k on k.kategoriid = m.kategoriid WHERE m.id = " + Request.QueryString["konu"]); ad.gridViewDoldur(rpt_yorumlar, "Yorumlar", "select * from Yorumlar where makaleid=" + Request.QueryString["konu"] + " order by yorumid desc"); lblIlkYorumuYapin.Visible = (string)Session["lblYorum"] == "0" ? true : false; //turnary if sayiUret(); } } }
public string GetGradeList(int stageId, int PageIndex, int PageSize) { Pageing <List <Grade> > gradeList = _iStageRespository.getGradeList(stageId, PageIndex, PageSize); string gradeStr = JsonConvert.SerializeObject(gradeList); return(gradeStr); }
/// <summary> /// 获取所有的学院信息 /// </summary> /// <param name="CollegeName">学院名称,用于模糊查询学院</param> /// <param name="PageIndex">分页当前页码</param> /// <param name="PageSize">分页的每页条数</param> /// <returns>返回得到的json字符串</returns> public Pageing <List <College> > GetCollegeList(string CollegeName, int PageIndex, int PageSize) { Pageing <List <College> > collegeList = new Pageing <List <College> >(); int Index = (PageIndex - 1) * PageSize; string sqlTwo = $"select id,collegename ,createtime,dean from college where 1=1"; string sqlone = $"select id,collegename ,createtime,dean from college where 1=1"; if (!string.IsNullOrEmpty(CollegeName)) { sqlTwo += " and collegename like concat(@CollegeName,'%') limit @Index,@PageSize"; sqlone += " and collegename like concat(@CollegeName,'%')"; } else { sqlTwo += " limit @Index,@PageSize"; } using (IDbConnection connection = new MySqlConnection(strSql)) { collegeList.Data = connection.Query <College>(sqlTwo, new { CollegeName = CollegeName, Index = Index, PageSize = PageSize }).ToList(); } using (IDbConnection connection = new MySqlConnection(strSql)) { collegeList.Count = connection.Query <College>(sqlone, new { CollegeName = CollegeName }).ToList().Count(); } return(collegeList); }
/// <summary> /// 根据单元获取题库信息 /// </summary> /// <param name="unitid"></param> /// <returns></returns> public string GetQuestion(int unitid, string tp, string qn, int index, int size) { //List<BackQuestionBank> list = question.GetQuestionById(unitid, tp, qn); Pageing <List <BackQuestionBank> > list = question.GetQuestion(unitid, tp, qn, index, size); return(Newtonsoft.Json.JsonConvert.SerializeObject(list)); }
/// <summary> /// 分页 /// </summary> /// <param name="Unitid">单元ID</param> /// <param name="tp">题目类型</param> /// <param name="qn">问题</param> /// <param name="index">第几页</param> /// <param name="size">每页几条</param> /// <returns></returns> public Pageing <List <BackQuestionBank> > GetQuestion(int Unitid, string tp, string qn, int index, int size) { int page = (index - 1) * size; Pageing <List <BackQuestionBank> > list = new Pageing <List <BackQuestionBank> >(); string sql = $"select * from BackQuestionBank where UnitId=" + Unitid; string sqlCount = $"select * from BackQuestionBank where UnitId=" + Unitid; if (!(string.IsNullOrEmpty(tp))) { if (Convert.ToInt32(tp) > 0) { var questiontype = Convert.ToInt32(tp); sql += " and QuestionType=" + questiontype; sqlCount += " and QuestionType=" + questiontype; } } if (!(string.IsNullOrEmpty(qn))) { sql += " and Question like '%" + qn + "%'"; sqlCount += " and Question like '%" + qn + "%'"; } sql += " limit " + page + "," + size; using (IDbConnection conn = new MySqlConnection(mysqlConnectionStr)) { list.Data = conn.Query <BackQuestionBank>(sql).ToList(); list.Count = conn.Query <BackQuestionBank>(sqlCount).ToList().Count(); } return(list); }
/// <summary> /// 得到对应的班级信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public Pageing <List <Grade> > getGradeList(int stageId, int PageIndex, int PageSize) { Pageing <List <Grade> > gradePageing = new Pageing <List <Grade> >(); List <Grade> gradeList = new List <Grade>(); int Index = (PageIndex - 1) * PageSize; string sql = $"SELECT Id,ClassName from grade where stageid=@stageId limit @Index,@PageSize"; using (IDbConnection connection = new MySqlConnection(strSql)) { gradeList = connection.Query <Grade>(sql, new { stageId = stageId, Index = Index, PageSize = PageSize }).ToList(); } gradePageing.Data = gradeList; gradePageing.Count = gradeList.Count; return(gradePageing); }
/// <summary> /// 根据班级id得到对应的学生信息 /// </summary> /// <param name="ClassId">关联班级的id</param> /// <returns>返回得到的学生信息</returns> public Pageing <List <Pupil> > GetPupilList(int ClassId, int PageIndex, int PageSize, string PupilName) { Pageing <List <Pupil> > pupilList = new Pageing <List <Pupil> >(); int Index = (PageIndex - 1) * PageSize; string sqlOne = $"select id, studentName ,studentnumber,studentpassword from pupil where 1=1"; string sqlTwo = $"select id, studentName ,studentnumber,studentpassword from pupil where 1=1"; if (!string.IsNullOrEmpty(PupilName)) { if (ClassId > 0) { sqlTwo += " and Classid=@ClassId and StudentName like concat('%',@PupilName,'%') limit @Index,@PageSize"; sqlOne += " and Classid=@ClassId and StudentName like concat('%',@PupilName,'%')"; } else { sqlTwo += " and StudentName like concat('%',@PupilName,'%') limit @Index,@PageSize"; } } else { if (ClassId > 0) { sqlTwo += " and Classid=@ClassId limit @Index,@PageSize"; sqlOne += " and Classid=@ClassId"; } else { sqlTwo += " limit @Index,@PageSize"; } } using (IDbConnection connection = new MySqlConnection(strSql)) { pupilList.Data = connection.Query <Pupil>(sqlTwo, new { ClassId = ClassId, PupilName = PupilName, Index = Index, PageSize = PageSize }).ToList(); } using (IDbConnection connection = new MySqlConnection(strSql)) { pupilList.Count = connection.Query <Pupil>(sqlOne, new { ClassId = ClassId, PupilName = PupilName }).ToList().Count(); } return(pupilList); }
/// <summary> /// 分页显示 /// </summary> /// <param name="UserId"></param> /// <param name="pageindex"></param> /// <param name="pagesize"></param> /// <returns></returns> public Pageing <List <Journal> > GetList(string UserName, int pageindex, int pagesize) { Pageing <List <Journal> > list = new Pageing <List <Journal> >(); int index = (pageindex - 1) * pagesize; string sql = $"select a.*,b.AccountName from Journal a inner join users b on a.UserId=b.Id where 1=1"; string sqlcount = $"select * from Journal a inner join users b on a.UserId=b.Id where 1=1"; if (!string.IsNullOrEmpty(UserName)) { sql += " and b.AccountName=@UserName ORDER BY a.operatetime DESC limit @index,@pagesize"; sqlcount += " and b.AccountName=@UserName"; } else { sql += " ORDER BY a.operatetime DESC limit @index,@pagesize"; } using (IDbConnection conn = new MySqlConnection(mysqlConnectionStr)) { list.Data = conn.Query <Journal>(sql, new { UserName = UserName, index = index, pagesize = pagesize }).ToList(); list.Count = conn.Query <Journal>(sqlcount, new { UserName = UserName }).ToList().Count(); } return(list); }
/// <summary> /// 得到对应班级所有的学生 /// </summary> /// <returns></returns> public string GetPupilList(int GradeId, int PageIndex, int PageSize, string PupilName) { Pageing <List <Pupil> > pupilList = StudentRespository.GetPupilList(GradeId, PageIndex, PageSize, PupilName); return(JsonConvert.SerializeObject(pupilList)); }
public string GetCollegeList(string CollegeName, int PageIndex, int PageSize) { Pageing <List <College> > collegeList = _iCollegeRespository.GetCollegeList(CollegeName, PageIndex, PageSize); return(JsonConvert.SerializeObject(collegeList)); }
/// <summary> /// 获取操作日志 /// </summary> /// <param name="UserName">用户名</param> /// <param name="pageindex">第几页</param> /// <param name="pagesize">每页几条</param> /// <returns></returns> public string GetList(string UserName, int pageindex, int pagesize) { Pageing <List <Journal> > pa = logs.GetList(UserName, pageindex, pagesize); return(Newtonsoft.Json.JsonConvert.SerializeObject(pa)); }