PageRenderTime 31ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/SQL/scripts/db/content.asp

http://github.com/khaneh/Orders
ASP | 247 lines | 236 code | 10 blank | 1 comment | 0 complexity | ba0ba8fad02200e9cd95c0994080e9a8 MD5 | raw file
  1<!-- #INCLUDE FILE="../inc/mla_sql_include.asp" -->
  2<%
  3	Dim myNodeId, myDbName, myObjName, myObjType, myStrTree, myArrCol, myColCount, i, j, myObjStr, myStrClass
  4	Dim myPgNb, myPgCount, myRecordCount, myStrRootLink, myStrBeginLnk, myStrPreviousLnk, myStrNextLnk, myStrEndLnk
  5	Dim mySortCol, mySortWay
  6	Dim myStrContent, myArrSQL, myObjRS
  7	Dim myStrImg
  8	Dim myStrCol, myStrWhere
  9	Dim myColSpan
 10	Dim myArrPK, ii, myPKFCount, myPKValue, myPKFlag
 11	Dim myStrLink
 12
 13	myNodeId = Request.QueryString("nid")
 14	myDbName = Request.QueryString("db")
 15	myObjName = Request.QueryString("obj")
 16	myObjType = Request.QueryString("type")
 17	
 18	myStrCol = Request.QueryString("col")
 19	myStrWhere = Request.QueryString("cnd")
 20
 21	mySortCol = Request.QueryString("sc")
 22	mySortWay = Request.QueryString("sw")
 23	If mySortWay <> "DESC" Then mySortWay = "ASC"
 24	
 25	myPgNb = Request("pg")
 26	If isNumeric(myPgNb) Then
 27		myPgNb = CLng(myPgNb)
 28		If myPgNb < 1 Then myPgNb = 1
 29	Else
 30		myPgNb = 1
 31	End If
 32	
 33	openConnection
 34	Select Case myObjType
 35		Case "tbl" :
 36			myStrTree = getTreeStr(Mid(myNodeId, 2) & "_1_1", Array(myDbName, myObjName))
 37			myArrPK = getTblPrimaryKey(myDbName, myObjName)
 38			If isArray(myArrPK) Then myPKFCount = UBound(myArrPK, 2)
 39			myStrImg = "table"
 40		Case "view" :
 41			myStrTree = getTreeStr(Mid(myNodeId, 2) & "_2_1", Array(myDbName, myObjName))
 42			myStrImg = "view"
 43	End Select
 44	myRecordCount = getSQLRecordCount(myDbName, myObjName, myStrWhere)
 45	myArrSQL = getSQLstr(myObjName, myStrCol, myStrWhere, mySortCol, mySortWay, mla_cfg_pagesize, myPgNb)
 46
 47	Set myObjRS = Server.CreateObject("ADODB.Recordset")
 48	myObjRS.ActiveConnection = gObjDC
 49	myObjRS.CursorType = 3
 50	myObjRS.PageSize = mla_cfg_pagesize
 51	myObjRS.Open myArrSQL(0)
 52
 53	myColCount = myObjRS.Fields.Count-1
 54	ReDim myArrCol(3, myColCount)
 55
 56	myPKFlag = False
 57	If isArray(myArrPK) Then
 58		' checks whether each PKField was in the SQL query
 59		For i = 0 To myPKFCount
 60			myPKFlag = False
 61			For ii = 0 To myColCount
 62				If myObjRS(ii).Name = myArrPK(0, i) Then 
 63					myPKFlag = True
 64					Exit For
 65				End If
 66			Next
 67			If myPKFlag = False Then Exit For
 68		Next
 69	End If
 70
 71	myPgCount = Int(myRecordCount / mla_cfg_pagesize)
 72	If (myRecordCount MOD mla_cfg_pagesize) > 0 Then myPgCount = myPgCount + 1
 73	If myPgNb > myPgCount Then myPgNb = myPgCount
 74
 75	myStrRootLink = "content.asp?nid=" & myNodeId & "&db=" & Server.URLEncode(myDbName) & "&obj=" & Server.URLEncode(myObjName) & "&type=" & Server.URLEncode(myObjType) & "&col=" & Server.URLEncode(myStrCol) & "&cnd=" & Server.URLEncode(myStrWhere)
 76	If myPgNb > 1 Then
 77		myStrBeginLnk = myStrRootLink & "&sc=" & mySortCol & "&sw=" & mySortWay & "&pg=1"
 78		myStrPreviousLnk = myStrRootLink & "&sc=" & mySortCol & "&sw=" & mySortWay & "&pg=" & (myPgNb - 1)
 79	Else
 80		myStrBeginLnk = Empty
 81		myStrPreviousLnk = Empty
 82	End If
 83	If myPgNb < myPgCount Then
 84		myStrNextLnk = myStrRootLink & "&sc=" & mySortCol & "&sw=" & mySortWay & "&pg=" & (myPgNb + 1)
 85		myStrEndLnk = myStrRootLink & "&sc=" & mySortCol & "&sw=" & mySortWay & "&pg=" & myPgCount
 86	Else
 87		myStrNextLnk = Empty
 88		myStrEndLnk = Empty
 89	End If
 90%>
 91<!-- #INCLUDE FILE="../inc/metaheader.asp" -->
 92<BODY>
 93	<P CLASS="treeinfo"><% = myStrTree %></P>
 94	<FORM NAME="mla_content" METHOD=POST ACTION="<% = myStrRootLink & "&sc=" & mySortCol & "&sw=" & mySortWay %>">
 95	<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 CLASS="content" SUMMARY="Database Information">
 96		<TR><TD CLASS="caption"><IMG SRC="../../themes/<% = mla_cfg_theme %>/images/mylittletree/<% = myStrImg %>.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="MIDDLE" ALT="Content"> <% = myTObj.getTerm(332) %></TD></TR>
 97		<TR><TD>
 98			<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1 CLASS="content" SUMMARY="Query">
 99				<TR><TD CLASS="formlabel" NOWRAP><% = myTObj.getTerm(452) %> :</TD><TD NOWRAP><% Response.Write myArrSQL(1) %></TD><TD WIDTH="100%">&nbsp;</TD></TR>
100				<TR><TD CLASS="formlabel" NOWRAP><% = myTObj.getTerm(453) %> :</TD><TD NOWRAP><% Response.Write myRecordCount %></TD><TD WIDTH="100%">&nbsp;</TD></TR>
101				<TR><TD CLASS="formlabel" NOWRAP><% = myTObj.getTerm(454) %> :</TD>
102					<TD NOWRAP>
103						<A HREF="search.asp?nid=<% = myNodeId %>&db=<% = Server.URLEncode(myDbName) %>&obj=<% = Server.URLEncode(myObjName) %>&type=<% = Server.URLEncode(myObjType) %>"><IMG SRC="../../themes/<% = mla_cfg_theme %>/images/action/search.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="MIDDLE" ALT="<% = myTObj.getTerm(154) %>"></A>
104						&nbsp;
105						<A HREF="<% If myObjType = "tbl" Then Response.Write "tblstruct" Else Response.Write "viewstruct" End If %>.asp?nid=<% = myNodeId %>&db=<% = Server.URLEncode(myDbName) %>&<% = myObjType%>=<% = Server.URLEncode(myObjName) %>"><IMG SRC="../../themes/<% = mla_cfg_theme %>/images/action/property.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="MIDDLE" ALT="<% = myTObj.getTerm(153) %>"></A>
106					</TD>
107					<TD WIDTH="100%">&nbsp;</TD></TR>
108			</TABLE>
109		</TD></TR>
110		<TR><TD>			
111			<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 ALIGN=CENTER CLASS="content" WIDTH="100%" SUMMARY="Content">
112				<THEAD>
113					<%
114						Set myObjStr = New mlt_string
115						myObjStr.strAppend "<TR>" & vbCrLf
116						If myPKFlag Then myObjStr.strAppend "<TD CLASS=""collabel"">&nbsp;</TD>" & vbCrLf
117						For i = 0 To myColCount
118							myArrCol(0, i) = myObjRS.Fields(i).Name
119							myArrCol(1, i) = getColAlign(myObjRS.Fields(i).Type)
120							myArrCol(2, i) = getColSort(myObjRS.Fields(i).Type)
121							myArrCol(3, i) = getColDisplay(myObjRS.Fields(i).Type)
122							myObjStr.strAppend "<TD CLASS=""collabel"">" & myArrCol(0, i) & "&nbsp;"
123							If myArrCol(2, i) Then
124								myObjStr.strAppend "<A HREF=""" & myStrRootLink & "&sc=" & Server.URLEncode(myArrCol(0, i)) & "&sw=ASC""><IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/asc.gif"" WIDTH=13 HEIGHT=9 BORDER=0 ALT=""ASC""></A>"
125								myObjStr.strAppend "<A HREF=""" & myStrRootLink & "&sc=" & Server.URLEncode(myArrCol(0, i)) & "&sw=DESC""><IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/desc.gif"" WIDTH=13 HEIGHT=9 BORDER=0 ALT=""DESC""></A>"
126							Else
127								myObjStr.strAppend "<IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/asc_dis.gif"" WIDTH=13 HEIGHT=9 BORDER=0 ALT=""ASC"">"
128								myObjStr.strAppend "<IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/desc_dis.gif"" WIDTH=13 HEIGHT=9 BORDER=0 ALT=""DESC"">"
129							End If
130							myObjStr.strAppend "</TD>"
131						Next
132						myObjStr.strAppend "</TR>" & vbCrLf
133						Response.Write myObjStr.getStr()
134						Set myObjStr = Nothing
135					%>	
136				</THEAD>
137				<TBODY>
138					<%
139						Set myObjStr = New mlt_string
140						i = 0
141						If myPgCount > 0 Then
142							myObjRS.Move (mla_cfg_pagesize * (myPgNb-1))
143							Do While Not myObjRS.EOF
144								If i MOD 2 = 0 Then myStrClass = "odd" Else myStrClass = "even" End If
145								i = i + 1
146								myObjStr.strAppend "<TR CLASS=""" & myStrClass & """>" & vbCrLf
147								If (mla_auth(1, 10) Or mla_auth(1, 11)) And myPKFlag Then 
148									myObjStr.strAppend "<TD NOWRAP ALIGN=CENTER WIDTH=""40"">"
149									myObjStr.strAppend "<INPUT TYPE=""hidden"" NAME=""mla_pk_value_" & i & """>"
150									myPKValue = ""
151									For ii = 0 To myPKFCount
152										If myPkValue <> "" Then myPKValue = myPKValue & " AND"
153										myPKValue = myPKValue & " [" & rembracket(myArrPK(0, ii)) & "] = "
154										Select Case myArrPK(1, ii)
155											Case 1, 6 :	' STRING and UNIQUEIDENTIFIER
156												myPKValue = myPKValue & "'" & remquote(myObjRS(myArrPK(0, ii))) & "'"
157											Case 4 : ' DATE
158												myPKValue = myPKValue & "CONVERT(DATETIME, '" & str2date(myObjRS(myArrPK(0, ii))) & "', 112)"
159											Case Else : 
160												myPKValue = myPKValue & myObjRS(myArrPK(0, ii))
161										End Select
162									Next
163									myObjStr.strAppend "<SCRIPT LANGUAGE=""JavaScript"" TYPE=""text/javascript"">" & vbCrLf & "<!--" & vbCrlf
164									myObjStr.strAppend "document.mla_content.mla_pk_value_" & i & ".value = """ & remdquote(myPKValue) & """;" & vbCrLf
165									myObjStr.strAppend "//-->" & vbCrLf & "</SCRIPT>"
166									myObjStr.strAppend "</TD>" & vbCrLf
167								End If
168								For j = 0 To myColCount
169									myObjStr.strAppend "<TD ALIGN=""" & myArrCol(1, j) & """>"
170									If isNull(myObjRS(j)) Then
171										myObjStr.strAppend "<SPAN CLASS=""moreinfo"">(" & myTObj.getTerm(60) & ")</SPAN>"
172									Else
173										myStrLink = "txtviewer.asp?db=" & Server.URLEncode(myDbName) & "&tbl=" & Server.URLEncode(myObjName) & "&fld=" & Server.URLEncode(myObjRS(j).Name) & "&pk=" & Server.URLEncode(myPKValue)
174										Select Case myArrCol(3, j) 
175											Case 1 :	' CHAR, NCHAR, VARCHAR, NVARCHAR
176												myStrContent = getStrBegin(myObjRS(j), mla_cfg_maxdisplayedchar)
177												myObjStr.strAppend txt2html(myStrContent(0))
178												If myStrContent(1) Then 
179													If myObjType = "tbl" And myPKFlag Then 
180														myObjStr.strAppend " <A HREF=# onclick=""openPopUp('" & myStrLink & "', 'moreinfo', 400, 400, 10, 10); return(false);"" CLASS=""moreinfo"">(...)</A>"
181													Else
182														myObjStr.strAppend " <SPAN CLASS=""moreinfo"">(...)</SPAN>"
183													End If
184												End If
185											Case 2 :	' TEXT, NTEXT
186												myStrContent = getStrBegin(myObjRS(j), mla_cfg_maxdisplayedchar)
187												myObjStr.strAppend txt2html(myStrContent(0))
188												If myStrContent(1) Then 
189													If myObjType = "tbl" And myPKFlag Then 
190														myObjStr.strAppend " <A HREF=# onclick=""openPopUp('" & myStrLink & "', 'moreinfo', 400, 400, 10, 10); return(false);"" CLASS=""moreinfo"">(...)</A>"
191													Else
192														myObjStr.strAppend " <SPAN CLASS=""moreinfo"">(...)</SPAN>"
193													End If
194												End If
195											Case 3 :	' BINARY, VARBINARY, IMAGE
196												myStrContent = bin2hex(myObjRS(j), mla_cfg_maxdisplayedbin)
197												myObjStr.strAppend txt2html(myStrContent(0))
198												If myStrContent(1) Then myObjStr.strAppend " <SPAN CLASS=""moreinfo"">(...)</SPAN>"
199											Case Else :	' ALL OTHERS
200												myObjStr.strAppend myObjRS(j)
201										End Select
202									End If
203									myObjStr.strAppend "</TD>" & vbCrLf
204								Next
205								myObjStr.strAppend "</TR>" & vbCrLf
206								myObjRS.MoveNext
207							Loop
208						End If
209						myObjRS.Close
210						Set myObjRS = Nothing
211						closeConnection
212						Response.Write myObjStr.getStr()
213						Set myObjStr = Nothing
214					%>
215				</TBODY>
216				<THEAD>
217					<%
218						Set myObjStr = New mlt_string
219						If myObjType = "tbl" And isArray(myArrPK) Then myColSpan = myColCount + 2 Else myColSpan = myColCount + 1 End If
220						myObjStr.strAppend "<TR><TD CLASS=""collabel"" COLSPAN=" & myColSpan & ">"
221						If isEmpty(myStrBeginLnk) Then
222							myObjStr.strAppend "<IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/begin_dis.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""Begin"">"
223							myObjStr.strAppend "<IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/previous_dis.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""Previous"">"
224						Else
225							myObjStr.strAppend "<A HREF=""" & myStrBeginLnk & """><IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/begin.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""Begin""></A>"
226							myObjStr.strAppend "<A HREF=""" & myStrPreviousLnk & """><IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/previous.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""Previous""></A>"
227						End If
228						myObjStr.strAppend "<INPUT TYPE=""text"" NAME=""pg"" VALUE=""" & myPgNb & """ CLASS=""numeric"" TITLE=""Page"" >"
229						myObjStr.strAppend " / " & myPgCount
230						If isEmpty(myStrEndLnk) Then
231							myObjStr.strAppend "<IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/next_dis.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""Next"">"
232							myObjStr.strAppend "<IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/end_dis.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""End"">"
233						Else
234							myObjStr.strAppend "<A HREF=""" & myStrNextLnk & """><IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/next.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""Next""></A>"
235							myObjStr.strAppend "<A HREF=""" & myStrEndLnk & """><IMG SRC=""../../themes/" & mla_cfg_theme & "/images/action/end.gif"" WIDTH=16 HEIGHT=16 BORDER=0 ALIGN=MIDDLE ALT=""End""></A>"
236						End If
237						Response.Write myObjStr.getStr()
238						Set myObjStr = Nothing
239					%>
240				</THEAD>
241			</TABLE>
242		</TD></TR>
243	</TABLE>
244	</FORM>
245</BODY>
246</HTML>
247<!-- #INCLUDE FILE="../inc/mla_sql_end.asp" -->