private void InsertSql(TMM.Model.DDocInfo doc) { Service.Bll.Doc.DDocInfoBLL bll = new TMM.Service.Bll.Doc.DDocInfoBLL(); doc.IsMajia = true; int docId = bll.Insert(doc); InsertTag(doc.Tags, docId); }
private void UpdateDoc(DataGridViewRow dr,TMM.Service.DocService bll,ref string errMsg) { if (dr.Cells[0].Value == null) return; UpdateModel um = new UpdateModel(); um.Title = dr.Cells[0].Value.ToString(); um.Tags = dr.Cells[1].Value.ToString(); um.Intro = dr.Cells[2].Value.ToString(); var p = new Hashtable(); p.Add("Title",um.Title); try { var docList = bll.DDocInfoBll.GetList(p, null, 0, 1); if (docList != null) { var doc = docList.FirstOrDefault(); if (doc == null) throw new Exception(string.Format("未找到标题为【{0}】的记录",um.Title)); doc.Tags = um.Tags; doc.Description = um.Intro; //更新doc bll.DDocInfoBll.Update(doc); //更新tag if (!string.IsNullOrEmpty(doc.Tags)) { var tags = doc.Tags.Split(' '); foreach (var item in tags) { var tagModel = bll.DTagBll.Get(item); if (tagModel != null) { tagModel.UseCount += 1; bll.DTagBll.Update(tagModel); } else { tagModel = new TMM.Model.D_Tag(); tagModel.Tag = item; tagModel.UseCount = 1; bll.DTagBll.Insert(tagModel); } } } } } catch (Exception ex) { errMsg = ex.Message; } dr.Cells[3].Value = string.IsNullOrEmpty(errMsg) ? "Success" : errMsg; }