<% On Error Resume Next Response.Expires = 0 Dim objConn, objRS, strQuery Dim strConnection Dim tID, tTitle, tIntroduction, tContent, tLinkF, tLinkT, tLinkP, tLinkI, tDocumentName Dim count, tDID, tIID Dim fs, tOName, tNName if Session("Admin") = "" then Response.Write "
" Response.Write "
You are not authorized to view this page.
" Response.Write "
" Response.Write "
" else Set Uploader = New FileUploader Uploader.Upload() Set objConn = Server.CreateObject("ADODB.Connection") strConnection = "DSN=pdsb;Database=BlogDB.mdb;" objConn.Open strConnection Set fs = Server.CreateObject("Scripting.FileSystemObject") tID = Uploader.Form("ID") tTitle = Uploader.Form("title") tIntroduction = Uploader.Form("introduction") tContent = Uploader.Form("content") tLinkF = Uploader.Form("linkF") tLinkT = Uploader.Form("linkT") tLinkP = Uploader.Form("linkP") tLinkI = Uploader.Form("linkI") %>
Hello <%= Session("Admin") %>!

Back to Home |  | Logout

<% if Uploader.Form("B1") <> "" then If tTitle = "" then Response.Write "
You have not input all the required fields. Please click on the Back button to try again.
" Response.Write "
" Response.Write "
" else if InStr(tTitle,"'") > 0 then tTitle = Replace(tTitle,"'","''") end if if InStr(tIntroduction,"'") > 0 then tIntroduction = Replace(tIntroduction,"'","''") end if if InStr(tContent,"'") > 0 then tContent = Replace(tContent,"'","''") end if strQuery = "UPDATE Product SET Title = '" & tTitle & "', Introduction = '" & tIntroduction & "', Content = '" & tContent & "', LinkF = '" & tLinkF & "', LinkT = '" & tLinkT & "', LinkP = '" & tLinkP & "', LinkI = '" & tLinkI & "' WHERE ID = " & tID objConn.Execute(strQuery) For Each File In Uploader.Files.Items tFileName = File.FileName DCheckQuery = "SELECT ID FROM Product WHERE Document = '" & tFileName & "'" set DobjCheck = objConn.execute(DCheckQuery) if not DobjCheck.EOF then count = 0 tDID = DobjCheck("ID") Do While not DobjCheck.EOF count = count + 1 DCheckQuery = "SELECT ID FROM Product WHERE Document = '" & count & tFileName & "'" set DobjCheck = objConn.execute(DCheckQuery) Loop tOName = Server.MapPath("/bDocument") & "\" & tFileName tNName = Server.MapPath("/bDocument") & "\" & count & tFileName fs.MoveFile tOName, tNName NstrQuery = "UPDATE Product SET Document = '" & count & tFileName & "' WHERE ID = " & tDID objConn.execute(NstrQuery) end if Path = Server.MapPath("/bDocument") File.SaveToDisk (Path) PstrQuery = "UPDATE Product SET Document = '" & tFileName & "' WHERE ID = " & tID objConn.Execute(PstrQuery) DobjCheck.close Set DobjCheck = Nothing Next Response.Write "
The blog has been updated.
" end if else RstrQuery = "SELECT * FROM ProductPhoto WHERE ProductID = " & tID set RobjRS = objConn.Execute(RstrQuery) Do While not RobjRS.EOF if fs.FileExists(Server.MapPath("/bPhoto") & "/" & RobjRS("Photo")) then fs.DeleteFile(Server.MapPath("/bPhoto") & "/" & RobjRS("Photo")) end if RobjRS.MoveNext Loop strQuery = "DELETE * FROM ProductPhoto WHERE ProductID = " & tID objConn.Execute(strQuery) strQuery = "DELETE * FROM ProductCategory WHERE ProductID = " & tID objConn.Execute(strQuery) strQuery = "DELETE * FROM Product WHERE ID = " & tID objConn.Execute(strQuery) Response.Write "
The blog has been deleted.
" end if objConn.close Set objRS = Nothing Set objConn = Nothing end if %>