public override List <PlayHistoryVO> GetModels(ref PlayHistoryPara 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 <PlayHistoryVO> list = new List <PlayHistoryVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new PlayHistoryVO(table.Rows[i])); } if (!mp.Recount.HasValue) { mp.Recount = GetRecords(mp); } return(list); }
public override string GetOrderByPara(PlayHistoryPara mp) { if (!string.IsNullOrEmpty(mp.OrderBy)) { return(string.Format(" order by {0}", mp.OrderBy)); } return(""); }
public override PlayHistoryVO GetSingle(PlayHistoryPara mp) { var list = GetModels(mp); if (list.Count == 1) { return(list[0]); } return(null); }
public override int GetRecords(PlayHistoryPara 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())); }
public override bool Delete(PlayHistoryPara 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 <PlayHistoryVO> GetModels(PlayHistoryPara 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 <PlayHistoryVO> list = new List <PlayHistoryVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new PlayHistoryVO(table.Rows[i])); } return(list); }
public override string GetOtherConditionByPara(PlayHistoryPara mp) { return(""); }
public override string GetConditionByPara(PlayHistoryPara mp) { StringBuilder sb = new StringBuilder(); if (mp.Id.HasValue) { sb.AppendFormat(" AND [Id]='{0}' ", mp.Id); } if (mp.AdUserId.HasValue) { sb.AppendFormat(" AND [AdUserId]='{0}' ", mp.AdUserId); } if (mp.FlowUserId.HasValue) { sb.AppendFormat(" AND [FlowUserId]='{0}' ", mp.FlowUserId); } if (mp.AdId.HasValue) { sb.AppendFormat(" AND [AdId]='{0}' ", mp.AdId); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.AdUrl))) { sb.AppendFormat(" AND [AdUrl]='{0}' ", mp.AdUrl); } if (mp.Time.HasValue) { sb.AppendFormat(" AND [Time]='{0}' ", mp.Time); } if (mp.Money.HasValue) { sb.AppendFormat(" AND [Money]='{0}' ", mp.Money); } if (mp.CreateDate.HasValue) { sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate); } if (mp.CreateUserId.HasValue) { sb.AppendFormat(" AND [CreateUserId]='{0}' ", mp.CreateUserId); } if (mp.ClientIp.HasValue) { sb.AppendFormat(" AND [ClientIp]='{0}' ", mp.ClientIp); } if (mp.ClientUv.HasValue) { sb.AppendFormat(" AND [ClientUv]='{0}' ", mp.ClientUv); } if (mp.ClientPv.HasValue) { sb.AppendFormat(" AND [ClientPv]='{0}' ", mp.ClientPv); } if (mp.Price.HasValue) { sb.AppendFormat(" AND [Price]='{0}' ", mp.Price); } sb.Insert(0, " WHERE 1=1 "); return(sb.ToString()); }