csierra
Posts: 123
|
Posted: 04/05/2008, 7:28 PM |
|
It is a matter of abstraction (taking one problem, then split into small bits); this is fare simple to achieve:
1. Make a customers grid
2. Make a search (search bulder) to output to that grid
3. On the customers grid, make the cust_id a link, to follow to the Customer_Detail page
4. Make multiple customer_detail pages (eg. cust orders, cust payments, cust deliveries, etc) based on one simple includable; the cust_cell
You make an includable header, right? well then make a cust:_cell (a record non editable, all labels) and make several pages made upon this one
On this several pages, you handle those small bits; eg. make a grid based o a query such as SELECT * FROM tb Cust_Orders WHERE CUst_Id=URL param(Cust Id) and you are done.
For the matter of files (xls, pdf's and so) make a table in your database called tbDocuments; with such fields like Cust_Id, FilePath, etc; then you make a grid and a form (with a fileupload component allowing your users to upload any documents related)
For downloading a document is very simple; you can use as follows:
Make a non ccs asp file (txt file change ext to asp) and put on it:
Class cFileHelper
Function KillDocumentFile(Document_Id)
Dim oFSO
Dim sSourceFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set db_club = New clsdb_club
db_club.Open
oSet.Open "SELECT * FROM tbDocuments WHERE Document_Id = " & Document_Id, db_club.Connection.ConnectionString
If oSet.EOF And oSet.BOF Then
oSet.Close
db_club.Close
Exit Function
End If
sSourceFile = "D:\Domains\holidayexpress.com.mx\wwwroot\extranet\repository\docbin\" & oSet.Fields("Document_Path").Value
' Check if file exists to prevent error
If oFSO.FileExists(sSourceFile) Then
oFSO.DeleteFile sSourceFile
End If
' Clean Up
Set oFSO = Nothing
End Function
Sub DownloadFile(file)
'--declare variables
Dim strAbsFile
Dim strFileExtension
Dim objFile
Dim objStream
Dim objFSO
'-- set absolute file location
strAbsFile = file
Response.Write file
'-- create FSO object to check if file exists and get properties
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'-- check to see if the file exists
If objFSO.FileExists(strAbsFile) Then
Set objFile = objFSO.GetFile(strAbsFile)
'-- first clear the response, and then set the appropriate headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name '& "'"
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(strAbsFile)
'-- send the stream in the response
'Response.Flush
Response.BinaryWrite(objStream.Read)
Response.Flush
objStream.Close
Set objStream = Nothing
Set objFile = Nothing
Else 'objFSO.FileExists(strAbsFile)
Response.Clear
Response.Write("El archivo no existe.")
End If
Set objFSO = Nothing
End Sub
End Class
When using this functions, just include this file you made, and instantiate the class, as follows:
Dim oFHelper
Set oFHelper = New cFileHelper
Call oFHelper.DownloadFile(CCGetParam("Document_Id",0)
Just the same for erasing a document from server document bin (a folder you make with read write permissions)
Hope this helps
cHUCk
_________________
Yes! I Can!!! |