/// <summary> /// 添加一条数据 /// </summary> /// <param name="model">数据实体</param> /// <returns></returns> public int Add(Models.APP.Comments model) { try { SqlParameter[] para = { new SqlParameter("@context", model.context), new SqlParameter("@m_id", model.m_id), new SqlParameter("@a_id", model.a_id), new SqlParameter("@type", model.type), 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_Comments( context ,m_id ,a_id ,type ,createtime ,modifytime ,userid ,muserid ) VALUES( @context ,@m_id ,@a_id ,@type ,@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); }
/// <summary> /// 修改一个实体 /// </summary> /// <param name="_entity"></param> /// <returns></returns> public int Update(Models.APP.Comments model) { try { SqlParameter[] para = { new SqlParameter("@c_id", model.c_id), new SqlParameter("@context", model.context), new SqlParameter("@m_id", model.m_id), new SqlParameter("@a_id", model.a_id), new SqlParameter("@type", model.type), 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_Comments] SET [context]=@context ,[m_id]=@m_id ,[a_id]=@a_id ,[type]=@type ,[createtime]=@createtime ,[modifytime]=@modifytime ,[userid]=@userid ,[muserid]=@muserid WHERE [c_id]=@c_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); }
/// <summary> /// 修改一个实体 /// </summary> /// <param name="_entity"></param> /// <returns></returns> public int Update(Models.APP.Comments model) { return(dal.Update(model)); }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="model">数据实体</param> /// <returns></returns> public int Add(Models.APP.Comments model) { return(dal.Add(model)); }