PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/beta/inventory/xml_InventoryItem.asp

http://github.com/khaneh/Orders
ASP | 89 lines | 77 code | 7 blank | 5 comment | 5 complexity | 7dcba4aba8a9be2d10e10346a9a56ce7 MD5 | raw file
 1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%>
 2<!--#include file="../config.asp" -->
 3<!--#include File="../JSON_2.0.4.asp"-->
 4<%
 5select case request("act")
 6	case "fromCode":
 7		Set result = jsObject()
 8		set store = jsArray()
 9		set result("store") = jsArray()
10		if request("invCode")<>"" then 
11			set rs = Conn.Execute("SELECT * From InventoryItems WHERE invCode="& request("invCode") & " ORDER BY id")	
12			if rs.eof then 
13				result("errMsg") = "���� ������ ���� �����"
14				result("err")=1
15			else
16				result("err")=0
17				itemID = cint(rs("id"))
18				result("itemID") = itemID
19				result("itemName") = rs("name")
20				set rs = Conn.Execute("select * from inventoryItemsInStore where itemID = " & itemID)
21				while not rs.eof
22					set result("store")(null) = jsObject()
23					result("store")(null)("storeID") = rs("storeID")
24					result("store")(null)("unit") = rs("unit")
25					rs.moveNext
26				wend
27			end if
28			rs.close()
29			conn.close()		
30		end if
31	case "getStore":
32		set result = jsArray()
33		set rs = Conn.Execute("select * from inventoryItemsInStore where itemID = " & request("itemID"))
34		while not rs.eof
35			set result(null) = jsObject()
36			result(null)("storeID") = rs("storeID")
37			result(null)("unit") = rs("unit")
38			rs.moveNext
39		wend
40		rs.close
41		conn.close
42	case "search":
43		set result = jsArray()
44		
45		mySQL="SELECT * From InventoryItems WHERE (REPLACE([Name], ' ', '') LIKE REPLACE(N'%"& URLDecode(Server.urlencode(request("search"))) & "%', ' ', '')) ORDER BY Name"
46		'mySQL="SELECT * From InventoryItems WHERE [Name] LIKE N'%���%' ORDER BY Name"
47		'response.write mySQL 'request("search")
48		Set rs = conn.Execute(mySQL)
49		while not rs.eof 
50			'response.write rs("name")
51			set result(null) = jsObject()
52			result(null)("id") = rs("id")
53			result(null)("name") = rs("name")
54			result(null)("invCode") = rs("invCode")
55			rs.moveNext
56		wend
57		rs.close
58		conn.close
59end select
60Response.Write toJSON(result)
61
62Function URLDecode(sConvert) 
63    Dim aSplit
64    Dim sOutput
65    Dim I
66    If IsNull(sConvert) Then
67       URLDecode = ""
68       Exit Function
69    End If
70
71    ' convert all pluses to spaces
72    sOutput = REPLACE(sConvert, "+", " ")
73
74    ' next convert %hexdigits to the character
75    aSplit = Split(sOutput, "%")
76
77    If IsArray(aSplit) Then
78      sOutput = aSplit(0)
79      For I = 0 to UBound(aSplit) -1
80        sOutput = sOutput & _
81          Chr("&H" & Left(aSplit(i + 1), 2)) &_
82          Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
83      Next
84    End If
85
86    URLDecode = sOutput 
87End Function 
88
89%>