⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 save.asp

📁 一个关于网站权限管理的经典例子,适合初学者
💻 ASP
字号:
<% Option explicit %>
<!-- #Include file="./connects.inc"-->
<!-- #Include file="../globals.inc"-->

<Html>
<Head>
  <title>增加或修改数据</title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  <link href="../style/style.css" rel="stylesheet">
</Head>
<Body topmargin="5" leftmargin="0" background="../../images/bg.gif">
<%
  Dim sSQL, rs1, iOrderid, iOrderid_old, sAccountId, sAccountName, sPassword, sAccountType, sUserName, sRemark, isToDo, sSQLCondition

  isToDo=trim(request("isToDo"))
  iOrderid=trim(request("Orderid"))
  sAccountId=trim(request("AccountId"))
  sAccountName=trim(request("AccountName"))
  sPassword=trim(request("Password"))
  sAccountType=trim(request("AccountType"))
  sUserName=trim(request("UserName"))
  sRemark=trim(request("Remark"))

  if isToDO<>"Insert" and isToDO<>"Update" then
    response.write("Error!")
    response.end
  end if

  select case isToDO
    case "Insert"
      sSQL="insert into tabAccountInfo (f_i_Orderid, f_accountid, f_accountname, f_password, f_accounttype, f_username, f_remark, f_datetime) values " & _
           "("& iOrderid &", '"& sAccountid &"', '"& sAccountname &"', '"& sPassword &"', '"& sAccounttype &"', '"& sUsername &"', '"& sRemark &"', '"& now &"')"
    case "Update"
      iOrderid_old=trim(request("orderid_old"))
      sSQLCondition=request("sSQLCondition")
      if iOrderid=iOrderid_old then  '没有修改排序号
        sSQL="update tabAccountInfo set f_accountid='"& sAccountid &"', f_accountname='"& sAccountname &"', f_password='"& sPassword &"', f_accounttype='"& sAccounttype &"', f_username='"& sUsername &"', f_remark='"& sRemark &"', f_datetime='"& now() &"' where " & sSQLCondition
      else                           '修改了排序号
        if HaveRecordCounts("tabAccountInfo", "f_i_orderid", iOrderid, "Number")>=1 then  '判断修改后的顺序号是否与现有的重复
          response.write("<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;顺序号重复!请选择合适的顺序号。")
          response.write("<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:history.go(-1);'>返回</a>")
          response.end
        else                         '没有重复,则保存修改后的记录
          sSQL="update tabAccountInfo set f_i_Orderid="& iOrderid &", f_accountid='"& sAccountid &"', f_accountname='"& sAccountname &"', f_password='"& sPassword &"', f_accounttype='"& sAccounttype &"', f_username='"& sUsername &"', f_remark='"& sRemark &"', f_datetime='"& now() &"' where " & sSQLCondition
        end if
      end if
    case else
      response.write "Error!"
      response.end
  end select

  response.write sSQL
  'sConn.execute sSQL '对Access该语句可以执行,等价于以下2条语句
  Set rs1 = Server.CreateObject("ADODB.Recordset")
  rs1.Open sSQL, sConn, 1, 3

  '重新排列记录的顺序号(数字间隔为5):
  sort_table_by_sortid("tabAccountInfo")  'tabAccountInfo是表名
%>

<Script language="javascript">
  //返回到浏览记录初始界面:
  this.location="lists.asp";
</Script>

</Body>
</Html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -