/// <summary> /// 添加新地址 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddAddress(AddressEntity model) { string sql = @"Insert into AddressInfo(UserId,[Type],CountryId,ProvinceId,CityId,AreaId,PostCode,[Address],Receiver,Phone,IsDefault,PapersType,PapersCode,CreateTime,CreateBy,IsEnable) Values(@UserId,@Type,@CountryId,@ProvinceId,@CityId,@AreaId,@PostCode,@Address,@Receiver,@Phone,@IsDefault,@PapersType,@PapersCode,@CreateTime,@CreateBy,@IsEnable);select @@Identity;"; var parameters = DbSFO2ORead.CreateParameterCollection(); parameters.Append("@UserId", model.UserId); parameters.Append("@Type", model.Type); parameters.Append("@CountryId", model.CountryId); parameters.Append("@ProvinceId", model.ProvinceId); parameters.Append("@CityId", model.CityId); parameters.Append("@AreaId", model.AreaId); parameters.Append("@PostCode", model.PostCode); parameters.Append("@Address", model.Address); parameters.Append("@Receiver", model.Receiver); parameters.Append("@Phone", model.Phone); parameters.Append("@IsDefault", model.IsDefault); parameters.Append("@PapersType", model.PapersType); parameters.Append("@PapersCode", model.PapersCode); parameters.Append("@CreateTime", model.CreateTime); parameters.Append("@CreateBy", model.CreateBy); parameters.Append("@IsEnable", model.IsEnable); object id = DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters); return(id == null?0:id.AsInt32()); }
//插入 DividedPercentStationVisitedLog public int InsertVisitedLog(string StationSource, int ChannelId) { string sql = @"INSERT INTO DividedPercentStationVisitedLog ( -- Id -- this column value is auto-generated DPID, ZDID, VisitedDate, VisitedCount ) VALUES ( @DPID, @ZDID, @VisitedDate, @VisitedCount )"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@DPID", ChannelId); parameters.Append("@ZDID", StationSource); parameters.Append("@VisitedDate", DateTime.Now); parameters.Append("@VisitedCount", 1); return(Convert.ToInt32(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters))); }
/// <summary> /// /// </summary> /// <returns></returns> public bool IsFirstOrderAuthorize(string userName) { string sql = @"SELECT FirstOrderAuthorize FROM Customer WHERE UserName=@UserName "; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserName", userName); return(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters).ToString() == "1" ? true : false); }
// 通过StationSource ChannelId 查询 DividedPercentStationVisitedLog 表中是否有记录 public int selectVisitedLog(string StationSource, int ChannelId) { string sql = "SELECT COUNT(*) FROM DividedPercentStationVisitedLog AS dpsvl WHERE dpsvl.DPID=@ChannelId AND dpsvl.ZDID=@StationSource "; var parameters = DbSFO2ORead.CreateParameterCollection(); parameters.Append("@StationSource", StationSource); parameters.Append("@ChannelId", ChannelId); return(Convert.ToInt32(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters))); }
public int InsertTemp(string UserName, string pwd, int UserType) { string sql = @"INSERT INTO CustomerTemp(UserName,UserPwd,UserType) VALUES(@UserName,@UserPwd,@UserType)"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserName", UserName); parameters.Append("@UserPwd", pwd); parameters.Append("@UserType", UserType); return(Convert.ToInt32(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters))); }
/// <summary> /// 查询用户的地址数量 /// </summary> /// <param name="userId"></param> /// <param name="countryId"></param> /// <returns></returns> public int GetUserAddressCount(int userId, int countryId) { string sql = "Select count(1) From AddressInfo (nolock) Where UserId=@UserId And CountryId=(select top 1 CountryId From Country Where Id=@CountryId) and IsEnable=1"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserId", userId); parameters.Append("@CountryId", countryId); object cnt = DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters); return(cnt == null ? 0 : cnt.AsInt32()); }
/// <summary> /// 增加一条记录 /// </summary> public int Insert(MessageInfo messageInfo) { const string INSERT_SQL = @" insert into Message(Title,Content,SendWay,SendType,MessageType,MessageGroup,Timing,MesasgeTypeContent,CreateUserType,Status,CreateTime,CreateBy,Sender,ContentType,MsgType,ObjectId) values(@Title,@Content,@SendWay,@SendType,@MessageType,@MessageGroup,@Timing,@MesasgeTypeContent,@CreateUserType,@Status,@CreateTime,@CreateBy,@Sender,@ContentType,@MsgType,@ObjectId) select @@IDENTITY"; var dbParameters = DbSFO2ORead.CreateParameterCollection(); dbParameters.Append("@Title", messageInfo.Title); dbParameters.Append("@Content", messageInfo.Content); dbParameters.Append("@SendWay", messageInfo.SendWay); dbParameters.Append("@SendType", messageInfo.SendType); dbParameters.Append("@MessageType", messageInfo.MessageType); dbParameters.Append("@MessageGroup", messageInfo.MessageGroup); dbParameters.Append("@Timing", messageInfo.Timing); dbParameters.Append("@MesasgeTypeContent", messageInfo.MesasgeTypeContent); dbParameters.Append("@CreateUserType", messageInfo.CreateUserType); dbParameters.Append("@Status", messageInfo.Status); dbParameters.Append("@CreateTime", messageInfo.CreateTime); dbParameters.Append("@CreateBy", messageInfo.CreateBy); dbParameters.Append("@Sender", messageInfo.Sender); dbParameters.Append("@ContentType", messageInfo.ContentType); dbParameters.Append("@MsgType", messageInfo.PushType); dbParameters.Append("@ObjectId", messageInfo.ObjectId); object result = DbSFO2OMain.ExecuteScalar(CommandType.Text, INSERT_SQL, dbParameters); return(result == null ? 0 : int.Parse(result.ToString())); }
/// <summary> /// 添加新用户 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Insert(CustomerEntity entity) { string sql = @"Insert Into Customer(UserName,Password,Mobile,RegionCode,Gender,Email,Type,Status,CreateTime,IsPushingInfo,SourceValue,SourceType,ChannelId) Values( @UserName,@Password,@Mobile,@RegionCode,@Gender,@Email,@Type,@Status,getdate(),1,@SourceValue,@SourceType,@ChannelId); select @@IDENTITY"; var parameters = DbSFO2OMain.CreateParameterCollection(); parameters.Append("@UserName", entity.Mobile); parameters.Append("@Password", MD5Hash.Md5Encrypt(entity.Password)); parameters.Append("@Mobile", entity.Mobile); parameters.Append("@RegionCode", entity.RegionCode); parameters.Append("@Gender", entity.Gender); parameters.Append("@Email", entity.Email); parameters.Append("@Type", entity.RegionCode == "86" ? 0 : 1); parameters.Append("@Status", 1); parameters.Append("@SourceValue", entity.SourceValue); parameters.Append("@SourceType", entity.SourceType); parameters.Append("@ChannelId", entity.ChannelId); return(Convert.ToInt32(DbSFO2OMain.ExecuteScalar(CommandType.Text, sql, parameters))); }