|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 ?5 u) }- u, L# L) L( [" Z8 H2 z4 A/ s9 o l
7 s# l1 ?6 ? ~( y* ^7 s8 A" C
Technique
& H, n9 v* y# ~( U$ `6 KUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This
! U9 B1 F/ U2 |1 [1 P8 yrecipe returns the XML from the applySQL() method and forms HTML for a table to % J0 [& a9 s. I$ B0 t9 {* k$ @$ |
display the data.
+ U+ r8 r1 V1 T7 C% K* f+ P* A( Q+ G& U" N/ W- k
: j4 l* N5 r2 C! h$ O
C#
6 F5 |6 Z# b/ jInnovator myInnovator = this.newInnovator(); + t# V! g1 T7 v% _2 m( X
Item results = myInnovator.applySQL( 6 ]1 `, r4 _& ?( f
"select login_name,first_name,last_name,email " +
' P6 d$ r1 Z/ h4 r* D "from [user] " + * d- C- K. P- c4 D, q4 q8 n$ v7 ^
"order by last_name,first_name"); & p& S! ~) k$ y% K) v2 C+ i( ~6 j8 j
7 C/ \& B g2 i2 ~
string content = "" +
' j" ^2 \, b" W3 H8 ` "<style type='text/css'>" + ' {$ I& U3 k( d; x/ W
"table {background:#000000;}" +
) m3 M3 f9 T; t4 S/ x1 d7 M "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
' H4 D+ c$ H/ S% R6 }0 |' @% z "td {font:normal 10pt Verdana; background:#FFFFFF;}" +
- g" H! I- }( k, B1 h' M, F4 N "caption {font:bold 14pt Verdana; text-align:left;}" + / \8 j; D, w1 H3 C
"</style>" +
, M; l0 @" l R* L3 A* \ "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + ' o: y. |8 q$ I
"<caption>User Directory</caption>" + 6 Q# L- z3 @& Q U. i! W% ^
"<thead>" + 2 j% d! A6 v3 ?# c. P
"<tr>" + ' R! w8 V6 T* q" O
"<th>Login Name</th>" +
1 D/ u8 Q0 L5 r$ ?8 T/ m/ f9 v "<th>First Name</th>" +
, p7 f2 z2 K1 Y% { "<th>Last Name</th>" +
0 }' f1 z$ y) W) r6 t "<th>EMail</th>" +
: F% Y9 m" g5 \* y- I "</tr>" +
$ l, ?4 J4 I- D4 a+ L" `' c/ S; W' j "</thead>" +
+ T4 y ^- l9 R! I- B3 h "<tbody>";
6 }3 K5 K: L3 U; ]5 B" c; e' r* u) V8 o
6 ]' [2 P4 v$ ~+ e* y$ E9 ]XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 8 K$ k5 v! ~6 g7 L7 V6 m9 o, W& W
for (int i=0; i<users.Count; i++) { - C" k* Z% H' a# j( W# _6 m
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? % j) a7 R- g$ s% G8 C- k0 y$ D
users.SelectSingleNode("login_name").InnerText : "") + "</td>"; ; y7 q$ z' \ Q: p& X; V5 A
% q! s G+ y* v+ u2 C' @( C content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
7 Q+ E8 U$ D. B1 y3 ~' A users.SelectSingleNode("first_name").InnerText : "") + "</td>"; 2 j8 t- q0 o8 N8 D" C1 O
7 N$ }) Y, k2 S% A2 c" C4 ]- l content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? 5 j) w" e/ ?: @1 ^' B1 A) P' _
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
( E: h: r+ [' [! V3 x# Q2 r
3 m+ T1 P1 l1 G* v" G4 c0 T content += "<td>" + ((users.SelectSingleNode("email") != null) ? % L6 f: N2 ~( U5 v
users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; * n- X2 L* q: i
( d$ |. V0 f* Q/ F$ e$ c T0 Q/ ?1 k
}
F& C+ f, p( l, Y9 o% f# Z " i4 H" E+ L8 ]8 L0 u! s: b% M
content += "" + . N5 k* D6 a% a' U( E- H
"</tbody>" +
+ W0 u' t% Y7 w" h/ T "</table>"; 5 j8 N& G3 a2 s
6 G; ?* R8 `2 _
return myInnovator.newResult(content);
8 k% f) P6 C, t' R7 K9 e* N2 c7 } @5 b& }, J6 [
|
|