protected void dltbtn_Click(object sender, EventArgs e)
        {
            NewsService.FeedServiceClient client = new NewsService.FeedServiceClient();
            NewsService.News news = new NewsService.News();
            news.NewsID = TextBox.Text.Trim();
            string result = client.DeleteNews(news);

            if (result == "News Deleted Successfully!")
            {
                bindgriddata();
                deletelabel.Text = "News ID : " + TextBox.Text.Trim() + " Deleted Successfully !";
            }
            else
            {
                deletelabel.Text = "News ID : " + TextBox.Text.Trim() + " Not Found !";
            }
        }
示例#2
0
 protected void add_news_Click(object sender, EventArgs e)
 {
     try
     {
         byte[]           bytes;
         NewsService.News nw = new NewsService.News();
         nw.NewsID      = newsId.Text;
         nw.Authorname  = author.Text;
         nw.Title       = ntitle.Text;
         nw.PublishDate = Convert.ToDateTime(publishdate.Text);
         nw.Content     = content.Text;
         HttpPostedFile postedFile    = imageUpload.PostedFile;
         string         filename      = Path.GetFileName(postedFile.FileName);
         string         fileExtension = Path.GetExtension(filename);
         int            fileSize      = postedFile.ContentLength;
         nw.Category  = categorylist.SelectedValue;
         nw.VideoLink = link.Text;
         Console.WriteLine(fileExtension);
         if (fileExtension.ToLower() == ".jpeg" || fileExtension.ToLower() == ".png" || fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".jfif")
         {
             Stream       stream       = postedFile.InputStream;
             BinaryReader binaryReader = new BinaryReader(stream);
             bytes        = binaryReader.ReadBytes((int)stream.Length);
             nw.NewsImage = bytes;
             Console.WriteLine(bytes);
             NewsService.FeedServiceClient client = new NewsService.FeedServiceClient();
             success.Text = "News Id : " + nw.NewsID + " " + client.AddNews(nw);
         }
         else
         {
             error.Text = "Image may be not in proper format.";
         }
     }
     catch (Exception ex)
     {
         success.Text = "News ID must be unique! or Error";
     }
 }