예제 #1
0
 public List<BannerCategory> GetBannerCategoryList(BannerCategory bc, out int totalCount)
 {
     try
     {
         return _bcDao.GetBannerCategoryList(bc, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("BannerCategoryMgr-->GetBannerCategoryList" + ex.Message, ex);
     }
 }
예제 #2
0
        public List<BannerCategory> GetBannerCategoryList(BannerCategory bc, out int totalCount)
        {
            totalCount = 0;
            StringBuilder sqlfield = new StringBuilder();
            StringBuilder sqlwhere = new StringBuilder();
            StringBuilder sql = new StringBuilder();
            sqlwhere.AppendLine(@" from banner_category bc ");
            //獲取下拉列表的數據
            if (bc.category_father_id == 0)
            {
                sqlfield.AppendLine(@" SELECT bc.category_id,bc.category_name "); ;
                sqlwhere.AppendLine(@" WHERE bc.category_father_id = 0 ORDER BY bc.category_sort ASC");
            }
            //獲取列表頁的數據
            else
            {
                sqlfield.AppendLine(@"SELECT bc.category_id,bc.category_father_id,bc.category_sort,");
                sqlfield.AppendLine(@" bc.category_name,bc.content_type,bc.content_id,bc.description,bc.activity,bc.created_on,bc.updated_on ");
                sqlfield.AppendLine(@" ,bcc.category_name as fcategory_name ");
                sqlfield.AppendLine(@" ,bs.banner_site_name ");
                sqlwhere.AppendLine(@" LEFT JOIN  (SELECT category_id,category_name FROM banner_category WHERE category_father_id = 0 ) bcc on bc.category_father_id=bcc.category_id");
                sqlwhere.AppendLine(@" LEFT JOIN  (SELECT banner_site_id,banner_site_name from banner_site) bs on bs.banner_site_id=bc.content_id");
                sqlwhere.AppendLine(@" WHERE 1=1 ");
                if (bc.category_father_id == -1)
                {
                    sqlwhere.AppendLine(@" AND bc.category_father_id>0 ");
                }
                else
                {
                    sqlwhere.AppendFormat(@" AND bc.category_father_id='{0}' ", bc.category_father_id);
                }
                sqlwhere.AppendLine(@"  ORDER BY category_father_id ASC, category_sort ASC  ");
            }

            sql.Append(sqlfield.ToString());
            sql.Append(sqlwhere.ToString());
            if (bc.IsPage)
            {
                sql.AppendFormat(@" LIMIT {0},{1};", bc.Start, bc.Limit);
                DataTable dt = _access.getDataTable("SELECT bc.category_id " + sqlwhere);
                totalCount = dt.Rows.Count;
            }
            try
            {
                return _access.getDataTableForObj<BannerCategory>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("BannerCategoryDao-->GetBannerCategoryList" + ex.Message + sql.ToString(), ex);
            }
        }
예제 #3
0
 public HttpResponseBase GetBannerCategoryList()
 {
     string json = string.Empty;
     List<BannerCategory> store = new List<BannerCategory>();
     BannerCategory bc = new BannerCategory();
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["category_father_id"]))
         {
             if (Request.Params["category_father_id"] == "0")
             {
                 bc.category_father_id = 0;
                 bc.IsPage = false;
             }
             else
             {
                 bc.category_father_id = int.Parse(Request.Params["category_father_id"]);
             }
         }
         bc.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
         bc.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
         _bcateMgr = new BannerCategoryMgr(mySqlConnectionString);
         int totalCount = 0;
         store = _bcateMgr.GetBannerCategoryList(bc, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss ";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }