Exemple #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.Adert DataRowToModel(DataRow row)
 {
     Model.Adert model = new Model.Adert();
     if (row != null)
     {
         if (row["a_ID"] != null && row["a_ID"].ToString() != "")
         {
             model.a_ID = int.Parse(row["a_ID"].ToString());
         }
         if (row["a_PID"] != null && row["a_PID"].ToString() != "")
         {
             model.a_PID = int.Parse(row["a_PID"].ToString());
         }
         if (row["a_Title"] != null)
         {
             model.a_Title = row["a_Title"].ToString();
         }
         if (row["a_Link"] != null)
         {
             model.a_Link = row["a_Link"].ToString();
         }
         if (row["a_Image"] != null)
         {
             model.a_Image = row["a_Image"].ToString();
         }
         if (row["a_Sorting"] != null && row["a_Sorting"].ToString() != "")
         {
             model.a_Sorting = int.Parse(row["a_Sorting"].ToString());
         }
         if (row["a_IsTop"] != null && row["a_IsTop"].ToString() != "")
         {
             model.a_IsTop = int.Parse(row["a_IsTop"].ToString());
         }
         if (row["a_CreateDate"] != null && row["a_CreateDate"].ToString() != "")
         {
             model.a_CreateDate = DateTime.Parse(row["a_CreateDate"].ToString());
         }
         if (row["a_CreateUser"] != null && row["a_CreateUser"].ToString() != "")
         {
             model.a_CreateUser = new Guid(row["a_CreateUser"].ToString());
         }
         if (row["a_Status"] != null && row["a_Status"].ToString() != "")
         {
             model.a_Status = int.Parse(row["a_Status"].ToString());
         }
         if (row["a_Delete"] != null && row["a_Delete"].ToString() != "")
         {
             model.a_Delete = int.Parse(row["a_Delete"].ToString());
         }
         if (row["a_spare1"] != null)
         {
             model.a_spare1 = row["a_spare1"].ToString();
         }
         if (row["a_spare2"] != null && row["a_spare2"].ToString() != "")
         {
             model.a_spare2 = int.Parse(row["a_spare2"].ToString());
         }
     }
     return model;
 }
Exemple #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Adert GetModel(int a_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 a_ID,a_PID,a_Title,a_Link,a_Image,a_Sorting,a_IsTop,a_CreateDate,a_CreateUser,a_Status,a_Delete,a_spare1,a_spare2 from Adert ");
            strSql.Append(" where a_ID=@a_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@a_ID", SqlDbType.Int,4)
            };
            parameters[0].Value = a_ID;

            Model.Adert model = new Model.Adert();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 品牌推广
        /// </summary>
        /// <returns></returns>
        public object GetBrandBaseAdert()
        {
            var brandBig = GetAdertsFormServer("BrandBase", 33) as List<Model.Adert>;
            var brandsmall = GetAdertsFormServer("BrandBaseSpan", 35) as List<Model.Adert>;

            if (!brandBig.Any() && !brandsmall.Any())
            {//都没有数据
                ViewData["BrandBase"] = "";
                ViewData["BrandBaseSpan"] = "";
            }
            else
            {
                int bigCount = brandBig.Count;
                int smallCount = brandsmall.Count;
                int bigPage = bigCount / 3 + (bigCount % 3 == 0 ? 0 : 1);
                int smallPage = smallCount / 4 + (bigCount % 4 == 0 ? 0 : 1);
                int page = bigPage > smallPage ? bigPage : smallPage;
                Model.Adert adertBig = new Model.Adert ();
                adertBig.a_Link = "/Index/Index";
                adertBig.a_Image = "/images/brand/brand_01.jpg";
                while (bigCount / 3 != page)
                {
                    brandBig.Add(adertBig);
                    bigCount++;
                }
                Model.Adert adertSmall = new Model.Adert();
                adertSmall.a_Link = "/Index/Index";
                adertSmall.a_Image = "/images/brand/brand_03.jpg";
                while (smallCount / 4 != page)
                {
                    brandsmall.Add(adertSmall);
                    smallCount++;
                }
                //广告
                StringBuilder brandStr = new StringBuilder();
                StringBuilder brandSpan = new StringBuilder();
                //组合
                for (int i = 0; i < page; i++)
                {
                    brandStr.AppendFormat("<li>");
                    brandStr.AppendFormat("<a href='{0}' target='_blank' class='brand-pos1'><img name='page_cnt_1' src='{1}' /></a>", brandBig[i * 3 + 0].a_Link, brandBig[i * 3 + 0].a_Image);
                    brandStr.AppendFormat("<a href='{0}' target='_blank' class='brand-pos2'><img name='page_cnt_1' src='{1}' /></a>", brandsmall[i * 4 + 0].a_Link, brandsmall[i * 4 + 0].a_Image);
                    brandStr.AppendFormat("<a href='{0}' target='_blank' class='brand-pos3'><img name='page_cnt_1' src='{1}' /></a>", brandsmall[i * 4 + 1].a_Link, brandsmall[i * 4 + 1].a_Image);
                    brandStr.AppendFormat("<a href='{0}' target='_blank' class='brand-pos4'><img name='page_cnt_1' src='{1}' /></a>", brandBig[i * 3 + 1].a_Link, brandBig[i * 3 + 1].a_Image);
                    brandStr.AppendFormat("<a href='{0}' target='_blank' class='brand-pos5'><img name='page_cnt_1' src='{1}' /></a>", brandsmall[i * 4 + 2].a_Link, brandsmall[i * 4 + 2].a_Image);
                    brandStr.AppendFormat("<a href='{0}' target='_blank' class='brand-pos6'><img name='page_cnt_1' src='{1}' /></a>", brandsmall[i * 4 + 3].a_Link, brandsmall[i * 4 + 3].a_Image);
                    brandStr.AppendFormat("<a href='{0}' target='_blank' class='brand-pos7'><img name='page_cnt_1' src='{1}' /></a>", brandBig[i * 3 + 2].a_Link, brandBig[i * 3 + 2].a_Image);
                    brandStr.AppendFormat("</li>");
                    brandSpan.AppendFormat("<span>{0}</span>", i + 1);
                }
                ViewData["BrandBase"] = brandStr.ToString();
                ViewData["BrandBaseSpan"] = brandSpan.ToString();
            }

            return ViewData["BrandBase"];
        }