public override List <ChannelInfoVO> GetModels(ref ChannelInfoPara mp) { string where = GetConditionByPara(mp); int pStart = mp.PageIndex.Value * mp.PageSize.Value; int pEnd = mp.PageSize.Value; string cmd = QUERYPAGE .Replace("@PAGESIZE", pEnd.ToString()) .Replace("@PTOP", pStart.ToString()) .Replace("@WHERE", where) .Replace("@ORDER", GetOrderByPara(mp)); CodeCommand command = new CodeCommand(); command.CommandText = cmd; var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command); List <ChannelInfoVO> list = new List <ChannelInfoVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new ChannelInfoVO(table.Rows[i])); } if (!mp.Recount.HasValue) { mp.Recount = GetRecords(mp); } return(list); }
public override string GetConditionByPara(ChannelInfoPara mp) { StringBuilder sb = new StringBuilder(); if (mp.Id.HasValue) { sb.AppendFormat(" AND [Id]='{0}' ", mp.Id); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Name))) { sb.AppendFormat(" AND [Name]='{0}' ", mp.Name); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Desc))) { sb.AppendFormat(" AND [Desc]='{0}' ", mp.Desc); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.LinkUrl))) { sb.AppendFormat(" AND [LinkUrl]='{0}' ", mp.LinkUrl); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ImgUrl))) { sb.AppendFormat(" AND [ImgUrl]='{0}' ", mp.ImgUrl); } if (mp.IsShow.HasValue) { sb.AppendFormat(" AND [IsShow]='{0}' ", mp.IsShow); } if (mp.IsHot.HasValue) { sb.AppendFormat(" AND [IsHot]='{0}' ", mp.IsHot); } if (mp.IsTop.HasValue) { sb.AppendFormat(" AND [IsTop]='{0}' ", mp.IsTop); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ColorValue))) { sb.AppendFormat(" AND [ColorValue]='{0}' ", mp.ColorValue); } if (mp.CreateDate.HasValue) { sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate); } if (mp.LastDate.HasValue) { sb.AppendFormat(" AND [LastDate]='{0}' ", mp.LastDate); } if (mp.CreateUserId.HasValue) { sb.AppendFormat(" AND [CreateUserId]='{0}' ", mp.CreateUserId); } sb.Insert(0, " WHERE 1=1 "); return(sb.ToString()); }
public override string GetOrderByPara(ChannelInfoPara mp) { if (!string.IsNullOrEmpty(mp.OrderBy)) { return(string.Format(" order by {0}", mp.OrderBy)); } return(""); }
public override ChannelInfoVO GetSingle(ChannelInfoPara mp) { var list = GetModels(mp); if (list.Count == 1) { return(list[0]); } return(null); }
public override int GetRecords(ChannelInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); command.CommandText = QUERYCOUNT + where; var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command); return(int.Parse(result.ToString())); }
private void Bind(int pageIndex = 1) { ChannelInfoPara cip = new ChannelInfoPara(); cip.PageIndex = pageIndex - 1; cip.PageSize = 10; var list = ChannelInfoBLL.Instance.GetModels(ref cip); rptTables.DataSource = list; rptTables.DataBind(); apPager.RecordCount = cip.Recount.Value; }
public override bool Delete(ChannelInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); command.CommandText = DELETE + where; int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command); if (result >= 1) { return(true); } return(false); }
public override List <ChannelInfoVO> GetModels(ChannelInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); string cmd = LOAD .Replace("@WHERE", where) .Replace("@ORDER", GetOrderByPara(mp)); command.CommandText = cmd; var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command); List <ChannelInfoVO> list = new List <ChannelInfoVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new ChannelInfoVO(table.Rows[i])); } return(list); }
public override string GetOtherConditionByPara(ChannelInfoPara mp) { return(""); }