Esempio n. 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            string newtype    = this.NewType.SelectedItem.Text;;
            string subject    = this.Subject.Text.Trim();
            string hidcontent = this.hidcontent.Value;
            string content    = HttpUtility.UrlDecode(hidcontent);

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.News news = new Model.News();
                    news.NewType    = newtype;
                    news.Subject    = subject;
                    news.Content    = content;
                    news.CreateBy   = Convert.ToInt32(Session["ID"] == null ? "0" : Session["ID"].ToString());
                    news.CreateTime = DateTime.Now;
                    entity.AddToNews(news);
                    entity.SaveChanges();
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
Esempio n. 2
0
        private static string AddNews()
        {
            string strreturn;
            string strTitle   = NetSchool.Common.Library.GetPostBack.GetPostBackStr("title");
            string strContent = Microsoft.JScript.GlobalObject.unescape(NetSchool.Common.Library.GetPostBack.GetPostBackStr("content"));

            NetSchool.Model.News newsInfo = new Model.News();
            newsInfo.NewsID     = Guid.NewGuid();
            newsInfo.Title      = strTitle;
            newsInfo.Content    = strContent;
            newsInfo.ViewNum    = 0;
            newsInfo.Author     = NetSchool.Common.Info.CurUserInfo.Username;
            newsInfo.CreateTime = DateTime.Now;
            newsInfo.EditTime   = DateTime.Now;

            if (NetSchool.BLL.News.Add(newsInfo))
            {
                strreturn = JsonConvert.SerializeObject(new { state = "success", msg = "OK" }, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
                {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                });
            }
            else
            {
                strreturn = JsonConvert.SerializeObject(new { state = "error", msg = "插入失败" }, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
                {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                });
            }
            return(strreturn);
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int itemId = Convert.ToInt32(Request.Params["id"]);

                if (itemId != 0)
                {
                    Model.News item = DataHelper.GetOneNews(itemId);

                    TextBoxDate.Text = item.Date.ToString("dd.MM.yyyy");

                    NewsText.Text = item.Text;
                    // DataHelper.GetUser(DataHelper.GetBill(cashOut.BillId).UserId).UserName;

                    LabelChangesDate.Text = item.CreateDate.ToString("dd.MM.yyyy HH:mm");

                    LabelAuthor.Text = DataHelper.GetUser(item.AuthorId).UserName;

                    CheckBoxActive.Checked = item.Active.HasValue && item.Active.Value;
                }
                else
                {
                    LabelChangesDate.Text = DateTime.Now.ToString("dd.MM.yyyy");
                    LabelAuthor.Text      = User.UserName;

                    CheckBoxActive.Checked = true;
                    TextBoxDate.Text       = DateTime.Now.ToString("dd.MM.yyyy");
                }
            }
        }
Esempio n. 4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == null || DropDownList1.SelectedIndex == 0 || DropDownList2.SelectedIndex == 0)
            {
                Response.Write("<script>alert('请填写新闻标题,选择所属课程和类别! ');</script>");
            }
            else
            {
                Model.News item = new Model.News();
                item.Title    = TextBox1.Text;
                item.ClassId  = Convert.ToInt32(DropDownList1.SelectedValue);
                item.Sort     = Convert.ToInt32(DropDownList2.SelectedValue);
                item.Text     = FCKeditor1.Value;
                item.Time     = DateTime.Now.ToString();
                item.WriterId = Convert.ToInt32(Request.Cookies["login"]["ID"]);

                int flag = BLL.News.BLLInsertNews(item);
                if (flag == 1)
                {
                    Response.Write("<script>alert('添加新闻成功! ');window.window.location.href='Default.aspx';</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加新闻失败! ');window.window.location.href='Default.aspx';</script>");
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnNew_Click(object sender, EventArgs e)
 {
     string newtype = this.NewType.SelectedItem.Text; ;
     string subject = this.Subject.Text.Trim();
     string hidcontent = this.hidcontent.Value;
     string content = HttpUtility.UrlDecode(hidcontent);
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             ZLzuche.Model.News news = new Model.News();
             news.NewType = newtype;
             news.Subject = subject;
             news.Content =content;
             news.CreateBy = Convert.ToInt32(Session["ID"] == null ? "0" : Session["ID"].ToString());
             news.CreateTime = DateTime.Now;
             entity.AddToNews(news);
             entity.SaveChanges();
         }
         Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
         Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
         return;
     }
 }
Esempio n. 6
0
        public SqlDataReader datareader(Model.News mn)
        {
            DAL.News      dn  = new DAL.News();
            SqlDataReader sdr = dn.datareader(mn);

            return(sdr);
        }
Esempio n. 7
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            Model.News news = new Model.News()
            {
                News_Title   = this.txtName.Text,
                News_Content = this.txtNewsContent.Value,
                News_Image   = upFileName(FileUpload1, "../../upload/news/")
            };

            var       res = newsSvc.Add(news);
            ReturnMsg rs  = res > 0
                ? new ReturnMsg()
            {
                Code    = StatusCode.Ok,
                Message = "添加新闻成功",
                Data    = null
            }
                : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "添加新闻失败",
                Data    = null
            };

            Session["Msg"] = rs;
            Response.Redirect("News_List.aspx");
        }
Esempio n. 8
0
        protected void txtOK_Click(object sender, EventArgs e)
        {
            BLL.NewsBLL n    = new BLL.NewsBLL();
            Model.News  news = new Model.News();

            news.Title   = txtTitle.Text;
            news.Content = txtContent.Text;
            news.Author  = txtAuthor.Text;

            bool flag = n.InsertNews(news);

            if (txtTitle.Text == "" || txtContent.Text == "" || txtAuthor.Text == "")
            {
                Response.Write("<script language='javascript'>alert('请将内容填写完整!');</script>");
            }
            else
            {
                if (flag)
                {
                    Response.Write("<script language='javascript'>alert('新闻发布成功!');</script>");
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('新闻发布失败!');</script>");
                }
            }
        }
Esempio n. 9
0
        public int update(Model.News mn)
        {
            DAL.News dn     = new DAL.News();
            int      result = dn.update(mn);

            return(result);
        }
Esempio n. 10
0
        public int add(Model.News mn)
        {
            DAL.News dn     = new DAL.News();
            int      result = dn.add(mn);

            return(result);
        }
Esempio n. 11
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (TextBox1.Text == null || DropDownList1.SelectedIndex == 0 || DropDownList2.SelectedIndex == 0)
     {
         Response.Write("<script>alert('请填写新闻标题,选择所属课程和类别! ');</script>");
     }
     else
     {
         Model.News item = new Model.News();
         item.Title   = TextBox1.Text;
         item.ClassId = Convert.ToInt32(DropDownList1.SelectedValue);
         item.Sort    = Convert.ToInt32(DropDownList2.SelectedValue);
         item.Text    = FCKeditor1.Value;
         item.ID      = Convert.ToInt32(Request.QueryString["id"]);
         int flag = BLL.News.BLLUpdateNews(item);
         if (flag == 1)
         {
             Response.Write("<script>alert('修改新闻成功! ');</script>");
         }
         else
         {
             Response.Write("<script>alert('修改新闻失败! ');</script>");
         }
     }
 }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);

            Model.News    item       = new Model.News();
            SqlDataReader sdr        = BLL.News.BLLGetOneClassView(id);
            string        personName = null;
            string        className  = null;

            while (sdr.Read())
            {
                item.Title = sdr[1].ToString();
                item.Text  = sdr[2].ToString();
                item.Time  = sdr[3].ToString();
                personName = sdr[5].ToString();
                className  = sdr[4].ToString();
            }

            Page.Title  = item.Title;
            Label1.Text = item.Title;
            Label2.Text = "所属课程:" + className;
            Label3.Text = "发布人:" + personName;
            Label4.Text = "发布时间:" + item.Time;
            Label5.Text = item.Text;
        }
Esempio n. 13
0
 public IActionResult Post([FromBody] Model.News news)
 {
     if (news == null)
     {
         return(BadRequest("News is null."));
     }
     _newsService.SubmitNews(news);
     return(Ok());
 }
Esempio n. 14
0
 public IActionResult OnePage(string cabh)
 {
     Model.News n = ndal.GetModelByCabh(cabh);
     if (n == null)
     {
         return(Content("无此新闻"));
     }
     return(View(n));
 }
Esempio n. 15
0
 public void ss(string sousuo)
 {
     Model.News news = new Model.News();
     news.title = sousuo;
     BLL.NewsBLL newsBLL = new BLL.NewsBLL();
     if (newsBLL.SearchTitle(news))
     {
         this.SqlDataSource1.SelectCommand = news.sql;
     }
 }
Esempio n. 16
0
 public void del(string id)
 {
     Model.News news = new Model.News();
     news.id = id;
     BLL.NewsBLL newsBLL = new BLL.NewsBLL();
     if (newsBLL.DelNews(news))
     {
         Response.Write("<script>alert('删除成功');location.href='report_check.aspx'</script>");
     }
 }
Esempio n. 17
0
 protected void Button2_Click1(object sender, EventArgs e)
 {
     Model.News news = new Model.News();
     news.id = s;
     BLL.NewsBLL newsBLL = new BLL.NewsBLL();
     if (newsBLL.DelNews(news))
     {
         Response.Write("<script>alert('删除成功');location.href='choose.aspx'</script>");
     }
 }
Esempio n. 18
0
 public async Task UpdateNew(Model.News model)
 {
     try
     {
         await db.UpdateAsync(model);
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
Esempio n. 19
0
 public async Task UpdateNew(Model.News model)
 {
     try
     {
         await db.UpdateAsync(model);
     }
     catch (Exception ex)
     {
         Log.SaveLog("UpdateNew", ex);
     }
 }
Esempio n. 20
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Model.News news = new Model.News();
     news.id         = s;
     news.category   = DropDownList1.SelectedItem.Text;
     news.title      = Request["ttitle"].ToString();
     news.author     = Request["author"].ToString();
     news.contents   = this.txtEditorContents.Text;
     news.createTime = DateTime.Now.ToLocalTime().ToString();
     BLL.NewsBLL newsBLL = new BLL.NewsBLL();
     newsBLL.UpdateNews(news);
 }
Esempio n. 21
0
        private void ShowInfo(int Id)
        {
            Maticsoft.BLL.Leaveword   bll   = new Maticsoft.BLL.Leaveword();
            Maticsoft.Model.Leaveword model = bll.GetModel(Id);
            this.lblId.Text = model.Id.ToString();
            BLL.News   BLLNews   = new BLL.News();
            Model.News ModelNews = BLLNews.GetModel((int)model.Fk_News_Id);
            this.lblFk_News_Id.Text = ModelNews.Name;
            this.lblContents.Text   = model.Contents;

            this.lblAddTimes.Text = model.AddTimes.ToString();
        }
Esempio n. 22
0
 /// <summary>
 /// 上一条新闻
 /// </summary>
 /// <param name="list"></param>
 /// <param name="news"></param>
 /// <returns></returns>
 private Model.News GetPreNews(List <News> list, News news)
 {
     Model.News preNews = null;
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].NewsId == news.NewsId)
         {
             preNews = i == 0 ? null : list[i - 1];
         }
     }
     return(preNews);
 }
Esempio n. 23
0
 /// <summary>
 /// 下一条新闻
 /// </summary>
 /// <param name="list"></param>
 /// <param name="news"></param>
 /// <returns></returns>
 private Model.News GetNextNews(List <News> list, News news)
 {
     Model.News nextNews = null;
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].NewsId == news.NewsId)
         {
             nextNews = i == list.Count - 1 ? null : list[i + 1];
         }
     }
     return(nextNews);
 }
Esempio n. 24
0
        public void newsupdate()
        {
            Model.News news = new Model.News();
            news.category   = DropDownList1.SelectedItem.Text;
            news.title      = Request["ttitle"].ToString();
            news.author     = Request["author"].ToString();
            news.contents   = this.txtEditorContents.Text;
            news.createTime = DateTime.Now.ToLocalTime().ToString();
            int click = 0;

            news.click = click.ToString();
            BLL.NewsBLL newsBLL = new BLL.NewsBLL();
            newsBLL.AddNews(news);
        }
Esempio n. 25
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         k = Convert.ToInt32(Request["id"]);
         this.Label6.Text = k.ToString();
         //更新点击量
         Model.News news = new Model.News();
         news.id = k.ToString();
         BLL.NewsBLL newsBLL = new BLL.NewsBLL();
         newsBLL.UpdateClick(news);
     }
     chaxun(k);
 }
Esempio n. 26
0
 public void chaxun(string id)
 {
     Model.News news = new Model.News();
     news.id = id;
     BLL.NewsBLL newsBLL = new BLL.NewsBLL();
     if (newsBLL.QueryNews(news))
     {
         this.Label1.Text = news.id.ToString();
         this.Label2.Text = news.title.ToString();
         Page.Title       = "匿名举报新闻 -" + news.title.ToString();
     }
     else
     {
         Response.Write("<script>alert('查询失败')</script>");
     }
 }
Esempio n. 27
0
 public void query(string id)
 {
     Model.News news = new Model.News();
     news.id = id;
     BLL.NewsBLL newsBLL = new BLL.NewsBLL();
     if (newsBLL.QueryNews(news))
     {
         this.ttitle.Value           = news.title.ToString();
         this.author.Value           = news.author.ToString();
         this.txtEditorContents.Text = news.contents;
     }
     else
     {
         Response.Write("<script>alert('查询失败')</script>");
     }
 }
Esempio n. 28
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Model.News  news    = new Model.News();
     BLL.NewsBLL newsBLL = new BLL.NewsBLL();
     if (this.DropDownList1.SelectedValue == "按标题")
     {
         news.title = Request["search"].ToString().Trim();
         newsBLL.SearchTitle(news);
         this.SqlDataSource1.SelectCommand = news.sql;
     }
     else if (this.DropDownList1.SelectedValue == "按类别")
     {
         news.category = Request["search"].ToString().Trim();
         newsBLL.SearchCategory(news);
         this.SqlDataSource1.SelectCommand = news.sql;
     }
 }
Esempio n. 29
0
 public ActionResult Add(string cabh)
 {
     Model.News n = dal.GetModelByCabh(cabh);
     if (n == null)
     {
         Model.Category ca = cadal.GetModelByBH(cabh);
         if (ca == null)
         {
             return(Content("分类不存在"));
         }
         n = new Model.News()
         {
             title = ca.caname, body = "", cabh = ca.bh, caname = ca.caname, createtime = DateTime.Now, visitnum = 0
         };
         int newsid = dal.Add(n);
         n.id = newsid;
     }
     return(View(n));
 }
Esempio n. 30
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            Model.News item = new Model.News();

            int itemId = 0;

            try
            {
                itemId = Convert.ToInt32(Request.Params["id"]);
            }
            catch (System.Exception ex)
            {
                DataHelper.AddException(ex);
            }

            if (itemId != 0)
            {
                item.Id = itemId;
            }

            try
            {
                var myDate = DateTime.ParseExact(TextBoxDate.Text, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);

                myDate = myDate.AddHours(DateTime.Now.Hour);
                myDate = myDate.AddMinutes(DateTime.Now.Minute);
                myDate = myDate.AddSeconds(DateTime.Now.Second);

                item.Date       = myDate;
                item.Text       = NewsText.Text;
                item.CreateDate = DateTime.Now;
                item.AuthorId   = User.UserId;
                item.Active     = CheckBoxActive.Checked;

                DataHelper.SubmitNews(item);
            }
            catch (System.Exception ex)
            {
                DataHelper.AddException(ex);
            }

            Response.Redirect("News.aspx");
        }
Esempio n. 31
0
 public ActionResult Add(Model.News m)
 {
     try
     {
         if (m.id == 0)
         {
             dal.Add(m);
             return(Json(new { code = 0, msg = "新增成功!" }));
         }
         else
         {
             dal.Update(m);
             return(Json(new { code = 0, msg = "编辑成功!" }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { code = 1, msg = $"出错:{ex.Message}" }));
     }
 }
Esempio n. 32
0
        protected void rbtnSubmit_Click(object sender, EventArgs e)
        {
            string TabV = TabStrip1.SelectedTab.Value;
            string titleString = "";
            string newsString = "";
            string newsString2 = "";
            string dataType = "";
            if (TabV == "1")
            {
                titleString = Title1.Text;
                newsString = contentText.Text;
                dataType = "DataType_Text";
            }
            else if (TabV == "2")
            {
                titleString = Title2.Text;
                newsString = contentEditor.Content;
                if (newsString.Contains("src=\"data:image"))
                {
                    RadScriptManager.RegisterStartupScript(Page, GetType(), "c1", "OpenAlert('图片不能直接复制到编辑器,请使用工具栏的图片上传功能!');", true);
                    return;
                }
                newsString2 = CheckStr(newsString);
                dataType = "DataType_Html";
            }
            RadTreeView categoryTreeView = RadDropDownTree2.Controls[0] as RadTreeView;
            if (titleString.Trim().Equals("") || newsString.Trim().Equals(""))
            {
                RadScriptManager.RegisterStartupScript(Page, GetType(), "c1", "OpenAlert('标题或内容不能为空!');", true);
                return;
            }
            if (categoryTreeView.SelectedNode == null)
            {
                RadScriptManager.RegisterStartupScript(Page, GetType(), "c2", "OpenAlert('分类不能为空!');", true);
                return;
            }

            string cgid = categoryTreeView.SelectedNode.Value;
            Model.News newsModel = new Model.News();
            newsModel.CategoryID = long.Parse(cgid);
            newsModel.Checked = 0;
            newsModel.Checker = "";
            newsModel.CheckMemo = "";
            newsModel.Contents = RadButton1.Checked ? newsString2 : newsString;//newsString;
            newsModel.DataSource = "DataSource_Manual";
            newsModel.DataType = dataType;
            newsModel.IsValid = true;
            newsModel.LastModifyTime = DateTime.Now;
            newsModel.Publisher = user.UserInfo.UserID;
            newsModel.Title = titleString;
            long newsId = 0;
            Model.Log logModel = new Model.Log();
            if (cgid.Equals("200"))
            {
                if (!imgHandle(newsModel.Contents))
                {
                    RadScriptManager.RegisterStartupScript(Page, GetType(), "c3", "OpenAlert('抱歉!添加条目失败!-缩略图生成失败');", true);
                    return;
                }
            }
            try
            {
                logModel.OperationItem = "添加条目";
                logModel.Operator = user.UserInfo.UserID;
                logModel.OperationTime = DateTime.Now;
                logModel.OperationDetail = "标题:" + titleString + " - 分类编号:" + cgid;
                newsId = news.Add(newsModel);
                if (newsId != 0)
                {
                    logModel.Memo = "成功";
                }
                else
                {
                    logModel.Memo = "失败!";
                }
            }
            catch (Exception ex)
            {
                logModel.Memo = "异常:" + ex.Message;
            }
            finally
            {
                log.Add(logModel);
                if (newsId != 0)
                {
                    RadScriptManager.RegisterStartupScript(Page, GetType(), "c", "OpenAlert('恭喜!添加条目成功!');", true);
                }
                else
                {
                    RadScriptManager.RegisterStartupScript(Page, GetType(), "c3", "OpenAlert('抱歉!添加条目失败!');", true);
                }
            }
        }
Esempio n. 33
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.News GetModel(long AutoID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select AutoID,Title,CategoryID,Contents,Publisher,DataSource,DataType,LastModifyTime,IsValid,Checked,Checker,CheckMemo from News");
            strSql.Append(" where AutoID=@AutoID limit 1");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@AutoID", MySqlDbType.Int64)
            };
            parameters[0].Value = AutoID;

            Model.News model=new Model.News();
            DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Esempio n. 34
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.News DataRowToModel(DataRow row)
 {
     Model.News model=new Model.News();
     if (row != null)
     {
         if(row["AutoID"]!=null && row["AutoID"].ToString()!="")
         {
             model.AutoID=long.Parse(row["AutoID"].ToString());
         }
         if(row["Title"]!=null)
         {
             model.Title=row["Title"].ToString();
         }
         if(row["CategoryID"]!=null && row["CategoryID"].ToString()!="")
         {
             model.CategoryID=long.Parse(row["CategoryID"].ToString());
         }
         if(row["Contents"]!=null)
         {
             model.Contents=row["Contents"].ToString();
         }
         if(row["Publisher"]!=null)
         {
             model.Publisher=row["Publisher"].ToString();
         }
         if(row["DataSource"]!=null)
         {
             model.DataSource=row["DataSource"].ToString();
         }
         if(row["DataType"]!=null)
         {
             model.DataType=row["DataType"].ToString();
         }
         if(row["LastModifyTime"]!=null && row["LastModifyTime"].ToString()!="")
         {
             model.LastModifyTime=DateTime.Parse(row["LastModifyTime"].ToString());
         }
         if(row["IsValid"]!=null && row["IsValid"].ToString()!="")
         {
             if((row["IsValid"].ToString()=="1")||(row["IsValid"].ToString().ToLower()=="true"))
             {
                 model.IsValid=true;
             }
             else
             {
                 model.IsValid=false;
             }
         }
         if (row["Checked"] != null)
         {
             model.Checked = int.Parse(row["Checked"].ToString());
         }
         if(row["Checker"]!=null)
         {
             model.Checker=row["Checker"].ToString();
         }
         if (row["CheckMemo"] != null)
         {
             model.CheckMemo = row["CheckMemo"].ToString();
         }
     }
     return model;
 }