|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' ~! [* |- P X4 I, R
& W3 I) B( ~9 x' E5 q8 W9 Y
# |* W, ^1 R. c$ K k/ lTechnique
+ |6 F6 ]+ ] ~; ~Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This 0 A$ y! x& U: n- M% v$ x, w+ j
recipe returns the XML from the applySQL() method and forms HTML for a table to % W V" B+ @% f" k
display the data.
D0 n7 J% p4 S* j# t( v+ E0 y. x+ C6 g" [8 `4 L
! i) }4 I3 c* m2 v! J! `C# _: m* Y* ~: M9 L% f; X' a1 |
Innovator myInnovator = this.newInnovator();
j- n* p& c: U! eItem results = myInnovator.applySQL(
1 C1 t% r" b. [ i& A "select login_name,first_name,last_name,email " + 5 g0 x; E N% W2 \. \
"from [user] " +
- W- i9 B) s, N0 l+ N$ g "order by last_name,first_name"); : M) o0 r8 ]+ o) `! \
7 I1 Y7 Y& K6 N) H2 k4 P J
string content = "" +
# {5 C U' Z9 p1 Y# M9 F "<style type='text/css'>" +
! \0 m4 }; k }# P "table {background:#000000;}" + ' m0 K" R: N8 y
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + , C0 F6 y% B# h: Z6 z' T
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + 1 w% U# |9 i2 e8 q" A2 S3 C
"caption {font:bold 14pt Verdana; text-align:left;}" + % _% i7 i5 G m9 E
"</style>" + % X9 T' n/ u& ~; \
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + O" l! Z4 X i
"<caption>User Directory</caption>" + ! f& I* @4 A2 i
"<thead>" +
! A/ |4 D( u; W7 p: j( D "<tr>" + ( D, A4 v+ ]( D6 _
"<th>Login Name</th>" +
$ i D7 @$ s' a6 ~( U "<th>First Name</th>" +
) w# O$ ^3 l0 |$ Y; |, t! e1 z "<th>Last Name</th>" +
! c: M; G8 k1 O "<th>EMail</th>" +
9 z* e& [: T- H5 K R; v0 U& K, H "</tr>" +
/ g" T% c5 H H& ^4 R2 ?* m "</thead>" + / Y$ t1 @- U/ E/ N
"<tbody>"; % y- S" Y6 b( h1 m. Q. Y' E! @
$ j- I+ R( v5 v$ L5 H& ~4 l
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
' `- m6 s3 M Sfor (int i=0; i<users.Count; i++) {
5 t2 `% M! }1 ~9 F content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
2 x" v# g ^$ y# W0 |. k users.SelectSingleNode("login_name").InnerText : "") + "</td>"; " ]: r6 N+ n) I8 f4 x* e o, H. |
1 ~4 h {1 g. T# C content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? 2 a6 k9 Z2 y' i6 u3 F' S9 n0 d% e/ ?" T
users.SelectSingleNode("first_name").InnerText : "") + "</td>"; - \% s6 X9 [( e) C' r6 c
; N$ r: i7 K' J9 k# m$ t& H content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
1 i0 B0 G" N/ U3 U1 _7 ^ users.SelectSingleNode("last_name").InnerText : "") + "</td>"; / |- c8 X& H& L2 p
; H* n n$ N+ N e1 y9 A' S! W
content += "<td>" + ((users.SelectSingleNode("email") != null) ? 4 K' }' U1 `/ ]( D# W, E
users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
# D- P n6 v9 @" C4 u
+ ?" {' X G( H: q} 5 f, [+ \' a) x' @' G
- r _( E' b0 `. o. {$ f' O
content += "" + 6 R% S) e2 b! ?9 J' A
"</tbody>" +
1 h3 w$ _8 N/ f) Y, P "</table>"; + w# \/ c$ O: }' I0 M
3 B+ w1 g7 b/ b) Q2 dreturn myInnovator.newResult(content); , A/ X. T$ V1 j1 S0 ^" _
2 D; x: ^2 y8 W3 f* h |
|