|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 B- [( w4 J+ X8 J# Q
( y- C8 u8 a1 O6 a4 o3 _, r2 B% g0 H% t0 |
Technique
1 A3 w) x6 H1 D, nUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This 8 b4 E5 U7 F/ Z
recipe returns the XML from the applySQL() method and forms HTML for a table to
' D1 w( ]' E$ j7 A1 Vdisplay the data. ; k6 I( v3 g) v2 I- ~& O% F
b( ~! G, e1 l( m9 l+ t4 x' H' s; L2 N
C# , A2 |* z% J8 }) h0 T9 C
Innovator myInnovator = this.newInnovator(); 1 i% u- [# P5 m8 d' S
Item results = myInnovator.applySQL( 8 p1 u. e [% J) M( @: s
"select login_name,first_name,last_name,email " + 5 N2 J# `, Z9 R
"from [user] " + [* l) F p( y5 p
"order by last_name,first_name"); 8 n* V% |7 I4 u6 M' y! t$ _; h( B
- D. Y( s u& `7 Y* v
string content = "" + . Q$ L7 \- _. Y3 G& F
"<style type='text/css'>" +
& t1 n3 u c# t0 W, U6 u( e( H w- x "table {background:#000000;}" +
: R$ \" F+ R7 u! i5 s8 w7 t "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
/ O+ n$ y8 d. Y5 X3 z "td {font:normal 10pt Verdana; background:#FFFFFF;}" +
2 Z& Y) \( J6 N "caption {font:bold 14pt Verdana; text-align:left;}" +
4 ^' y/ X3 W9 q5 x9 B! l* L "</style>" +
! u0 _, b; \/ U "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
7 ~. q; q. U! {6 g "<caption>User Directory</caption>" + 5 T/ ~' u" b1 N7 U
"<thead>" +
: K4 ^# w) V7 s2 U. m; l. ? "<tr>" + 9 x1 p2 X9 D5 E, r* w8 A
"<th>Login Name</th>" +
# z2 r/ {. A* @# y& X' i "<th>First Name</th>" + ( f; a/ \9 H @2 |
"<th>Last Name</th>" +
J+ [9 O3 l/ D/ P; d "<th>EMail</th>" +
5 x0 \: p4 ?* L( n/ g "</tr>" + % a& L- b6 Q- C4 `7 I% s; v
"</thead>" +
/ i) {; C1 O' X& B* |) \ "<tbody>";
4 v% k6 q5 X3 E: g$ i* y
) v2 ]5 X4 a4 c$ [1 SXmlNodeList users = results.dom.SelectNodes("//recordset/row");
" A& Y' f% q$ p! K1 ^for (int i=0; i<users.Count; i++) { 1 B, Q* a: D2 i5 b( [2 {
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? ! `. @2 b5 P7 k: z
users.SelectSingleNode("login_name").InnerText : "") + "</td>"; : _! n/ Z$ U9 I/ V- d8 w
# G% w7 V! S9 u( i; Q
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
H0 L9 U& l- e& O* } users.SelectSingleNode("first_name").InnerText : "") + "</td>";
# Q: o% X: c: h
; _, I1 z5 B4 ? content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? % m. F1 i/ q# d& J7 i, Y& G
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
8 s1 O! F6 ~/ m. T 3 E# |/ D, ^4 t! ~5 y( T, F
content += "<td>" + ((users.SelectSingleNode("email") != null) ? 5 S/ P/ S/ w( r9 e! J
users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; ' A+ O- A+ u5 E# t1 G5 W& u
2 F/ ~" ], y2 A, O# U} ! \! Q; I) b8 B
, J; B/ [; a/ n! g6 A2 gcontent += "" + 5 D+ U1 j4 h" `8 P2 ?9 }
"</tbody>" +
: g% O5 G7 ~) q3 _( f% ]* I! a9 C "</table>";
# Q6 q" {/ S% N' b1 ? 2 t. W+ } W" ~$ O4 w
return myInnovator.newResult(content);
: w8 [, J2 S" M; ?$ X, I/ A6 D+ {* h9 X- x
|
|