Exemplo n.º 1
0
 //Update news info after editing
 protected void LinkButton1_Click(object sender, EventArgs e)
 {
     try
     {
         string NewsHeadline, News, NewsID;
         NewsHeadline = txtnewsheadup.Text.Trim();
         News         = txtnewsup.Text.Trim();
         NewsID       = lblnewsid.Text;
         if (NewsHeadline == "")
         {
             lblmsgup.Text = "*Please Enter News Headlines!!";
         }
         else if (News == "")
         {
             lblmsgup.Text = "*please Enter News!!";
         }
         else
         {
             NewsInfoData data = new NewsInfoData();
             data.NewsHeadline = NewsHeadline;
             data.News         = News;
             data.NewsID       = int.Parse(NewsID);
             int result = new NewsInfoAction().UpdateNews(data); //method caling to update news
             if (result > 0)
             {
                 ViewNews();
                 Panel1.Visible = false;
             }
         }
     }
     catch (Exception ex)
     {
         lblmsgup.Text = ex.Message;
     }
 }
Exemplo n.º 2
0
    //Add news info
    public int AddNews(NewsInfoData Nidata)
    {
        NZEduEntities apData = new NZEduEntities();
        NewsInfo      data   = new NewsInfo();

        data.News         = Nidata.News;
        data.NewsDate     = Nidata.NewsDate;
        data.NewsHeadline = Nidata.NewsHeadline;

        apData.NewsInfoes.Add(data);
        int ans = apData.SaveChanges();

        return(ans);
    }
Exemplo n.º 3
0
    //Update news info
    public int UpdateNews(NewsInfoData data)
    {
        NZEduEntities nidata = new NZEduEntities();
        NewsInfo      ni     = new NewsInfo();

        var nsd = from p in nidata.NewsInfoes where p.NewsID == data.NewsID select p;

        foreach (NewsInfo nifo in nsd)
        {
            nifo.NewsID       = data.NewsID;
            nifo.NewsHeadline = data.NewsHeadline;
            nifo.News         = data.News;
            nifo.NewsDate     = data.NewsDate;
        }
        int ans = nidata.SaveChanges();

        return(ans);
    }
Exemplo n.º 4
0
 //Add News
 protected void lnknews_Click(object sender, EventArgs e)
 {
     try
     {
         string NewsHeadline, News, NewsDate;
         NewsHeadline = txtnewsheadline.Text.Trim();
         News         = txtnews.Text.Trim();
         NewsDate     = DateTime.Now.Date.ToString("dd-MM-yyyy");
         if (NewsHeadline == "" && News == "")
         {
             lblmsg.Text = "Please Fill all Fields!!";
         }
         else if (NewsHeadline == "")
         {
             lblmsg.Text = "Please Enter News Headlines!!";
         }
         else if (News == "")
         {
             lblmsg.Text = "please Enter News!!";
         }
         else
         {
             NewsInfoData data = new NewsInfoData();
             data.NewsHeadline = NewsHeadline;
             data.News         = News;
             data.NewsDate     = NewsDate;
             int ans = new NewsInfoAction().AddNews(data); //method calling to submit new News
             if (ans > 0)
             {
                 txtnewsheadline.Text = "";
                 txtnews.Text         = "";
                 ViewNews();
                 lblmsg.Text = "News submitted!";
             }
         }
     }
     catch (Exception ex)
     {
         lblmsg.Text = ex.Message;
     }
 }