Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(starweibo.Model.relationInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into relationInfo(");
            strSql.Append("userId,friendId,groupId,focusTime,friendNoteName)");
            strSql.Append(" values (");
            strSql.Append("@userId,@friendId,@groupId,@focusTime,@friendNoteName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId",         SqlDbType.Int,       4),
                new SqlParameter("@friendId",       SqlDbType.Int,       4),
                new SqlParameter("@groupId",        SqlDbType.Int,       4),
                new SqlParameter("@focusTime",      SqlDbType.DateTime),
                new SqlParameter("@friendNoteName", SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.userId;
            parameters[1].Value = model.friendId;
            parameters[2].Value = model.groupId;
            parameters[3].Value = model.focusTime;
            parameters[4].Value = model.friendNoteName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public starweibo.Model.relationInfo DataRowToModel(DataRow row)
 {
     starweibo.Model.relationInfo model = new starweibo.Model.relationInfo();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["userId"] != null && row["userId"].ToString() != "")
         {
             model.userId = int.Parse(row["userId"].ToString());
         }
         if (row["friendId"] != null && row["friendId"].ToString() != "")
         {
             model.friendId = int.Parse(row["friendId"].ToString());
         }
         if (row["groupId"] != null && row["groupId"].ToString() != "")
         {
             model.groupId = int.Parse(row["groupId"].ToString());
         }
         if (row["focusTime"] != null && row["focusTime"].ToString() != "")
         {
             model.focusTime = DateTime.Parse(row["focusTime"].ToString());
         }
         if (row["friendNoteName"] != null)
         {
             model.friendNoteName = row["friendNoteName"].ToString();
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(starweibo.Model.relationInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update relationInfo set ");
            strSql.Append("userId=@userId,");
            strSql.Append("friendId=@friendId,");
            strSql.Append("groupId=@groupId,");
            strSql.Append("focusTime=@focusTime,");
            strSql.Append("friendNoteName=@friendNoteName");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId",         SqlDbType.Int,        4),
                new SqlParameter("@friendId",       SqlDbType.Int,        4),
                new SqlParameter("@groupId",        SqlDbType.Int,        4),
                new SqlParameter("@focusTime",      SqlDbType.DateTime),
                new SqlParameter("@friendNoteName", SqlDbType.NVarChar,  20),
                new SqlParameter("@id",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.userId;
            parameters[1].Value = model.friendId;
            parameters[2].Value = model.groupId;
            parameters[3].Value = model.focusTime;
            parameters[4].Value = model.friendNoteName;
            parameters[5].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        public int guanzhu(int friendId)
        {
            string userid = Session["userid"].ToString();

            //string userid = "2";
            starweibo.BLL.relationInfo          Bguanzhu  = new starweibo.BLL.relationInfo();
            starweibo.Model.relationInfo        Mguanzhu  = new starweibo.Model.relationInfo();
            List <starweibo.Model.relationInfo> MfriendId = new List <starweibo.Model.relationInfo>();

            MfriendId = Bguanzhu.GetModelList("friendId=" + friendId + " and userId=" + userid);
            if (MfriendId.Count == 0)
            {
                Mguanzhu.userId   = Convert.ToInt32(userid);
                Mguanzhu.friendId = friendId;
                Mguanzhu.groupId  = 6;

                return(Bguanzhu.Add(Mguanzhu));
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public starweibo.Model.relationInfo GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,userId,friendId,groupId,focusTime,friendNoteName from relationInfo ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }