protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { var model = new InfoContentPage(); BindKit.FillModelFromContainer(this.editor, model); model.Title = this.ContentTitle.Text; if (!string.IsNullOrEmpty(this.Thumb.FileName)) { //清理老图像 if (!string.IsNullOrEmpty(this.PreviewThumb.ImageUrl)) { var f = new FileInfo(Server.MapPath(this.PreviewThumb.ImageUrl)); if (f.Exists) { f.Delete(); } } //更新新图 model.Thumb = FileKit.SaveZoomImage(this.Thumb.PostedFile, 1024, 1024); } if (this.Id.Value == "") { model.GroupCode = this.GroupCode; model.CategoryId = 0; model.Click = 0; model.CreateDate = DateTime.Now; model.IsEnabled = 1; model.Author = this.CurrentUserName; _bus.Insert(model); } else { _bus.Update(model, null); } ShowThumb(model.Thumb); this.promptControl.ShowSuccess("保存成功!"); } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { var model = new InfoContentPage(); BindKit.FillModelFromContainer(this.editor, model); if (!string.IsNullOrEmpty(this.Thumb.FileName)) { //清理老图像 if (!string.IsNullOrEmpty(this.PreviewThumb.ImageUrl)) { var f = new FileInfo(Server.MapPath(this.PreviewThumb.ImageUrl)); if (f.Exists) { f.Delete(); } } //更新新图 if (this.Thumb.PostedFile.ContentLength > 0) { if (FileKit.IsImage(this.Thumb.PostedFile.FileName)) { model.Thumb = FileKit.SaveZoomImage(this.Thumb.PostedFile, 1024, 1024); } else { this.Alert("您上传的不是图片!"); } } ShowThumb(model.Thumb); } if (Request.QueryString["m"] == "content") { model.Title = this.InfoTitle.Text; if (!_infoBus.Update(model, "GroupCode='" + this.GroupCode + "'")) { model.GroupCode = this.GroupCode; model.CategoryId = 0; model.Click = 0; model.CreateDate = DateTime.Now; model.IsEnabled = 1; model.Author = this.CurrentUserName; model.Id = _infoBus.InsertIdentity(model); BindKit.BindModelToContainer(this.editor, model); } } else { if (string.IsNullOrEmpty(this.Id.Value) || this.Id.Value == "0") { model.Title = this.InfoTitle.Text; model.GroupCode = this.GroupCode; model.CategoryId = 0; model.Click = 0; model.CreateDate = DateTime.Now; model.IsEnabled = 1; model.Author = this.CurrentUserName; //_infoBus.Insert(model); model.Id = _infoBus.InsertIdentity(model); this.Id.Value = model.Id.ToString(); } else { model.Title = this.InfoTitle.Text; _infoBus.Update(model, null); } } this.promptControl.ShowSuccess("保存成功!"); } }