%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
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
%>
<%
If Session("design-desk-shop-DAT_status") <> "login" Then
Response.Redirect "login.asp"
Else
' Restore Security Table - created in Login
arrSecurity = Session("ewSecurity")
' Get Current Table Security
sTmp1 = -1
For sTmp = 1 to UBound(arrSecurity, 2)
If arrSecurity(0, sTmp) = "accessories" Then
sTmp1 = sTmp
Exit For
End If
Next
ewCurLvl = Session("design-desk-shop-DAT_status_UserLevel")
If IsNumeric(ewCurLvl) And sTmp1 <> -1 Then
If ewCurLvl = -1 Then ' System Administrator
ewCurSec = 31
ElseIf ewCurLvl > 0 and ewCurLvl <= 1 Then
ewCurSec = arrSecurity(ewCurLvl, sTmp1)
End If
End If
If (ewCurSec And ewAllowedit) <> ewAllowedit Then Response.Redirect "accessorieslist.asp"
End If
%>
<%
' Initialize common variables
x_Part_No = Null
x_Sale = Null
x_Image = Null
x_Special = Null
x_SpecialPrice = Null
x_Description = Null
x_RedMessage = Null
x_Upsell1_Name = Null
x_Upsell1_PartNo = Null
x_Upsell2_Name = Null
x_Upsell2_PartNo = Null
x_Upsell3_Name = Null
x_Upsell3_PartNo = Null
x_Category = Null
x_Product_Name = Null
x_Preferred_Supplier = Null
x_Image_Prefix = Null
x_ImageSuffix = Null
x_Weight = Null
x_WeightPrice = Null
x_VAT = Null
x_Percentage = Null
x_Retail_Price = Null
x_Retail_Inc = Null
x_CartPrefix = Null
x_CartHyphen = Null
x_CartCode1 = Null
x_CartSuffix = Null
x_Upsell_Prefix = Null
x_Upsell_Suffix1 = Null
x_Cost_Price = Null
%>
<%
Response.Buffer = True
sKey = Request.Querystring("key")
If sKey = "" Or IsNull(sKey) Then sKey = Request.Form("key")
' Get action
sAction = Request.Form("a_edit")
If sAction = "" Or IsNull(sAction) Then
sAction = "I" ' Display with input box
Else
' Get fields from form
x_Part_No = Request.Form("x_Part_No")
x_Sale = Request.Form("x_Sale")
x_Image = Request.Form("x_Image")
x_Special = Request.Form("x_Special")
x_SpecialPrice = Request.Form("x_SpecialPrice")
x_Description = Request.Form("x_Description")
x_RedMessage = Request.Form("x_RedMessage")
x_Upsell1_Name = Request.Form("x_Upsell1_Name")
x_Upsell1_PartNo = Request.Form("x_Upsell1_PartNo")
x_Upsell2_Name = Request.Form("x_Upsell2_Name")
x_Upsell2_PartNo = Request.Form("x_Upsell2_PartNo")
x_Upsell3_Name = Request.Form("x_Upsell3_Name")
x_Upsell3_PartNo = Request.Form("x_Upsell3_PartNo")
x_Category = Request.Form("x_Category")
x_Product_Name = Request.Form("x_Product_Name")
x_Preferred_Supplier = Request.Form("x_Preferred_Supplier")
x_Image_Prefix = Request.Form("x_Image_Prefix")
x_ImageSuffix = Request.Form("x_ImageSuffix")
x_Weight = Request.Form("x_Weight")
x_WeightPrice = Request.Form("x_WeightPrice")
x_VAT = Request.Form("x_VAT")
x_Percentage = Request.Form("x_Percentage")
x_Retail_Price = Request.Form("x_Retail_Price")
x_Retail_Inc = Request.Form("x_Retail_Inc")
x_CartPrefix = Request.Form("x_CartPrefix")
x_CartHyphen = Request.Form("x_CartHyphen")
x_CartCode1 = Request.Form("x_CartCode1")
x_CartSuffix = Request.Form("x_CartSuffix")
x_Upsell_Prefix = Request.Form("x_Upsell_Prefix")
x_Upsell_Suffix1 = Request.Form("x_Upsell_Suffix1")
x_Cost_Price = Request.Form("x_Cost_Price")
End If
If sKey = "" Or IsNull(sKey) Then Response.Redirect "accessorieslist.asp"
' Open connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case sAction
Case "I": ' Get a record to display
If Not LoadData(sKey) Then ' Load Record based on key
Session("ewmsg") = "No Record Found for Key = " & sKey
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "accessorieslist.asp"
End If
Case "U": ' Update
If EditData(sKey) Then ' Update Record based on key
Session("ewmsg") = "Update Record Successful for Key = " & sKey
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "accessorieslist.asp"
End If
End Select
%>
Edit TABLE: Accessories
Back to List
<%
conn.Close ' Close Connection
Set conn = Nothing
%>
<%
'-------------------------------------------------------------------------------
' Function LoadData
' - Load Data based on Key Value sKey
' - Variables setup: field variables
Function LoadData(sKey)
Dim sKeyWrk, sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
sKeyWrk = "'" & AdjustSql(sKey) & "'"
sSql = "SELECT * FROM [accessories]"
sSql = sSql & " WHERE [Part_No] = " & sKeyWrk
sGroupBy = ""
sHaving = ""
sOrderBy = ""
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_Part_No = rs("Part_No")
x_Sale = rs("Sale")
x_Image = rs("Image")
x_Special = rs("Special")
x_SpecialPrice = rs("SpecialPrice")
x_Description = rs("Description")
x_RedMessage = rs("RedMessage")
x_Upsell1_Name = rs("Upsell1_Name")
x_Upsell1_PartNo = rs("Upsell1_PartNo")
x_Upsell2_Name = rs("Upsell2_Name")
x_Upsell2_PartNo = rs("Upsell2_PartNo")
x_Upsell3_Name = rs("Upsell3_Name")
x_Upsell3_PartNo = rs("Upsell3_PartNo")
x_Category = rs("Category")
x_Product_Name = rs("Product Name")
x_Preferred_Supplier = rs("Preferred Supplier")
x_Image_Prefix = rs("Image_Prefix")
x_ImageSuffix = rs("ImageSuffix")
x_Weight = rs("Weight")
x_WeightPrice = rs("WeightPrice")
x_VAT = rs("VAT")
x_Percentage = rs("Percentage")
x_Retail_Price = rs("Retail Price")
x_Retail_Inc = rs("Retail Inc")
x_CartPrefix = rs("CartPrefix")
x_CartHyphen = rs("CartHyphen")
x_CartCode1 = rs("CartCode1")
x_CartSuffix = rs("CartSuffix")
x_Upsell_Prefix = rs("Upsell_Prefix")
x_Upsell_Suffix1 = rs("Upsell_Suffix1")
x_Cost_Price = rs("Cost Price")
End If
rs.Close
Set rs = Nothing
End Function
%>
<%
'-------------------------------------------------------------------------------
' Function EditData
' - Edit Data based on Key Value sKey
' - Variables used: field variables
Function EditData(sKey)
Dim sKeyWrk, sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
' Open record
sKeyWrk = "'" & AdjustSql(sKey) & "'"
sSql = "SELECT * FROM [accessories]"
sSql = sSql & " WHERE [Part_No] = " & sKeyWrk
sGroupBy = ""
sHaving = ""
sOrderBy = ""
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
If rs.Eof Then
EditData = False ' Update Failed
Else
' Field Part_No
sTmp = Trim(x_Part_No)
If Trim(sTmp) = "" Then sTmp = Null
rs("Part_No") = sTmp
' Field Sale
sTmp = x_Sale
If sTmp <> "" Then
rs("Sale") = True
Else
rs("Sale") = False
End If
' Field Image
sTmp = Trim(x_Image)
If Trim(sTmp) = "" Then sTmp = Null
rs("Image") = sTmp
' Field Special
sTmp = x_Special
If sTmp <> "" Then
rs("Special") = True
Else
rs("Special") = False
End If
' Field SpecialPrice
sTmp = Trim(x_SpecialPrice)
If Trim(sTmp) = "" Then sTmp = Null
rs("SpecialPrice") = sTmp
' Field Description
sTmp = Trim(x_Description)
If Trim(sTmp) = "" Then sTmp = Null
rs("Description") = sTmp
' Field RedMessage
sTmp = Trim(x_RedMessage)
If Trim(sTmp) = "" Then sTmp = Null
rs("RedMessage") = sTmp
' Field Upsell1_Name
sTmp = Trim(x_Upsell1_Name)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell1_Name") = sTmp
' Field Upsell1_PartNo
sTmp = Trim(x_Upsell1_PartNo)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell1_PartNo") = sTmp
' Field Upsell2_Name
sTmp = Trim(x_Upsell2_Name)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell2_Name") = sTmp
' Field Upsell2_PartNo
sTmp = Trim(x_Upsell2_PartNo)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell2_PartNo") = sTmp
' Field Upsell3_Name
sTmp = Trim(x_Upsell3_Name)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell3_Name") = sTmp
' Field Upsell3_PartNo
sTmp = Trim(x_Upsell3_PartNo)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell3_PartNo") = sTmp
' Field Category
sTmp = Trim(x_Category)
If Trim(sTmp) = "" Then sTmp = Null
rs("Category") = sTmp
' Field Product Name
sTmp = Trim(x_Product_Name)
If Trim(sTmp) = "" Then sTmp = Null
rs("Product Name") = sTmp
' Field Preferred Supplier
sTmp = Trim(x_Preferred_Supplier)
If Trim(sTmp) = "" Then sTmp = Null
rs("Preferred Supplier") = sTmp
' Field Image_Prefix
sTmp = Trim(x_Image_Prefix)
If Trim(sTmp) = "" Then sTmp = Null
rs("Image_Prefix") = sTmp
' Field ImageSuffix
sTmp = Trim(x_ImageSuffix)
If Trim(sTmp) = "" Then sTmp = Null
rs("ImageSuffix") = sTmp
' Field Weight
sTmp = Trim(x_Weight)
If Trim(sTmp) = "" Then sTmp = Null
rs("Weight") = sTmp
' Field WeightPrice
sTmp = x_WeightPrice
If Not IsNumeric(sTmp) Then
sTmp = Null
Else
sTmp = cDbl(sTmp)
End If
rs("WeightPrice") = sTmp
' Field VAT
sTmp = Trim(x_VAT)
If Trim(sTmp) = "" Then sTmp = Null
rs("VAT") = sTmp
' Field Percentage
sTmp = Trim(x_Percentage)
If Trim(sTmp) = "" Then sTmp = Null
rs("Percentage") = sTmp
' Field Retail Price
sTmp = Trim(x_Retail_Price)
If Trim(sTmp) = "" Then sTmp = Null
'rs("Retail Price") = sTmp
' Field Retail Inc
sTmp = Trim(x_Retail_Inc)
If Trim(sTmp) = "" Then sTmp = Null
' rs("Retail Inc") = sTmp
'NEW**************
retail_price=c_retail_price(x_Cost_Price,x_Percentage,x_Weight,x_WeightPrice)
xxretail_inc=cretail_inc(retail_price,x_VAT)
rs("Retail Price") =retail_price
rs("Retail Inc")=xxretail_inc
'**END
' Field CartPrefix
sTmp = Trim(x_CartPrefix)
If Trim(sTmp) = "" Then sTmp = Null
rs("CartPrefix") = sTmp
' Field CartHyphen
sTmp = Trim(x_CartHyphen)
If Trim(sTmp) = "" Then sTmp = Null
rs("CartHyphen") = sTmp
' Field CartCode1
sTmp = Trim(x_CartCode1)
If Trim(sTmp) = "" Then sTmp = Null
rs("CartCode1") = sTmp
' Field CartSuffix
sTmp = Trim(x_CartSuffix)
If Trim(sTmp) = "" Then sTmp = Null
rs("CartSuffix") = sTmp
' Field Upsell_Prefix
sTmp = Trim(x_Upsell_Prefix)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell_Prefix") = sTmp
' Field Upsell_Suffix1
sTmp = Trim(x_Upsell_Suffix1)
If Trim(sTmp) = "" Then sTmp = Null
rs("Upsell_Suffix1") = sTmp
' Field Cost Price
sTmp = x_Cost_Price
If Not IsNumeric(sTmp) Then
sTmp = Null
Else
sTmp = cDbl(sTmp)
End If
rs("Cost Price") = sTmp
rs.Update
EditData = True ' Update Successful
End If
rs.Close
Set rs = Nothing
End Function
%>