protected void btnAdd_OnClick(object sender, EventArgs e) { New n = new New(); BNew bn = new BNew(); BSysOperateLog bsol = new BSysOperateLog(); n.NewsID = bn.GetMaxID() + 1; n.IsTop = CbIstop.Checked; n.IsHot = CbIsHot.Checked; n.NewsContent = container.Text; n.SubmitTime = DateTime.Now; //n.SavePath = "details" + DateTime.Now.Year + "_" + DateTime.Now.Month + "/" +DateTime.Now.Day; n.Uploader = PubCom.CheckString(txtauthor.Text.Trim()); n.Title = PubCom.CheckString(txtTitle.Text.Trim()); n.summary = PubCom.CheckString(txtsummary.Text.Trim()); n.NewsType = dpNewstype.SelectedValue; n.StaticType = dpstatictype.SelectedValue; //string PicUrl = ""; //if (UploadValidate(out PicUrl)) //{ // n.IsImg = 1; // mp.Id = mpm.GetMaxID() + 1; // mp.NewsId = n.Id; // mp.Title = pic_upload.FileName; // mp.PicUrl = PicUrl; // mpm.Insert(mp); //} //else //{ // n.IsImg = 1; //}NewsManage if (bn.Insert(n) != 1) { Message.ShowWrong(this, "添加文章失败!"); } else { bn.UploadValidate(pic_upload, lbl_pic, PicFilePath, n.NewsID); //// 插入日志 add SysOperateLog log = new SysOperateLog(); log.LogID = StringHelper.getKey(); log.LogType = LogType.新闻信息.ToString(); log.OperateUser = GetLogUserName(); log.OperateDate = DateTime.Now; log.LogOperateType = "新闻新增"; log.LogAfterObject = JsonHelper.Obj2Json(n); bsol.Insert(log); Message.ShowOKAndRedirect(this, "添加文章成功", "NewsManage.aspx"); } }
protected void btnEdit_OnClick(object sender, EventArgs e) { New oldn = bn.GetNewsByID(Utils.StrToInt(ID, 0)); if (bn.Update(new New { NewsID = Utils.StrToInt(hfNewsID.Value, 0), Title = PubCom.CheckString(txtTitle.Text.Trim()), NewsContent = container.Text, summary = PubCom.CheckString(txtsummary.Text.Trim()), Uploader = txtauthor.Text.Trim(), SubmitTime = DateTime.Now, IsHot = CbIsHot.Checked, IsTop = CbIstop.Checked, NewsType = dpNewstype.SelectedValue, StaticType = dpstatictype.SelectedValue }) != 1) { Message.ShowWrong(this, "更新文章失败"); } else { bn.UploadValidate(pic_upload, lbl_pic, PicFilePath, Utils.StrToInt(hfNewsID.Value, 0)); New n = bn.GetNewsByID(Utils.StrToInt(ID, 0)); SysOperateLog log = new SysOperateLog(); log.LogID = StringHelper.getKey(); log.LogType = LogType.新闻信息.ToString(); log.OperateUser = GetLogUserName(); log.OperateDate = DateTime.Now; log.LogOperateType = "新闻修改"; log.LogBeforeObject = JsonHelper.Obj2Json(oldn); log.LogAfterObject = JsonHelper.Obj2Json(n); bsol.Insert(log); Message.ShowOKAndRedirect(this, "更新新闻成功", "NewsManage.aspx"); } }