本文整理汇总了C#中News.Save方法的典型用法代码示例。如果您正苦于以下问题:C# News.Save方法的具体用法?C# News.Save怎么用?C# News.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类News
的用法示例。
在下文中一共展示了News.Save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public void Save()
{
string newsTitle = txtNewsTitle.Text;
string newsDescription = txtNewsDescription.Text;
News news = new News();
news.IsNew = true;
news.NewsTitle = newsTitle;
news.NewsDescription = newsDescription;
news.Save();
//Now Save Picture As Well..
string result = UploadPrintableFile(news);
if (result.Equals(""))
{
divStatusError.Visible = false;
divStatusSuccess.Visible = true;
lblStatusSuccess.Text = Global.SuccessLabelStatus;
//lblStatusSuccess.ForeColor = System.Drawing.Color.Green;
}
else
{
divStatusSuccess.Visible = false;
divStatusError.Visible = true;
labelStatusError.Text = Global.ErrorLabelStatus + result;
//labelStatusError.ForeColor = System.Drawing.Color.Red;
}
ClearForm();
}
示例2: btnAddNews_Click
protected void btnAddNews_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
if (newsId > 0)
{
News news = new News(newsId);
news.IsNew = false;
news.NewsTitle = txtNewsTitle.Text;
news.NewsDescription = txtNewsDescription.Text;
try
{
news.Save();
UploadPrintableFile(news);
divStatusError.Visible = false;
divStatusSuccess.Visible = true;
lblStatusSuccess.Text = Global.UpdatedLabelStatus;
//lblStatusSuccess.ForeColor = System.Drawing.Color.Green;
}
catch (Exception ex)
{
divStatusSuccess.Visible = false;
divStatusError.Visible = true;
labelStatusError.Text = Global.ErrorLabelStatus + ex.ToString();
//labelStatusError.ForeColor = System.Drawing.Color.Red;
}
}
else
{
try
{
Save();
}
catch (Exception ex)
{
divStatusSuccess.Visible = false;
divStatusError.Visible = true;
labelStatusError.Text = Global.ErrorLabelStatus + ex.ToString();
}
}
}
}
示例3: UploadPrintableFile
string UploadPrintableFile(News news)
{
string NewFileName = news.NewsId + "-" + Path.GetFileName(fuNewsPicture.PostedFile.FileName);
string FileNameWithoutExt = news.NewsId + "-" + Path.GetFileNameWithoutExtension(fuNewsPicture.PostedFile.FileName);
string error;
if (fuNewsPicture.PostedFile.FileName == null || fuNewsPicture.PostedFile.FileName.Equals("") && newsId == 0)
{
news = new News(News.Columns.NewsId, news.NewsId);
news.IsNew = false;
news.NewsImage = "NoImage.jpg";
news.Save(Guid.NewGuid());
return string.Empty;
}
if (fuNewsPicture.PostedFile.ContentLength > 1)
{
Utility.DeleteFile(Global.NewsImages + news.NewsImage);
if (Utility.UploadFile(fuNewsPicture, FileNameWithoutExt, Global.NewsImages, out error))
{
news = new News(News.Columns.NewsId, news.NewsId);
news.IsNew = false;
news.NewsImage = NewFileName;
news.Save(Guid.NewGuid());
}
else
{
News.Destroy(news.NewsId);
return error.ToString();
}
}
return String.Empty;
}
示例4: SendNewsToArchive
/// <summary>
/// Send news to archive.
/// </summary>
/// <param name="newsID">News identificator.</param>
public static void SendNewsToArchive(int newsID)
{
News news = new News(newsID);
DateTime expDateTime = new DateTime(1900, 1, 1, 0, 0, 0);
news.ExpireTime = expDateTime;
news.Save();
}
示例5: Update
public void Update(int NewsId,string NewsTitle,string NewsDescription,string NewsImage)
{
News item = new News();
item.MarkOld();
item.IsLoaded = true;
item.NewsId = NewsId;
item.NewsTitle = NewsTitle;
item.NewsDescription = NewsDescription;
item.NewsImage = NewsImage;
item.Save(UserName);
}
示例6: Insert
public void Insert(string NewsTitle,string NewsDescription,string NewsImage)
{
News item = new News();
item.NewsTitle = NewsTitle;
item.NewsDescription = NewsDescription;
item.NewsImage = NewsImage;
item.Save(UserName);
}