Inheritance: System.Web.UI.Page
Exemplo n.º 1
0
 // GET: news/Delete/5
 public ActionResult Delete(int?id)
 {
     if (Session["role"] != null)
     {
         if (Session["role"].ToString() == "ADM")
         {
             try
             {
                 if (id == null)
                 {
                     return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                 }
                 news news = db.news.Find(id);
                 if (news == null)
                 {
                     return(HttpNotFound());
                 }
                 return(View(news));
             }
             catch (Exception e)
             {
                 ViewBag.GenericException = e.Message;
             }
             return(RedirectToAction("Errors", "Navigate"));
         }
         else
         {
             return(RedirectToAction("RestrictedAccess", "Navigate"));
         }
     }
     else
     {
         return(RedirectToAction("RestrictedAccess", "Navigate"));
     }
 }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int nid = -1;
         try
         {
             nid = Convert.ToInt32(Request.QueryString["nid"].ToString());
             using (var db = new SiewebEntities())
             {
                 var se = from it in db.news
                          where it.id == nid && it.lang == 0
                          select it;
                 news News = db.news.SingleOrDefault(a => a.id == nid);
                 if (se.ToList().Count == 0)
                 {
                     Response.Redirect("newslist.aspx");
                 }
                 else
                 {
                     addStyle(News.newclass);
                     Rpt.DataSource = se.ToList();
                     Rpt.DataBind();
                 }
             }
         }
         catch
         {
             Response.Redirect("newslist.aspx");
         }
     }
 }
Exemplo n.º 3
0
        public ActionResult NewsDetail(string id)
        {
            var  context = new ApplicationDbContext();
            news Model   = context.newsList.Where(x => x.id == id).FirstOrDefault();

            return(View(Model));
        }
Exemplo n.º 4
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     using (var db = new CstwebEntities())
     {
         try
         {
             news new1 = db.news.FirstOrDefault(a => a.@class == 5);
             new1.title = TxtTitle.Text;
             new1.body  = myEditor.InnerText;
             new1.time  = DateTime.Now;
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'training.aspx';</script>");
         }
         catch
         {
             news new1 = new news();
             new1.title  = TxtTitle.Text;
             new1.body   = myEditor.InnerText;
             new1.time   = DateTime.Now;
             new1.@class = 5;
             db.news.Add(new1);
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'training.aspx';</script>");
         }
     }
 }
Exemplo n.º 5
0
    // Cập nhật thông tin tin
    public void CapnhatTin(news n)
    {
        con.Open();
        if (n.news_avatar != null)
        {
            string     sql = "Update news Set news_title=@news_title,news_description=@news_description,news_content=@news_content,news_avatar=@news_avatar,news_status=@news_status,news_cat_id=@news_cat_id where news_id=@news_id";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.Parameters.AddWithValue("news_title", n.news_title);
            cmd.Parameters.AddWithValue("news_description", n.news_description);
            cmd.Parameters.AddWithValue("news_content", n.news_content);
            cmd.Parameters.AddWithValue("news_avatar", n.news_avatar);
            cmd.Parameters.AddWithValue("news_status", n.news_status);
            cmd.Parameters.AddWithValue("news_cat_id", n.news_cat_id);
            cmd.Parameters.AddWithValue("news_id", n.news_id);

            cmd.ExecuteNonQuery();
        }
        else
        {
            string     sql = "Update news Set news_title=@news_title,news_description=@news_description,news_content=@news_content,news_status=@news_status,news_cat_id=@news_cat_id where news_id=@news_id";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.Parameters.AddWithValue("news_title", n.news_title);
            cmd.Parameters.AddWithValue("news_description", n.news_description);
            cmd.Parameters.AddWithValue("news_content", n.news_content);
            cmd.Parameters.AddWithValue("news_status", n.news_status);
            cmd.Parameters.AddWithValue("news_cat_id", n.news_cat_id);
            cmd.Parameters.AddWithValue("news_id", n.news_id);

            cmd.ExecuteNonQuery();
        }
        con.Close();
    }
Exemplo n.º 6
0
    //Lấy 1 tin ra

    public news get1New(int news_id)
    {
        string sql = "Select * From news, news_categories where news.news_cat_id=news_categories.news_cat_id And news_id=@news_id";

        con.Open();
        SqlCommand cmd = new SqlCommand(sql, con);

        cmd.Parameters.AddWithValue("news_id", news_id);
        SqlDataReader rd = cmd.ExecuteReader();
        news          n  = null;

        if (rd.Read())
        {
            n                  = new news();
            n.news_id          = (int)rd["news_id"];
            n.news_title       = (string)rd["news_title"];
            n.news_description = (string)rd["news_description"];
            n.news_content     = (string)rd["news_content"];
            n.news_avatar      = (string)rd["news_avatar"];
            n.news_status      = (Boolean)rd["news_status"];
            n.news_cat_id      = (int)rd["news_cat_id"];
        }
        con.Close();
        return(n);
    }
Exemplo n.º 7
0
    //Lấy ra tin hiện
    public List <news> getAllNews()
    {
        string sql = "Select * From news, news_categories where news.news_cat_id=news_categories.news_cat_id and news.news_status=1 ORDER BY news_id DESC";

        con.Open();
        SqlCommand    cmd = new SqlCommand(sql, con);
        SqlDataReader rd  = cmd.ExecuteReader();
        List <news>   li  = new List <news>();

        while (rd.Read())
        {
            news n = new news();
            n.news_id          = (int)rd["news_id"];
            n.news_title       = (string)rd["news_title"];
            n.news_description = (string)rd["news_description"];
            n.news_content     = (string)rd["news_content"];
            n.news_avatar      = (string)rd["news_avatar"];
            n.news_cat_id      = (int)rd["news_cat_id"];
            n.news_cat_name    = (string)rd["news_cat_name"];
            n.news_content     = (string)rd["news_content"];
            n.news_status      = (Boolean)rd["news_status"];
            li.Add(n);
        }
        con.Close();
        return(li);
    }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("id,title,newscontent,createdate,newstype,createuser")] news news)
        {
            if (id != news.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(news);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!newsExists(news.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(news));
        }
Exemplo n.º 9
0
        public ActionResult 消息(int page = 1)
        {
            MotaiDataEntities db = new MotaiDataEntities();

            int cpage = page < 1 ? 1 : page;
            //資料庫讀取 tPromotions 為資料庫名稱
            var promotion = db.tPromotions.OrderByDescending(c => c.PromotionId).ToList();
            //開新List 取值
            List <news> reslsit = new List <news>();

            foreach (var items in promotion)
            {
                //實體化 class
                news res = new news();
                NewPromotionViewModel npv = new NewPromotionViewModel();
                //Prom 讀取入get set
                npv.sPromotinoCategory   = items.tPromotionCategory.PromtionCategory;
                npv.PromotionDescription = items.PromotionDescription;
                npv.pADimage             = items.pADimage;
                npv.pPromotionWeb        = items.pPromotionWeb;
                npv.pPromotionPostDate   = items.pPromotionPostDate;
                res.newPrmotion          = npv;
                reslsit.Add(res);
            }
            var result = reslsit.ToPagedList(cpage, pageSize);

            return(View(result));
        }
Exemplo n.º 10
0
 public void edit(news t)
 {
     try
     {
         comando = new SqlCommand(UPDATE, con.GetConexion());
         comando.Parameters.AddWithValue("@val1", t.author);
         comando.Parameters.AddWithValue("@val2", t.title);
         comando.Parameters.AddWithValue("@val3", t.description);
         comando.Parameters.AddWithValue("@val4", t.url);
         comando.Parameters.AddWithValue("@val5", t.urlToImage);
         comando.Parameters.AddWithValue("@val6", t.publishedAt);
         comando.Parameters.AddWithValue("@val7", t.content);
         comando.Parameters.AddWithValue("@val8", t.id);
         comando.Prepare();
         comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw new Exception("error en sql", e);
     }
     finally
     {
         con.SqlClose();
     }
 }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            CorpSendBase.Send("text 1234", touser: "******", msgType: MsgType.text);
            CorpSendBase.Send("D:\\Demo\\MyServiceLog.txt", "YuanHuiHui", msgType: MsgType.file);
            CorpSendBase.Send("C:\\Users\\yuanhh\\Desktop\\微信图片_20190520134904.png", "YuanHuiHui", msgType: MsgType.image);
            CorpSendBase.Send("C:\\Users\\yuanhh\\Desktop\\VQLC0849.MP4", "YuanHuiHui", msgType: MsgType.video);
            news news = new news()
            {
                articles = new List <articles>()
                {
                    new articles()
                    {
                        title       = "端午浓情,粽相随",
                        description = "集团消息,祝端午节快乐,",
                        picurl      = "http://b.hiphotos.baidu.com/image/pic/item/9825bc315c6034a8ef5250cec5134954082376c9.jpg",
                        url         = "www.baidu.com",
                    }
                },
            };

            CorpSendBase.Send(news, touser: "******", msgType: MsgType.news);
            var textCard = new textcard()
            {
                btntxt      = "更多",
                description = "<div class=\"gray\">2016年9月26日</div> <div class=\"normal\">恭喜你抽中iPhone 7一台,领奖码:xxxx</div><div class=\"highlight\">请于2016年10月10日前联系行政同事领取</div>",
                title       = "恭喜你抽中iPhone 7一台",
                url         = "www.baidu.com"
            };

            CorpSendBase.Send(textCard, touser: "******", msgType: MsgType.textcard);
            Console.ReadKey();
        }
Exemplo n.º 12
0
        public ActionResult EditCoverPicture(newsViewModels itemm, HttpPostedFileBase idFile, HttpPostedFileBase idFilee)
        {
            if (ModelState.IsValid)
            {
                string uniqueName = Guid.NewGuid().ToString() +
                                    System.IO.Path.GetExtension(idFile.FileName);
                var uploadUrl = Server.MapPath("~/Content/img");

                idFile.SaveAs(Path.Combine(uploadUrl, uniqueName));



                var imgPath = "~/Content/img" + uniqueName;
                itemm.link_img = "img\\" + uniqueName;

                news g = artSer.GetById(itemm.idArticle);

                g.link_img = itemm.link_img;


                artSer.Update(g);
                return(RedirectToAction("Edit", new { id = itemm.idArticle }));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 13
0
        public async Task <IViewComponentResult> InvokeAsync(string index)
        {
            return(await Task.Run(() =>
            {
                //根据Index查询用户编号
                var entity = userRepository.GetUserByIndexAsync(index);
                if (entity != null)
                {
                    //查询特别推荐文章列表
                    ViewBag.SpecialRecommendNewsList = newsRepository.GetSpecialRecommendNewsList(entity.id, 3);


                    //查询点击排行文章列表
                    IList <news> topNewsList = newsRepository.GetTopNewsList(entity.id, 5);
                    news topFirst = topNewsList.FirstOrDefault();
                    ViewBag.TopNewFirst = topFirst;
                    if (topFirst != null)
                    {
                        ViewBag.TopNewsList = topNewsList.Where(w => w.id != topFirst.id).ToList();
                    }

                    //查询栏目推荐文章列表
                    IList <news> recommendNewsList = newsRepository.GetRecommendNewsList(entity.id, 5);
                    news recommendFirst = recommendNewsList.FirstOrDefault();
                    ViewBag.RecommendNewsFirst = recommendFirst;
                    if (recommendFirst != null)
                    {
                        ViewBag.RecommendNewsList = recommendNewsList.Where(w => w.id != recommendFirst.id).ToList();
                    }
                }

                return View();
            }));
        }
Exemplo n.º 14
0
 public IActionResult Save(news vmodel)
 {
     if (vmodel != null)
     {
         if (string.IsNullOrEmpty(vmodel.name))
         {
             throw new MessageBox("请输入标题");
         }
         if (!string.IsNullOrEmpty(vmodel.id))
         {
             vmodel.update_time = DateTime.Now;
             _newsService.Update(vmodel);
         }
         else
         {
             vmodel.id           = Guid.NewGuid().ToString();
             vmodel.created_time = DateTime.Now;
             vmodel.update_time  = DateTime.Now;
             _newsService.Insert(vmodel);
         }
     }
     else
     {
         return(Json(new { status = 0, msg = "无效参数" }));
     }
     return(Json(new { status = 1, msg = "操作成功" }));
 }
Exemplo n.º 15
0
        public IHttpActionResult Putnews(int id, news news)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != news.news_id)
            {
                return(BadRequest());
            }

            db.Entry(news).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!newsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 16
0
        public async Task <ResultDto> Add([FromBody] newsmodeldto model)
        {
            if (!ModelState.IsValid)
            {
                return(new ResultErrorDto
                {
                    Status = 500,
                    Errors = CustomValidator.GetErrorsByModel(ModelState)
                });
            }

            var news1 = new news()
            {
                Text     = model.Text,
                Title    = model.Title,
                ImageUrl = model.ImageUrl,
                Likes    = model.Likes,
                Subtitle = model.Subtitle
            };

            _context.News.AddAsync(news1);
            _context.SaveChanges();

            return(new ResultDto
            {
                Status = 200
            });
        }
Exemplo n.º 17
0
    protected news PBind(int i)
    {
        news re = new news();

        try
        {
            using (var db = new SiewebEntities())
            {
                var se = from it in db.news
                         where it.lang == 0 && it.newclass == i
                         orderby it.updatetime descending
                         select it;
                for (int j = 0; j < se.ToList().Count; j++)
                {
                    if (se.ToList()[j].listpicture != "")
                    {
                        return(se.ToList()[j]);
                    }
                }
            }
        }
        catch
        {
            re.id          = 0;
            re.listpicture = "";
        }
        return(re);
    }
Exemplo n.º 18
0
        public ActionResult DeleteConfirmed(int id)
        {
            //DELETE IMAGES FROM DATABASE
            List <image> images = db.images.Where(i => i.news_article_id == id).ToList();

            foreach (image img in images)
            {
                db.images.Remove(img);
            }

            //DELETE FROM NEWS
            news news = db.news.Find(id);

            db.news.Remove(news);
            db.SaveChanges();

            //REMOVE FROM DIRECTORY
            string        pathToDirectory = Request.MapPath("~/News_Images/" + id.ToString());
            DirectoryInfo DirInfo         = new DirectoryInfo(pathToDirectory);

            foreach (FileInfo file in DirInfo.GetFiles())
            {
                file.Delete();
            }

            //IF THERE AREN'T ANY MORE FILES IN THE DIRECTORY, DELETE THE DIRECTORY
            if (!Directory.EnumerateFileSystemEntries(pathToDirectory).Any())
            {
                Directory.Delete(pathToDirectory);
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 19
0
        public string donews()
        {
            string   title   = Request["title"];
            string   author  = Request["author"];
            DateTime addtime = DateTime.Parse(Request["addtime"]);
            string   content = Request["content"];

            var db = new airenEntities();

            //id 为空 添加
            if (string.IsNullOrWhiteSpace(Request["id"]))
            {
                news news = new news();
                news.Title   = title;
                news.Author  = author;
                news.AddTime = addtime;
                news.Content = content;
                db.news.Add(news);
                db.SaveChanges();
                return("success");
            }
            //id 不为空 修改
            else
            {
                int id  = int.Parse(Request["id"]);
                var nws = db.news.Where(n => n.ID == id).FirstOrDefault();
                nws.Title   = title;
                nws.Author  = author;
                nws.AddTime = addtime;
                nws.Content = content;
                db.SaveChanges();
                return("success1");
            }
        }
Exemplo n.º 20
0
        public ActionResult Create([Bind(Include = "newsid,title,text,users_userid,date")] news news, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                //Get the user id of the current user and add it to the News item
                string     username = User.Identity.Name.ToString();
                var        userid   = db.AspNetUsers.SqlQuery("SELECT * FROM AspNetUsers WHERE UserName = "******"'" + username + "'").ToList();
                AspNetUser user     = userid[0];
                news.users_userid = user.Id;

                //Get the current data and add it to the News item
                news.date = DateTime.Now;
                if (upload != null && upload.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(upload.InputStream))
                    {
                        news.thumbnail = reader.ReadBytes(upload.ContentLength);
                    }
                }


                db.news.Add(news);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.users_userid = new SelectList(db.AspNetUsers, "Id", "Email", news.users_userid);
            return(View(news));
        }
Exemplo n.º 21
0
    protected void btnThemTin_Click(object sender, EventArgs e)
    {
        try
        {
            news n = new news();
            n.news_title       = news_title.Text;
            n.news_description = news_description.Text;
            n.news_content     = news_content.Text;
            //n.news_avatar = news_avatar.Text;
            //upload file ảnh
            if (Page.IsValid && FileUpload1.HasFile)
            {
                string fileName = "images/" + FileUpload1.FileName;
                string filePath = MapPath(fileName);
                FileUpload1.SaveAs(filePath);
                n.news_avatar = FileUpload1.FileName;
            }

            n.news_status = Convert.ToBoolean(news_status.SelectedValue);
            n.news_cat_id = Convert.ToInt32(news_cat_id.SelectedValue);

            data.ThemTin(n);

            err_msg.ForeColor = System.Drawing.Color.Green;
            err_msg.Text      = "Thêm phòng thành công!";
        }
        catch (Exception ex)
        {
            err_msg.ForeColor = System.Drawing.Color.Red;
            err_msg.Text      = "Đã xảy ra lỗi: " + ex.Message;
        }
    }
Exemplo n.º 22
0
        /// <summary>
        /// 获取最新资讯
        /// </summary>
        private async void GetNews(int i)
        {
            string news = "http://dxy.com/app/i/columns/article/list?page_index=" + i + "&items_per_page=10&order=publishTime";


            HttpResponseMessage response = await client.GetAsync(news);

            string responseBody = await response.Content.ReadAsStringAsync();

            string tmp = responseBody.Substring(8, responseBody.Length - 9);

            resNews = JsonConvert.DeserializeObject <news>(tmp);

            resNews.Items.ToList().ForEach(z =>
            {
                bindNews.Add(z);
            });
            if (resNews.Items.Count < 10)
            {
                addMore.Text = end;
                return;
            }
            page++;
            loading.Visibility = Visibility.Collapsed;
        }
Exemplo n.º 23
0
        public ActionResult Edit([Bind(Include = "Newsid,Name,Description,ShortDescription,Image,Thumbnail,date")] news news, HttpPostedFileBase file, Helper Help)
        {
            if (ModelState.IsValid)
            {
                news.date  = System.DateTime.Now;
                news.Image = file != null?Help.uploadfile(file) : img;

                #region delete file
                string fullPath = Request.MapPath("~/UploadedFiles/" + img);
                if (img == news.Image)
                {
                }
                else
                {
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                }
                #endregion
                news.Thumbnail = file != null?Help.uploadfile(file) : thumb;

                db.Entry(news).State = EntityState.Modified;
                db.SaveChanges();
                TempData["Success"] = "Updated Successfully";
                return(RedirectToAction("Index"));
            }
            return(View(news));
        }
Exemplo n.º 24
0
        public ActionResult GetDetails(int id = 0)
        {
            news news = db.news.Find(id);

            if (news == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.menuleft = Config.getProjectMenu();
            ViewBag.datetime = "<span itemprop=\"datePublished\" style=\"color:green;\">" + news.datetime.Value + "</span>";
            ViewBag.content  = news.fullcontent;
            if (news.des != null)
            {
                ViewBag.des = Regex.Replace(news.des, "<.*?>", string.Empty);
            }
            else
            {
                ViewBag.des = news.title;
            }
            ViewBag.image     = Config.domain + news.image;
            ViewBag.url       = Config.domain + "/" + Config.unicodeToNoMark(news.title) + "-" + id;
            ViewBag.title     = news.title;
            ViewBag.keywords  = news.keywords;
            ViewBag.newsother = null;
            try
            {
                var p = (from q in db.news where q.id != id select q).OrderByDescending(o => o.id).Take(5).ToList();
                ViewBag.newsother = p;
            }
            catch (Exception ex) {
            }
            return(View(news));
        }
Exemplo n.º 25
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     using (var db = new CstwebEntities())
     {
         try
         {
             news new1 = db.news.FirstOrDefault(a => a.@class == 0);
             new1.title = TxtTitle.Text;
             new1.body = myEditor.InnerText;
             new1.time = DateTime.Now;
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'introduce.aspx';</script>");
         }
         catch
         {
             news new1 = new news();
             new1.title = TxtTitle.Text;
             new1.body = myEditor.InnerText;
             new1.time = DateTime.Now;
             new1.@class = 0;
             db.news.Add(new1);
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'introduce.aspx';</script>");
         }
     }
 }
Exemplo n.º 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            neid = Convert.ToInt32(Request.QueryString["id"]);
            if (!IsPostBack)
            {
                using (var db = new CstwebEntities())
                {
                    news ne = db.news.First <news>(a => a.id == neid);
                    newsclass          = ne.@class;
                    TxtTitle.Text      = ne.title;
                    myEditor.InnerHtml = ne.body;
                }
            }
        }
        catch
        {
            neid = 0;
            if (!Int32.TryParse(Request.QueryString["nc"], out newsclass))
            {
                newsclass = 9;
            }
        }

        if (IsPostBack)
        {
            newsclass = Convert.ToInt32(DdlNew.SelectedValue);
        }
        if (!IsPostBack)
        {
            Refresh_DDlclss();
        }
    }
Exemplo n.º 27
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (loaded)
            {
                return;
            }
            if (!NavigationContext.QueryString.Keys.Contains("id"))
            {
                return;
            }
            string     id      = NavigationContext.QueryString["id"];
            string     url     = "http://dxy.com/app/i/columns/article/list?page_index=1&items_per_page=10&order=publishTime&special_id=" + id;
            HttpClient client  = new HttpClient();
            var        content = await client.GetAsync(url);

            string res = await content.Content.ReadAsStringAsync();

            string tmp = res.Substring(8, res.Length - 9);

            tmpnew = JsonConvert.DeserializeObject <news>(tmp);
            tmpnew.Items.ToList().ForEach(z =>
            {
                bindNews.Add(z);
            });
        }
Exemplo n.º 28
0
        //返回news对象
        private news generateNews(dynamic d)
        {
            news n = new news();

            n.id          = d["id"].ToString();
            n.cityId      = d["cityId"].ToString();
            n.cityName    = d["cityName"].ToString();
            n.newsType    = d["newsType"].ToString();
            n.newsTitle   = d["newsTitle"].ToString();
            n.newsCover   = util.generateImage(d["newsCover"].ToString());
            n.newsContent = d["newsContent"].ToString();
            n.newsAuthor  = d["newsAuthor"].ToString();
            n.newsBrief   = d["newsBrief"].ToString();
            n.state       = Convert.ToInt32(d["state"].ToString());
            n.readNum     = Convert.ToInt32(d["readNum"].ToString());
            n.updator     = d["updator"].ToString();
            n.updatorName = d["updatorName"].ToString();
            n.update_time = d["update_time"].ToString();
            n.creator     = d["creator"].ToString();
            n.creatorName = d["creatorName"].ToString();
            n.typeName    = d["typeName"].ToString();
            n.create_time = d["create_time"].ToString();

            return(n);
        }
Exemplo n.º 29
0
 public ActionResult CommentNewsByMember(news n)
 {
     /*commentValue = null;
      * //var nm = new NewsModels();
      * //nm.member.id_Member = 1;
      * //nm.topic_idTopic = 1;
      *
      * if(ModelState.IsValid)
      * {
      *  //UploadImage();
      *  var n = ns.getNewsById(nm.idNews);
      *
      *  //  title = nm.title,
      *  // description = nm.description,
      *  // picture = nm.picture,
      *  n.idNews = nm.idNews;
      *  n.comment = commentValue;
      *  n.admin_id_Member = nm.admin_id_Member;
      *  n.topic_idTopic = nm.topic_idTopic;
      *
      *  ns.Update(n);
      *  ns.Commit();
      * }
      * // return View();
      * return RedirectToAction("Index");*/
     ns.UpdateNewsById(n.idNews);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 30
0
        public JsonResult delNews(news news)
        {
            User user = (User)Session["user"];

            if (user != null)
            {
                if (user.type == 1)
                {
                    DbNewsDataContext db = new DbNewsDataContext();
                    var query            = from t in db.news
                                           where t.id == news.id
                                           select t;
                    foreach (news item in query)
                    {
                        db.news.DeleteOnSubmit(item);
                    }
                    db.SubmitChanges();
                    return(Json(Result.success()));
                }
                else
                {
                    return(Json(Result.fail()));
                }
            }
            else
            {
                return(Json(Result.fail()));
            }
        }
Exemplo n.º 31
0
        public JsonResult addNews(news news)
        {
            User user = (User)Session["user"];

            if (user != null)
            {
                if (user.type == 1)
                {
                    news.userId = user.id;
                    news.date   = DateTime.Now;
                    DbNewsDataContext db = new DbNewsDataContext();
                    db.news.InsertOnSubmit(news);
                    db.SubmitChanges();
                    return(Json(Result.success()));
                }
                else
                {
                    return(Json(Result.fail()));
                }
            }
            else
            {
                return(Json(Result.fail()));
            }
        }
Exemplo n.º 32
0
        public void AdminAddNewsItem(AddNewsItemViewModel model)
        {
            news newNewsItem = new news()
            {
                active = model.Active,
                body = model.Body,
                created_date = DateTime.Now,
                creator_id = model.CreatorID,
                image = model.ImageFilePath,
                title = model.Title
            };
            _dbContext.news.Add(newNewsItem);

            Save();
        }
Exemplo n.º 33
0
 public void addupdate()
 {
     news news = new news
     {
         newid = DateTime.Now.ToString("yyyyMMddHHmmssffff"),
         type = new int?(int.Parse(this.DropDownList1.SelectedValue)),
         subjects = this.txtPD_PROJECT_SUBJECTS.Text,
         contents = this.txtPD_PROJECT_CONTENTS.Value
     };
     if (news.contents.Length == 0)
     {
         news.contents = " ";
     }
     news.sysdate_ = new DateTime?(DateTime.Now);
     int count = 0;
     count = this.B_news.Add(news);
     if (count > 0)
     {
         PD_PROJECT_REGULATE_DETAIL_Bll bll = new PD_PROJECT_REGULATE_DETAIL_Bll();
         PD_PROJECT_REGULATE_DETAIL_Model model = new PD_PROJECT_REGULATE_DETAIL_Model
         {
             PD_PROJECT_CODE = news.newid
         };
         DataSet set = null;
         string s = base.Server.UrlDecode(this.FilePostCtr1.getFileName);
         if ((s != null) && (s.Trim() != ""))
         {
             set = new DataSet();
             XmlTextReader reader = new XmlTextReader(new StringReader(s));
             set.ReadXml(reader);
         }
         if (((set != null) && (set.Tables.Count > 0)) && ((set.Tables[0].Rows.Count > 0) && (set.Tables[0].Rows[0]["FileSysName"].ToString().Trim() != "")))
         {
             model.FILENAME = set.Tables[0].Rows[0]["FileName"].ToString();
             model.FILESYSNAME = set.Tables[0].Rows[0]["FileSysName"].ToString();
         }
         bll.Add(model);
     }
     if (base.Request["reload"] != null)
     {
         Const.AddSuccess(count, base.Request["reload"].ToString(), this.Page);
     }
     else
     {
         Const.AddSuccess(count, "", this.Page);
     }
 }
Exemplo n.º 34
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string str = Server.HtmlDecode(myEditor.InnerHtml);
        if (TxtTitle.Text.Trim() == "") Response.Write("<script>alert('标题不能为空')</script>");
        else if (str.Trim() == "") Response.Write("<script>alert('文章不能为空')</script>");
        else
            try
            {
                using (var db = new CstwebEntities())
                {
                    news ne;
                    if (neid == 0)
                        ne = new news();
                    else
                        ne = db.news.First<news>(a => a.id == neid);

                    ne.title = TxtTitle.Text.Trim();
                    ne.body = str.Trim();
                    ne.@class =11;
                    ne.time = DateTime.Now;
                    if (neid == 0)
                    {
                        db.news.Add(ne);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('发布成功');window.location = 'graduatenews.aspx';</script>");
                    }
                    else
                    {
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'graduatenews.aspx';</script>");
                    }

                }
            }
            catch
            {
                Response.Write("<script>alert('失败')</script>");
            }
    }
Exemplo n.º 35
0
 public static news Createnews(int id, global::System.DateTime pubdate, byte sourceID, string title)
 {
     news news = new news();
     news.id = id;
     news.pubdate = pubdate;
     news.sourceID = sourceID;
     news.title = title;
     return news;
 }
Exemplo n.º 36
0
 public void AddTonews(news news)
 {
     base.AddObject("news", news);
 }
Exemplo n.º 37
0
    public string getNewsNav()
    {
        string res = string.Empty;
        string lb = Request.QueryString.Get("sid");
        string newsid = Request.QueryString.Get("id");
        newsManager mgr = new newsManager();
        if (!string.IsNullOrEmpty(newsid))
        {
            WhereClip where = new WhereClip();

            where = where && news._.id == lb;
            news model = new news();
            model = mgr.GetnewsItemById(where);
            string typeid = model.sid.ToString();
            res = getHtmlFromTypeID(typeid);
            //根据新闻找到 新闻的上一级
        }
        else
        {
            res = getHtmlFromTypeID(lb);
            //看看该分类有没有上一级
        }
        return res;

    }