private AjaxResult Edit() { var title = Request.Form["title"]; var channel = Request.Form["channel"]; var content = Request.Form["content"]; var recommend = Request.Form["recommend"]; var image = Request.Form["image"]; var remark = Request.Form["remark"]; var id = Request.Form["id"]; AjaxResult re = new AjaxResult(); if (string.IsNullOrEmpty(title)) { re.Success = 0; re.Message = "标题不能为空"; return(re); } if (string.IsNullOrEmpty(channel)) { re.Success = 0; re.Message = "栏目不能为空"; return(re); } if (string.IsNullOrEmpty(content)) { re.Success = 0; re.Message = "内容不能为空"; return(re); } BLL.BLLBase bll = new BLLBase(); ctx.BeginTransaction(); try { var tb = ctx.ExecuteDataTable("Select * from Channel Where ID=" + channel); if (tb == null && tb.Rows.Count < 1) { throw new Exception("获取频道信息出错"); } var channelObj = tb.ToList <Model.Channel>()[0]; var contentObj = new Model.Content() { ID = Convert.ToInt16(id), Attributes = recommend, ChannelCode = channelObj.Code, ChannelName = channelObj.Name, ChannelID = channelObj.ID, ContentText = content, ImageUrls = common.Common.UploadImagePath + image.Replace("common.Common.UploadImagePath", ""), ModifiedBy = PubFunc.GetAdminID(), ModifyDate = DateTime.Now, Remark = remark, Type = channelObj.ContentType, State = 0, Title = title }; bll.Update(ctx, contentObj); ctx.CommitTransaction(); re.Success = 1; re.Message = "添加成功"; } catch (Exception exception) { ctx.RollBackTransaction(); re.Success = 0; re.Message = exception.Message; throw; } finally { ctx.CloseConnection(); } return(re); }