示例#1
0
        private string BuildSqlFrom(FranchiseeFilter filter)
        {
            if (filter == null)
            {
                return(null);
            }

            var sb = new System.Text.StringBuilder();

            if (!string.IsNullOrEmpty(filter.Email))
            {
                sb.Append(" email like '%" + SqlFilter.FilterQueryParameter(filter.Email) + "%' ");
                sb.Append(" and ");
            }

            if (!string.IsNullOrEmpty(filter.Name))
            {
                sb.Append(" name like '%" + SqlFilter.FilterQueryParameter(filter.Name) + "%' ");
                sb.Append(" and ");
            }
            if (!string.IsNullOrEmpty(filter.Phone))
            {
                sb.Append(" phone like '%" + SqlFilter.FilterQueryParameter(filter.Phone) + "%' ");
                sb.Append(" and ");
            }

            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 4, 4);
            }

            return(sb.ToString());
        }
示例#2
0
        private string BuildSqlFrom(MaterialFilter filter)
        {
            if (filter == null)
            {
                return(null);
            }

            var sb = new System.Text.StringBuilder();

            if (filter.AddTimeFrom.HasValue)
            {
                sb.Append(" addtime >= " + filter.AddTimeFrom.Value.ToString("yyyy-MM-dd"));
                sb.Append(" and ");
            }
            if (filter.AddTimeTo.HasValue)
            {
                sb.Append(" addtime <= " + filter.AddTimeTo.Value.ToString("yyyy-MM-dd"));
                sb.Append(" and ");
            }
            if (filter.MaterialType > 0)
            {
                sb.AppendFormat(" materialtype = '{0}' ", SqlFilter.FilterQueryParameter(filter.MaterialType.Value.ToString()));
                sb.Append(" and ");
            }
            if (!string.IsNullOrEmpty(filter.Title))
            {
                sb.AppendFormat(" title like '{0}' ", SqlFilter.FilterQueryParameter(filter.Title));
                sb.Append(" and ");
            }

            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 4, 4);
            }

            return(sb.ToString());
        }