public IActionResult List(string key, string startdate, string enddate, string cabh, int pagesize = 12, int pageindex = 1) { string cond = "1=1"; if (!string.IsNullOrEmpty(key)) { key = CommonTools.GetSafeSQL(key); cond += $" and Title like '%{key}%'"; } if (!string.IsNullOrEmpty(startdate)) { startdate = CommonTools.GetSafeSQL(startdate); cond += $" and replace(CONVERT(char(10),CreateDate,111),'/','-')>='{startdate}'"; } if (!string.IsNullOrEmpty(enddate)) { enddate = CommonTools.GetSafeSQL(enddate); cond += $" and replace(CONVERT(char(10),CreateDate,111),'/','-')<='{enddate}'"; } if (!string.IsNullOrEmpty(cabh) && cabh != "0") { cabh = CommonTools.GetSafeSQL(cabh); cond += $" and CateNo='{cabh}'"; } int total = blogdal.CalcCount(cond); int pagecount = total % pagesize == 0 ? total / pagesize : total / pagesize + 1;//总页数 List <Model.Blog> list = blogdal.GetList("id desc", pagesize, pageindex, cond); string str = CommonTools.ToJsonString(new { totalrecord = total, pagecount = pagecount, list = list }); return(Content(str)); }
public IActionResult List(string key, string month, string cate, int pagesize = 12, int pageindex = 1) { string cond = "1=1"; if (!string.IsNullOrEmpty(key)) { key = CommonTools.GetSafeSQL(key); cond += $" and Title like '%{key}%'"; } if (!string.IsNullOrEmpty(month)) { month = CommonTools.GetSafeSQL(month); DateTime d = DateTime.Parse(month + "-01"); cond += $"and CreateDate >= '{d:yyyy-MM-dd}' and CreateDate < '{d.AddMonths(1):yyyy-MM-dd}'"; } if (!string.IsNullOrEmpty(cate) && cate != "0") { cate = CommonTools.GetSafeSQL(cate); cond += $" and CateNo='{cate}'"; } int total = blogdal.CalcCount(cond); int pagecount = total % pagesize == 0 ? total / pagesize : total / pagesize + 1;//总页数 List <Model.Blog> list = blogdal.GetList("id desc", pagesize, pageindex, cond); string str = CommonTools.ToJsonString(new { totalrecord = total, pagecount = pagecount, list = list }); return(Content(str)); }
public IActionResult Welcome() { ViewBag.blogcount = blogdal.CalcCount(""); ViewBag.casecount = casedal.CalcCount("remark='case'"); ViewBag.videocount = casedal.CalcCount("remark='video'"); ViewBag.diarycount = diarydal.CalcCount(""); ViewBag.shuqiancount = sqdal.CalcCount(""); return(View()); }
public IActionResult Delete(int id) { Model.Category ca = cadal.GetModel(id); if (ca == null) { return(Json(new { status = "n", info = $"删除失败,没有对应分类!" })); } if (blogdal.CalcCount($"cabh='{ca.CateNo}'") > 0) { return(Json(new { status = "n", info = $"删除失败,该分类下还有博客!" })); } int res = cadal.Delete(id); return(Json(new { status = "y", info = $"成功删除{res}个分类!" })); }
/// <summary> /// 取博客总记录数 /// </summary> /// <returns></returns> public IActionResult GetTotalCount(string key, string start, string end, string cabh) { int totalcount = dal.CalcCount(GetCond(key, start, end, cabh)); return(Content(totalcount.ToString())); }
/// <summary> /// 取博客总记录数 /// </summary> /// <returns></returns> public ActionResult GetTotalCount(string key, string month, string cabh) { int totalcount = dal.CalcCount(GetCond(key, month, cabh)); return(Content(totalcount.ToString())); }
public IActionResult Welcome() { ViewBag.blogcount = blogdal.CalcCount(""); return(View()); }