|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 a# v( t: U% K' v8 O! z' P) _
% p b0 `2 I6 s$ @" _% M" O8 {
$ [& r6 m1 R* P1 t1 k0 FTechnique
: c7 |1 C) a3 _* Q, s. a$ WUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This
+ G" p& z. M# }recipe returns the XML from the applySQL() method and forms HTML for a table to 2 c! t0 d s+ v' O9 r" d( m
display the data. ( [5 J. O6 m) A L
0 F0 e" U! q8 @: r0 n$ N+ R
; D% ^+ o2 |6 ~3 P+ x4 MC# $ k( H# @8 x9 V" S) E
Innovator myInnovator = this.newInnovator(); ; V! K+ B& |4 H: D
Item results = myInnovator.applySQL(
- R* i- P3 ~9 d8 k6 v "select login_name,first_name,last_name,email " + 4 n: w# w5 C3 {; m
"from [user] " +
?( M9 P" j+ b* Y N. q/ o: _ "order by last_name,first_name");
3 ^1 l8 A* _4 |* H
; v" M+ ~( b4 C4 Y$ P2 {$ V" Q8 R) hstring content = "" +
9 K4 z8 u5 N: Z, z6 p "<style type='text/css'>" +
* Y# U& U4 {8 w. W "table {background:#000000;}" +
) o4 g4 e3 P7 E! d; ~ "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
3 z% o! I7 d3 E. W9 q, a P "td {font:normal 10pt Verdana; background:#FFFFFF;}" + 9 l, s) y4 ~1 m k) q ~9 Q
"caption {font:bold 14pt Verdana; text-align:left;}" + - g" g2 Q+ ?* J& B, u0 Y
"</style>" + 1 D% f: ?: J& y! a) ~
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
- `( I$ m# P" n7 f V "<caption>User Directory</caption>" +
& X$ C2 Z, ?0 y0 T3 _! ^6 V4 C "<thead>" +
6 C7 E/ R" R2 U "<tr>" +
! @$ ~, e+ {! k# z) Y& ^3 A "<th>Login Name</th>" +
! j9 U3 k* m4 O6 x* c {( o2 @7 { "<th>First Name</th>" +
2 v; x2 c& o( r" @% G, m "<th>Last Name</th>" + $ S+ R2 g. \: d9 e0 r$ U4 i% ^7 N
"<th>EMail</th>" +
+ P6 N) e" J" `% n! Y; |5 R* J- O: | "</tr>" +
" U) d2 ^* [2 ^ T5 e" a5 q2 D "</thead>" +
4 g1 w' O2 u8 ` "<tbody>"; 3 p @7 a3 p# G! v# W
Q( f1 e: I* S B
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
; @$ J/ h4 G' I% ?4 N/ r2 qfor (int i=0; i<users.Count; i++) {
3 K$ A! J! Q. [1 W) Y) O content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? 9 c% y. ~0 r# c3 I( @8 @
users.SelectSingleNode("login_name").InnerText : "") + "</td>"; ) A3 D V5 S9 H: h) ^ v
8 j! [$ F/ n3 n5 K4 i content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? + y* k2 y9 o2 u& J6 a7 Q
users.SelectSingleNode("first_name").InnerText : "") + "</td>";
+ \8 i7 y, ^% x1 o7 [/ k2 l. w" h1 @
; \7 b A) H1 [ t/ q, G/ H content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? 3 D$ g; G: A+ L& c: ]
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; ) g+ Z) D% B" U3 F; _/ ^3 H7 ~
% ~8 ~/ J5 k% y5 {% Z
content += "<td>" + ((users.SelectSingleNode("email") != null) ? 1 u# }5 ?6 m9 d
users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
4 d7 m* T; H) B% k6 b" B1 E3 Y* T
6 y% l" ~1 A) y: a}
& v' G9 O5 c# a. @! g 4 w! k+ p8 v" N4 B+ D
content += "" +
' i2 D0 n4 i3 |& g1 z "</tbody>" +
' t! b+ h2 Y6 { o4 o* G: L "</table>"; , v1 i1 k/ _0 I3 P
8 H! S; d! l, d1 E( p& s. S* breturn myInnovator.newResult(content); + E( u2 {- L0 e g: c: S. t) { R# f
8 \9 L; W: {1 v8 x% y$ D* }
|
|