|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* j( z$ }7 n) d, J2 X0 J0 G. q* [
6 [9 y2 K) H; d3 g3 |7 s- ^
* t0 u4 |) ]2 K! f. X4 q, h0 g
Technique
/ a3 ^0 d) E4 p2 M" h: ?Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
- A, R. b( O6 {7 l9 Y9 `7 zrecipe returns the XML from the applySQL() method and forms HTML for a table to 5 ~9 v8 t+ X: E! i X, x4 o4 Z
display the data. + ^9 p7 g8 j9 R! |* C
6 L, a5 X8 ]: h0 Q# Q" }: c4 L1 }$ s9 A/ G* G
C#
4 p- a! u. V ?* P+ G( a' q5 f$ tInnovator myInnovator = this.newInnovator(); . ?6 X5 }# s& }) ~5 Q. a
Item results = myInnovator.applySQL(
, o+ A; V# Q( {! A "select login_name,first_name,last_name,email " + . c3 l7 C/ V3 X; E
"from [user] " + " W' K5 c6 z0 W# C4 u! b% Y5 N8 v9 ~
"order by last_name,first_name"); ! k) t" ^" b9 u1 n0 h7 C. }
* z6 D0 q6 }1 l+ |string content = "" +
( Q1 L8 i/ ?* {+ n "<style type='text/css'>" +
+ C* _7 g0 O; g& X "table {background:#000000;}" +
( [) q* F7 ^: h$ q4 X& a8 C "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + 4 D* y2 p$ M( E2 k9 W5 E! h- F
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + 4 @& t. b; U M" [6 T7 |
"caption {font:bold 14pt Verdana; text-align:left;}" + 8 v: y& e! M* C; D% k
"</style>" +
- O }4 s/ m2 s. o* p' A "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
# q$ i+ |0 F2 P3 g' u "<caption>User Directory</caption>" +
1 \- u8 d3 `0 }' {$ |. | "<thead>" + # O, o2 H% |: {9 Y. ~/ d
"<tr>" + " J% Z j! L, ^' i, N
"<th>Login Name</th>" +
4 I1 k! ^$ v( ^ "<th>First Name</th>" + . S! F) r6 l3 J3 s; H! L
"<th>Last Name</th>" +
# e) S3 x! f) s "<th>EMail</th>" +
/ D* p0 F2 n% F "</tr>" + 4 n+ o. U* j$ ~
"</thead>" +
% J+ d8 Q4 K2 M3 X4 N "<tbody>";
4 e! I+ l7 `" D: m8 I4 ^ 6 n( m/ K3 ~3 z8 W
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
% n" f+ ?6 T9 ~6 L9 Ofor (int i=0; i<users.Count; i++) {
1 ]5 J- A) D6 b8 d8 V! ^( W& t content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
+ ?$ Q z/ Z3 k users.SelectSingleNode("login_name").InnerText : "") + "</td>";
# w6 c3 [) }" ]6 ^( J0 g3 k
; Q1 U" H7 q K" K' z' B content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
$ B& ?! i) d4 G users.SelectSingleNode("first_name").InnerText : "") + "</td>";
8 \4 u B3 z/ ~" n# z! Z * p, [( j. ?# E1 i
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
0 C% P3 s; n/ P2 Z" s5 B users.SelectSingleNode("last_name").InnerText : "") + "</td>"; t. \% j2 {$ p3 H6 [4 |7 x5 a! t
1 y5 n. Y1 |+ ^) F, u
content += "<td>" + ((users.SelectSingleNode("email") != null) ?
1 o5 A" r; k, C0 Z users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; ; j& o, w3 E9 i) b) Y( B
# ^6 W2 d* K9 I* u1 U}
Y' I1 I. B( N' L 1 E* l/ t! ?6 H7 p5 g/ G6 c
content += "" + ' k2 p% U0 b3 @
"</tbody>" +
- [" t8 \/ @4 U2 t! J "</table>"; + n! ^3 H c) f) F. H! n
: w$ U7 h, L2 I: d# H$ u) Dreturn myInnovator.newResult(content);
( J6 }) m( \6 |& j0 f9 z
) G n8 p3 i% o- Z" X |
|