%@ LCID = 3082 %>
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.addHeader "cache-control", "no-cache"
Response.addHeader "cache-control", "no-store"
Response.CacheControl = "no-cache"
%>
<%
ewCurSec = 0 ' Initialise
' User levels
Const ewAllowAdd = 1
Const ewAllowDelete = 2
Const ewAllowEdit = 4
Const ewAllowView = 8
Const ewAllowList = 8
Const ewAllowReport = 8
Const ewAllowSearch = 8
Const ewAllowAdmin = 16
%>
<%
' Initialize common variables
x_idreferencia = Null: ox_idreferencia = Null
x_NOMBRE = Null: ox_NOMBRE = Null
x_FECHA = Null: ox_FECHA = Null
x_EMAIL = Null: ox_EMAIL = Null
x_SECTOR = Null: ox_SECTOR = Null
x_TELEFONO = Null: ox_TELEFONO = Null
x_TEXTO = Null: ox_TEXTO = Null
x_CATEGORIA = Null: ox_CATEGORIA = Null
x_IMAGEN = Null: ox_IMAGEN = Null
fs_x_IMAGEN = 0
fn_x_IMAGEN = ""
ct_x_IMAGEN = ""
w_x_IMAGEN = 0
h_x_IMAGEN = 0
a_x_IMAGEN = ""
%>
<%
Response.Buffer = True
' Load key from QueryString
bCopy = True
x_idreferencia = Request.QueryString("idreferencia")
If x_idreferencia = "" Or IsNull(x_idreferencia) Then
bCopy = False
End If
sAction = ""
If Not RequestBlobData() Then
If bCopy Then
sAction = "C" ' Copy Record
Else
sAction = "I" ' Display Blank Record
End If
End If
' Open connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case sAction
Case "C": ' Get a record to display
If Not LoadData() Then ' Load Record based on key
Session("ewmsg") = "No se han encontrado registros"
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "LICO.asp"
End If
Case "A": ' Add
If AddData() Then ' Add New Record
Session("ewmsg") = "Nuevo Registro Aņadido Satisfactoriamente"
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "LICO.asp"
Else
End If
End Select
%>
Alquileres entre particulares
Volver al Listado
<%
conn.Close ' Close Connection
Set conn = Nothing
%>
<%
'-------------------------------------------------------------------------------
' Function RequestBlobData
' - Handle mult-part data (for file upload)
' - Variables setup: sAction, field variables, EW_Max_File_Size
Function RequestBlobData()
Dim rawData, separator, lenSeparator, dict
Dim currentPos, inStrByte, tempValue, mValue, value
Dim intDict, begPos, endPos, nValue
Dim nameN, isValid, nameValue, midValue
If Request.TotalBytes > 0 Then
rawData = Request.BinaryRead(Request.TotalBytes)
separator = MidB(rawData, 1, InStrB(1, rawData, ChrB(13)) - 1)
lenSeparator = LenB(separator)
Set dict = Server.CreateObject("Scripting.Dictionary")
currentPos = 1
inStrByte = 1
tempValue = ""
While inStrByte > 0
inStrByte = InStrB(currentPos, rawData, separator)
mValue = inStrByte - currentPos
If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)
Set intDict = Server.CreateObject("Scripting.Dictionary")
begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos
nameN = MidB(value, begPos, endPos - begPos)
isValid = True
If InStrB(1, value, stringToByte("Content-Type")) > 1 Then
begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If
midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", Trim(byteToString(midValue))
begPos = 14 + InStrB(endPos + 1, value, stringToByte("Content-Type:"))
endPos = InStrB(begPos, value, ChrB(13))
midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentType", Trim(byteToString(midValue))
begPos = endPos + 4
endPos = LenB(value)
nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = Trim(byteToString(MidB(value, nValue + 5)))
End If
If isValid = True Then
If dict.Exists(byteToString(nameN)) Then
Set intDict = dict.Item(byteToString(nameN))
If Right(intDict.Item("Value"), 2) = vbCrLf Then
intDict.Item("Value") = Left(intDict.Item("Value"), Len(intDict.Item("Value"))-2)
End If
intDict.Item("Value") = intDict.Item("Value") & ", " & nameValue
Else
intDict.Add "Value", nameValue
intDict.Add "Name", nameN
dict.Add byteToString(nameN), intDict
End If
End If
End If
currentPos = lenSeparator + inStrByte
Wend
' Get action
sAction = getValue(dict, "a_add")
EW_Max_File_Size = getValue(dict, "EW_Max_File_Size")
x_idreferencia = getValue(dict, "x_idreferencia")
x_NOMBRE = getValue(dict, "x_NOMBRE")
x_FECHA = getValue(dict, "x_FECHA")
x_EMAIL = getValue(dict, "x_EMAIL")
x_SECTOR = getValue(dict, "x_SECTOR")
x_TELEFONO = getValue(dict, "x_TELEFONO")
x_TEXTO = getValue(dict, "x_TEXTO")
x_CATEGORIA = getValue(dict, "x_CATEGORIA")
fs_x_IMAGEN = getFileSize(dict, "x_IMAGEN")
' check the file size
If fs_x_IMAGEN > 0 And CLng(EW_Max_File_Size) > 0 Then
If fs_x_IMAGEN > CLng(EW_Max_File_Size) Then
Response.Write "Max. file size (" & EW_Max_File_Size & " bytes) exceeded."
Response.End
End If
End If
fn_x_IMAGEN = getFileName(dict, "x_IMAGEN")
ct_x_IMAGEN = getFileContentType(dict, "x_IMAGEN")
x_IMAGEN = getFileData(dict, "x_IMAGEN")
w_x_IMAGEN = getValue(dict, "w_x_IMAGEN")
h_x_IMAGEN = getValue(dict, "h_x_IMAGEN")
a_x_IMAGEN = getValue(dict, "a_x_IMAGEN")
If IsObject(intDict) Then
intDict.RemoveAll
Set intDict = Nothing
End If
dict.RemoveAll
Set dict = Nothing
RequestBlobData = True
Else
RequestBlobData = False
End If
End Function
%>
<%
'-------------------------------------------------------------------------------
' Function LoadData
' - Load Data based on Key Value
' - Variables setup: field variables
Function LoadData()
Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
sSql = "SELECT * FROM `tablageneral`"
sWhere = ""
sGroupBy = ""
sHaving = ""
sOrderBy = ""
If sWhere <> "" Then sWhere = sWhere & " AND "
sWhere = sWhere & "(`idreferencia` = " & AdjustSql(x_idreferencia) & ")"
sSql = sSql & " WHERE " & sWhere
If sGroupBy <> "" Then
sSql = sSql & " GROUP BY " & sGroupBy
End If
If sHaving <> "" Then
sSql = sSql & " HAVING " & sHaving
End If
If sOrderBy <> "" Then
sSql = sSql & " ORDER BY " & sOrderBy
End If
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sSql, conn
If rs.Eof Then
LoadData = False
Else
LoadData = True
rs.MoveFirst
' Get the field contents
x_idreferencia = rs("idreferencia")
x_NOMBRE = rs("NOMBRE")
x_FECHA = rs("FECHA")
x_EMAIL = rs("EMAIL")
x_SECTOR = rs("SECTOR")
x_TELEFONO = rs("TELEFONO")
x_TEXTO = rs("TEXTO")
x_CATEGORIA = rs("CATEGORIA")
x_IMAGEN = rs("IMAGEN")
End If
rs.Close
Set rs = Nothing
End Function
%>
<%
'-------------------------------------------------------------------------------
' Function AddData
' - Add Data
' - Variables used: field variables
Function AddData()
Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
Dim bCheckKey, sSqlChk, sWhereChk
sSql = "SELECT * FROM `tablageneral`"
sWhere = ""
sGroupBy = ""
sHaving = ""
sOrderBy = ""
' Check for duplicate key
bCheckKey = True
sWhereChk = sWhere
If x_idreferencia = "" Or IsNull(x_idreferencia) Then
bCheckKey = False
Else
If sWhereChk <> "" Then sWhereChk = sWhereChk & " AND "
sWhereChk = sWhereChk & "(`idreferencia` = " & AdjustSql(x_idreferencia) & ")"
End If
If bCheckKey Then
sSqlChk = sSql & " WHERE " & sWhereChk
Set rsChk = conn.Execute(sSqlChk)
If Not rsChk.Eof Then
Session("ewmsg") = ""
rsChk.Close
Set rsChk = Nothing
AddData = False
Exit Function
End If
rsChk.Close
Set rsChk = Nothing
End If
' Add New Record
If sWhere <> "" Then sWhere = sWhere & " AND "
sWhere = sWhere & "(0 = 1)"
sSql = sSql & " WHERE " & sWhere
If sGroupBy <> "" Then
sSql = sSql & " GROUP BY " & sGroupBy
End If
If sHaving <> "" Then
sSql = sSql & " HAVING " & sHaving
End If
If sOrderBy <> "" Then
sSql = sSql & " ORDER BY " & sOrderBy
End If
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Open sSql, conn, 1, 2
rs.AddNew
' Field NOMBRE
sTmp = Trim(x_NOMBRE)
If Trim(sTmp) = "" Then sTmp = Null
rs("NOMBRE") = sTmp
' Field FECHA
sTmp = EW_UnFormatDateTime(x_FECHA,7)
If IsDate(sTmp) Then
rs("FECHA") = CDate(sTmp)
Else
rs("FECHA") = Null
End If
' Field EMAIL
sTmp = Trim(x_EMAIL)
If Trim(sTmp) = "" Then sTmp = Null
rs("EMAIL") = sTmp
' Field SECTOR
sTmp = Trim(x_SECTOR)
If Trim(sTmp) = "" Then sTmp = Null
rs("SECTOR") = sTmp
' Field TELEFONO
sTmp = Trim(x_TELEFONO)
If Trim(sTmp) = "" Then sTmp = Null
rs("TELEFONO") = sTmp
' Field TEXTO
sTmp = Trim(x_TEXTO)
If Trim(sTmp) = "" Then sTmp = Null
rs("TEXTO") = sTmp
' Field CATEGORIA
sTmp = Trim(x_CATEGORIA)
If Trim(sTmp) = "" Then sTmp = Null
rs("CATEGORIA") = sTmp
' Field IMAGEN
sTmp = x_IMAGEN
If Trim(sTmp) = "" Then sTmp = Null
If IsNull(sTmp) Then
rs("IMAGEN") = Null
Else
rs("IMAGEN") = ewUploadFileName(fn_x_IMAGEN)
' Save to File
Set oStream = Server.CreateObject("ADODB.Stream")
oStream.Type = 1 ' 1=adTypeBinary
oStream.open
oStream.Write ConvertToBinary(sTmp)
oStream.SaveToFile ewUploadPath(1) & ewUploadFileName(fn_x_IMAGEN), 2 ' 2=adSaveCreateOverwrite
oStream.close
Set oStream = Nothing
End If
rs.Update
rs.Close
Set rs = Nothing
AddData = True
End Function
%>