Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(starweibo.Model.chatV model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update chatV set ");
            strSql.Append("senderId=@senderId,");
            strSql.Append("msgContent=@msgContent,");
            strSql.Append("pubTime=@pubTime,");
            strSql.Append("msgState=@msgState,");
            strSql.Append("receiverId=@receiverId,");
            strSql.Append("userName=@userName,");
            strSql.Append("userHeadimage=@userHeadimage,");
            strSql.Append("recuserName=@recuserName,");
            strSql.Append("recuserHeadimage=@recuserHeadimage,");
            strSql.Append("shortMsgId=@shortMsgId");
            strSql.Append(" where shortMsgId=@shortMsgId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@senderId",         SqlDbType.Int,         4),
                new SqlParameter("@msgContent",       SqlDbType.NVarChar,  200),
                new SqlParameter("@pubTime",          SqlDbType.DateTime),
                new SqlParameter("@msgState",         SqlDbType.NVarChar,   50),
                new SqlParameter("@receiverId",       SqlDbType.Int,         4),
                new SqlParameter("@userName",         SqlDbType.NVarChar,   20),
                new SqlParameter("@userHeadimage",    SqlDbType.NVarChar,  150),
                new SqlParameter("@recuserName",      SqlDbType.NVarChar,   20),
                new SqlParameter("@recuserHeadimage", SqlDbType.NVarChar,  150),
                new SqlParameter("@shortMsgId",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.senderId;
            parameters[1].Value = model.msgContent;
            parameters[2].Value = model.pubTime;
            parameters[3].Value = model.msgState;
            parameters[4].Value = model.receiverId;
            parameters[5].Value = model.userName;
            parameters[6].Value = model.userHeadimage;
            parameters[7].Value = model.recuserName;
            parameters[8].Value = model.recuserHeadimage;
            parameters[9].Value = model.shortMsgId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public starweibo.Model.chatV DataRowToModel(DataRow row)
 {
     starweibo.Model.chatV model = new starweibo.Model.chatV();
     if (row != null)
     {
         if (row["senderId"] != null && row["senderId"].ToString() != "")
         {
             model.senderId = int.Parse(row["senderId"].ToString());
         }
         if (row["msgContent"] != null)
         {
             model.msgContent = row["msgContent"].ToString();
         }
         if (row["pubTime"] != null && row["pubTime"].ToString() != "")
         {
             model.pubTime = DateTime.Parse(row["pubTime"].ToString());
         }
         if (row["msgState"] != null)
         {
             model.msgState = row["msgState"].ToString();
         }
         if (row["receiverId"] != null && row["receiverId"].ToString() != "")
         {
             model.receiverId = int.Parse(row["receiverId"].ToString());
         }
         if (row["userName"] != null)
         {
             model.userName = row["userName"].ToString();
         }
         if (row["userHeadimage"] != null)
         {
             model.userHeadimage = row["userHeadimage"].ToString();
         }
         if (row["recuserName"] != null)
         {
             model.recuserName = row["recuserName"].ToString();
         }
         if (row["recuserHeadimage"] != null)
         {
             model.recuserHeadimage = row["recuserHeadimage"].ToString();
         }
         if (row["shortMsgId"] != null && row["shortMsgId"].ToString() != "")
         {
             model.shortMsgId = int.Parse(row["shortMsgId"].ToString());
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(starweibo.Model.chatV model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into chatV(");
            strSql.Append("senderId,msgContent,pubTime,msgState,receiverId,userName,userHeadimage,recuserName,recuserHeadimage,shortMsgId)");
            strSql.Append(" values (");
            strSql.Append("@senderId,@msgContent,@pubTime,@msgState,@receiverId,@userName,@userHeadimage,@recuserName,@recuserHeadimage,@shortMsgId)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@senderId",         SqlDbType.Int,         4),
                new SqlParameter("@msgContent",       SqlDbType.NVarChar,  200),
                new SqlParameter("@pubTime",          SqlDbType.DateTime),
                new SqlParameter("@msgState",         SqlDbType.NVarChar,   50),
                new SqlParameter("@receiverId",       SqlDbType.Int,         4),
                new SqlParameter("@userName",         SqlDbType.NVarChar,   20),
                new SqlParameter("@userHeadimage",    SqlDbType.NVarChar,  150),
                new SqlParameter("@recuserName",      SqlDbType.NVarChar,   20),
                new SqlParameter("@recuserHeadimage", SqlDbType.NVarChar,  150),
                new SqlParameter("@shortMsgId",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.senderId;
            parameters[1].Value = model.msgContent;
            parameters[2].Value = model.pubTime;
            parameters[3].Value = model.msgState;
            parameters[4].Value = model.receiverId;
            parameters[5].Value = model.userName;
            parameters[6].Value = model.userHeadimage;
            parameters[7].Value = model.recuserName;
            parameters[8].Value = model.recuserHeadimage;
            parameters[9].Value = model.shortMsgId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public starweibo.Model.chatV GetModel(int shortMsgId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 senderId,msgContent,pubTime,msgState,receiverId,userName,userHeadimage,recuserName,recuserHeadimage,shortMsgId from chatV ");
            strSql.Append(" where shortMsgId=@shortMsgId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shortMsgId", SqlDbType.Int, 4)
            };
            parameters[0].Value = shortMsgId;

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

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