<%server.ScriptTimeout = "1000000"%>
<% dim id dim sql If Len(Request.Querystring("ID"))>0 AND IsNumeric(Request.Querystring("ID")) Then id = Request.QueryString("ID") else Response.write("Invalid ID") Response.end end if dim pathArray(5) dim fileArray(5) pathArray(0) = "renderings_hi" 'pathArray(1) = "renderings_md" pathArray(2) = "renderings_lo" pathArray(3) = "renderings_th" 'pathArray(4) = "renderings_zip" ' Create the FileUploader Dim Uploader, File Set Uploader = New FileUploader ' This starts the upload process Uploader.Upload() if Uploader.Form("submit") = "Update" then '+++++++ UPDATE +++++++ Dim a,i,key,path, FileName_HI, FileName_LO, FileName_ZIP FileName_HI = "" FileName_LO = "" FileName_ZIP = "" 'Fetch existing path names Set rsDesigns = Server.CreateObject("ADODB.Recordset") rsDesigns.ActiveConnection = MM_AbexDesignsNew_STRING rsDesigns.Source = "SELECT * FROM Table_Renderings WHERE ID = " + id rsDesigns.CursorType = 0 rsDesigns.CursorLocation = 2 rsDesigns.LockType = 1 rsDesigns.Open() fileArray(0) = rsDesigns.Fields.Item("Renderings_HI").Value 'fileArray(1) = rsDesigns.Fields.Item("Renderings_MD").Value fileArray(2) = rsDesigns.Fields.Item("Renderings_LO").Value fileArray(3) = rsDesigns.Fields.Item("Renderings_TH").Value 'fileArray(4) = rsDesigns.Fields.Item("Renderings_ZIP").Value i=0 a=Uploader.Files.Keys For Each File In Uploader.Files.Items key=a(i) path = pathArray(cStr(key)) 'Delete existing file dim fs Set fs=Server.CreateObject("Scripting.FileSystemObject") if fs.FileExists("C:\DOMAINS\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item(path).Value) then fs.DeleteFile("C:\DOMAINS\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item(path).Value) end if ' Save new file File.SaveToDisk "C:\DOMAINS\abex.com\design_database\" & path & "\" if fs.FileExists("C:\DOMAINS\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item("Project").Value & "_hi.jpg") then fs.DeleteFile("C:\DOMAINS\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item("Project").Value & "_hi.jpg") end if fs.MoveFile "C:\DOMAINS\abex.com\design_database\" & path & "\" & File.FileName , "C:\DOMAINS\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item("Project").Value & "_hi.jpg" set filename = fs.GetFile("C:\DOMAINS\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item("Project").Value & "_hi.jpg") fileArray(cStr(key)) = filename.name 'set myImg = Loadpicture("C:\DOMAINS\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item("Project").Value & "_hi.jpg") 'Width = Round(myImg.width / 26.4583) set filename = nothing File.SaveToDisk "C:\DOMAINS\abex.com\design_database\renderings_lo\" 'if Width > 640 then call ResizeImage("C:\DOMAINS\abex.com\design_database\renderings_lo\" & File.FileName, "jpg", 640, "") 'resize 'end if if fs.FileExists("C:\DOMAINS\abex.com\design_database\renderings_lo\" & rsDesigns.Fields.Item("Project").Value & "_lo.jpg") then fs.DeleteFile("C:\DOMAINS\abex.com\design_database\renderings_lo\" & rsDesigns.Fields.Item("Project").Value & "_lo.jpg") end if fs.MoveFile "C:\DOMAINS\abex.com\design_database\renderings_lo\" & File.FileName , "C:\DOMAINS\abex.com\design_database\renderings_lo\" & rsDesigns.Fields.Item("Project").Value & "_lo.jpg" set filename = fs.GetFile("C:\DOMAINS\abex.com\design_database\renderings_lo\" & rsDesigns.Fields.Item("Project").Value & "_lo.jpg") fileArray(2) = filename.name set filename = nothing File.SaveToDisk "C:\DOMAINS\abex.com\design_database\renderings_th\" call ResizeImage("C:\DOMAINS\abex.com\design_database\renderings_th\" & File.FileName, "jpg", 176, "") 'resize if fs.FileExists("C:\DOMAINS\abex.com\design_database\renderings_th\" & rsDesigns.Fields.Item("Project").Value & "_th.jpg") then fs.DeleteFile("C:\DOMAINS\abex.com\design_database\renderings_th\" & rsDesigns.Fields.Item("Project").Value & "_th.jpg") end if fs.MoveFile "C:\DOMAINS\abex.com\design_database\renderings_th\" & File.FileName , "C:\DOMAINS\abex.com\design_database\renderings_th\" & rsDesigns.Fields.Item("Project").Value & "_th.jpg" set filename = fs.GetFile("C:\DOMAINS\abex.com\design_database\renderings_th\" & rsDesigns.Fields.Item("Project").Value & "_th.jpg") fileArray(3) = filename.name set filename = nothing 'fileArray(cStr(key)) = File.FileName set fs=nothing i = i + 1 Next if (Not IsNull(fileArray(0))) Then FileName_HI = fileArray(0) End If if (Not IsNull(fileArray(2))) Then FileName_LO = fileArray(2) End If if (Not IsNull(fileArray(3))) Then FileName_TH = fileArray(3) End If Set rsDesigns = Server.CreateObject("ADODB.Recordset") rsDesigns.ActiveConnection = MM_AbexDesignsNew_STRING '========== added 01/27/2010-DWN: Dim sSort sSort = Uploader.Form("Project") '========== sql = "UPDATE Table_Renderings SET " sql = sql + "Project = '" + Uploader.Form("Project") + "', " '========== added 01/27/2010-DWN: sql = sql + "Project_Sort = '" + MakeSort(sSort) + "', " '========== sql = sql + "Web_Product = '" + Uploader.Form("Web_Product") + "'," sql = sql + "Web_Budget = '" + Uploader.Form("Web_Budget") + "', " sql = sql + "Price = '" + Uploader.Form("Price") + "', " sql = sql + "Client = '" + Uploader.Form("Client") + "', " sql = sql + "Web_Configuration = '" + Uploader.Form("Web_Configuration") + "', " sql = sql + "Web_Options = '" + Uploader.Form("Web_Options") + "', " sql = sql + "Renderings = '" + Uploader.Form("Renderings") + "', " '========== added 03/09/2010-DWN: if FileName_HI <> "" Then sql = sql + "Renderings_HI = '" + FileName_HI + "', " sql = sql + "Renderings_LO = '" + FileName_LO + "', " sql = sql + "Renderings_TH = '" + FileName_TH + "', " 'sql = sql + "Renderings_MD = '" + fileArray(1) + "', " '========== added 03/09/2010-DWN: 'if FileName_LO <> "" Then sql = sql + "Renderings_LO = '" + FileName_LO + "', " '========== added 03/09/2010-DWN: 'if FileName_TH <> "" Then sql = sql + "Renderings_TH = '" + FileName_TH + "', " '========== 'sql = sql + "Renderings_ZIP = '" + fileArray(4) + "', " sql = sql + "Size = '" + Uploader.Form("Size") + "', " sql = sql + "Web_Size = '" + Uploader.Form("Web_Size") + "', " sql = sql + "Industry = '" + Uploader.Form("Industry") + "', " sql = sql + "ryn = '" + Uploader.Form("ryn") + "' " sql = sql + "WHERE ID = " + id 'Response.write ("
" + sql) rsDesigns.Source = sql rsDesigns.CursorType = 0 rsDesigns.CursorLocation = 2 rsDesigns.LockType = 1 rsDesigns.Open() '========== added 03/09/2010-DWN: ' Verify that files were indeed uploaded successfully: dim f,b, p b = true p = "C:\DOMAINS\abex.com\design_database\" if FileName_HI <> "" then Set f=Server.CreateObject("Scripting.FileSystemObject") if not f.FileExists(p & "renderings_hi\" & FileName_HI) then b = false Response.write "High rendering not uploaded correctly" end if set f = nothing end if if FileName_LO <> "" then Set f=Server.CreateObject("Scripting.FileSystemObject") if not f.FileExists(p & "renderings_lo\" & FileName_lo) then b = false Response.write "Low rendering not uploaded correctly" end if set f = nothing end if if FileName_TH <> "" then Set f=Server.CreateObject("Scripting.FileSystemObject") if not f.FileExists(p & "renderings_th\" & FileName_TH) then b = false Response.write "Thumbnail not uploaded correctly" end if set f = nothing end if if b then Response.write "Record Updated Successfully" else Response.write "Errors exist in uploading files" Response.write "Please re-try" end if Response.end elseif Uploader.Form("submit") = "Delete" then '+++++++ DELETE +++++++ Set rsDesigns = Server.CreateObject("ADODB.Recordset") rsDesigns.ActiveConnection = MM_AbexDesignsNew_STRING rsDesigns.Source = "DELETE FROM Table_Renderings WHERE ID = " + id rsDesigns.CursorType = 0 rsDesigns.CursorLocation = 2 rsDesigns.LockType = 1 rsDesigns.Open() Response.write "Record Deleted Successfully" Response.end end if %> <% Set rsDesigns = Server.CreateObject("ADODB.Recordset") rsDesigns.ActiveConnection = MM_AbexDesignsNew_STRING rsDesigns.Source = "SELECT * FROM Table_Renderings WHERE ID = " + id rsDesigns.CursorType = 0 rsDesigns.CursorLocation = 2 rsDesigns.LockType = 1 rsDesigns.Open() %> <% '========== added 01/27/2010-DWN: function MakeSort(sSrt) Dim s, s1, s2, s3 Dim i1, i2 s = sSrt s1 = "" s2 = "" s3 = "" If Len(s) > 0 Then ' get first part i1 = InStr(s, "-") If i1 = 0 Then i1 = Len(s) + 1 s1 = Left(s, i1 - 1) s = Mid(s, i1 + 1, Len(s)) End If If Len(s) > 0 Then ' get second part i1 = InStr(s, "-") If i1 = 0 Then i1 = Len(s) + 1 s2 = Left(s, i1 - 1) s = Mid(s, i1 + 1, Len(s)) End If If Len(s) > 0 Then ' get third part i1 = InStr(s, "-") If i1 = 0 Then i1 = Len(s) s3 = Left(s, i1) End If ' format our string here s = right("00000000" & trim(s1), 8) ' s = FormatNumber(CLng(s1), "00000000") If Len(s2) > 0 Then s = s & Right("0000" & s2, 4) Else s = s & "0000" If Len(s3) > 0 Then s = s & Right("0000" & s3, 4) Else s = s & "0000" MakeSort = s End Function '========== %>
<%=id%>
">
">
">
">
<%=(rsDesigns.Fields.Item("Renderings_HI").Value)%>
">
">
">
<% Function ResizeImage(FileName, OutFormat, Width, Height) 'Dim Chs, chConstants 'Create an OWC chart object 'Set Chs = CreateObject("OWC10.ChartSpace") 'Set chConstants = Chs.Constants 'Set background of the chart 'Chs.Interior.SetTextured FileName, chConstants.chStretchPlot, , chConstants.chAllFaces 'Chs.border.color = -3 'Do something with border 'Chs.border.color = &H0000FF 'Chs.border.Weight = 3 'export the picture to a file 'Chs.ExportPicture OutFileName, OutFormat, Width, Height 'or return it as a binary data for BinaryWrite 'ResizeImage = Chs.GetPicture(OutFormat, Width, Height) FileName = FileName OutFormat = OutFormat OutFileName = FileName NewWidth = Width NewHeight = 0 '*** Auto Resize *** Set objFso = CreateObject("Scripting.FileSystemObject") IF objFso.FileExists(FileName) Then set myImg = Loadpicture(FileName) Width = Round(myImg.width / 26.4583) if (Width < 640 and NewWidth = 640) then exit function Height = Round(myImg.height / 26.4583) NewHeight = Round((NewWidth*Height)/Width) End If Set Chs = Server.CreateObject("OWC10.ChartSpace") Set objConst = Chs.Constants Chs.Interior.SetTextured FileName, objConst.chStretchPlot, , objConst.chAllFaces Chs.border.color = -3 Chs.ExportPicture OutFileName,OutFormat,NewWidth,NewHeight Set objConst = Nothing Set Chs = Nothing End Function %>