xt_data_add_update.asp
来自「用ASP写的电子购物系统」· ASP 代码 · 共 186 行
ASP
186 行
<%@ LANGUAGE = VBScript %>
<!--#INCLUDE FILE="include/manager.asp" -->
<% REM ######################################################################### %>
<% REM %>
<% REM XT_DATA_ADD_UPDATE.ASP %>
<% REM Volcano Coffee %>
<% REM Microsoft Commerce Server v3.00 %>
<% REM %>
<% REM Copyright (c) 1996-98 Microsoft Corporation. All rights reserved. %>
<% REM %>
<% REM ######################################################################### %>
<%
dim errorList
op = Request("op")
if op="" then op="add"
Select Case Request.Form("type")
Case "product"
product_no = checklength(Request("product_no"), 25)
if IsNull(product_no) then
errorList=errorList & "商品编号的长度为1至25个字符。<br>"
end if
dept_id = Request("dept_id")
if IsNull(dept_id) then
errorList=errorList & "请选择商品分类。<br>"
end if
name =checklength(Request("name"),25)
if IsNull(name) then
errorList=errorList & "商品名称的长度为1至25个汉字。<br>"
end if
provider =checklength(Request("provider"),50)
unit =checklength(Request("unit"),2)
short_description = checklength(Request.Form ("short_description"),120)
if isnull(short_description) then
errorList=errorList & "商品简介的长度不能超过120个汉字。<br>"
end if
long_description = Request.Form ("long_description")
hot=Request("hot")
list_price = checknum(request("list_price"), 16)
if IsNull(list_price) then
errorList=errorList & "价格必须为大于或等于0的数值。<br>"
end if
adjusted_price = checknum(Request("adjusted_price"),16)
if IsNull(adjustedt_price) then
errorList=errorList & "特价必须为大于或等于0的数值。<br>"
end if
Case "department"
dept_id = checknum(Request("dept_id"),10)
if IsNull(dept_id) then
errorList=errorList & "分类ID长度为1至10个数字。<br>"
end if
parent_id = Request("parent_id")
if IsNull(parent_id) then
errorList=errorList & "所属分类必须存在。<br>"
end if
name = checklength(Request("name"),25)
if IsNull(name) then
errorList=errorList & "名称长度为1至25个汉字。<br>"
end if
description = Request("description")
if len(description) > 120 then
errorList=errorList & "备注不能超过120个汉字。<br>"
end if
Case "order"
order_id = checknum(Request("order_id"),20)
if IsNull(order_id) then
errorList=errorList & "订单号长度为1至20个数字。<br>"
end if
Case Else
errorList=errorList & "不知到的类型" & Request.Form("type")
End Select
if errorList="" then 'No Error
Select Case Request.Form("type")
Case "department"
cmdTemp.CommandText = "SELECT * FROM product_level WHERE level_id = " & dept_id
Case "product"
cmdTemp.CommandText = "SELECT * FROM product WHERE product_no = '" & Replace(product_no, "'", "''") & "'"
Case "order"
cmdTemp.CommandText = "SELECT * FROM shop_order where order_id = " & order_id
End Select
Set recordSet = Server.CreateObject("ADODB.Recordset")
recordSet.Open cmdTemp, , adOpenKeyset, adLockOptimistic
if (op = "add" and recordSet.RecordCount = 0) or (op = "update" and recordSet.RecordCount = 1) then
if op = "add" then
recordSet.AddNew
end if
Select Case Request.Form("type")
Case "department"
if op = "add" then
recordSet("level_id").Value = dept_id
end if
recordSet("parent_id").Value = parent_id
recordSet("name").Value = name
recordSet("date_changed").Value = Now
recordSet("description").Value = description
Case "product"
if op = "add" then
cmdTemp.CommandText = "select seq_productid.nextval as product_id from dual"
Set rstPfid = Server.CreateObject("ADODB.Recordset")
rstPfid.Open cmdTemp, , adOpenKeyset, adLockOptimistic
pfid=rstPfid("product_id")
Session("product_id")=pfid
rstpfid.Close
recordSet("product_id").Value = pfid
recordSet("intro_date").Value = Now
recordSet("product_no").Value = product_no
else
Session("product_id")=recordSet("product_id")
end if
if hot<>"" then
recordSet("hot").Value="Y"
else
recordSet("hot").Value=""
end if
recordSet("provider").Value = provider
recordSet("unit").Value = unit
recordSet("list_price").Value = list_price
recordSet("adjusted_price").Value = adjusted_price
recordSet("level_id").Value = dept_id
recordSet("name").Value = name
recordSet("short_description").Value = short_description
recordSet("long_description").Value = long_description
recordSet("date_changed").Value = Now
Case "order"
recordSet("status").Value=Request("status")
End Select
recordSet.Update
If Request("goto")<>"" Then
Response.redirect Cstr(Request("goto"))
End If
else
if op = "add" then
Select Case Request.Form("type")
Case "product"
errorList=errorList & "商品编号已存在。<br>"
Case "department"
errorList=errorList & "商品分类ID已存在。<br>"
End Select
else
Select Case Request.Form("type")
Case "product"
errorLis=errorList & "商品编号已存在或者是错误的编号。<br>"
Case "order"
errorList=errorList & "订单不存在。<br>"
Case "department"
errorList=errorList & "商品分类不存在。<br>"
End Select
end if
end if
end if
if errorList <> "" then
%>
<!--#INCLUDE FILE="error.asp" -->
<%
end if
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?