/// <summary> /// 获得数据列表 /// </summary> public List <NoName.NetShop.Model.NewsModel> GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); List <NoName.NetShop.Model.NewsModel> modelList = new List <NoName.NetShop.Model.NewsModel>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { NoName.NetShop.Model.NewsModel model; for (int n = 0; n < rowsCount; n++) { model = new NoName.NetShop.Model.NewsModel(); if (ds.Tables[0].Rows[n]["NewsId"].ToString() != "") { model.NewsId = int.Parse(ds.Tables[0].Rows[n]["NewsId"].ToString()); } if (ds.Tables[0].Rows[n]["NewsType"].ToString() != "") { model.NewsType = int.Parse(ds.Tables[0].Rows[n]["NewsType"].ToString()); } if (ds.Tables[0].Rows[n]["Status"].ToString() != "") { model.Status = int.Parse(ds.Tables[0].Rows[n]["Status"].ToString()); } model.Title = ds.Tables[0].Rows[n]["Title"].ToString(); model.SubTitle = ds.Tables[0].Rows[n]["SubTitle"].ToString(); model.Brief = ds.Tables[0].Rows[n]["Brief"].ToString(); model.Content = ds.Tables[0].Rows[n]["Content"].ToString(); model.SmallImageUrl = ds.Tables[0].Rows[n]["SmallImageUrl"].ToString(); model.Author = ds.Tables[0].Rows[n]["Author"].ToString(); model.From = ds.Tables[0].Rows[n]["From"].ToString(); model.VideoUrl = ds.Tables[0].Rows[n]["VideoUrl"].ToString(); model.ImageUrl = ds.Tables[0].Rows[n]["ImageUrl"].ToString(); model.ProductId = ds.Tables[0].Rows[n]["ProductId"].ToString(); if (ds.Tables[0].Rows[n]["InsertTime"].ToString() != "") { model.InsertTime = DateTime.Parse(ds.Tables[0].Rows[n]["InsertTime"].ToString()); } if (ds.Tables[0].Rows[n]["ModifyTime"].ToString() != "") { model.ModifyTime = DateTime.Parse(ds.Tables[0].Rows[n]["ModifyTime"].ToString()); } model.Tags = ds.Tables[0].Rows[n]["Tags"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(NoName.NetShop.Model.NewsModel model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(NoName.NetShop.Model.NewsModel model) { dal.Add(model); }
/// <summary> /// ��������б� /// </summary> public List<NoName.NetShop.Model.NewsModel> GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); List<NoName.NetShop.Model.NewsModel> modelList = new List<NoName.NetShop.Model.NewsModel>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { NoName.NetShop.Model.NewsModel model; for (int n = 0; n < rowsCount; n++) { model = new NoName.NetShop.Model.NewsModel(); if(ds.Tables[0].Rows[n]["NewsId"].ToString()!="") { model.NewsId=int.Parse(ds.Tables[0].Rows[n]["NewsId"].ToString()); } if(ds.Tables[0].Rows[n]["NewsType"].ToString()!="") { model.NewsType=int.Parse(ds.Tables[0].Rows[n]["NewsType"].ToString()); } if(ds.Tables[0].Rows[n]["Status"].ToString()!="") { model.Status=int.Parse(ds.Tables[0].Rows[n]["Status"].ToString()); } model.Title=ds.Tables[0].Rows[n]["Title"].ToString(); model.SubTitle=ds.Tables[0].Rows[n]["SubTitle"].ToString(); model.Brief=ds.Tables[0].Rows[n]["Brief"].ToString(); model.Content=ds.Tables[0].Rows[n]["Content"].ToString(); model.SmallImageUrl=ds.Tables[0].Rows[n]["SmallImageUrl"].ToString(); model.Author=ds.Tables[0].Rows[n]["Author"].ToString(); model.From=ds.Tables[0].Rows[n]["From"].ToString(); model.VideoUrl=ds.Tables[0].Rows[n]["VideoUrl"].ToString(); model.ImageUrl=ds.Tables[0].Rows[n]["ImageUrl"].ToString(); model.ProductId=ds.Tables[0].Rows[n]["ProductId"].ToString(); if(ds.Tables[0].Rows[n]["InsertTime"].ToString()!="") { model.InsertTime=DateTime.Parse(ds.Tables[0].Rows[n]["InsertTime"].ToString()); } if(ds.Tables[0].Rows[n]["ModifyTime"].ToString()!="") { model.ModifyTime=DateTime.Parse(ds.Tables[0].Rows[n]["ModifyTime"].ToString()); } model.Tags=ds.Tables[0].Rows[n]["Tags"].ToString(); modelList.Add(model); } } return modelList; }