public void DoCatalog([DataBind("S_Catalog")] S_Catalog cata) { try { if (string.IsNullOrEmpty(cata.CatalogName)) { throw new TmmException("分类名称不能为空"); } SystemService ss = Context.GetService <SystemService>(); if (cata.CatalogId == 0) { ss.SCatalogBll.Insert(cata); } else { ss.SCatalogBll.Update(cata); AddSuccess("操作成功"); Redirect("Catalog.do"); return; } AddSuccess("操作成功"); } catch (TmmException te) { Flash["model"] = cata; AddError(te.Message); } catch { AddError("系统错误"); Flash["model"] = cata; } RedirectToReferrer(); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(S_Catalog obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "S_Catalog.Insert"; return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(S_Catalog obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "S_Catalog.Update"; int result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj); return(result > 0 ? true : false); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(S_Catalog obj) { return(dal.Update(obj)); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(S_Catalog obj) { return(dal.Insert(obj)); }
public void Default(int docId) { UserService us = Context.GetService <UserService>(); SystemService ss = Context.GetService <SystemService>(); DDocInfo doc = us.DocInfoBll.Get(docId); doc.Description = doc.Description.ReplaceEnterStr(); PropertyBag["doc"] = doc; if (!doc.IsAudit && !doc.IsTaskDoc) { if (!(Context.UrlReferrer.IndexOf("/admin/doc/index.do") > -1)) //如果从管理页面过来,不抛异常 { throw new Common.TmmException("该文档不存在"); } } try { //该用户其他文档 IList <DDocInfo> otherList = us.DocInfoBll.GetListByUser(doc.UserId, 0, 9, doc.DocId); PropertyBag["otherList"] = otherList; //文档分类 if (doc.CateId.HasValue) { S_Catalog c3 = ss.SCatalogBll.Get(doc.CateId.Value); S_Catalog c2 = null; S_Catalog c1 = null; if (c3 != null && c3.Pid.HasValue) { c2 = ss.SCatalogBll.Get(c3.Pid.Value); if (c2.Pid.HasValue) { c1 = ss.SCatalogBll.Get(c2.Pid.Value); } } StringBuilder sb = new StringBuilder(); if (c3 != null) { sb.Append(string.Format("<a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c3.CatalogName, c3.CatalogId)); if (c2 != null) { sb.Append(string.Format(" -- <a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c2.CatalogName, c2.CatalogId)); if (c1 != null) { sb.Append(string.Format(" -- <a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c1.CatalogName, c1.CatalogId)); } } } PropertyBag["catalog"] = sb.ToString(); } //标签 if (!string.IsNullOrEmpty(doc.Tags)) { string[] tags = doc.Tags.Split(' '); List <D_Tag> tagList = new List <D_Tag>(); tags.ToList().ForEach(s => { if (!string.IsNullOrEmpty(s.Trim())) { D_Tag dt = us.DTagBll.Get(s); if (dt != null) { tagList.Add(dt); } } }); PropertyBag["tagList"] = tagList; } //相关文档 IList <DDocInfo> recommandList = us.DocInfoBll.GetRelativeList(docId); if (recommandList == null) { PropertyBag["relativeDocs"] = us.DocInfoBll.GetRecommendList(0, 25); PropertyBag["recommend"] = true; } else { PropertyBag["relativeDocs"] = recommandList; } //浏览量 us.DocInfoBll.UpdateViewCount(docId); } catch (Exception ex) { Utils.Log4Net.Error(ex.Message + "\r\n" + ex.StackTrace); } }