-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateItem.asp
60 lines (50 loc) · 2.26 KB
/
updateItem.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<%@ Language="VBScript" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<%
if session("empid") = "" then
response.redirect("sessionTimedOut.asp")
end if
itemno = request.querystring("itemno")
attribute = request.querystring("attribute")
changedValue = request.querystring("changedValue")
response.write itemno & attribute & changedValue
Dim Connection
Dim Recordset
Dim RecordsetS
Dim SQL
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
Set RecordsetS = Server.CreateObject("ADODB.Recordset")
Connection.Open "DSN=csidsn"
SQL = "select * from inventory where itemno = "&itemno
RecordsetS.Open SQL,Connection
SQL = ""
SQL1 = ""
if attribute = "cost_per_item" then
SQL = "update inventory set " & attribute & " = " & changedValue & " where itemno="&itemno&";"
newtotalvalue = changedValue * RecordsetS("stock_quantity")
SQL1 = "update inventory set total_value = "& newtotalvalue & " where itemno = " &itemno& ";"
Recordset.Open SQL1,Connection
elseif attribute = "stock_quantity" then
tempvalue = RecordsetS("stock_quantity") + changedValue
SQL = "update inventory set " & attribute & " = " & tempvalue & " where itemno="&itemno&";"
newtotalvalue = tempvalue * RecordsetS("cost_per_item")
SQL1 = "update inventory set total_value = "& newtotalvalue & " where itemno = " &itemno& ";"
Recordset.Open SQL1,Connection
else
SQL = "update inventory set " & attribute & " = '" & changedValue & "' where itemno="&itemno&";"
end if
Recordset.Open SQL,Connection
response.write "0"
Set RecordsetS=nothing
Set Recordset=nothing
Set Connection=nothing
%>
<body>
</body>
</html>