public static List<TopicReplyInfo> GetAllTopicReplyBySearch(TopicReplySearchCondition rsc) { return GetTopicReplyByTopicId(0, rsc); }
public static List<TopicReplyInfo> GetValidTopicReplyByTopicId(int topicSysNo) { TopicReplySearchCondition sc = new TopicReplySearchCondition(); sc.Status = 0; return GetTopicReplyByTopicId(topicSysNo, sc); }
private static List<TopicReplyInfo> GetTopicReplyByTopicId(int topicSysNo, TopicReplySearchCondition rsc) { string sqlStr = SQL_GET_TOPICREPLY_BY_TOPICID; DataTable dt = new DataTable(); if (topicSysNo != 0) { sqlStr = sqlStr.Replace("@select", "select "); sqlStr = sqlStr.Replace("@sqlPar", " Topic_Reply.TopicSysNo = @TopicSysNo @STATUS ORDER BY Topic_Reply.CreateDate desc"); if (rsc != null && rsc.Status != null) sqlStr = sqlStr.Replace("@STATUS", "AND Topic_Reply.Status = " + rsc.Status); else sqlStr = sqlStr.Replace("@STATUS", ""); SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@TopicSysNo", SqlDbType.Int) }; parms[0].Value = topicSysNo; dt = SqlHelper.ExecuteDataSet(sqlStr, parms).Tables[0]; } else { StringBuilder sb = new StringBuilder(" CreateUserType = 0 "); if (rsc.DateFrom != null) sb.Append(" and Topic_Reply.CreateDate >= '" + rsc.DateFrom + "' "); if (rsc.DateTo != null) sb.Append(" and Topic_Reply.CreateDate <= '" + rsc.DateTo.Value.AddDays(1).AddSeconds(-1) + "' "); if (rsc.Status != null) sb.Append(" and Topic_Reply.Status = " + rsc.Status + ""); if (rsc.CustomerId != string.Empty) sb.Append(" and CreateUserSysNo IN (SELECT SysNo FROM Customer (NOLOCK) WHERE CustomerId LIKE '%" + rsc.CustomerId + "%') "); sb.Append(" ORDER BY Topic_Reply.CreateDate DESC"); if (rsc.InEmpty == true) sqlStr = sqlStr.Replace("@select", "select top 50 "); else sqlStr = sqlStr.Replace("@select", "select "); sqlStr = sqlStr.Replace("@sqlPar", sb.ToString()); dt = SqlHelper.ExecuteDataSet(sqlStr).Tables[0]; } if (dt == null || dt.Rows.Count == 0) return null; List<TopicReplyInfo> list = new List<TopicReplyInfo>(); foreach (DataRow row in dt.Rows) list.Add(Map(row)); return list; }