addts.asp

来自「创建和运行动态、交互的Web服务器应用程序」· ASP 代码 · 共 136 行

ASP
136
字号
<!--#include file="conn.asp"-->
<%
dim tsid,ts,tsindex,index,bkcount,tszk,bk_countbz
 
    ts     = Session("myts") 
    tsindex= session("tsindex")

    action = request.QueryString("action")

select case action
       case "addts"

if request.QueryString("tsid")="" then
  tsid=request("tsid")
else 
  tsid=request.QueryString("tsid")
end if

set rs=server.CreateObject("adodb.recordset")
    rs.open "select * from shop_gongyi where gyid="&tsid,conn,1,3

    ts(0,0)=tsid
    ts(0,1)=rs("zk")

    Session("myts")   =ts
    tsindex           =tsindex+1
    session("tsindex")=tsindex
              
response.redirect "showts.asp?action=tslist"

        '//增加数据
         case "addbk"
dim bookname,isbn,txm

bookname=request("bookname")
isbn    =request("isbn")
txm     =request("txm")
 
if bookname="" then bookname=request.QueryString("bookname")
if isbn=""     then isbn    =request.QueryString("isbn")
if txm=""      then txm     =request.QueryString("txm")
set rs=server.createobject("adodb.recordset")

if bookname="" and isbn="" and txm="" then 
    response.write "<script language=javascript>alert('您没有选择图书检索条件,请选择检索项!');window.location.reload('showts.asp?action=tslist')</script>"
    response.end
end if
if (bookname<>"" and isbn<>"" and txm<>"") or (isbn<>"" and txm<>"") or (bookname<>"" and isbn<>"") or (bookname<>"" and txm<>"") then 
    response.write "<script language=javascript>alert('检索条件不能选多项,请选单个!');window.location.reload('showts.asp?action=tslist')</script>"
    response.end
else
    if bookname<>"" then rs.open "SELECT shop_cgaction.gyid, shop_cgaction.bookid, shop_books.bookname, shop_books.isbn, shop_books.booktxm, shop_books.shichangjia, Sum(shop_cgaction.kccount) AS Sum_kccount FROM shop_cgaction INNER JOIN shop_books ON shop_cgaction.bookid = shop_books.bookid where shop_cgaction.gyid="&ts(0,0)&" and shop_books.bookname='"&bookname&"' GROUP BY shop_cgaction.gyid, shop_cgaction.bookid, shop_books.bookname, shop_books.isbn, shop_books.booktxm, shop_books.shichangjia HAVING Sum(shop_cgaction.kccount)<>0",conn,1,1
    if isbn<>""     then rs.open "SELECT shop_cgaction.gyid, shop_cgaction.bookid, shop_books.bookname, shop_books.isbn, shop_books.booktxm, shop_books.shichangjia, Sum(shop_cgaction.kccount) AS Sum_kccount FROM shop_cgaction INNER JOIN shop_books ON shop_cgaction.bookid = shop_books.bookid where shop_cgaction.gyid="&ts(0,0)&" and shop_books.isbn='"&isbn&"'         GROUP BY shop_cgaction.gyid, shop_cgaction.bookid, shop_books.bookname, shop_books.isbn, shop_books.booktxm, shop_books.shichangjia HAVING Sum(shop_cgaction.kccount)<>0",conn,1,1
    if txm<>""      then rs.open "SELECT shop_cgaction.gyid, shop_cgaction.bookid, shop_books.bookname, shop_books.isbn, shop_books.booktxm, shop_books.shichangjia, Sum(shop_cgaction.kccount) AS Sum_kccount FROM shop_cgaction INNER JOIN shop_books ON shop_cgaction.bookid = shop_books.bookid where shop_cgaction.gyid="&ts(0,0)&" and shop_books.booktxm='"&txm&"'       GROUP BY shop_cgaction.gyid, shop_cgaction.bookid, shop_books.bookname, shop_books.isbn, shop_books.booktxm, shop_books.shichangjia HAVING Sum(shop_cgaction.kccount)<>0",conn,1,1
     '//没有找到图书
    if  rs.eof and rs.bof then
        response.write "<script language=javascript>alert('采购库中没有找到该图书,可能售完或退完或未采购!');window.location.reload('showts.asp?action=tslist')</script>"
        response.end
    else
        '//找到了图书
           bookid          = rs("bookid")
           bookname	   = rs("bookname")
           bkcount         = rs("Sum_kccount")
           shichangjia     = rs("shichangjia")
           tszk            = ts(0,1)
           bk_countbz      = rs("Sum_kccount")

           if bkcount <>"" then
              bkcount=Cint(bkcount)

              '//检查数组
              for i=1 to tsindex
              '//是否重复
	         if bookid=ts(i,0) then
                    response.write "<script language=javascript>alert('你已选购了该图书!');window.location.reload('showts.asp?action=tslist')</script>"
                    response.End
                 end if
               next
               '//不重复
               ts(tsindex,0)=bookid
               ts(tsindex,1)=bookname
               ts(tsindex,2)=bkcount
               ts(tsindex,3)=shichangjia
               ts(tsindex,4)=tszk
               ts(tsindex,5)=bk_countbz

               Session("myts") =ts
               tsindex           =tsindex+1
               session("tsindex")=tsindex
               response.redirect"showts.asp?action=tslist"

            else

	       response.write "<script language=javascript>alert('你没有选择图书数量!');window.location.reload('javascript:window.close()')</script>"
               response.End
           end if
       end if
 end if
 
    '//修改数据
    case "adchange"
    index     = request.form("index")
    bkcount   = request.form("bkcount")
    tszk      = request.form("tszk")
    bk_countbz= request.form("bk_countbz")
  
    if cint(bkcount)>cint(bk_countbz) then
       response.write "<script language=javascript>alert('你的退书超过了该书的总库存量!');window.location.reload('showts.asp?action=tslist')</script>"
       response.End
    else
       ts(index,2)= bkcount
    end if
   
    if tszk>1 then
       response.write "<script language=javascript>alert('折扣不能大于1!');window.location.reload('showts.asp?action=tslist')</script>"
       response.End
    else
       ts(index,4)= tszk
    end if

    Session("myts")= ts
    response.redirect"showts.asp?action=tslist"
        
    '//删除数据
    case "addelet"
    ts= Session("myts")

    index= request("index")
    for i=0 to 4
	ts(index,i)="0"
    next
    Session("myts")= ts
    response.redirect"showts.asp?action=tslist"

end select
%>

⌨️ 快捷键说明

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