<!--#include file="../p_inc/Include_func.asp"-->
<!--#include file="../p_inc/openconn.asp"-->
<!--#include file="config.asp"-->
<!--#include file="function_u.asp"-->

<%
IF Not ChkPost() Then
	response.Redirect "../"
	response.End()
End IF
%>
<%
action=Request("action")

IF action="Pg28_save" Then
	Call Pg28_save() 'Pg310彩票保存	
ElseIF action="login" Then
	Call Loginf() '开始登陆		
End IF

Sub Pg28_save()
	oSMONEYSUM=Replace(Trim(Request("SMONEYSUM")),",","") '所有投注总和
	oALLSMONEY=Trim(Request("ALLSMONEY")) '详细投注数
	oPid=Bint(Replace(Request("LID"),"'","")) '彩票ID

	IF Request.Cookies(G_u_Cookies)("soojs_id")="" Then	
		response.Write "<script>"
		Response.Write "window.parent.showmessage(""14"",""请先登陆！"","""")"
		response.Write "</script>"	
		Response.End()
	End IF	
	
	Set oRs=server.CreateObject(G_Rs)
	oRs.open "Select * From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,1
	IF Not oRs.Eof Then	
		zsoojs_jifen=Bint(oRs("soojs_jifen")) 
	End IF
	oRs.close
	IF Clng(oSMONEYSUM)>Clng(zsoojs_jifen) Then
		response.Write "<script>"
		Response.Write "window.parent.showmessage(""16"",""您的"&G_jifen_jifen_name&"不足！"","""")"
		response.Write "</script>"		
		Response.End()
	End IF
	
	
	Set oRs4=Conn.Execute("Select * From qingtiandy_caipiao28 Where Id="&oPid&"")
	IF Not oRs4.Eof Then
		opStartTime=oRs4("pStartTime")
	Else
		response.Write "<script>"
		Response.Write "window.parent.showmessage(""15"",""无效投注！"","""")"
		response.Write "</script>"		
		Response.End()		
	End IF
	
	
	IF DateDiff("s",opStartTime,Now())>0 Then
		response.Write "<script>"
		Response.Write "window.parent.showmessage(""17"",""已经关闭投注！"","""")"
		response.Write "</script>"		
		Response.End()		
	End IF	
	
	oTrue=False
	oALLSMONEY_a=split(oALLSMONEY,",")
	opDate=ForMatDate(Now(),55)
	kpNumb=0
	For ii=0 To 27
		oALLSMONEY_a_1=oALLSMONEY_a(ii) '用户投了多少
		oALLSMONEY_a_1=bint(oALLSMONEY_a_1)
		opNumb=ii '选择彩票的数字
		opNumb2=oALLSMONEY_a_1 '选择彩票的数字所投注的数目
		opUid=Request.Cookies(G_u_Cookies)("soojs_id") '用户ID
		IF oALLSMONEY_a_1<>0 Then
			oTrue=True
			Set oRs=Server.CreateObject(G_RS)
			oRs.open "Select * From qingtiandy_caipiao28_list_user Where 1<>1",Conn,1,3
			oRs.AddNew()
			oRs("pId")				= oPid
			oRs("pNumb")			= opNumb
			oRs("pNumb2")			= opNumb2
			oRs("pDate")			= opDate
			oRs("pUid")				= opUid
			oRs("pStatus")			= 0
			kpNumb=kpNumb+1
			oRs.Update()
			oRs.close
			Conn.Execute("Update qingtiandy_caipiao28 Set pn"&ii&"=pn"&ii&"+"&opNumb2&" Where id="&oPid&"")
		End IF
	Next	
	IF oTrue Then
		Get_qingtiandy_jifen_ip Request.Cookies(G_u_Cookies)("soojs_id"),19,-oSMONEYSUM
		conn.Execute("Update qingtiandy_caipiao28 set pNumb3=pNumb3+"&oSMONEYSUM&",pNumb1=pNumb1+"&oSMONEYSUM&",pNumb=pNumb+"&Cint(kpNumb)&" Where id="&oPid&"")		
	End IF	
	response.Write "<script>"
	Response.Write "window.parent.showmessage(""18"",""投注成功！"","""&oPid&""")"
	response.Write "</script>"		
	Response.End()	
End Sub
%>