|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 N: C/ H4 U& h# t( Y* C
4 R) X7 z1 S0 b9 Y0 C' I
6 |% x3 ]7 U9 q& R$ P' \6 YTechnique
- Z( d9 A$ x) C) j; KUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This * A& j+ A" ^2 I) c5 Y
recipe returns the XML from the applySQL() method and forms HTML for a table to
# t* u. D3 s6 d; n" v \* udisplay the data.
0 j/ B8 m& M; O% G& v$ }9 f! \& J1 _5 \( d
0 p, ^( a. `# p ]' T/ T5 n
C# $ Z, S+ x c5 W& G/ _, T% L
Innovator myInnovator = this.newInnovator();
& k. s% o, R5 U$ {! u: j! y7 IItem results = myInnovator.applySQL( $ @/ L/ s- Q8 I0 R
"select login_name,first_name,last_name,email " + , v' I0 Y$ s3 [0 G7 [! T% n
"from [user] " + ) r& o, B, |. [ m) m5 g: h* G
"order by last_name,first_name"); 9 k5 J3 z9 ?" I+ h8 v2 M1 ?( L
# U. F h, e: J
string content = "" +
1 S4 Y$ Q+ o9 J! w! n+ { "<style type='text/css'>" +
3 G9 [, A/ K- {, A1 d "table {background:#000000;}" +
) D" h& s: o+ { "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + - E6 k2 d: z" ~6 x8 K$ n0 }: u7 U
"td {font:normal 10pt Verdana; background:#FFFFFF;}" +
5 B* G% C( ]+ K3 ?! Z8 Q5 I# B "caption {font:bold 14pt Verdana; text-align:left;}" + : {: }+ v. y2 U
"</style>" + . T& d' U/ }8 F Q! w2 c* U
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
2 D7 g- p9 x0 w. ^/ A) p "<caption>User Directory</caption>" +
' `1 ?. y9 T+ s4 {* O' |" Z "<thead>" +
- a/ G9 ]+ L4 X% ` "<tr>" + 9 J- w+ L8 R2 H. p9 o
"<th>Login Name</th>" +
. b% X3 i" L9 p; l9 M "<th>First Name</th>" + # Y5 _) D. D- b/ P4 |: s4 j
"<th>Last Name</th>" + 2 s6 n) Z" f7 b8 \
"<th>EMail</th>" + ; Q3 O# [0 j$ E: L8 V
"</tr>" +
% @; e+ l5 R* K3 O$ X. y "</thead>" +
; |6 A8 p7 A1 M) n/ h( ?3 [ "<tbody>";
1 X8 m& v( j& a" y
0 H$ `) C- E! ]7 f- DXmlNodeList users = results.dom.SelectNodes("//recordset/row");
! Z- \$ [5 T& y" l/ Ifor (int i=0; i<users.Count; i++) {
1 }, M" G& l: u! l content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
% B! w) a7 h! y" e users.SelectSingleNode("login_name").InnerText : "") + "</td>"; - E% t- n0 z% f* W
; Q$ Z" Q/ S- {2 R [" N2 Q0 ^5 ~
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? ; Y0 w( [2 v7 h: O' t4 Q
users.SelectSingleNode("first_name").InnerText : "") + "</td>"; ) b7 z$ Z. l* @, z$ x" k
+ Z3 D4 D% H& O5 }' { content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? % b; A9 ~# M3 n0 G
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
. w. R* z2 m+ S, E
- y3 b/ F, b, |1 u1 o content += "<td>" + ((users.SelectSingleNode("email") != null) ? ; {! k6 A' f$ W T( P
users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
3 R/ m2 J5 ]8 y1 O/ l ) N# K+ I6 k, a0 J; i/ M1 \
}
3 D _% Z- \* z" F6 F
0 ~; `! ~1 U. }: vcontent += "" +
0 w2 H2 [4 X5 ~3 r "</tbody>" +
% S. {8 k; a. ^9 A "</table>";
' O1 |: k' t% Y0 A4 f# o8 Z; P0 Z + e6 ^( }9 O+ m) _! Y v% r( Z
return myInnovator.newResult(content); ; v- r5 T Q: g5 R' }- O7 u
" [3 D. @3 P$ f4 j9 U! ?0 o% P$ w |
|