コード例 #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="top">条数</param>
        /// <param name="strWhere">条件</param>
        /// <returns>Links集合</returns>
        public List <ClassLibrary.Model.Links> GetModelList(int top, string strWhere)
        {
            DataTable dt = GetData(top, strWhere);
            List <ClassLibrary.Model.Links> modelList = new List <ClassLibrary.Model.Links>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                ClassLibrary.Model.Links model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ClassLibrary.Model.Links();
                    if (dt.Rows[n]["ID"] != DBNull.Value)
                    {
                        model.ID = Convert.ToInt32(dt.Rows[n]["ID"]);
                    }
                    if (dt.Rows[n]["Title"] != DBNull.Value)
                    {
                        model.Title = Convert.ToString(dt.Rows[n]["Title"]);
                    }
                    if (dt.Rows[n]["Img"] != DBNull.Value)
                    {
                        model.Img = Convert.ToString(dt.Rows[n]["Img"]);
                    }
                    if (dt.Rows[n]["LinkURL"] != DBNull.Value)
                    {
                        model.LinkURL = Convert.ToString(dt.Rows[n]["LinkURL"]);
                    }
                    if (dt.Rows[n]["CreatedTime"] != DBNull.Value)
                    {
                        model.CreatedTime = Convert.ToDateTime(dt.Rows[n]["CreatedTime"]);
                    }
                    if (dt.Rows[n]["LinkClass"] != DBNull.Value)
                    {
                        model.LinkClass = Convert.ToInt32(dt.Rows[n]["LinkClass"]);
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #2
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model对象</param>
 public int Add(ClassLibrary.Model.Links model)
 {
     return(dal.Add(model));
 }
コード例 #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model对象</param>
 /// <returns>影响行数</returns>
 public int Update(ClassLibrary.Model.Links model)
 {
     return(dal.Update(model));
 }