|
<%
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("G:\Inetpub\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item(path).Value) then
fs.DeleteFile("G:\Inetpub\abex.com\design_database\" & path & "\" & rsDesigns.Fields.Item(path).Value)
end if
set fs=nothing
' Save new file
File.SaveToDisk "G:\Inetpub\abex.com\design_database\" & path & "\"
fileArray(cStr(key)) = File.FileName
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_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 = "G:\Inetpub\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 '========== %> |