PLM之家PLMHome-工业软件践行者

【Aras二次开发源码】使用ApplySQL进行快速查询

[复制链接]

2018-8-1 14:16:36 3208 0

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82172
QQ
发表于 2018-8-1 14:16:36 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
* j( z$ }7 n) d, J2 X0 J0 G. q* [
6 [9 y2 K) H; d3 g3 |7 s- ^
* t0 u4 |) ]2 K! f. X4 q, h0 g
Technique  
/ a3 ^0 d) E4 p2 M" h: ?Use the  Innovator.applySQL( … )  method to submit SQL direct to the database.  This
- A, R. b( O6 {7 l9 Y9 `7 zrecipe returns the XML from the  applySQL()  method and forms HTML for a table to 5 ~9 v8 t+ X: E! i  X, x4 o4 Z
display the data. + ^9 p7 g8 j9 R! |* C

6 L, a5 X8 ]: h0 Q
# Q" }: c4 L1 }$ s9 A/ G* G
C#  
4 p- a! u. V  ?* P+ G( a' q5 f$ tInnovator myInnovator = this.newInnovator(); . ?6 X5 }# s& }) ~5 Q. a
Item results = myInnovator.applySQL(
, o+ A; V# Q( {! A  "select login_name,first_name,last_name,email " + . c3 l7 C/ V3 X; E
  "from [user] " + " W' K5 c6 z0 W# C4 u! b% Y5 N8 v9 ~
  "order by last_name,first_name"); ! k) t" ^" b9 u1 n0 h7 C. }

* z6 D0 q6 }1 l+ |string content = "" +
( Q1 L8 i/ ?* {+ n  "<style type='text/css'>" +
+ C* _7 g0 O; g& X    "table {background:#000000;}" +
( [) q* F7 ^: h$ q4 X& a8 C    "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + 4 D* y2 p$ M( E2 k9 W5 E! h- F
    "td {font:normal 10pt Verdana; background:#FFFFFF;}" + 4 @& t. b; U  M" [6 T7 |
    "caption {font:bold 14pt Verdana; text-align:left;}" + 8 v: y& e! M* C; D% k
  "</style>" +
- O  }4 s/ m2 s. o* p' A    "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
# q$ i+ |0 F2 P3 g' u    "<caption>User Directory</caption>" +
1 \- u8 d3 `0 }' {$ |. |    "<thead>" + # O, o2 H% |: {9 Y. ~/ d
      "<tr>" + " J% Z  j! L, ^' i, N
        "<th>Login Name</th>" +
4 I1 k! ^$ v( ^        "<th>First Name</th>" + . S! F) r6 l3 J3 s; H! L
        "<th>Last Name</th>" +
# e) S3 x! f) s        "<th>EMail</th>" +
/ D* p0 F2 n% F      "</tr>" + 4 n+ o. U* j$ ~
    "</thead>" +
% J+ d8 Q4 K2 M3 X4 N    "<tbody>";
4 e! I+ l7 `" D: m8 I4 ^     6 n( m/ K3 ~3 z8 W
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
% n" f+ ?6 T9 ~6 L9 Ofor (int i=0; i<users.Count; i++) {
1 ]5 J- A) D6 b8 d8 V! ^( W& t content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?  
+ ?$ Q  z/ Z3 k                       users.SelectSingleNode("login_name").InnerText : "") + "</td>";   
# w6 c3 [) }" ]6 ^( J0 g3 k   
; Q1 U" H7 q  K" K' z' B content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
$ B& ?! i) d4 G                       users.SelectSingleNode("first_name").InnerText : "") + "</td>";   
8 \4 u  B3 z/ ~" n# z! Z   * p, [( j. ?# E1 i
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
0 C% P3 s; n/ P2 Z" s5 B                       users.SelectSingleNode("last_name").InnerText : "") + "</td>";     t. \% j2 {$ p3 H6 [4 |7 x5 a! t
         1 y5 n. Y1 |+ ^) F, u
content += "<td>" + ((users.SelectSingleNode("email") != null) ?
1 o5 A" r; k, C0 Z                       users.SelectSingleNode("email").InnerText : "") + "</td></tr>";   ; j& o, w3 E9 i) b) Y( B
   
# ^6 W2 d* K9 I* u1 U}
  Y' I1 I. B( N' L 1 E* l/ t! ?6 H7 p5 g/ G6 c
content += "" + ' k2 p% U0 b3 @
    "</tbody>" +
- [" t8 \/ @4 U2 t! J  "</table>"; + n! ^3 H  c) f) F. H! n

: w$ U7 h, L2 I: d# H$ u) Dreturn myInnovator.newResult(content);
( J6 }) m( \6 |& j0 f9 z
) G  n8 p3 i% o- Z" X
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了