|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
$ ?, Y6 S+ P t3 e! f! t+ Y- i# k: _0 ]$ [+ h5 V, }6 H" P8 j
# Y% W6 ^8 d4 @" j8 h5 N* Q
Technique
7 J8 E& L, ~0 m! J: X6 s5 LUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This
3 L7 }2 o( u$ c4 W8 J' J. A& trecipe returns the XML from the applySQL() method and forms HTML for a table to
% ]! E- e3 G7 H: g/ ndisplay the data. 7 z8 R$ X+ q' ^: }
6 O# d( J9 y* X: Y0 K
3 e' d L& D. u. fC# ; T" H9 T' ]2 c8 @; ?" U
Innovator myInnovator = this.newInnovator();
4 }$ n$ S" P0 D: \1 U }Item results = myInnovator.applySQL(
2 m) ~. ^- J+ t "select login_name,first_name,last_name,email " + / j$ k# F" | P/ I5 ?0 u# U; G
"from [user] " + * |3 T: o" i+ m; Y' ~7 t
"order by last_name,first_name"); ' o7 p' f- [7 @
/ \0 t" f' i* R* a3 e6 ]
string content = "" +
9 i- E5 o% L2 C* G3 O+ e "<style type='text/css'>" + & C, M# M* m# Q9 j5 F
"table {background:#000000;}" + 6 q5 J3 J7 A: o; Q+ N, \
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + # h# [$ I4 y' G
"td {font:normal 10pt Verdana; background:#FFFFFF;}" +
. _# Q s. ^5 V7 o2 M "caption {font:bold 14pt Verdana; text-align:left;}" + & E% K3 [9 r. k- w: H* b
"</style>" +
% c* s: E9 a- h "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
0 Y) d' ?: ~/ e/ I7 ^1 e' l "<caption>User Directory</caption>" +
( V$ u4 d$ R* C+ W "<thead>" +
7 }# e0 M9 M' `2 N1 S) V) \ "<tr>" + - b$ ~8 \& C4 ^! }
"<th>Login Name</th>" + + e4 k0 T# C4 e! P% b1 c9 ~, L3 F
"<th>First Name</th>" + / _. _$ [" ?( Y* s; A
"<th>Last Name</th>" + % }: g3 N- z/ W$ u5 l
"<th>EMail</th>" +
3 z6 y* O9 [6 \- f6 g "</tr>" + " i' \4 k v$ T' H4 u8 ]& }
"</thead>" + - A# w) c( R+ Y7 l5 h9 r
"<tbody>"; * }6 t0 A1 L3 ]/ B3 P! _% N
. r) `' H/ Z; c6 x* p# I# U+ G
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 7 q, s3 Z2 e7 ?, W; s3 Q
for (int i=0; i<users.Count; i++) {
7 I/ @3 i/ w9 _2 g* j I) M# u content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? 9 Z4 }/ j) d1 ^5 w6 W$ G
users.SelectSingleNode("login_name").InnerText : "") + "</td>";
9 E! E1 |7 k+ L% I6 p0 \: c0 v % A- F* t$ j1 r7 l5 r& C- A: ^, J
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
& M9 C5 G- e2 G8 y, V: X users.SelectSingleNode("first_name").InnerText : "") + "</td>";
+ H6 F4 z7 f3 O8 _5 j7 A! P- @% E P
8 k: { g# ]; k; { content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? , y6 ^ P& z& P* n; W, f; A4 G
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; " U2 T2 e1 r% s% @7 d+ Z
! f$ B* }" v1 R, Y9 ? content += "<td>" + ((users.SelectSingleNode("email") != null) ? ) y; s! n* w8 e4 x1 @% I
users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
l) o8 q- P b7 n+ }/ Z& b: U9 ]! r 7 ?1 \5 K z1 ~$ u& _
} % k8 C* ?; k2 y Y( b8 P, I
+ H2 L7 B: F/ J9 m) Y
content += "" +
1 f: ]2 w! h& k$ d: V6 ? "</tbody>" +
J$ W4 s: B' i. c "</table>"; . H+ A/ z, z+ e5 r6 b
# _# }: E" C' [* k7 O; ureturn myInnovator.newResult(content); 5 |8 e; I2 d8 b( K) w: A) v) W0 y/ `
1 i. }" F4 B$ @: Z3 z! D
|
|