public static IEnumerable <MemberShipLogStatisticLabelModels> GetItems(MemberShipLogStatisticLabelSearchModels search, int pageSize, int pageIndex, out int recordCount) { List <MemberShipLogStatisticLabelModels> items = new List <MemberShipLogStatisticLabelModels>(); if (search == null) { recordCount = 0; return(items); } string sql = "Select * From MemberShipLogStatisticLabels Where 1=1 {0} Order By LabelDate Desc"; List <string> where = new List <string>(); if (!string.IsNullOrWhiteSpace(search.Keyword)) { where.Add(string.Format(" ( Title Like N'%{0}%' )", search.Keyword.Replace("'", "''"))); } if (search.StartDate.HasValue) { where.Add(string.Format(" LabelDate >= '{0:yyyy/MM/dd HH:mm}' ", search.StartDate)); } if (search.EndDate.HasValue) { where.Add(string.Format(" LabelDate <= '{0:yyyy/MM/dd HH:mm}' ", search.EndDate)); } SQLData.Database db = new SQLData.Database(WebInfo.Conn); DataTable datas = db.GetPageData(string.Format(sql, where.Count > 0? " And " + string.Join(" And ", where):""), pageSize, pageIndex, out recordCount); if (datas != null) { foreach (DataRow dr in datas.Rows) { items.Add(new MemberShipLogStatisticLabelModels { ID = (long)dr["ID"], Title = dr["Title"].ToString().Trim(), LabelColor = dr["LabelColor"].ToString().Trim(), LabelDate = (DateTime)dr["LabelDate"], ShowStatus = (bool)dr["ShowStatus"], CreateTime = DateTime.Parse(dr["CreateTime"].ToString()), Creator = (long)dr["Creator"], ModifyTime = DateTime.Parse(dr["ModifyTime"].ToString()), Modifier = (long)dr["Modifier"] }); } } return(items); }
public ActionResult CustomLabelLine(int?index, MemberShipLogStatisticLabelSearchModels search) { bool IsShowLabelLine = GetCustomLableCookie(); if (Request.HttpMethod == "GET") { if (index == null) { WorkV3.Common.Utility.ClearSearchValue(); } else { MemberShipLogStatisticLabelSearchModels prevSearch = WorkV3.Common.Utility.GetSearchValue <MemberShipLogStatisticLabelSearchModels>(); if (prevSearch != null) { search = prevSearch; } } } else if (Request.HttpMethod == "POST") { WorkV3.Common.Utility.SetSearchValue(search); } ViewBag.Search = search; Pagination pagination = new Pagination { PageIndex = index ?? 1, PageSize = WebInfo.PageSize }; int totalRecord; IEnumerable <MemberShipLogStatisticLabelModels> items = MemberShipLogStatisticLabelDAO.GetItems(search, pagination.PageSize, pagination.PageIndex, out totalRecord); pagination.TotalRecord = totalRecord; ViewBag.Pagination = pagination; ViewBag.SelectCustomLabel = IsShowLabelLine; return(View(items)); }