Beispiel #1
0
        private void AddCollection(out string msg)
        {
            int userId;
            int refId;
            int type;

            if (int.TryParse(CollectRefId, out refId) && int.TryParse(CollectType, out type))
            {
                Entities.QueryKLFavorites query = new Entities.QueryKLFavorites();
                query.UserId  = BLL.Util.GetLoginUserID();
                query.KLRefId = refId;
                query.Type    = type;
                bool isCollected = BLL.Personalization.Instance.IsCollected(query);
                if (isCollected)
                {
                    msg = "您已收藏了该条数据!";
                }
                else
                {
                    query.CreateTime = DateTime.Now;
                    msg = BLL.Personalization.Instance.Insert(query) > 0 ? "success" : "收藏失败!";
                }
            }
            else
            {
                msg = "数据格式有误!";
            }
        }
Beispiel #2
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Insert(Entities.QueryKLFavorites model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",      SqlDbType.Int),
                new SqlParameter("@UserId",  SqlDbType.Int),
                new SqlParameter("@KLRefId", SqlDbType.Int),
                new SqlParameter("@Type",    SqlDbType.Int)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.UserId;
            parameters[2].Value     = model.KLRefId;
            parameters[3].Value     = model.Type;

            SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_PersonalCollection_Insert, parameters);
            return((int)parameters[0].Value);
        }
Beispiel #3
0
        /// <summary>
        /// 判断此本人是否已经收藏了该条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns>true:已经收藏;false:未收藏</returns>
        public bool IsCollected(Entities.QueryKLFavorites model)
        {
            string sqlStr = "SELECT COUNT(*) FROM dbo.KLFavorites WHERE UserId=@UserId AND KLRefId=@KLRefId AND Type=@Type";

            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",  SqlDbType.Int),
                new SqlParameter("@KLRefId", SqlDbType.Int),
                new SqlParameter("@Type",    SqlDbType.Int),
            };
            parameters[0].Value = model.UserId;
            parameters[1].Value = model.KLRefId;
            parameters[2].Value = model.Type;
            string objValue = SqlHelper.ExecuteScalar(CONNECTIONSTRINGS, CommandType.Text, sqlStr, parameters).ToString();

            if (int.Parse(objValue) == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #4
0
 public bool IsCollected(Entities.QueryKLFavorites model)
 {
     return(Dal.Personalization.Instance.IsCollected(model));
 }
Beispiel #5
0
 public int Insert(Entities.QueryKLFavorites model)
 {
     return(Dal.Personalization.Instance.Insert(model));
 }