/// <summary> /// 添加一条数据 /// </summary> /// <param name="model">数据实体</param> /// <returns></returns> public int Add(Models.APP.Member model) { try { SqlParameter[] para = { new SqlParameter("@username", model.username), new SqlParameter("@account", model.account), new SqlParameter("@pwd", model.pwd), new SqlParameter("@pic", model.pic), new SqlParameter("@name", model.name), new SqlParameter("@phon", model.phon), new SqlParameter("@sex", model.sex), new SqlParameter("@age", model.age), new SqlParameter("@city", model.city), new SqlParameter("@district", model.district), new SqlParameter("@address", model.address), new SqlParameter("@tp_pfid", model.tp_pfid), new SqlParameter("@tp_id", model.tp_id), new SqlParameter("@context", model.context), new SqlParameter("@isopen", model.isopen), new SqlParameter("@type", model.type), new SqlParameter("@ip", model.ip), new SqlParameter("@logintype", model.logintype), new SqlParameter("@loginnum", model.loginnum), new SqlParameter("@logintime", model.logintime), new SqlParameter("@openid", model.openid), new SqlParameter("@opentype", model.opentype), new SqlParameter("@datum", model.datum), new SqlParameter("@signnum", model.signnum), new SqlParameter("@sharenum", model.sharenum), new SqlParameter("@pushuserid", model.pushuserid), new SqlParameter("@pushchannelid", model.pushchannelid), new SqlParameter("@m_valid", model.m_valid) }; StringBuilder cmdText = new StringBuilder(); cmdText.Append(@"INSERT INTO App_Member( username ,account ,pwd ,pic ,name ,phon ,sex ,age ,city ,district ,address ,tp_pfid ,tp_id ,context ,isopen ,type ,ip ,logintype ,loginnum ,logintime ,openid ,opentype ,datum ,signnum ,sharenum ,pushuserid ,pushchannelid ,m_valid ) VALUES( @username ,@account ,@pwd ,@pic ,@name ,@phon ,@sex ,@age ,@city ,@district ,@address ,@tp_pfid ,@tp_id ,@context ,@isopen ,@type ,@ip ,@logintype ,@loginnum ,@logintime ,@openid ,@opentype ,@datum ,@signnum ,@sharenum ,@pushuserid ,@pushchannelid ,@m_valid );SELECT @@Identity" ); return(Convert.ToInt32(SqlHelper.ExecuteScalar(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.Member model) { return(dal.Update(model)); }
/// <summary> /// 修改一个实体 /// </summary> /// <param name="_entity"></param> /// <returns></returns> public int Update(Models.APP.Member model) { try { SqlParameter[] para = { new SqlParameter("@m_id", model.m_id), new SqlParameter("@username", model.username), new SqlParameter("@account", model.account), new SqlParameter("@pwd", model.pwd), new SqlParameter("@pic", model.pic), new SqlParameter("@name", model.name), new SqlParameter("@phon", model.phon), new SqlParameter("@sex", model.sex), new SqlParameter("@age", model.age), new SqlParameter("@city", model.city), new SqlParameter("@district", model.district), new SqlParameter("@address", model.address), new SqlParameter("@tp_pfid", model.tp_pfid), new SqlParameter("@tp_id", model.tp_id), new SqlParameter("@context", model.context), new SqlParameter("@isopen", model.isopen), new SqlParameter("@type", model.type), new SqlParameter("@ip", model.ip), new SqlParameter("@logintype", model.logintype), new SqlParameter("@loginnum", model.loginnum), new SqlParameter("@logintime", model.logintime), new SqlParameter("@openid", model.openid), new SqlParameter("@opentype", model.opentype), new SqlParameter("@datum", model.datum), new SqlParameter("@signnum", model.signnum), new SqlParameter("@sharenum", model.sharenum), new SqlParameter("@pushuserid", model.pushuserid), new SqlParameter("@pushchannelid", model.pushchannelid), new SqlParameter("@m_valid", model.m_valid), new SqlParameter("@modifytime", model.modifytime) }; StringBuilder cmdText = new StringBuilder(); cmdText.Append(@"UPDATE [App_Member] SET [username]=@username ,[account]=@account ,[pwd]=@pwd ,[pic]=@pic ,[name]=@name ,[phon]=@phon ,[sex]=@sex ,[age]=@age ,[city]=@city ,[district]=@district ,[address]=@address ,[tp_pfid]=@tp_pfid ,[tp_id]=@tp_id ,[context]=@context ,[isopen]=@isopen ,[type]=@type ,[ip]=@ip ,[logintype]=@logintype ,[loginnum]=@loginnum ,[modifytime]=@modifytime ,[logintime]=@logintime ,[openid]=@openid ,[opentype]=@opentype ,[datum]=@datum ,[signnum]=@signnum ,[sharenum]=@sharenum ,[pushuserid]=@pushuserid ,[pushchannelid]=@pushchannelid ,[m_valid]=@m_valid WHERE [m_id]=@m_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.Member model) { return(dal.Add(model)); }