Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.tb_FriendDynamicGood model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_FriendDynamicGood set ");

            strSql.Append(" UserID = @UserID , ");
            strSql.Append(" DynamicID = @DynamicID , ");
            strSql.Append(" AddTime = @AddTime  ");
            strSql.Append(" where ID=@ID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",        SqlDbType.BigInt, 8),
                new SqlParameter("@UserID",    SqlDbType.BigInt, 8),
                new SqlParameter("@DynamicID", SqlDbType.BigInt, 8),
                new SqlParameter("@AddTime",   SqlDbType.DateTime)
            };

            parameters[0].Value = model.ID;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.DynamicID;
            parameters[3].Value = model.AddTime;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(lgk.Model.tb_FriendDynamicGood model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_FriendDynamicGood(");
            strSql.Append("UserID,DynamicID,AddTime");
            strSql.Append(") values (");
            strSql.Append("@UserID,@DynamicID,@AddTime");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID",    SqlDbType.BigInt, 8),
                new SqlParameter("@DynamicID", SqlDbType.BigInt, 8),
                new SqlParameter("@AddTime",   SqlDbType.DateTime)
            };

            parameters[0].Value = model.UserID;
            parameters[1].Value = model.DynamicID;
            parameters[2].Value = model.AddTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Пример #3
0
        //点赞动态
        public bool PointDynamicNum(long userid, long dynamicid, out string message)
        {
            var dygoodList = FriendDynamicGoodBLL.GetModelList("userid = " + userid + " and dynamicid=" + dynamicid);

            if (dygoodList.Count > 0)
            {
                FriendDynamicGoodBLL.Delete(dygoodList.First().ID);
                UpdateFriendDynamic("GoodNum", dygoodList.First().DynamicID, 1, 0);
                message = "取消点赞";
                return(true);
            }

            lgk.Model.tb_FriendDynamicGood friendDynamGood = new lgk.Model.tb_FriendDynamicGood()
            {
                UserID    = userid,
                DynamicID = dynamicid,
                AddTime   = DateTime.Now,
            };

            if (FriendDynamicGoodBLL.Add(friendDynamGood) > 0)
            {
                UpdateFriendDynamic("GoodNum", dynamicid, 1, 1);
                message = "点赞成功";
                return(true);
            }
            else
            {
                message = "点赞失败";
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.tb_FriendDynamicGood GetModel(long ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID, UserID, DynamicID, AddTime  ");
            strSql.Append("  from tb_FriendDynamicGood ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;


            lgk.Model.tb_FriendDynamicGood model = new lgk.Model.tb_FriendDynamicGood();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = long.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DynamicID"].ToString() != "")
                {
                    model.DynamicID = long.Parse(ds.Tables[0].Rows[0]["DynamicID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }