PageRenderTime 29ms CodeModel.GetById 26ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/reports/reports_tah.asp

http://github.com/khaneh/Orders
ASP | 158 lines | 109 code | 15 blank | 34 comment | 12 complexity | d1802610efacab174bc285e06fafe4af MD5 | raw file
  1<%
  2	'mySQL = Request.Form("SQL") 
  3	'connector = " WHERE ("
  4	'Set Params = Request.Form
  5	'For Each p in Params
  6	'	Param = Params(p)
  7'		response.write "param : #" & p & " :: " & Param & "# <br>"
  8	'	If Param <> "" AND p <> "SQL" Then
  9	'		Do While Instr(Param,"||") <> 0
 10	'			mySQL = mySQL & connector & p & " " & Left(Param,Instr(Param,"||")-1)
 11	'			connector = " OR "
 12	'			Param = Right(Param,Len(Param) - Instr(Param,"||")-1)
 13	'		Loop
 14	'		mySQL = mySQL & connector & p & " " & Param & ")"
 15	'		connector = " AND ("
 16	'	End If
 17	'Next
 18
 19'	------------------ 
 20'	-----  Show Result using:
 21'	-----  
 22'	-----  String:				mySQL	;	the SQL
 23'	-----  ADODB.Connection:	conn:	;	the connection string
 24'	-----  
 25'	------------------ 
 26
 27'---------------------------------------------
 28'------------------------------------ Separate
 29'---------------------------------------------
 30function Separate(inputTxt)
 31
 32if not isnumeric(inputTxt) or "" & inputTxt="" then 
 33	Separate=inputTxt
 34else
 35	myMinus=""
 36	input=inputTxt
 37	t=instr(input, ".")
 38	if t>0 then 
 39		expPart = mid(input, t+1, 2)
 40		input = left(input, t-1)
 41	end if
 42	if left(input,1)="-" then
 43		myMinus="-"
 44		input=right(input,len(input)-1)
 45	end if
 46	if len(input) > 3 then
 47		tmpr=right(input ,3)
 48		tmpl=left(input , len(input) - 3 )
 49		result = tmpr
 50		while len(tmpl) > 3
 51			tmpr=right(tmpl,3)
 52			result = tmpr & "," & result 
 53			tmpl=left(tmpl , len(tmpl) - 3 )
 54		wend
 55		if len(tmpl) > 0 then
 56			result = tmpl & "," & result
 57		end if 
 58	else
 59		result = input
 60	end if 
 61	if t>0 then 
 62		result = result & "." & expPart
 63	end if
 64
 65	Separate=myMinus & result
 66end if
 67end function
 68'-------------------------------------------------------
 69'---------------------
 70
 71	'Set conn = Server.CreateObject("ADODB.Connection")
 72	'conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db1.mdb") & ";"
 73
 74	Set rs = Server.CreateObject("ADODB.Recordset")
 75	rs.Open mySQL, conn, 3, 3
 76	
 77	'----------------------------------G e n   H T M L   T a b l e------------------------------------
 78	Dim myXls
 79	myXls = "<style> .resTable1 { Font-family:tahoma; Font-Size:9pt; Background-color:#336699; border: 1 solid #336699;} .resTable1 th {Background-color:#6699CC;} .resRow1 {Background-color:#F8F8FF;} .resRow0 {Background-color:#CCCCDD;} </style>"
 80	
 81	myXls = myXls & "<CENTER><H3>"&Server.HTMLEncode(reportTitle)&"</H3></CENTER>"
 82	myXls = myXls & "<table class='resTable1' Cellspacing=1 Cellpadding=2 align=center><tr>"
 83	
 84	For i = 0 To rs.Fields.Count - 1
 85		myXls = myXls & "<th>"&Server.HTMLEncode(rs.Fields(i).Name)&"</th>"
 86	
 87	Next
 88	myXls = myXls & "</tr>"
 89	
 90	if rs.eof then
 91		myXls = myXls & "<tr><td width='100%' class=resRow1 colspan="&rs.Fields.Count&" align='center'>جوابي يافت نشد</td></tr>"
 92	else
 93		rs.MoveFirst
 94		rowCounter=0
 95		do while Not rs.eof
 96			rowCounter = rowCounter + 1
 97			myXls = myXls &"<tr class='resRow"& (rowCounter mod 2) &"'>"
 98			For i = 0 To rs.Fields.Count - 1
 99				FieldValue = trim(rs.Fields(rs.Fields(i).Name).Value)
100				'if isnumeric(FieldValue) then
101				'FieldValue = 111
102				'end if
103
104				if FieldValue <> "" and not isnumeric(FieldValue) then
105					FieldValue = Server.HTMLEncode(FieldValue)
106				elseif FieldValue = "" then
107					FieldValue = "&nbsp;"
108				end if
109
110				myXls = myXls & "<td >" & Separate(FieldValue) & "</td>"
111			Next
112		%>
113		  </tr>
114		<%
115			rs.MoveNext
116		loop
117	End if
118	rs.Close
119	set rs = nothing
120	conn.Close
121	set conn = nothing
122		
123	myXls = myXls & "</table>"
124	Response.Clear()
125	Response.Buffer = True
126	Response.AddHeader "Content-Disposition", "attachment;filename=" & reportTitle & ".xls"  
127	Response.ContentType = "application/vnd.ms-excel"
128	Response.Charset = "UTF-8"
129	Response.Write myXls
130	Response.End()
131else
132%>
133<CENTER><H3><%=reportTitle%></H3></CENTER>
134	<form METHOD="Post" ACTION="?act=show">
135		<div align="left">
136		<table align=center border="0" cellpadding="0" cellspacing="0" width="300">
137		<tr align="center">
138			<td width="142">date From</td>
139			<td width="190"><input onblur="acceptDate(this)" NAME="dateFrom" size="20"></td>
140		</tr>
141		<tr align="center">
142			<td width="142">date To</td>
143			<td width="190"><input onblur="acceptDate(this)" NAME="dateTo" size="20"></td>
144		</tr>
145		<tr align="center">
146			<td colspan=2>
147				<br><input TYPE="Submit" VALUE="Run Query">
148			</td>
149		</tr>
150		</table>
151		</div>
152	</form>
153
154<%
155end if
156%>
157</body>
158</html>