Esempio n. 1
0
        public ActionResult CpyNewsInfoEdit(int newsId, int companyId)
        {
            var news = NewsBll.LoadEntities(n => n.Id == newsId).FirstOrDefault();

            news.CompanyId = int.Parse(Request["companyId"].ToString());
            news.Title     = Request["title"];
            news.Game      = Request["gameName"];
            news.Kewords   = Request["keyword"];
            news.Type      = Request["type"];
            news.Memo      = Request["memo"];
            news.Msg       = Request["msg"];
            news.State     = "2";
            if (NewsBll.Update(news))
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("no"));
            }
        }
Esempio n. 2
0
        public ActionResult Views(int id)
        {
            var news = NewsBll.LoadEntities(n => n.Id == id).FirstOrDefault();

            if (news != null)
            {
                news.Views = news.Views == null?1:news.Views + 1;
                if (NewsBll.Update(news))
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }
            else
            {
                return(Content("noExist"));
            }
        }
Esempio n. 3
0
    /// <summary>
    /// 确定提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strError = Validates();

        if (!string.IsNullOrEmpty(strError))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>");
            return;
        }
        model.CategoryId      = Convert.ToInt32(this.ddlType.SelectedValue);
        model.Title           = SafeRequest.GetFormString("txtTitle");
        model.SubHead         = SafeRequest.GetFormString("txtSubHead");
        model.PublicationUnit = SafeRequest.GetFormString("txtUnit");
        model.FromSource      = SafeRequest.GetFormString("txtFromSouce");
        // model.KeyWord = SafeRequest.GetFormString("txtKeyWord");
        model.ReleaseDate  = !string.IsNullOrEmpty(this.txtReleaseDate.Text.Trim()) ? Convert.ToDateTime(this.txtReleaseDate.Text.Trim()) : System.DateTime.Now;
        model.IsTop        = 0; //SafeRequest.GetFormInt("radioTopList", 0);
        model.IndexCommend = 0; //SafeRequest.GetFormInt("radioIndexCommentList", 0);
        model.HotPic       = SafeRequest.GetFormString("radioHotList");
        model.HotDays      = SafeRequest.GetFormInt("txtHotDays", 3);
        //model.ArticleType = SafeRequest.GetFormInt("radioArticleTypeList", 0);
        model.Body = this.fckBody.Text;

        //追加底部
        if (cbFooter.Checked)
        {
            if (model.Body.IndexOf("start_auto_footer") == -1 && model.Body.IndexOf("end_auto_footer") == -1)
            {
                string autoFooter = "<!--start_auto_footer-->" + this.fckBodyFooter.Text + "<!--end_auto_footer-->";
                model.Body = model.Body + autoFooter;
            }
            //写入缓存
            NG.CachHelper.Redis.RedisHelper redis = new NG.CachHelper.Redis.RedisHelper();
            redis.SetStringCash("News_Footer", this.fckBodyFooter.Text);
            redis.Close();
        }

        //   model.IsComment = 0;// SafeRequest.GetFormInt("radioIsComment", 0);
        model.Approved   = SafeRequest.GetFormInt("radioApproved", 0);
        model.Sort       = SafeRequest.GetFormInt("txtSort", 99);
        model.AddedDate  = System.DateTime.Now;
        model.ExpireDate = System.DateTime.Now;
        model.ViewCount  = 0;
        // model.IsScrool = 0;
        // model.AddedUserId = Convert.ToInt32(_userId);//默认登录进来人的编号
        model.AddedUserId = 1;
        //~/upload/News/
        #region 保存图片
        if (!this.picUpload.Value.Equals("") && this.picUpload.PostedFile.ContentLength > 10)
        {
            string FileTZM = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名

            if (!IsPic(FileTZM.ToLower()))
            {
                JSUtility.Alert("上传图片格式不正确!");
                return;
            }
            if (this.picUpload.PostedFile.ContentLength > 1048576)
            {
                JSUtility.Alert("上传图片过大!");
                return;
            }
            Random rnd            = new Random();
            string UpLoadFileTime = DateTime.Now.ToString("yyMMddHHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称
            string fileName       = UpLoadFileTime + "." + FileTZM;                                          //产生上传图片的名称
            if (!Directory.Exists(Request.MapPath("~/upload/News/")))
            {
                Directory.CreateDirectory(Request.MapPath("~/upload/News/"));
            }
            string Url = Request.MapPath("~/upload/News/" + fileName);
            picUpload.PostedFile.SaveAs(Url);
            model.ImgLink = "/upload/News/" + fileName;
        }
        else
        {
            model.ImgLink = ViewState["ImgLink"].ToString();
        }
        #endregion


        if (_Pid != "")
        {
            model.NewsID = _Pid;
            if (bll.Update(model))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            model.NewsID = IdCreator.CreateId("T_News", "NewsId");
            if (bll.Add(model))
            {
                JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString());
            }
        }
    }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            NewsModel newsModel = (NewsModel)Session["newsModel"];
            string    strErr    = "";

            if (this.txtTitle.Text.Trim().Length == 0)
            {
                strErr += "标题不能为空!\\n";
            }
            if (this.txtNTypes.Text.Trim().Length == 0)
            {
                strErr += "分类不能为空!\\n";
            }
            if (this.txtContentVal.Text.Trim().Length == 0)
            {
                strErr += "内容不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtPushTime.Value))
            {
                strErr += "发布时间格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            string   Title    = this.txtTitle.Text;
            string   NTypes   = this.txtNTypes.Text;
            string   Content  = this.txtContentVal.Text;
            string   PhotoUrl = this.txtPhotoUrl.FileName;
            DateTime PushTime = DateTime.Parse(this.txtPushTime.Value);
            int      States   = 0;//置顶

            if (this.txtStates1.Checked)
            {
                States = 1;
            }

            //上传商品图片
            //判断是否存在上传的文件
            if (this.txtPhotoUrl.HasFile == true)
            {
                //获取文件的后缀名
                string temp = this.txtPhotoUrl.FileName.Substring(this.txtPhotoUrl.FileName.LastIndexOf('.') + 1).ToLower();
                //判断是否为图片文件
                if (temp != "bmp" && temp != "jpg" && temp != "png")
                {
                    ClientScript.RegisterStartupScript(
                        this.GetType(), "error", "alert('只能上传图片文件!');", true);
                    return;
                }
                //为了防止不同用户上传图片重名,为文件进行重命名
                string newFileName = DateTime.Now.Ticks + "." + temp;
                //保存文件
                this.txtPhotoUrl.SaveAs(Server.MapPath("/") + "UploadFiles/" + newFileName);
                newsModel.PhotoUrl = "UploadFiles/" + newFileName;
            }

            newsModel.Title    = Title;
            newsModel.NTypes   = NTypes;
            newsModel.Content  = Content;
            newsModel.PushTime = PushTime;
            newsModel.States   = States;

            if (newsBll.Update(newsModel))
            {
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "修改成功!", "News.aspx");
                //MessageBox.Show(this, "修改成功!");
                //Response.Redirect("News.aspx");
            }
        }