/// <summary> /// 添加一条数据 /// </summary> /// <param name="model">数据实体</param> /// <returns></returns> public int Add(Models.APP.Venues model) { try { SqlParameter[] para = { new SqlParameter("@title", model.title), new SqlParameter("@pic", model.pic), new SqlParameter("@address", model.address), new SqlParameter("@province", model.province), new SqlParameter("@city", model.city), new SqlParameter("@district", model.district), new SqlParameter("@longitude", model.longitude), new SqlParameter("@latitude", model.latitude), new SqlParameter("@context", model.context), new SqlParameter("@type", model.type), new SqlParameter("@environmentType", model.environmentType), new SqlParameter("@openness", model.openness), new SqlParameter("@state", model.state), 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_Venues( title ,pic ,address ,province ,city ,district ,longitude ,latitude ,context ,type ,environmentType ,openness ,state ,createtime ,modifytime ,userid ,muserid ) VALUES( @title ,@pic ,@address ,@province ,@city ,@district ,@longitude ,@latitude ,@context ,@type ,@environmentType ,@openness ,@state ,@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.Venues model) { return(dal.Update(model)); }
/// <summary> /// 修改一个实体 /// </summary> /// <param name="_entity"></param> /// <returns></returns> public int Update(Models.APP.Venues model) { try { SqlParameter[] para = { new SqlParameter("@Id", model.Id), new SqlParameter("@title", model.title), new SqlParameter("@pic", model.pic), new SqlParameter("@address", model.address), new SqlParameter("@province", model.province), new SqlParameter("@city", model.city), new SqlParameter("@district", model.district), new SqlParameter("@longitude", model.longitude), new SqlParameter("@latitude", model.latitude), new SqlParameter("@context", model.context), new SqlParameter("@type", model.type), new SqlParameter("@environmentType", model.environmentType), new SqlParameter("@openness", model.openness), new SqlParameter("@state", model.state), 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_Venues] SET [title]=@title ,[pic]=@pic ,[address]=@address ,[province]=@province ,[city]=@city ,[district]=@district ,[longitude]=@longitude ,[latitude]=@latitude ,[context]=@context ,[type]=@type ,[environmentType]=@environmentType ,[openness]=@openness ,[state]=@state ,[createtime]=@createtime ,[modifytime]=@modifytime ,[userid]=@userid ,[muserid]=@muserid WHERE [Id]=@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="model">数据实体</param> /// <returns></returns> public int Add(Models.APP.Venues model) { return(dal.Add(model)); }