Esempio n. 1
0
        public string DeleteSectionBySectionId(string sectionId,string userid)
        {
            var tran = Utility.Database.BeginDbTransaction();
            try
            {
                //先删除评论表
                StringBuilder rStrSql = new StringBuilder();
                rStrSql.AppendFormat("select * from B_BBSReply where RSID="+sectionId);
                DataSet rds = Utility.Database.ExcuteDataSet(rStrSql.ToString(), tran);
                string rJsonData = JsonConvert.SerializeObject(rds.Tables[0]);
                List<B_BBSReply> listReply = (List<B_BBSReply>)JsonConvert.DeserializeObject(rJsonData, typeof(List<B_BBSReply>));
                foreach (B_BBSReply reply in listReply)
                {
                    reply.Condition.Add("rid=" + reply.rid);
                    Utility.Database.Delete(reply, tran);
                }

                //删除主贴
                StringBuilder tStrSql = new StringBuilder();
                tStrSql.AppendFormat("select * from B_BBSTopic where tsid=" + sectionId);
                DataSet tds = Utility.Database.ExcuteDataSet(rStrSql.ToString(), tran);
                string tJsonData = JsonConvert.SerializeObject(tds.Tables[0]);
                List<B_BBSTopic> listTopic = (List<B_BBSTopic>)JsonConvert.DeserializeObject(tJsonData, typeof(List<B_BBSTopic>));
                foreach (B_BBSTopic topic in listTopic)
                {
                    topic.Condition.Add("tid=" + topic.tid);
                    Utility.Database.Delete(topic, tran);
                }
                //删除模块
                B_BBSSection bbsSection = new B_BBSSection();
                bbsSection.Condition.Add("sid=" + sectionId);
                Utility.Database.Delete(bbsSection, tran);

                Utility.Database.Commit(tran);
                return Utility.JsonResult(true, "删除成功");
            }
            catch (Exception e)
            {
                Utility.Database.Rollback(tran);
                return Utility.JsonResult(false, "数据加载失败!异常信息: " + e.Message);
            }
        }
Esempio n. 2
0
 public string DeleteSectionData(string id, string userid)
 {
     var tran = Utility.Database.BeginDbTransaction();
     try
     {
         B_BBSSection bbsSection = new B_BBSSection();
         bbsSection.Condition.Add("sid=" + id);
         Utility.Database.Delete(bbsSection, tran);
         Utility.Database.Commit(tran);
         return Utility.JsonResult(true, "删除成功!");
     }
     catch (Exception e)
     {
         Utility.Database.Rollback(tran);
         return Utility.JsonResult(false, "删除失败!异常信息: " + e.Message);
     }
 }