public static DataTable SearchUser(XiHuan_UserSearchFilter f, out int rowcount) { int minId = f.PageIndex * f.PageSize; int maxId = (f.PageIndex + 1) * f.PageSize + 1; string sql = @"DECLARE @indextable table(Id int identity(1,1) PRIMARY KEY,uid int); insert into @indextable(uid) select Id from XiHuan_UserInfo with(nolock) where IsLocked=0 {0}; select @@ROWCOUNT; select {1} from XiHuan_UserInfo u with(nolock) inner join @indextable t on u.Id=t.uid and t.Id>{2} and t.Id<{3} "; StringBuilder sqlwhere = new StringBuilder(""); if (f.UserName.Trim().Length > 0) { sqlwhere.AppendFormat(" AND UserName like'%{0}%' ", ValidatorHelper.SafeSql(f.UserName.Trim())); } if (f.ProvinceId != int.MaxValue) { sqlwhere.AppendFormat(" AND ProvinceId={0} ", f.ProvinceId); } if (f.CityId != int.MaxValue) { sqlwhere.AppendFormat(" AND CityId={0} ", f.CityId); } if (f.AreaId != int.MaxValue) { sqlwhere.AppendFormat(" AND AreaId={0} ", f.AreaId); } if (f.SchooId != int.MaxValue) { sqlwhere.AppendFormat(" AND SchoolId={0} ", f.SchooId); } if (f.IsStartUser != int.MaxValue) { sqlwhere.AppendFormat(" AND IsStarUser={0} ", f.IsStartUser); } if (f.Gender != int.MaxValue) { sqlwhere.AppendFormat(" AND Gender={0} ", f.Gender); } if (f.IsHavePhoto != int.MaxValue) { sqlwhere.Append(" AND HeadImage <> 'images/nophoto.gif'"); } if (f.CreateDateBegin != DateTime.MinValue) { sqlwhere.AppendFormat(" AND RegisterDate>='{0}' ", f.CreateDateBegin); } if (f.CreateDateEnd != DateTime.MaxValue) { sqlwhere.AppendFormat(" AND RegisterDate<'{0}' ", f.CreateDateEnd.AddDays(1)); } DataSet ds = Query.ProcessMultiSql(string.Format(sql, sqlwhere.ToString() + " order by " + f.OrderByParam, f.SelectFileds, minId, maxId), GlobalVar.DataBase_Name); rowcount = CommonMethodFacade.ConvertToInt(ds.Tables[0].Rows[0][0], 0); return(ds.Tables[1]); }
public static DataTable GetUserRequire(XiHuan_ChangeRequireSearchFilter f) { string sql = "select * from XiHuan_UserGoodsChangeRequire with(nolock) where 1=1 "; if (f.GoodsId != int.MaxValue) { sql += string.Format(" and GoodsId={0} ", f.GoodsId); } if (f.OwnerId != int.MaxValue) { sql += string.Format(" and OwnerId={0} ", f.OwnerId); } if (f.SenderId != int.MaxValue) { sql += string.Format(" and SenderId={0} ", f.SenderId); } if (f.OwnerName.Trim().Length > 0) { sql += string.Format(" and OwnerName={0} ", ValidatorHelper.SafeSql(f.OwnerName.Trim())); } if (f.GoodsName.Trim().Length > 0) { sql += string.Format(" and GoodsName like '%{0}%' ", ValidatorHelper.SafeSql(f.GoodsName.Trim())); } if (f.SenderName.Trim().Length > 0) { sql += string.Format(" and SenderName like '%{0}%' ", ValidatorHelper.SafeSql(f.SenderName.Trim())); } if (f.RequireType != int.MaxValue) { sql += string.Format(" and RequireType={0} ", f.RequireType); } if (f.Flag != int.MaxValue) { sql += string.Format(" and Flag={0} ", f.Flag); } if (f.Flags.Trim().Length > 0) { sql += string.Format(" and Flag in({1}) ", f.Flags.Trim()); } if (f.RequireDateBegin != DateTime.MinValue) { sql += string.Format(" and RequireDate>='{0}' ", f.RequireDateBegin); } if (f.RequireDateEnd != DateTime.MaxValue) { sql += string.Format(" and RequireDate<'{1}' ", f.RequireDateEnd.AddDays(1)); } return(Query.ProcessSql(sql + " order by RequireDate desc; ", GlobalVar.DataBase_Name)); }
public static bool IsUserValid(string uname, string upass) { uname = CommonMethodFacade.FinalString(uname); upass = CommonMethodFacade.FinalString(upass); if (uname.Length > 0 && upass.Length > 0) { string sqlLogin = @"UPDATE XiHuan_UserInfo SET LastLoginTime=getdate(), Score=Score+(CASE WHEN LastLoginTime<'{0}' THEN {1} ELSE 0 END ) WHERE UserName='******' AND OrignalPwd='{3}' ;"; int effcount = Query.ProcessSqlNonQuery(string.Format(sqlLogin, DateTime.Now.ToString("yyyy-MM-dd"), SystemConfigFacade.Instance().LoginAddScore(), ValidatorHelper.SafeSql(uname), ValidatorHelper.SafeSql(upass)), GlobalVar.DataBase_Name); return(effcount > 0); } else { return(false); } }