Hi
Im currently try to run this scrippt where by when the user clicks the delete button the function deleteline() function runs which will display the line id on the page. However I cant seem to get the lineid value to be sent to the broswer.
Any ideas?
Andy
Im currently try to run this scrippt where by when the user clicks the delete button the function deleteline() function runs which will display the line id on the page. However I cant seem to get the lineid value to be sent to the broswer.
Any ideas?
Andy
Code:
<SCRIPT id=DebugDirectives runat=server language=javascript>
// Set these to true to enable debugging or tracing
@set @debug=false
@set @trace=false
</SCRIPT>
<script language="JavaScript" type="text/javascript">
<!--
SetPageTitle('View Order')
//-->
</script>
<%
if len(request("recID")) > 0 then
strRecordid = request("recID")
else
strRecordid = request("OrderNo")
end if
Response.Write "<script language=""JavaScript"" type=""text/javascript"">" & VbCr
Response.Write "<!--// "& VbCr
Response.Write "function ConfirmChoice()"& VbCr
Response.Write "{ "& VbCr
Response.Write "answer = confirm(""Are you sure you want to delete this order?"")"& VbCr
Response.Write "if (answer !=""0"") "& VbCr
Response.Write "{ "& VbCr
Response.Write "window.location = 'showorder.asp?switch=d&OrderID=" & strRecordid & "&recID=" & strRecordid & "'"& VbCr
Response.Write "} "& VbCr
Response.Write "}"& VbCr
Response.Write "//-->"& VbCr
Response.Write "</script>"& VbCr
Response.Write "<script language=""JavaScript"" type=""text/javascript"">" & VbCr
Response.Write "<!--// "& VbCr
Response.Write "function DeleteLine()"& VbCr
Response.Write "{ "& VbCr
Response.Write "answer = confirm(""Are you sure you want to delete this line?"")"& VbCr
Response.Write "if (answer !=""0"") "& VbCr
Response.Write "{ "& VbCr
Response.Write "window.location = 'showorder.asp?switch=dl&OrderID=" & strRecordid & "&recID=" & strRecordid & "&lID=" & strid & "'"& VbCr
Response.Write "} "& VbCr
Response.Write "}"& VbCr
Response.Write "//-->"& VbCr
Response.Write "</script>"& VbCr
Dim lngOrderID
Dim objRs
Dim objConn
'START OF SWITCH - DELETE ORDER
if Request("switch") = "d" then
strConn = Application("conLIVEoledb_ConnectionString")
'strConn = Application("conDevTest_ConnectionString")
Set objConn = Server.CreateObject ("adodb.connection")
Set cmd = Server.CreateObject ("adodb.command")
Set objRs = Server.CreateObject ("adodb.recordset")
cmd.CommandTimeout = 600
objConn.Open strConn
Set cmd.ActiveConnection = objConn
objRs.CursorType = adOpenForwardOnly
objRs.LockType = adLockReadOnly
objRs.CursorLocation = adUseServer
cmd.CommandText = "deleteorder"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Append cmd.CreateParameter("OrderID", adVarChar, adParamInput, 20)
cmd("OrderID") = CStr(strRecordid)
cmd.Execute
Set objRs = nothing
Set objConn = nothing
'DELETE LINE ITEM
elseif Request ("Switch") = "dl" then
if Request("strid") = "" then
strid = Request("id")
'strid = "noid"
end if
Response.Write"Line Item Deleted orderid=" & strRecordid & " and line No =" & strid & ""
end if
'END OF SWITCH
Response.Write "<BR><BR><FORM name=thisForm1 id=thisForm1 action=""showorder.asp?switch=d&OrderID=" & strRecordid & "&lID=" & strid & "&recID="& strRecordid &""" Method=POST><table width=""90%"" border=1 FRAME=Box RULES=none BORDERCOLOR=#666699 cellpadding=3 cellspacing=0 align=center style=""border-color:#666699;border-width:1px;border-style:solid;border-collapse:collapse;"">"
strLogonUser = TRIM(Request.ServerVariables("REMOTE_HOST"))
If strLogonUser = "192.168.1.200" OR strLogonUser = "62.254.128.4" then
CanConfirm = True
Else
CanConfirm = False
End If
strConn = Application("conLIVEoledb_ConnectionString")
Set objConn = Server.CreateObject ("adodb.connection")
objConn.Open strConn
Set objRs = Server.CreateObject ("adodb.recordset")
objRs.CursorType = adOpenForwardOnly
objRs.LockType = adLockReadOnly
objRs.CursorLocation = adUseServer
'****************************************************************************************
SQL= **SQL SCRIPT HERE**
'****************************************************************************************
Set objRs = objConn.Execute(SQL)
if objRS.bof and objRS.eof then
Response.Write"Order Deleted"
else
lngOrderID = CLng(objRs("OrderNo"))
Response.Write "<input type=hidden id=OrderNo name=OrderNo value="& cstr(lngOrderID) & ">"& VbCr
Response.Write "<input type=hidden id=recID name=recID value=" & Request("recID") & ">"& VbCr
Response.Write "<TR BGCOLOR=#666699><TD colspan=6><B><FONT COLOR=#ffffff>Order No " & objRs("OrderNo") & " : " & objRs("Outlet") & " : Supplied by " & objRs("Wholesaler") & "</FONT></B></TD><TD></TD><TD></TD></TR>"
Response.Write "<TR BGCOLOR=#b0c4de><TD>Wholesaler</TD>"
Response.Write "<TD>Description</TD>"
Response.Write "<TD align=left colspan=2>Qty Ordered</TD>"
Response.Write "<TD align=right>Price</TD>"
Response.Write "<TD align=center>Qty Dispatched</TD>"
Response.Write "<TD align=right>Line Total</TD>"
Response.Write "<TD align=right></TD></TR>"
If IsNull(objRs("VAT")) then
strVAT = "0.00"
strNetTotal = convertCurrency(CStr(objRs("Total")))
else
strVAT = convertCurrency(CStr(objRs("VAT")))
strNetTotal = convertCurrency(CStr(objRs("Total")+ objRs("VAT")))
End If
strGrossTotal = convertCurrency(objRs("Total"))
If objRs("Dispatched") = 1 then
Dispatched = True
else
Dispatched = False
End If
count = 1
While Not objRs.EOF
if (count mod 2) = 1 then
Response.Write "<TR BGCOLOR=#ffffff>" & VbCr
Else
Response.Write "<TR BGCOLOR=#b0c4de>" & VbCr
End If
count = count + 1
If objRs("Split") = 0 then
If Trim(objRs("BulkName")) = " " then
strUnit = objRs("SplitName")
Else
strUnit = objRs("BulkName")
End If
Else
strUnit = objRs("SplitName")
End If
If IsNull(objRs("LineTotal")) then
strLineTotal = "0.00"
else
strLineTotal = convertCurrency(CStr(objRs("LineTotal")))
End If
Response.Write "<TD>" & objRs("Wholesaler") & "</TD><TD> " & objRs("DescriptionName") & " " & objRs("DetailName") & " " & objRs("OriginName") & "</TD>" & VbCr
Response.Write "<TD align=right> " & objRs("Quantity") & "x</TD>" & VbCr
Response.Write "<TD align=left> " & strUnit & "</TD>" & VbCr
Response.Write "<TD align=right> " & convertCurrency(CStr(objRs("Price"))) & "</TD>" & VbCr
Response.Write "<TD align=center> " & objRs("QuantityDispatched") & "</TD>" & VbCr
Response.Write "<TD align=right> " & strLineTotal & "</TD>" & VbCr
Response.Write "<TD colspan=6 align=right>" & VbCr
Response.Write "<input type=text id=lineid name=lineid value=" & objRs("id") & ">" & VbCr
Response.Write "<Input Type=Button onclick=DeleteLine(); return false; value=""Delete"" id=Button1 name=Button1></TD></TR>"
objRs.moveNext
Wend
Response.Write "<TR height=1 bgcolor=#666699><TD colspan=6></TD><TD></TD><TD></TD></TR>"
Response.Write "<TR><TD></TD><TD></TD><TD align=right colspan=5> Gross Total </TD><TD align=right>" & strGrossTotal & "</TD><TD></TD></TR>" & VbCr
Response.Write "<TR><TD></TD><TD></TD><TD align=right colspan=5> VAT </TD><TD align=right>" & strVAT & "</TD><TD></TD></TR>" & VbCr
Response.Write "<TR><TD></TD><TD></TD><TD align=right colspan=5> Nett Total </TD><TD align=right>" & strNetTotal & "</TD><TD></TD></TR>" & VbCr
Response.Write "<TR bgcolor=#b0c4de><TD></TD><TD></TD><TD colspan=6 align=right><Input Type=Button onclick=ConfirmChoice(); return false; value=""Delete Order""></TD></TR>"
If Dispatched AND CanConfirm then
Response.Write "<TR bgcolor=#b0c4de><TD></TD><TD></TD><TD colspan=6 align=right><Input Type=Button id=Button_1 name=Button_1 value=""Confirm This Order""></TD></TR>"
else
Response.Write "<TR bgcolor=#b0c4de><TD></TD><TD></TD><TD colspan=6 align=right><Input Type=Button id=Button_1 name=Button_1 disabled=True value=""Confirm This Order""></TD></TR>"
End If
Response.Write "</table></form>"
end if
Set objRs = nothing
Set objConn = nothing
%>