打印本文 打印本文  关闭窗口 关闭窗口
ASP与SQL网站数据库程序设计(16)
作者:.. 文章来源:科学出版社 点击数: 更新时间:2004/1/25 1:09:56
说明='" & request.form("currencyinfo"&i) & "' where 编号=" & request.form("currencyno" & i )

145:             set rs = objconn.execute(sql)

146:         end if

147:     next

148:     objconn.close

149:     if counters = 0 then

150:         showinfo "没有选择任何币别!\n\n 修改程序无效!","",0

151:     else

152:         showinfo "币别修改完成!","/Currency.asp",1

153:     end if

154:     OBJConn.Close

155: end function

156: %>

程序说明

本段程序代码用于选取多条记录进行更新时,利用“For…Next”循环及“update”检查复选框是否被按下。如果已经被按下时,则分别执行更新该币别信息记录的操作。

15-6  类别管理

产品类别管理的相关信息不单单是作为产品分类所使用的,同时也是在上一章的“Function.asp”中,“产品类别”动态菜单中的数据来源。这个子系统将会用到“产品类别”表。以下是这个子系统的执行结果、程序内容以及程序说明。

AdminClassify.asp 程序段

16: <%

17: Public datas

18: if trim(request.form("submit")) <> "" then

19: Set OBJConn = Server.CreateObject("ADODB.Connection")

20: OBJConn.Open "Trade", "test", "test1"

21: select case request.form("Submit")

22: case "确定新增"

23:      SQL = "insert into 产品类别(类别编号,类别名称) values("

24:      sql = sql & "'" & left(trim(request.form("New ClassifyNo") ),4) & "',"

25:      sql = sql & "'" & trim(request.form("NewClass ifyInfo")) & "'"

26:      sql = sql & ")"

27:      On Error Resume Next

28:      Set Rs = OBJConn.Execute(SQL)

29:      sql1 = "select * from 产品类别 where 类别编号='" & left(trim(request.form("NewClassifyNo") ),4) & "'"

30:      Set Rs = OBJConn.Execute(SQL1)

31:      if not rs.eof then

32:          call ShowInfo("数据新增完成!\n您将会立即见到新增的分类信息!",1)

33:      else

34:          Set Rs = OBJConn.Execute(SQL)

35:      end if

36: case "确定删除"

37:      On Error Resume Next

38: '       SQL = "Delete from 产品类别 Where "

39:      for I = 0 to request.form("amount")

40:          if request.form("Delete" & I ) = "on" then

41:              SQL = "Delete from 产品类别 Where 类别编号 = " & trim(request.form("banner" & I))

42:              SQL1 = "Delete from 产品基本信息 Where 类别编号 = " & trim(request.form("banner" & I))

43:              Set Rs = OBJConn.Execute(SQL)

44:              set Rs = OBJConn.Execute(SQL1)

45: '               response.write SQL & "<br>"

46:          end if

47:      next

48: '       response.write request.form("amount")

49: case "确定修改"

50:      On Error Resume Next

51:      for I = 0 to request.form("amount")

52:          if request.form("Modify" & I ) = "on" then

53:              SQL = "update 产品类别 set 类别名称='" & request.form("ClassifyInfo" & I) & "'"

54:              sql = sql & " Where 类别编号 = " & trim(request.form("banner" & I))

55:              Set Rs = OBJConn.Execute(SQL)

56:          end if

57:      next

58: end select

59: objconn.close

60: end if

61: call GetClassify

62: %>

程序说明

22~35行:执行新增产品类别的程序,同时在检查输入的数据之后,执行表的写操作。

36~48行:执行删除产品类别的程序。在此,同时进行多条记录删除的操作。接着利用“For…Next”循环,自动产生即将执行的SQL Query内容后,再执行表的写操作。

AdminClassify.asp 程序段

64: <%

65: sub GetClassify

66: MaxRecords = 500

67: Exist = 0

68: Set OBJConn = Server.CreateObject("ADODB.Connection")

69:

70: OBJConn.Open "Trade", "test", "test1"

71:

72: SQL = "Select * from 产品类别 order by 类别编号"

73: On Error Resume Next

74: Set Rs = OBJConn.Execute(SQL)

75:

76: if rs.eof then

77: Call ShowInfo("尚未建立任何分类编号!",0)

78: else

79: exist = 1

80: datas = rs.getrows(MaxRecords)

81: end if

82: OBJConn.Close

83: %>

84:

85: <BODY>

86:

87: <center class="ChiDingTitle">&lt;产品类别新增修改系统&gt;</center>

88:

89: <Form method="Post">

90:

91: <table Border=1 border=0 cellpadding=1 cellspacing=1 align="center" width="80%">

92: <tr align="center" bgcolor="Tan">

93:      <td class="tsize" width="5%">修改</td>

94:      <td class="tsize" width="5%">删除</td>

95:      <td class="tsize" width="8%">类别编号</td>

96:      <td class="tsize" width="74%" Valign="Middle">类别名称</td>

97: </tr>

98:

99: <%

100: if exist = 1 then

101:     for i = 0 to ubound(datas,2) %>

102:

103:     <tr align="left" bgcolor=CornflowerBlue>

104:         <td class="tsize"><input type="CheckBox" Name= "Modify<%=I%>"></td>

105:         <td class="tsize"><input type="CheckBox" Name= "De lete<%=I%>"></td>

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 



打印本文 打印本文  关闭窗口 关闭窗口