<%
Function GetWuliuNameByNumber(WuliuNumber)  
	IsExists=""
	if len(WuliuNumber)>0 then
		set HyNameByNumberRs=nothing
		set HyNameByNumberRs=server.CreateObject("adodb.recordset")
		sql = "select WuliuName from WuliuInfo where  WuliuNumber ='" & WuliuNumber & "'"
		HyNameByNumberRs.Open sql,conn		
		if HyNameByNumberRs.recordcount>0 then
			IsExists=HyNameByNumberRs("WuliuName")
		end if
	end if
	GetWuliuNameByNumber=IsExists	
End Function 

Function GetTjBuyCount(HyNumber)
	set HyTjBuyCountRs=nothing
	set HyTjBuyCountRs=server.CreateObject("adodb.recordset")
	TjCount=0
	if len(HyNumber)>0 then
		sql = "SELECT sum(HyBuyCount) as TjCount FROM HyClub where HyTjNumber='" & HyNumber & "' and IsApproved=true"
		HyTjBuyCountRs.Open sql,conn
		
		if HyTjBuyCountRs.RecordCount>0 then
			if len(HyTjBuyCountRs("TjCount"))>0 then
				TjCount=HyTjBuyCountRs("TjCount")
			end if
		end if 
	end if
	GetTjBuyCount=TjCount
End Function

Function GetFindHyNameByHyNumber(HyName)
	IsExists=HyName
	if len(HyName)>0 then
		set HyNameByNumberRs=nothing
		set HyNameByNumberRs=server.CreateObject("adodb.recordset")
		sql = "select HyClub.HyNumber from hy left join hyClub on hy.ID=HyClub.HyID where  Hy.HyName ='" & HyName & "'"
		HyNameByNumberRs.Open sql,conn		
		if HyNameByNumberRs.recordcount=1 then
			IsExists=HyNameByNumberRs("HyNumber")
		end if
	end if
	GetFindHyNameByHyNumber=IsExists
end function

function GetKeyStringByHyNumber(HyNumber)
	TempKeyString=""
	set GetProductNamers=nothing
	set GetProductNamers=server.CreateObject("adodb.recordset")	
	sql ="select KeyString from HyCLub where HyNumber='"&HyNumber&"'"
	GetProductNamers.Open sql,conn
	if GetProductNamers.recordcount>0 then
		TempKeyString=GetProductNamers("KeyString")
	end if
	GetKeyStringByHyNumber=TempKeyString
end function

Function GetWuliuLevelByHyNumber(HyNumber) 
	IsExists=""
	if len(HyNumber)>0 then
		set HyWuLiuNumberRs=nothing
		set HyWuLiuNumberRs=server.CreateObject("adodb.recordset")
		sql = "select WuliuLevel from wuliuinfo where  HyNumber ='" & HyNumber & "'"
		HyWuLiuNumberRs.Open sql,conn		
		if HyWuLiuNumberRs.recordcount>0 then
			IsExists=HyWuLiuNumberRs("WuliuLevel")
		end if
	end if
	GetWuliuLevelByHyNumber=IsExists	
End Function 

Function GetWuLiuNumber(HyNumber) 
	IsExists=""
	if len(HyNumber)>0 then
		set HyWuLiuNumberRs=nothing
		set HyWuLiuNumberRs=server.CreateObject("adodb.recordset")
		sql = "select WuliuNumber from WuliuInfo where  HyNumber ='" & HyNumber & "'"
		HyWuLiuNumberRs.Open sql,conn		
		if HyWuLiuNumberRs.recordcount>0 then
			IsExists=HyWuLiuNumberRs("WuliuNumber")
		end if
	end if
	GetWuLiuNumber=IsExists	
End Function 

Function GetWuliuDanTimeCount(WuliuNumber,time1,time2,DispType)
	set HyWuliuDanTimeRs=nothing
	set HyWuliuDanTimeRs=server.CreateObject("adodb.recordset")
	Count=0
	time1=trim(time1)
	time2=trim(time2)
	if len(WuliuNumber)>0 then
		sql = "SELECT sum(HyBuyCount) as TjCount FROM HyClub where WuliuNumber in ('" & WuliuNumber & "') and IsApproved=true and ApprovedTime>='"&time1&"' and ApprovedTime<='"&time2&"'"
		'response.write sql
		HyWuliuDanTimeRs.Open sql,conn		
		if HyWuliuDanTimeRs.RecordCount>0 then
			if len(HyWuliuDanTimeRs("TjCount"))>0 then
				Count=HyWuliuDanTimeRs("TjCount")
			end if
		end if 
	end if
	GetWuliuDanTimeCount=Count
End Function

Function GetWuliuDanCount(WuliuNumber,GetType)
	set HyWuliuDanRs=nothing
	set HyWuliuDanRs=server.CreateObject("adodb.recordset")
	Count=0
	if len(WuliuNumber)>0 then
		sql = "SELECT sum(HyBuyCount) as TjCount FROM HyClub where WuliuNumber='" & WuliuNumber & "' and IsApproved=true"
		HyWuliuDanRs.Open sql,conn		
		if HyWuliuDanRs.RecordCount>0 then
			if len(HyWuliuDanRs("TjCount"))>0 then
				Count=HyWuliuDanRs("TjCount")
			end if
		end if 
	end if
	GetWuliuDanCount=Count
End Function

Function getcurrentWuliuNumber() 
	CurrentHyNumber=""
	set HyCurrentNumberRs=nothing
	set HyCurrentNumberRs=server.CreateObject("adodb.recordset")
	sql = "select WuliuNumber from wuliuinfo where id=(select max(id) from wuliuinfo)"
	HyCurrentNumberRs.Open sql,conn		
	if HyCurrentNumberRs.recordcount>0 then
		TempHyNumber=right(HyCurrentNumberRs("WuliuNumber"),3)
		TempHyNumber=clng(TempHyNumber)+1
		TempLen=len(TempHyNumber)
		if TempLen<3 then
			for kk=1 to 3-TempLen
				TempHyNumber="0"&TempHyNumber
			next
		end if
		CurrentHyNumber=TempHyNumber		
	else
		CurrentHyNumber="101"
	end if
	getcurrentWuliuNumber=CurrentHyNumber	
End Function 

Function GetCurrentEndMoney() 
	CurrentNumber=0
	randomize
	TempEndMoney=Int(100 * Rnd(2) )
	set HyCurrentEndMoneyRs=nothing
	set HyCurrentEndMoneyRs=server.CreateObject("adodb.recordset")
	sql = "select ID from HyClub where IsApproved=false and  OtherStringFiled='"&TempEndMoney &"'"
	HyCurrentEndMoneyRs.Open sql,conn		
	if HyCurrentEndMoneyRs.recordcount>0 then
		CurrentNumber=GetCurrentEndMoney
	else
		CurrentNumber=TempEndMoney
	end if
	if len(CurrentNumber)<2 then
		CurrentNumber="0"&CurrentNumber
	end if
	GetCurrentEndMoney=CurrentNumber	
End Function 

Function GetHyMoneyAccountByHyNumber(HyNumber)
	set HyHyMoneyAccountRs=nothing
	set HyHyMoneyAccountRs=server.CreateObject("adodb.recordset")
	Count=0
	if len(HyNumber)>0 then
		sql = "select sum(AllMOney) as SumMOney from HyMoneyLog where HyNumber ='" & HyNumber & "'"
		HyHyMoneyAccountRs.Open sql,conn	
		if HyHyMoneyAccountRs.RecordCount>0 then
			if len(HyHyMoneyAccountRs("SumMOney"))>0 then
				Count=HyHyMoneyAccountRs("SumMOney")
			end if
		end if 
	end if
	GetHyMoneyAccountByHyNumber=Count
End Function 

Function GetDisplayFunc(FuncName)
	IsExists=false
	if len(FuncName)>0 then
		set HyDisplayFuncRs=nothing
		set HyDisplayFuncRs=server.CreateObject("adodb.recordset")
		sql = "select IsDisplay from Setting_Function where FuncName ='" & FuncName & "'"
		HyDisplayFuncRs.Open sql,conn		
		if HyDisplayFuncRs.recordcount>0 then
			IsExists=HyDisplayFuncRs("IsDisplay")
		end if
	end if
	GetDisplayFunc=IsExists
End Function

Function GetDisplay(FieldName)
	IsExists=false
	if len(FieldName)>0 then
		set HyDisplayRs=nothing
		set HyDisplayRs=server.CreateObject("adodb.recordset")
		sql = "select FieldIsDisplay from Setting_Field where FieldName ='" & FieldName & "'"
		HyDisplayRs.Open sql,conn		
		if HyDisplayRs.recordcount>0 then
			IsExists=HyDisplayRs("FieldIsDisplay")
		end if
	end if
	GetDisplay=IsExists
End Function

Function GetIsMustInput(FieldName)
	IsExists=false
	if len(FieldName)>0 then
		set HyDisplayRs=nothing
		set HyDisplayRs=server.CreateObject("adodb.recordset")
		sql = "select FieldIsMustInput from Setting_Field where FieldName ='" & FieldName & "'"
		HyDisplayRs.Open sql,conn		
		if HyDisplayRs.recordcount>0 then
			IsExists=HyDisplayRs("FieldIsMustInput")
		end if
	end if
	GetIsMustInput=IsExists
End Function

Function GetDisplayName(FieldName)
	DisplayName=""
	if len(FieldName)>0 then
		set HyDisplayNameRs=nothing
		set HyDisplayNameRs=server.CreateObject("adodb.recordset")
		sql = "select MyFieldText from Setting_Field where FieldName ='" & FieldName & "'"
		HyDisplayNameRs.Open sql,conn		
		if HyDisplayNameRs.recordcount>0 then
			DisplayName=HyDisplayNameRs("MyFieldText")
		end if
	end if
	GetDisplayName=DisplayName
End Function
Function GetOtherSettingValue(FuncName)
	OtherSettingValue=""
	if len(FuncName)>0 then
		set HyOtherSettingRs=nothing
		set HyOtherSettingRs=server.CreateObject("adodb.recordset")
		sql = "select FuncValue from Setting_other where FuncName ='" & FuncName & "'"
		HyOtherSettingRs.Open sql,conn		
		if HyOtherSettingRs.recordcount>0 then
			OtherSettingValue=HyOtherSettingRs("FuncValue")
		end if
	end if
	GetOtherSettingValue=OtherSettingValue
End Function

Function GetTjCount(HyNumber)
	set HyTjRs=nothing
	set HyTjRs=server.CreateObject("adodb.recordset")
	Count=0
	if len(HyNumber)>0 then
		sql = "SELECT count(ID) as TjCount FROM HyClub where HyTjNumber='" & HyNumber & "' and IsApproved=true"
		HyTjRs.Open sql,conn
		
		if HyTjRs.RecordCount>0 then
			if len(HyTjRs("TjCount"))>0 then
				Count=HyTjRs("TjCount")
			end if
		end if 
	end if
	GetTjCount=Count
End Function

Function GetNameByNumber(HyNumber)  '¼ì²éMoneyLogÊÇ·ñ´æÔÚ¼ÇÂ¼
	IsExists=""
	if len(HyNumber)>0 then
		set HyNameByNumberRs=nothing
		set HyNameByNumberRs=server.CreateObject("adodb.recordset")
		sql = "select Hy.HyName from hy left join hyClub on hy.ID=HyClub.HyID where  HyClub.HyNumber ='" & HyNumber & "'"
		HyNameByNumberRs.Open sql,conn		
		if HyNameByNumberRs.recordcount>0 then
			IsExists=HyNameByNumberRs("HyName")
		end if
	end if
	GetNameByNumber=IsExists	
End Function 
%>