当前位置: 首页>>代码示例>>C#>>正文


C# News.Save方法代码示例

本文整理汇总了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();
        }
开发者ID:zaheerahmad,项目名称:Admin,代码行数:29,代码来源:ctlAddNews.ascx.cs

示例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();
                    }
                }
            }
        }
开发者ID:zaheerahmad,项目名称:Admin,代码行数:44,代码来源:ctlAddNews.ascx.cs

示例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;
 }
开发者ID:zaheerahmad,项目名称:Admin,代码行数:31,代码来源:ctlAddNews.ascx.cs

示例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();
        }
开发者ID:Confirmit,项目名称:Portal,代码行数:12,代码来源:NewsManager.cs

示例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);
        }
开发者ID:zaheerahmad,项目名称:Admin,代码行数:16,代码来源:NewsController.cs

示例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);
        }
开发者ID:zaheerahmad,项目名称:Admin,代码行数:12,代码来源:NewsController.cs


注:本文中的News.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。