Ejemplo n.º 1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public long Add(JY.Model.Advert model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(JY.Model.Advert model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <JY.Model.Advert> DataTableToList(DataTable dt)
        {
            List <JY.Model.Advert> modelList = new List <JY.Model.Advert>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                JY.Model.Advert model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new JY.Model.Advert();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = long.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["AdvertTypeId"] != null && dt.Rows[n]["AdvertTypeId"].ToString() != "")
                    {
                        model.AdvertTypeId = long.Parse(dt.Rows[n]["AdvertTypeId"].ToString());
                    }
                    if (dt.Rows[n]["AdvertCategory"] != null && dt.Rows[n]["AdvertCategory"].ToString() != "")
                    {
                        model.AdvertCategory = int.Parse(dt.Rows[n]["AdvertCategory"].ToString());
                    }
                    if (dt.Rows[n]["AdvertName"] != null && dt.Rows[n]["AdvertName"].ToString() != "")
                    {
                        model.AdvertName = dt.Rows[n]["AdvertName"].ToString();
                    }
                    if (dt.Rows[n]["AdvertPic"] != null && dt.Rows[n]["AdvertPic"].ToString() != "")
                    {
                        model.AdvertPic = dt.Rows[n]["AdvertPic"].ToString();
                    }
                    if (dt.Rows[n]["AdvertUrl"] != null && dt.Rows[n]["AdvertUrl"].ToString() != "")
                    {
                        model.AdvertUrl = dt.Rows[n]["AdvertUrl"].ToString();
                    }
                    if (dt.Rows[n]["Description"] != null && dt.Rows[n]["Description"].ToString() != "")
                    {
                        model.Description = dt.Rows[n]["Description"].ToString();
                    }
                    if (dt.Rows[n]["Height"] != null && dt.Rows[n]["Height"].ToString() != "")
                    {
                        model.Height = int.Parse(dt.Rows[n]["Height"].ToString());
                    }
                    if (dt.Rows[n]["Width"] != null && dt.Rows[n]["Width"].ToString() != "")
                    {
                        model.Width = int.Parse(dt.Rows[n]["Width"].ToString());
                    }
                    if (dt.Rows[n]["Sort"] != null && dt.Rows[n]["Sort"].ToString() != "")
                    {
                        model.Sort = long.Parse(dt.Rows[n]["Sort"].ToString());
                    }
                    if (dt.Rows[n]["CreateDate"] != null && dt.Rows[n]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
                    }
                    if (dt.Rows[n]["IsDelete"] != null && dt.Rows[n]["IsDelete"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsDelete"].ToString() == "1") || (dt.Rows[n]["IsDelete"].ToString().ToLower() == "true"))
                        {
                            model.IsDelete = true;
                        }
                        else
                        {
                            model.IsDelete = false;
                        }
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }