Exemple #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int res = 0;

            if (this.hfAboutId.Value == "")
            {
                //这种情况下我们去执行新增方法
                res = aSvc.Add(new Model.reception.About()
                {
                    About_Title   = this.txtName.Text,
                    About_Content = this.txtAboutContent.Value,
                    About_Image   = upFileName(FileUpload1, "../../upload/about/")
                });
            }
            else
            {
                var oldModel = aSvc.GetAll();
                //这种情况下我们执行修改方法
                var imgName = upFileName(FileUpload1, "../../upload/about/");
                if (imgName != "")
                {
                    //我们上传图片了
                    oldModel.About_Image = imgName;
                }

                oldModel.About_Title      = this.txtName.Text;
                oldModel.About_Content    = this.txtAboutContent.Value;
                oldModel.About_UpdateTime = DateTime.Now;

                res = aSvc.Edit(oldModel);
            }

            ReturnMsg rm = res > 0 ? new ReturnMsg()
            {
                Code    = StatusCode.Ok,
                Message = "编辑成功",
                Data    = null
            } : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "编辑失败",
                Data    = null
            };

            Session["Msg"] = rm;
            Response.Redirect("About_List.aspx");
        }
Exemple #2
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            int rs = 0;

            var data = aboutSvc.GetAboutById(int.Parse(this.txtId.Text));

            if (data.Title == null)
            {
                //这种是我们执行新增
                Model.About about = new Model.About()
                {
                    Title   = this.txtTitle.Text,
                    Content = this.txtContent.Value,
                    Images  = upload.UpFileName(FileUpload1, "../../upload/about")
                };
                rs = aboutSvc.Add(about);
            }
            else
            {
                //执行修改
                data.Title      = this.txtTitle.Text;
                data.Content    = this.txtContent.Value;
                data.UpdateTime = DateTime.Now;
                var imgSrc = upload.UpFileName(FileUpload1, "../../upload/about");
                if (imgSrc != "")
                {
                    data.Images = imgSrc;
                }
                rs = aboutSvc.Edit(data);
            }


            if (rs > 0)
            {
                //提示编辑成功
                Response.Write("<script>alert('编辑成功');location.href='EditAbout.aspx?action=1'</script>");
            }
            else
            {
                //编辑失败
                Response.Write("<script>alert('编辑失败');location.href='EditAbout.aspx?action=1'</script>");
            }
        }