%@ LANGUAGE = JScript %> <% Response.Expires= -1 %> <% var Ccl,oConn,oRs,a,b="",c="",d="",e="",f,g,h,i,aa,ab,ac,ad,ae,af,ag,ah=0,ai,aj,ak,al,am,an,ao,ap,aq,ar,as; if(Request.QueryString("LdFl")>""){ab=parseInt(Request.QueryString("LdFl"));}else{ab=1;} ad=parseInt(Request.QueryString("PgNo"));ae=parseInt(Request.QueryString("PgSz")); af=Request.QueryString("Pgs");ai=Request.QueryString("FNm");aj=Request.QueryString("FVl"); ak=Request.QueryString("FSt");al=Request.QueryString("FltTp"); if(Request.QueryString("FVl1")>""){am=Request.QueryString("FVl1");}else{am="";} if(ao=Request.QueryString("FSt1")>""){ao=Request.QueryString("FSt1");}else{ao="";} aq=Request.QueryString("FlF");ar=Request.QueryString("FlTo");as=Request.QueryString("Act"); oConn = Server.CreateObject("ADODB.Connection"); oConn.Open(as); %> <% if(ab==1){a="Select CategoryID As [Category ID], CategoryName As [Category Name], Description From Categories"; if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="CategoryID;";}} %> <% if(ab==2){a="Select CustomerID As [Customer ID], CompanyName As [Company Name], ContactName As [Contact Name],"; a=a+"ContactTitle As [Contact Title], Address, City, iif(isnull(Region),'-',Region) As Region, PostalCode As [Postal Code], "; a=a+"Country, Phone, iif(isnull(Fax),'-',Fax) As Fax From Customers"; if(ai=="Region"||ai=="Fax"){ai="iif(isnull("+ai+"),'-',"+ai+")";} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="CustomerID;";}} %> <% if(ab==3){a="Select Employees.EmployeeID As [Employee ID], iif(isnull(Employees_1.EmployeeID),'-',"; a=a+"Employees_1.FirstName&' '&Employees_1.LastName) As [Reports To], Format(Employees.HireDate,'dd/mm/yyyy') As HireDate, "; a=a+"Employees.Title As Title, Employees.TitleOfCourtesy As [Title Of Courtesy], Employees.FirstName&' '&Employees.LastName "; a=a+"As [Employee Name], Employees.Address As Address, Employees.City As City, iif(isnull(Employees.Region),'-',"; a=a+"Employees.Region) As Region, Employees.PostalCode, Employees.Country As Country, Employees.HomePhone as [Home Phone], "; a=a+"Employees.Extension As Extension, Format(Employees.Birthdate,'dd/mm/yyyy') As Birthdate From Employees LEFT OUTER JOIN "; a=a+"Employees AS Employees_1 ON Employees.ReportsTo=Employees_1.EmployeeID"; if(ai=="Region"){ai="iif(isnull(Employees."+ai+"),'-',Employees."+ai+")";} if(ai=="Birthdate"||ai=="HireDate"){ai="Format(Employees."+ai+",'dd/mm/yyyy')";} if(ai=="ReportsTo"){ai="iif(isnull(Employees_1.EmployeeID),'-',Employees_1.FirstName&' '&Employees_1.LastName)";} if(ai=="EmployeeName"){ai="Employees.FirstName&' '&Employees.LastName";} if(ai=="Title"||ai=="TitleOfCourtesy"||ai=="Country"||ai=="HomePhone"||ai=="Extension"||ai=="PostalCode"||ai=="Address"||ai=="City"||ai=="EmployeeID") {ai="Employees."+ai;} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak=="Title"||ak=="TitleOfCourtesy"||ak=="Country"||ak=="HomePhone"||ak=="Extension"||ak=="PostalCode"||ak=="Address"||ak=="City"||ai=="EmployeeID") {ak="Employees."+ak;} if(ak=="Birthdate"||ak=="HireDate"){ak="Format(Employees."+ak+",'dd/mm/yyyy')";} if(ak=="Region"){ak="iif(isnull(Employees."+ak+"),'-',Employees."+ak+")";} if(ak=="ReportsTo"){ak="iif(isnull(Employees_1.EmployeeID),'-',Employees_1.FirstName&' '&Employees_1.LastName)";} if(ak=="EmployeeName"){ak="Employees.FirstName&' '&Employees.LastName";} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="Employees.EmployeeID;";}} %> <% if(ab==4){a="SELECT OrderID, Format(OrderDate,'dd/mm/yyyy') As [Order Date], [Customers].[CustomerID] As [Customer ID], "; a=a+"ShipName As [Ship Name], ContactName As [Contact Name],Customers.Phone As Phone, iif(isnull(ShipPostalCode),'-',"; a=a+"ShipPostalCode) As [Post Code], Shippers.CompanyName As [Ship Via], Format(RequiredDate,'dd/mm/yyyy') As "; a=a+"[Required Date], Format(ShippedDate,'dd/mm/yyyy') AS [Shipped Date], Shippers.Phone As [Shipper Phone], FirstName"; a=a+"&' '&LastName AS [Employee Name] FROM Employees INNER JOIN (Shippers RIGHT JOIN (Customers INNER JOIN Orders ON Customers"; a=a+".CustomerID = Orders.CustomerID) ON Shippers.ShipperID = Orders.ShipVia) ON Employees.EmployeeID = Orders.EmployeeID"; if(ai=="ShipVia"){ai="Shippers.CompanyName";}if(ai=="CustomerID"){ai="Orders."+ai;} if(ai=="EmployeeName"){ai="Employees.FirstName&' '&Employees.LastName";}if(ai=="ContactName"||ai=="Phone"){ai="Customers."+ai;} if(ai=="RequiredDate"||ai=="ShippedDate"||ai=="OrderDate"){ai="Format("+ai+",'dd/mm/yyyy')";} if(ai=="ShipperPhone"){ai="Shippers.Phone";}if(ai=="PostCode"){ai="iif(isnull(ShipPostalCode),'-',ShipPostalCode)";} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak=="CustomerID"){ak="Orders."+ak;}if(ak=="ContactName"||ak=="Phone"){ak="Customers."+ak;} if(ak=="EmployeeName"){ak="Employees.FirstName&' '&Employees.LastName";}if(ak=="PostCode"){ak="Orders.ShipPostalCode";} if(ak=="ShipVia"){ak="Shippers.CompanyName";}if(ak=="ShipperPhone"){ak="Shippers.Phone";} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="OrderID;";}} %> <% if(ab==5){a="SELECT ProductID As [Product ID], ProductName As [Product Name], Format(UnitPrice,'$#,###,##0.00') As"; a=a+" [Unit Price], QuantityPerUnit As [Quantity Per Unit], UnitsInStock AS [Units In Stock], UnitsOnOrder As "; a=a+"[Units On Order], ReorderLevel AS [Reorder Level], Discontinued, CompanyName As [Company Name], ContactName As"; a=a+" [Contact Name], Phone FROM Products LEFT OUTER JOIN Suppliers ON Products.SupplierID=Suppliers.SupplierID"; if(ai=="SupplierID"){ai="Products."+ai;}if(ai=="CompanyName"||ai=="ContactName"||ai=="Phone"){ai="Suppliers."+ai;} if(ai=="UnitPrice"){ai="Format("+ai+",'$#,###,##0.00')";}if(ai=="Discontinued"){if(aj==1){aj=-1;}else{aj=0;}} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak=="SupplierID"){ak="Products."+ak;}if(ak=="CompanyName"||ak=="ContactName"||ak=="Phone"){ak="Suppliers."+ak;} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="ProductID;";}} %> <% if(ab==6){a="Select CustomerID As [Customer ID], CompanyName As [Company Name], City, Country From [Quarterly Orders]"; if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="CustomerID;";}} %> <% if(ab==7){a="Select ProductName AS [Product Name], [CustomerID] As [Customer ID], OrderYear AS [Order Year], "; a=a+"Format(iif(isnull([Qtr 1]),0,[Qtr 1]),'$#,###,##0.00') As [Qtr 1], "; a=a+"Format(iif(isnull([Qtr 2]),0,[Qtr 2]),'$#,###,##0.00') As [Qtr 2], "; a=a+"Format(iif(isnull([Qtr 3]),0,[Qtr 3]),'$#,###,##0.00') As [Qtr 3], "; a=a+"Format(iif(isnull([Qtr 4]),0,[Qtr 4]),'$#,###,##0.00') As [Qtr 4] FROM [Quarterly Orders by Product]"; if(ai=="Qtr1"){ai="Format(iif(isnull([Qtr 1]),0,[Qtr 1]),'$#,###,##0.00')";} if(ai=="Qtr2"){ai="Format(iif(isnull([Qtr 2]),0,[Qtr 2]),'$#,###,##0.00')";} if(ai=="Qtr3"){ai="Format(iif(isnull([Qtr 3]),0,[Qtr 3]),'$#,###,##0.00')";} if(ai=="Qtr4"){ai="Format(iif(isnull([Qtr 4]),0,[Qtr 4]),'$#,###,##0.00')";} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak=="Qtr1"){ak="iif(isnull([Qtr 1]),0,[Qtr 1])";} if(ak=="Qtr2"){ak="iif(isnull([Qtr 2]),0,[Qtr 2])";} if(ak=="Qtr3"){ak="iif(isnull([Qtr 3]),0,[Qtr 3])";} if(ak=="Qtr4"){ak="iif(isnull([Qtr 4]),0,[Qtr 4])";} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="ProductName";}} %> <% if(ab==8){a="Select CategoryID As [Category ID], CategoryName As [Category Name], ProductName As [Product Name],"; a=a+" Format(ProductSales,'$#,###,###0.00') As [Product Sales] FROM [Sales by Category]"; if(ai=="ProductSales"){ai="Format("+ai+",'$#,###,##0.00')";} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="Categories.CategoryID;";}} %> <% if(ab==9){a="Select ShipperID As [Shipper ID], CompanyName As [Company Name], Phone From Shippers"; if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="ShipperID;";}} %> <% if(ab==10){a="Select SupplierID As [Supplier ID], CompanyName As [Company Name], ContactName As [Contact Name],"; a=a+"ContactTitle As [Contact Title], Address, City, iif(isnull(Region),'-',Region) As Region, PostalCode As [Postal Code], "; a=a+"Country, Phone, iif(isnull(Fax),'-',Fax) As Fax From Suppliers"; if(ai=="Region"||ai=="Fax"){ai="iif(isnull("+ai+"),'-',"+ai+")";} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="SupplierID;";}} %> <% if(ab==11){a="Select TenMostExpensiveProducts AS [Ten Most Expensive Products], Format(UnitPrice,'$#,###,###0.00')"; a=a+" As [Unit Price] FROM [Ten Most Expensive Products]"; if(ai=="UnitPrice"){ai="Format("+ai+",'$#,###,##0.00')";} if(ai>""&&al>""||aq>""||ar>""){if(am>""){b=" And "+ai;}else{b=" where "+ai;}if(al==1){b=b+" Like '"+aj+"' ";} else if(al==2){b=b+" Not Like '"+aj+"' ";}else if(aq>""&&ar>""){b=b+" Between "+aq+" And "+ar;} else if(aq>""){b=b+">="+aq;}else if(ar>""){b=b+"<="+ar;}} if(ak>""){if(ao>""){c=c+", "+ak;}else{c=c+ak;}}else{e="UnitPrice DESC;";}} a=a+am+b;d=a+" Order By ";if(c>""){d=d+ao+c+";";}else if(ao>""){d=d+ao+";";}else{d=d+e;} oRs=oConn.Execute(d); am=am+b;ao=ao+c;aq="";ar=""; for(i=0;oRs.EOF!=1;i++){oRs.moveNext;} %>