<%@ LANGUAGE = JScript %> <% Response.Expires= -1 %> <% var oConn, oRs, oRs1, a, b="", c, aa, ab, ac, ad, ae, af, ag=0,ah,as,od,oe,of; aa=parseInt(Request.QueryString("OrderID"));ac=parseInt(Request.QueryString("ProductID")); ad=parseFloat(Request.QueryString("UnitPrice"));ae=parseInt(Request.QueryString("QuantityPerUnit")); af=parseFloat(Request.QueryString("Discount"));oc=parseInt(Request.QueryString("PID")); od=parseFloat(Request.QueryString("UPr"));oe=parseInt(Request.QueryString("Qty"));of=parseFloat(Request.QueryString("Dsc")); ah=Request.QueryString("Tot");as=Request.QueryString("Act"); oConn = Server.CreateObject("ADODB.Connection"); oConn.Open(as); if(Request.QueryString("UpID")==1){ a="Select max(case when OrderID="+aa+" And ProductID="+ac+" then '1' else '0' end) FROM [Order Details];"; oRs = oConn.Execute(a); if(oRs.Fields.Item(0).Value>=1){ag=1;} else{a="insert into [Order Details] (OrderID,ProductID,UnitPrice,Quantity,Discount) values ("+aa+","+ac+","+ad+","+ae+","; a=a+af+");"; oConn.Execute (a);}} if(Request.QueryString("UpID")==2){a="Delete from [Order Details] where OrderID="+aa+" And ProductID="+oc; a=a+" And UnitPrice="+od+" And Quantity="+oe+" And Discount="+of+";"; oConn.Execute(a);} if(Request.QueryString("UpID")==3){oConn.Execute("Delete from [Order Details] where OrderID="+aa+";");} if(Request.QueryString("UpID")==4){a=" update [Order Details] SET OrderID='"+aa+"',ProductID="+ac+","; a=a+"UnitPrice="+ad+",Quantity="+ae+",Discount="+af+" where OrderID="+aa+" And ProductID="+oc+" And UnitPrice="+od; a=a+" And Quantity="+oe+" And Discount="+of+";"; oConn.Execute(a);} %> SQL Northwind - Order Details Updater
<% a="Select OrderID,[Order Details].ProductID,[Order Details].UnitPrice,Quantity,convert(money,(Discount*100)/100) As Discount, "; a=a+"ProductName,'$'+convert(varchar,([Order Details].[UnitPrice]*[Quantity]*(1-[Discount])/100)*100) AS Subtotal "; a=a+"from [Order Details] Inner Join Products On Products.ProductID=[Order Details].ProductID where [Order Details].OrderID="; if(aa>0){a=a+aa;}else{a=a+null;} a=a+" ORDER BY "; if(Request.QueryString("Srt")==1||ae==1){a=a+"ProductName;";}else{a=a+"OrderID, ProductName;";} oRs = oConn.Execute(a); b="\n\n\n\n\n\n\n\n\n"; Response.Write(b);b="";c=0; while(oRs("OrderID")!=null&&oRs.EOF!=1){c=c+1; b=b+"\n"; b=b+"\n"; b=b+"\n"; b=b+"\n"; b=b+"\n"; b=b+"\n"; oRs.moveNext();} Response.Write(b);b=""; b=b+"\n"; b=b+"\n"; b=b+"\n"; b=b+"\n"; b=b+"\n"; a="Select '$'+convert(varchar,sum(([Order Details].[UnitPrice]*[Quantity]*(1-[Discount])/100)*100)) AS Total, "; a=a+"convert(decimal(9,2),sum(([Order Details].[UnitPrice]*[Quantity]*(1-[Discount])/100)*100)) As Tot from "; a=a+"[Order Details] where [Order Details].OrderID="; if(aa>0){a=a+aa;}else{a=a+null;}a=a+";"; oRs = oConn.Execute(a); b=b+"\n"; Response.Write(b); %>
Order IDProduct NameUnit PriceQuantityDiscountSubtotal"; b=b+"
"+oRs("OrderID")+""+oRs("Subtotal")+"
"+aa+"
<% if(ag==1){Response.Write("Could not add Record, Record with that Product already exists!");}%>
"> ADD!     DELETE!     DELETE ALL!     UPDATE!     REFRESH!