Exemple #1
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model">数据实体</param>
        /// <returns></returns>
        public int Add(Models.APP.Chat model)
        {
            try
            {
                SqlParameter[] para =
                {
                    new SqlParameter("@m_id",       model.m_id),
                    new SqlParameter("@g_id",       model.g_id),
                    new SqlParameter("@context",    model.context),
                    new SqlParameter("@createtime", model.createtime),
                    new SqlParameter("@modifytime", model.modifytime),
                    new SqlParameter("@userid",     model.userid),
                    new SqlParameter("@muserid",    model.muserid)
                };
                StringBuilder cmdText = new StringBuilder();
                cmdText.Append(@"INSERT INTO App_Chat(
			                        m_id
						            ,g_id
						            ,context
						            ,createtime
						            ,modifytime
						            ,userid
						            ,muserid
						  ) VALUES(
									@m_id
									,@g_id
									,@context
									,@createtime
									,@modifytime
									,@userid
									,@muserid
					)"                    );

                return(SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.Text, cmdText.ToString(), para));
            }
            catch (ArgumentNullException ex)
            {
                logger.Error("调用方法Add()发生ArgumentNullException", ex);
            }
            catch (SqlException ex)
            {
                logger.Error("调用方法Add()发生SqlException", ex);
            }
            catch (Exception ex)
            {
                logger.Error("调用方法Add()发生Exception", ex);
            }
            return(-1);
        }
Exemple #2
0
        /// <summary>
        /// 修改一个实体
        /// </summary>
        /// <param name="_entity"></param>
        /// <returns></returns>
        public int Update(Models.APP.Chat model)
        {
            try
            {
                SqlParameter[] para =
                {
                    new SqlParameter("@ct_id",      model.ct_id),
                    new SqlParameter("@m_id",       model.m_id),
                    new SqlParameter("@g_id",       model.g_id),
                    new SqlParameter("@context",    model.context),
                    new SqlParameter("@createtime", model.createtime),
                    new SqlParameter("@modifytime", model.modifytime),
                    new SqlParameter("@userid",     model.userid),
                    new SqlParameter("@muserid",    model.muserid)
                };

                StringBuilder cmdText = new StringBuilder();
                cmdText.Append(@"UPDATE [App_Chat]
								SET [m_id]=@m_id
									   ,[g_id]=@g_id
							       ,[context]=@context
							       ,[createtime]=@createtime
							       ,[modifytime]=@modifytime
							       ,[userid]=@userid
							       ,[muserid]=@muserid
							  WHERE [ct_id]=@ct_id"                            );
                return(SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.Text, cmdText.ToString(), para));
            }
            catch (ArgumentNullException ex)
            {
                logger.Error("调用方法Update()发生ArgumentNullException", ex);
            }
            catch (SqlException ex)
            {
                logger.Error("调用方法Update()发生SqlException", ex);
            }
            catch (Exception ex)
            {
                logger.Error("调用方法Update()发生Exception", ex);
            }
            return(-1);
        }
Exemple #3
0
 /// <summary>
 /// 修改一个实体
 /// </summary>
 /// <param name="_entity"></param>
 /// <returns></returns>
 public int Update(Models.APP.Chat model)
 {
     return(dal.Update(model));
 }
Exemple #4
0
 /// <summary>
 /// 添加一条数据
 /// </summary>
 /// <param name="model">数据实体</param>
 /// <returns></returns>
 public int Add(Models.APP.Chat model)
 {
     return(dal.Add(model));
 }