<%
Act = Request.QueryString("act")
ProductName=TextEnCode(Request.Form("ProductName"))
ProductImg=TextEnCode(Request.Form("ProductImg"))
unit=TextEnCode(Request.Form("unit"))
moq=TextEnCode(Request.Form("moq"))
nosale=Request.Form("nosale")
num=Request.Form("num")
price=Request.Form("price")
note=TextEnCode(Request.Form("note"))
tips=TextEnCode(Request.Form("tips"))
If act = "save" Then
Set Rs = Server.CreateObject("ADODB.RecordSet")
isedit = False
id = Request.Form("id")
If id<>"" And IsNumeric(id) Then isedit = True
If isedit Then
Rs.Open "Select * From Products Where id="&id,Conn,1,3
Rs("ProductName") = ProductName
Rs("ProductImg") = ProductImg
Rs("Addtime")=now()
Rs("moq")=moq
Rs("unit")=unit
Rs("nosale")=nosale
Rs("note")=note
Rs("tips")=tips
Rs.Update:Rs.Close
Set Rs=Nothing
numarr=split(num,",")
pricearr=split(price,",")
Conn.execute("delete from price where productId="&id&" and AreaId=0")
For i=0 to ubound(numarr)
If numarr(i)="" then numarr(i)=0
If pricearr(i)="" then pricearr(i)=0
Conn.execute("insert into price (productId,AreaId,num,price) values("&id&",0,"&numarr(i)&",'"&pricearr(i)&"')")
Next
Conn.close
Set Conn=Nothing
Page = Request.QueryString("Page")
Keys=Server.UrlEnCode(Request.QueryString("Keys"))
Response.Redirect "?keys="&Keys&"&Page="&Page&urlStr
Set Rs=Nothing:Conn.Close:Set Conn=Nothing
Else
Rs.Open "Products",Conn,1,3
Rs.Addnew()
Rs("ProductName") = ProductName
Rs("ProductImg") = ProductImg
Rs("Addtime")=now()
Rs("unit")=unit
Rs("moq")=moq
Rs("nosale")=nosale
Rs("note")=note
Rs("tips")=tips
Rs.Update:Rs.Close
Rs.open "select top 1 id from Products order by id desc",Conn,1,3
id=Rs("id")
Rs.close
numarr=split(num,",")
pricearr=split(price,",")
For i=0 to ubound(numarr)
If numarr(i)="" then numarr(i)=0
If pricearr(i)="" then pricearr(i)=0
Conn.execute("insert into price (productId,AreaId,num,price) values("&id&",0,"&numarr(i)&",'"&pricearr(i)&"')")
Next
Set Rs=Nothing
Conn.close
Set Conn=Nothing
Page = Request.QueryString("Page")
Keys=Server.UrlEnCode(Request.QueryString("Keys"))
Response.Redirect "?keys="&Keys&"&Page="&Page&urlStr
Set Rs=Nothing:Conn.Close:Set Conn=Nothing
End If
Conn.Close:Set Conn=Nothing
Response.End
End If 'end save
If Act = "add" or Act = "edit" Then
id = Request.QueryString("id")
isedit = False
If id<>"" And IsNumeric(id) Then isedit=True
If isedit Then
Set Rs = Server.CreateObject("ADODB.RecordSet")
Rs.Open "Select ProductName,ProductImg,unit,moq,nosale,note,tips from Products Where id="&id,Conn,1,1
If Not Rs.Bof And Not Rs.Eof Then
ProductName=TextUnCode(Rs("ProductName"))
ProductImg=TextUnCode(Rs("ProductImg"))
unit=Rs("unit")
moq=TextUnCode(Rs("moq"))
nosale=Rs("nosale")
note=TextUnCode(Rs("note"))
tips=TextUnCode(Rs("tips"))
Else
isedit = False
End If
Rs.Close:Set Rs=Nothing
End If
Page = Request.QueryString("Page")
Keys=Server.UrlEnCode(Request.QueryString("Keys"))
hrefstr = "?keys="&Keys&"&Page="&Page
%>
<%
Set Rs=Nothing
conn.close
Set conn=Nothing
Response.End
End If 'End Edit
If Act="postchk" Then
Keys = Server.UrlEnCode(Request.QueryString("Keys"))
Page = Request.QueryString("Page")
chkact = Request.Form("chkact")
SqlStr = ""
For i = 1 To Request.Form("chkbox").Count
If SqlStr<>"" Then
SqlStr = SqlStr & " Or id="&Request.Form("chkbox")(i)
Else
SqlStr = " Where id="&Request.Form("chkbox")(i)
End If
Next
Select Case chkact
Case "0":SqlStr = "Update customer Set cs_state="&chkact&SqlStr
Case "1":SqlStr = "Update customer Set cs_state="&chkact&SqlStr
Case Else:SqlStr = "Delete From products"&SqlStr
End Select
Conn.Execute(SqlStr):Conn.Close:Set Conn=Nothing
Response.Redirect "?Keys="&Keys&"&Page="&Page
Response.End
End If 'End postchk
Keyscode=TextEnCode(Request.QueryString("Keys"))
Page = Request.QueryString("Page")
sqlStr="Select id,ProductName,ProductImg from Products order by id Desc"
Set Rs=Server.CreateObject("ADODB.RecordSet")
Keys=Server.UrlEnCode(Request.QueryString("Keys"))
hrefstr = "?keys="&Keys&urlStr
Set Rs1=Server.CreateObject("ADODB.RecordSet")
%>