%
ID = request("id")
set Conn = Server.Createobject("adodb.connection")
Conn.open application("homeconn")
set RS = Server.CreateObject("adodb.recordset")
set RS1 = Server.CreateObject("adodb.recordset")
set RS_fitment = server.createobject("adodb.recordset")
savetype=request("save")
delxuhao=request("delxuhao")
addxuhao=request("addxuhao")
if delxuhao="" then delxuhao=9999
if addxuhao="" then addxuhao=9999
if id="" then id=1
if id<0 then
sqldel="delete from home_budget where fitmentid="&id&""
conn.execute(sqldel)
allrows=request.form("num")
for i=0 to allrows-1
Project=request.form("Project"&i)
Material=request.form("Material"&i)
description=request.form("description"&i)
unit=request.form("unit"&i)
qty=request.form("qty"&i)
if qty="" then qty="0"
price=request.form("price"&i)
if price="" then price="0.00"
sqlinsert="insert into home_budget(material,proj,unit,description,price,number,fitmentid) values('"&material&"','"&project&"','"&unit&"','"&description&"',"&price&","&qty&","&id&")"
if i<>cint(delxuhao) then
if i=cint(addxuhao) then
conn.execute("insert into home_budget(material,proj,unit,description,price,number,fitmentid) values('','','','',0,0,"&id&")")
end if
conn.execute(sqlinsert)
end if
next
end if
if savetype="追加" then
sqlinsert="insert into home_budget(material,proj,unit,description,price,number,fitmentid) values('','','','',0,0,"&id&")"
conn.execute(sqlinsert)
end if
SQL = "SELECT COUNT(*) num FROM home_Budget where FitmentID = "&ID&""
SQL1 = "SELECT * FROM home_Budget where FitmentID = "&ID&" order by id"
SQL_fitment = "select * from home_fitment where FitmentID = "&abs(ID)&""
RS.open SQL,Conn,3,1
RS1.open SQL1,Conn,3,1
RS_fitment.open SQL_fitment,conn,3,1
%>
<%
rs.close
set rs=nothing
rs1.close
set rs1=nothing
RS_fitment.close
set RS_fitment=nothing
if id<0 then
sqldel="delete from home_budget where fitmentid="&id&""
conn.execute(sqldel)
end if
conn.close
set conn=nothing
%>