|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; n4 ?! i- D/ }" r& `9 d
0 N& { u0 v' ?7 W' i M4 g1 H
1 d2 [* g4 P# }Technique # }+ f5 C+ V; r; H% ^
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
5 p& @0 Z; _3 u( | Y- ^ W( krecipe returns the XML from the applySQL() method and forms HTML for a table to * k5 Q1 _, N$ q8 H
display the data.
4 y7 `( k) a% E; W! c- K
2 I8 u/ R- C' f% _- F
& B+ Q0 ?' i, l' I) y. iC#
' \8 H7 A p% Y6 d2 x* AInnovator myInnovator = this.newInnovator();
9 h+ |$ P9 h! kItem results = myInnovator.applySQL(
5 U( O9 H; m+ a6 C& n( e "select login_name,first_name,last_name,email " +
; y" i# x% e4 U( U% p$ z# E. l "from [user] " + 0 E& K x O' \* k+ j8 R! L
"order by last_name,first_name"); ) F+ d2 A6 E ]) `8 N& {
' _1 u% T& W, C8 J$ Q# f* g
string content = "" +
) M- t( B( y9 Q% u$ C8 ?" m "<style type='text/css'>" +
6 L6 a+ ^; o. f" ~& L "table {background:#000000;}" +
" u3 [; { } P5 M& ?, |, P "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
' W, C& }" ^ ?' I% T- m! V "td {font:normal 10pt Verdana; background:#FFFFFF;}" + , q4 T8 K3 I+ ^
"caption {font:bold 14pt Verdana; text-align:left;}" + 1 P z) e% R/ V- _" C' L
"</style>" + ) }1 a; m8 ^7 R! N8 B3 U
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + & c) [% O' E, }' B" {
"<caption>User Directory</caption>" +
8 H2 W+ B7 R% P: l3 N! R3 z$ l) y "<thead>" +
1 n& f9 {! A5 p' m) w/ y& h "<tr>" +
6 y$ j6 y0 y. C8 T/ V/ D "<th>Login Name</th>" + ; z* N% y4 R6 F% u8 W: z
"<th>First Name</th>" + 7 G" I* _) d' j4 D4 [7 A; t( C
"<th>Last Name</th>" +
2 n% W7 S# d( U D "<th>EMail</th>" + $ X+ D0 i, k( S
"</tr>" +
' V) J3 n8 a" s! i# |+ I& a& [ "</thead>" + ; J5 N+ x$ A$ g; V- W8 m
"<tbody>";
* H% A& i* n4 q3 o, z # ?: p& S$ A C* ^: H
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
9 Z1 Z' r9 p, k1 ^* Hfor (int i=0; i<users.Count; i++) { / k0 H6 T N# H
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? + m0 S/ M& f6 g. c' s
users.SelectSingleNode("login_name").InnerText : "") + "</td>";
7 e+ F8 l0 e! I. s7 F
* ^" \& P. D5 B$ V" _ content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? U: j# `, f W8 X8 m$ X
users.SelectSingleNode("first_name").InnerText : "") + "</td>"; ' n9 ^4 ~, s3 K. z% |# N$ o" E: H
" F$ K1 u( O" e# M content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? , b( _6 h$ q4 m5 {% I
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
( f, n: p5 D$ F7 G" d - \% \# p/ U2 [6 ]& j: J" h! ^
content += "<td>" + ((users.SelectSingleNode("email") != null) ?
. A3 D1 C2 o% H users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
' d! |/ M- B" s) i. F- W1 H9 b 2 l) m/ p/ X9 T6 A+ q2 R; s; e
} & t8 a1 E) Y! O
3 j8 ]7 E$ Z6 c- qcontent += "" + , t7 _# W+ [3 Z* z. ?
"</tbody>" +
8 J& |% o- M& `1 p) T+ p: k- X) H "</table>"; $ h0 A# O- Q9 g% \; e* F0 [
! X l. l$ V' t3 `* z
return myInnovator.newResult(content);
' l) r+ h/ t' N) c! H
% {8 y$ [- j, y* V; J8 [ |
|