/// <summary> /// ����һ������ /// </summary> public void Add(NewsModel model) { DbCommand dbCommand = dbw.GetStoredProcCommand("UP_neNews_ADD"); dbw.AddInParameter(dbCommand, "NewsId", DbType.Int32, model.NewsId); dbw.AddInParameter(dbCommand, "NewsType", DbType.Byte, model.NewsType); dbw.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status); dbw.AddInParameter(dbCommand, "Title", DbType.AnsiString, model.Title); dbw.AddInParameter(dbCommand, "SubTitle", DbType.AnsiString, model.SubTitle); dbw.AddInParameter(dbCommand, "Brief", DbType.AnsiString, model.Brief); dbw.AddInParameter(dbCommand, "newsContent", DbType.String, model.Content); dbw.AddInParameter(dbCommand, "SmallImageUrl", DbType.AnsiString, model.SmallImageUrl); dbw.AddInParameter(dbCommand, "Author", DbType.AnsiString, model.Author); dbw.AddInParameter(dbCommand, "newsfrom", DbType.AnsiString, model.From); dbw.AddInParameter(dbCommand, "VideoUrl", DbType.AnsiString, model.VideoUrl); dbw.AddInParameter(dbCommand, "ImageUrl", DbType.AnsiString, model.ImageUrl); dbw.AddInParameter(dbCommand, "ProductId", DbType.AnsiString, model.ProductId); dbw.AddInParameter(dbCommand, "InsertTime", DbType.DateTime, model.InsertTime); dbw.AddInParameter(dbCommand, "ModifyTime", DbType.DateTime, model.ModifyTime); dbw.AddInParameter(dbCommand, "Tags", DbType.AnsiString, model.Tags); dbw.AddInParameter(dbCommand, "cateid", DbType.Int32, model.CategoryID); dbw.ExecuteNonQuery(dbCommand); }
protected void Button_Submit_Click(object sender, EventArgs e) { bool isEndCate = false; int SelectedParentCategoryID = NewsCategorySelect1.GetSelectedRegionInfo(out isEndCate).CateID; string strErr = String.Empty; if (TextBox_Title.Text == String.Empty) { strErr += "新闻标题不能为空!\\n"; } if (TextBox_Author.Text==String.Empty) { strErr += "新闻作者不能为空!\\n"; } if (TextBox_NewsFrom.Text == String.Empty) { strErr += "新闻来源不能为空!\\n"; } if (TextBox_Tags.Text == String.Empty) { strErr += "新闻标签不能为空!\\n"; } if (!isEndCate) { strErr += "新闻不能添加在非末级分类下!\\n"; } if (strErr != String.Empty) { MessageBox.Show(this, strErr); return; } int NewsID = CommDataHelper.GetNewSerialNum("ne"); NewsModel model = new NewsModel(); model.NewsId = NewsID; model.Title = TextBox_Title.Text; model.SubTitle = TextBox_SubTitle.Text; model.Author = TextBox_Author.Text; model.From = TextBox_NewsFrom.Text; model.CategoryID = SelectedParentCategoryID; model.Tags = TextBox_Tags.Text; model.Brief = TextBox_Brief.Text; model.Content = TextBox_Content.Text; model.InsertTime = DateTime.Now; model.ModifyTime = DateTime.Now; model.ProductId = String.IsNullOrEmpty(TextBox_ProductID.Text) ? "0" : TextBox_ProductID.Text; model.NewsType = 1; model.Status = 1; model.ImageUrl = ""; model.SmallImageUrl = ""; model.VideoUrl = ""; if (!String.IsNullOrEmpty(FileUpload_Image.FileName)) { string ImageUrl = String.Empty; if (NewsImageRule.SaveNewsImage(NewsID, FileUpload_Image.PostedFile, out ImageUrl)) { model.ImageUrl = ImageUrl; } else { MessageBox.Show(this, "图片上传失败,请检查格式及大小是否正确。"); return; } } if (!String.IsNullOrEmpty(FileUpload_Video.FileName)) { string VideoUrl = String.Empty; if (NewsVideoRule.SaveNewsVideo(NewsID, FileUpload_Video.PostedFile, out VideoUrl)) { model.VideoUrl = VideoUrl; } else { MessageBox.Show(this, "视频上传失败,请检查格式及大小是否正确。"); return; } } bll.Add(model); PageControler.Publish(6, true); Response.Redirect("List.aspx"); }
public static NewsModel GetImageUrl(NewsModel model) { model.ImageUrl = Config.UrlRoot + model.ImageUrl; return model; }
/// <summary> /// ����һ������ /// </summary> public void Add(NewsModel model) { dal.Add(model); }
/// <summary> /// ����һ������ /// </summary> public void Update(NewsModel model) { dal.Update(model); }
/// <summary> /// ��������б� /// </summary> public List<NewsModel> GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); List<NewsModel> modelList = new List<NewsModel>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { NewsModel model; for (int n = 0; n < rowsCount; n++) { model = new 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; }
public static NewsModel GetVideoUrl(NewsModel model) { model.VideoUrl = Config.UrlRoot + model.VideoUrl; return model; }
/// <summary> /// ����ʵ������� /// </summary> public NewsModel ReaderBind(IDataReader dataReader) { NewsModel model=new NewsModel(); object ojb; ojb = dataReader["NewsId"]; if(ojb != null && ojb != DBNull.Value) { model.NewsId=Convert.ToInt32(ojb); } ojb = dataReader["NewsType"]; if(ojb != null && ojb != DBNull.Value) { model.NewsType=Convert.ToInt32(ojb); } ojb = dataReader["Status"]; if(ojb != null && ojb != DBNull.Value) { model.Status = Convert.ToInt32(ojb); } model.Title=dataReader["Title"].ToString(); model.SubTitle=dataReader["SubTitle"].ToString(); model.Brief=dataReader["Brief"].ToString(); model.SmallImageUrl=dataReader["SmallImageUrl"].ToString(); model.Author=dataReader["Author"].ToString(); model.From=dataReader["newsFrom"].ToString(); model.VideoUrl=dataReader["VideoUrl"].ToString(); model.ImageUrl=dataReader["ImageUrl"].ToString(); model.ProductId=dataReader["ProductId"].ToString(); ojb = dataReader["InsertTime"]; if(ojb != null && ojb != DBNull.Value) { model.InsertTime=(DateTime)ojb; } ojb = dataReader["ModifyTime"]; if(ojb != null && ojb != DBNull.Value) { model.ModifyTime=(DateTime)ojb; } model.Tags=dataReader["Tags"].ToString(); model.CategoryID = Convert.ToInt32(dataReader["cateid"]); model.Content = Convert.ToString(dataReader["newscontent"]); return model; }