<!-- #include file="conn2.asp" -->

<%

for i=1 to 50

	pkid=request.form("pkid"&i)
	kind=request.form("kind"&i)
	model=trim(request.form("model"&i))
	productname=trim(request.form("productname"&i))
	
	pipai=trim(request.form("pipai"&i))
	color=trim(request.form("color"&i))
	psize=trim(request.form("psize"&i))
	
	price1=trim(request.form("price1_"&i))
	price2=trim(request.form("price2_"&i))
	price3=trim(request.form("price3_"&i))
	price4=trim(request.form("price4_"&i))
	price5=trim(request.form("price5_"&i))
	price6=trim(request.form("price6_"&i))
	oneweight=trim(request.form("oneweight"&i))
	kuchushu=trim(request.form("kuchushu"&i))
	hit=trim(request.form("hit"&i))
	saleshu=trim(request.form("saleshu"&i))
	if hit="" or not isnumeric(hit) then hit=0
	if saleshu="" or not isnumeric(saleshu) then saleshu=0
	
	
	if oneweight="" or not isnumeric(oneweight) then
	oneweight=0
	end if

	if color<>"" then
		color=color&"，"
		color=replace(color,",","，")
		color=replace(color,"，，","，")
		color=replace(color,"，，","，")
		color=replace(color,"，，","，")
	end if
	if psize<>"" then
		psize=psize&"，"
		psize=replace(psize,",","，")
		psize=replace(psize,"，，","，")
		psize=replace(psize,"，，","，")
		psize=replace(psize,"，，","，")
	end if

	if pkid<>"" then
		sql="select * from e_product where pkid="&pkid&""
		set rs=server.CreateObject("adodb.recordset")
		rs.open sql,conn,1,3
		if rs.bof or rs.eof then
		else
			rs("kind")=kind
			rs("model")=model
			rs("productname")=productname
			
			rs("pipai")=pipai
			rs("color")=color
			rs("psize")=psize
			
			rs("price1")=price1
			rs("price2")=price2
			rs("price3")=price3
			rs("price4")=price4
			rs("price5")=price5
			rs("price6")=price6

			rs("oneweight")=oneweight
			rs("kuchushu")=kuchushu
			rs("hit")=hit
			rs("saleshu")=saleshu			
	
			rs.update
			
			
			sql2="select gid from e_guige where pkid="&pkid&" order by gid"
			set rs2=conn.execute(sql2)
			if rs2.bof or rs2.eof then
			else
				gid=rs2("gid")
				conn.execute("update e_guige set price2='"&price2&"',price3='"&price3&"',price4='"&price4&"',price5='"&price5&"',price6='"&price6&"'  where gid="&gid)
			end if
			rs2.close
			set rs2=nothing
			
		end if
		rs.close
		set rs=nothing
	end if
	
next


sql = "insert into e_guige(pkid, guige, price2,price3,price4,price5,price6) select pkid, '{单一规格}', price2,price3,price4,price5,price6 from e_product where pkid not in(select pkid from e_guige) "
conn.execute(sql) 



'response.redirect "pl_modify.asp?page="&request("page")
response.write "<script language=JavaScript>" & "alert('成功保存此页的修改！');" & "window.location.href='pl_modify.asp?page="&request("page")&"&selectkind="&request("selectkind")&"&myword="&request("myword")&"&no=';" & "</script>"

%>










