示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TieZiVsImgModel GetModel(decimal TieZiId, string ImgId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select TieZiId, ImgId, vsType  ");
            strSql.Append("  from BBS.dbo.TieZiVsImg ");
            strSql.Append(" where TieZiId=@TieZiId and ImgId=@ImgId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TieZiId", SqlDbType.Decimal, 9),
                new SqlParameter("@ImgId",   SqlDbType.VarChar, 50)
            };
            parameters[0].Value = TieZiId;
            parameters[1].Value = ImgId;


            TieZiVsImgModel model = new TieZiVsImgModel();
            DataSet         ds    = helper.ExecSqlReDs(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["TieZiId"].ToString() != "")
                {
                    model.TieZiId = decimal.Parse(ds.Tables[0].Rows[0]["TieZiId"].ToString());
                }
                model.ImgId  = ds.Tables[0].Rows[0]["ImgId"].ToString();
                model.vsType = ds.Tables[0].Rows[0]["vsType"].ToString();

                return(model);
            }
            else
            {
                return(model);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(TieZiVsImgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BBS.dbo.TieZiVsImg (");
            strSql.Append("TieZiId,ImgId,vsType");
            strSql.Append(") values (");
            strSql.Append("@TieZiId,@ImgId,@vsType");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@TieZiId", SqlDbType.Decimal,  9),
                new SqlParameter("@ImgId",   SqlDbType.VarChar, 50),
                new SqlParameter("@vsType",  SqlDbType.VarChar, 10)
            };

            parameters[0].Value = model.TieZiId;
            parameters[1].Value = model.ImgId;
            parameters[2].Value = model.vsType;

            bool result = false;

            try
            {
                helper.ExecSqlReInt(strSql.ToString(), parameters);
                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TieZiVsImgModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update BBS.dbo.TieZiVsImg set ");

            strSql.Append(" TieZiId = @TieZiId , ");
            strSql.Append(" ImgId = @ImgId , ");
            strSql.Append(" vsType = @vsType  ");
            strSql.Append(" where TieZiId=@TieZiId and ImgId=@ImgId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@TieZiId", SqlDbType.Decimal,  9),
                new SqlParameter("@ImgId",   SqlDbType.VarChar, 50),
                new SqlParameter("@vsType",  SqlDbType.VarChar, 10)
            };

            parameters[0].Value = model.TieZiId;
            parameters[1].Value = model.ImgId;
            parameters[2].Value = model.vsType; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }
示例#4
0
        private void SaveTieZiInfo()
        {
            BLL.BBSBLL bbll = new BLL.BBSBLL();


            Model.TieZiModel model = new TieZiModel();
            model.TieZiId = ReDecimal("TieZiId", 0);

            if (bbll.HasTieZiPower(model.TieZiId))
            {
                //是否有操作权限
            }
            else
            {
                throw new Exception("您没有操作权限!");
            }

            if (model.TieZiId > 0)
            {//修改
                model            = bbll.GetTieZiModel(model.TieZiId);
                model.CreateTime = ReTime("CreateTime", DateTime.Now);
            }
            else
            {
                //新增
                model.Ip           = ReStr("Ip", HttpContext.Current.Request.UserHostAddress);
                model.CreateUser   = Common.CookieSings.GetCurrentUserId();
                model.Source       = ReStr("Source", "");
                model.HideUser     = ReBool("HideUser");
                model.WxOpenId     = ReStr("WxOpenId", "");
                model.YueMingZhong = "";
                model.RecommendLv  = ReInt("RecommendLv", 0);
            }


            model.TieZiTitle = ReStr("TieZiTitle", "");
            bool AddHot = ReBool("AddHot", false);

            model.TieZiContent = ReStrDeCode("TieZiContent");

            model.TieZiSummary = Common.StringPlus.GetLeftStr(Common.StringPlus.OutHtmlText(model.TieZiContent), 120, "");



            model.TieZiImgId = ReStr("TieZiImgId", "");
            model.MiniImgUrl = ReStr("MiniImgUrl", "");

            model.ForumId    = ReDecimal("ForumId");
            model.TieZiType  = ReStr("TieZiType", "");
            model.TieZiClass = ReStr("TieZiClass", "");


            model.ParentTieZiId = ReDecimal("ParentTieZiId", 0);


            model.RepLastUser = model.CreateUser;
            model.Invalid     = ReBool("Invalid", false);
            DataTable dtImg = ReTable("imgArray");

            #region 事务开启

            TransactionOptions transactionOption = new TransactionOptions();
            transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOption))
            {
                #endregion
                dtImg = BLL.BJ.ImgSetting.ImgArraySetting(dtImg, model.TieZiContent);
                if (dtImg != null)
                {
                    model.TieZiImgId = dtImg.Rows[0]["ImgId"].ToString();
                }


                bbll.SaveTieZi(model);
                bbll.DeleteTieZiVsImgByTieZiId(model.TieZiId);              //删除帖子下所有的图片,重新插入.
                if (dtImg != null)
                {
                    foreach (DataRow dr in dtImg.Rows)
                    {
                        Model.TieZiVsImgModel VsImgModel = new TieZiVsImgModel();
                        VsImgModel.TieZiId = model.TieZiId;
                        VsImgModel.ImgId   = dr["ImgId"].ToString();
                        VsImgModel.vsType  = "UserImg";
                        bbll.AddTieZiVsImg(VsImgModel);
                    }
                }
                ReDict2.Add("ForumId", model.ForumId.ToString());
                ReDict2.Add("TieZiId", model.TieZiId.ToString());

                if (model.ParentTieZiId > 0)
                {
                    int ParentRepCount = DAL.DalComm.ExInt(" select RepCount from BBS.DBO.TIEZI WHERE TieZiId='" + model.ParentTieZiId + "'  ");
                    ReDict2.Add("ParentRepCount", ParentRepCount.ToString());
                    #region 开始提醒
                    RemindModel remindmodel = new RemindModel();
                    remindmodel.CreateTime   = DateTime.Now;
                    remindmodel.MerLook      = false;
                    remindmodel.ReKey        = model.ParentTieZiId.ToString();
                    remindmodel.ReMerchantId = 0;
                    remindmodel.RemindTitle  = "您发布的帖子有了新的回应!";
                    remindmodel.RemindTypeId = model.TieZiType;
                    remindmodel.ReUserId     = ReStr("ReUserId", "");
                    remindmodel.Url          = "/t/?TieZiId=" + ReDecimal("ReTieZiId") + "";


                    remindmodel.UserLook = false;


                    BLL.CommBLL commBll = new BLL.CommBLL();

                    if (remindmodel.ReUserId.Trim() != "")
                    {
                        commBll.SaveReMind(remindmodel);
                    }



                    #endregion
                    #region 如果是回帖,更新主贴时间

                    if (model.TieZiType == "回帖")
                    {
                        //说明本帖是个回帖,更新回帖数目, 和最后发表人
                        int i = DAL.DalComm.ExReInt(" update bbs.dbo.TieZi set UpdateTime ='" + DateTime.Now.ToString() + "' , RepLastUser='******'  where TieZiId='" + model.ParentTieZiId + "'  ");
                        if (i <= 0)
                        {
                            throw new Exception("没有找到ID为" + model.ParentTieZiId + "的主贴!");
                        }
                    }
                    #endregion
                }
                #region 事务结束

                transactionScope.Complete();
            }
            #endregion
            ReTrue();
        }