/// <summary> /// 修改一个实体 /// </summary> /// <param name="_entity"></param> /// <returns></returns> public int Update(Models.APP.package model) { return(dal.Update(model)); }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="model">数据实体</param> /// <returns></returns> public int Add(Models.APP.package model) { try { SqlParameter[] para = { new SqlParameter("@a_id", model.a_id), new SqlParameter("@title", model.title), new SqlParameter("@amount", model.amount), new SqlParameter("@number", model.number), new SqlParameter("@numberlimit", model.numberlimit), new SqlParameter("@context", model.context), new SqlParameter("@bytime", model.bytime), new SqlParameter("@begintime", model.begintime), new SqlParameter("@endtime", model.endtime), new SqlParameter("@address", model.address), new SqlParameter("@city", model.city), new SqlParameter("@district", model.district), new SqlParameter("@longitude", model.longitude), new SqlParameter("@latitude", model.latitude), new SqlParameter("@modifytime", model.modifytime), new SqlParameter("@userid", model.userid), new SqlParameter("@muserid", model.muserid), new SqlParameter("@createtime", model.createtime), new SqlParameter("@ptype", model.ptype) }; StringBuilder cmdText = new StringBuilder(); cmdText.Append(@"INSERT INTO App_package( a_id ,title ,amount ,number ,numberlimit ,context ,bytime ,begintime ,endtime ,address ,city ,district ,longitude ,latitude ,modifytime ,userid ,muserid ,createtime ,ptype ) VALUES( @a_id ,@title ,@amount ,@number ,@numberlimit ,@context ,@bytime ,@begintime ,@endtime ,@address ,@city ,@district ,@longitude ,@latitude ,@modifytime ,@userid ,@muserid ,@createtime ,@ptype );SELECT @@Identity;" ); 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="model">数据实体</param> /// <returns></returns> public int Add(Models.APP.package model) { return(dal.Add(model)); }
/// <summary> /// 修改一个实体 /// </summary> /// <param name="_entity"></param> /// <returns></returns> public int Update(Models.APP.package model) { try { SqlParameter[] para = { new SqlParameter("@pk_id", model.pk_id), new SqlParameter("@a_id", model.a_id), new SqlParameter("@title", model.title), new SqlParameter("@amount", model.amount), new SqlParameter("@number", model.number), new SqlParameter("@numberlimit", model.numberlimit), new SqlParameter("@context", model.context), new SqlParameter("@bytime", model.bytime), new SqlParameter("@begintime", model.begintime), new SqlParameter("@endtime", model.endtime), new SqlParameter("@address", model.address), new SqlParameter("@city", model.city), new SqlParameter("@district", model.district), new SqlParameter("@longitude", model.longitude), new SqlParameter("@latitude", model.latitude), new SqlParameter("@modifytime", model.modifytime), new SqlParameter("@userid", model.userid), new SqlParameter("@muserid", model.muserid), new SqlParameter("@createtime", model.createtime), new SqlParameter("@ptype", model.ptype) }; StringBuilder cmdText = new StringBuilder(); cmdText.Append(@"UPDATE [App_package] SET [a_id]=@a_id ,[title]=@title ,[amount]=@amount ,[number]=@number ,[numberlimit]=@numberlimit ,[context]=@context ,[bytime]=@bytime ,[begintime]=@begintime ,[endtime]=@endtime ,[address]=@address ,[city]=@city ,[district]=@district ,[longitude]=@longitude ,[latitude]=@latitude ,[modifytime]=@modifytime ,[userid]=@userid ,[muserid]=@muserid ,[createtime]=@createtime ,[ptype]=@ptype WHERE [pk_id]=@pk_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); }