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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x

  M. E& |9 N' S* |  }9 C1 @0 Y5 N7 A) Z

  M' ?( z% `+ R$ xTechnique  $ ]' I- y/ T5 Y" S+ w/ N
Use the  Innovator.applySQL( … )  method to submit SQL direct to the database.  This
) w4 y0 ]+ U7 Z% B& Yrecipe returns the XML from the  applySQL()  method and forms HTML for a table to % l4 w7 @8 L# a
display the data.
' n7 `  X. V% s# R; Q/ g2 U. x- g
9 e5 a7 @! {5 \! P
, E, K8 ^. K9 O0 o
C#  
3 {- q) M; c! Z* c& j0 \9 g+ IInnovator myInnovator = this.newInnovator();
7 V9 V7 x. l8 g% xItem results = myInnovator.applySQL( ) m- M% I$ ^( P% H) Z
  "select login_name,first_name,last_name,email " +
* N0 U: _- n6 x! d- S5 F: D  "from [user] " + * g, D; Y) @1 s2 i7 E+ f" I
  "order by last_name,first_name");
; M# c) V9 r: J - h6 h) ?% [. _
string content = "" +
4 Y* ?( u. S$ y+ i  t' l  "<style type='text/css'>" +
: ~  S" [1 ~# ]; F    "table {background:#000000;}" + 3 s  ?; n0 h6 i* V
    "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
: z8 L9 n; F( I    "td {font:normal 10pt Verdana; background:#FFFFFF;}" +
" p+ L% }6 M9 e/ d, u    "caption {font:bold 14pt Verdana; text-align:left;}" + 3 A0 T* T( o) M, }
  "</style>" + , Z! \- x5 f% N6 y; P
    "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
% |! b, ~' b$ w4 S# \    "<caption>User Directory</caption>" + ) p" O+ d& _7 V1 D
    "<thead>" +
* X6 K- D( a# o( ]+ b( d. a  d8 X      "<tr>" + , P# H0 [8 G1 ^8 e; h( `( @
        "<th>Login Name</th>" + $ R& G7 \' q1 N- Z4 d
        "<th>First Name</th>" +
# I9 M* Q- ?6 ?) B% p( I" _        "<th>Last Name</th>" +
/ G5 I0 C* f4 r        "<th>EMail</th>" +
7 O0 @# G4 t5 [8 p      "</tr>" +
3 U2 n- w& j$ m( l7 I% `    "</thead>" +
) I+ I* K! l! v: {1 L. G    "<tbody>"; , h6 L6 O1 u3 [! }# z* ~
     / Z6 h0 i$ O- H" Y8 z
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
" n* ~3 m* f3 g( Q/ q5 H1 a0 Rfor (int i=0; i<users.Count; i++) {
& d1 J. I5 o$ a2 U content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?  $ O/ l/ W; h: P1 F5 n) x! o
                       users.SelectSingleNode("login_name").InnerText : "") + "</td>";   6 d- J- u; g$ o& B& X3 k6 p0 q+ x
   - i, E: s; t" Y( ?
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
2 W' n. ~# d% c* e' l- B) \                       users.SelectSingleNode("first_name").InnerText : "") + "</td>";   
/ Y; J5 U9 \: u5 e- Z8 v   
- ?0 B* Q$ ]+ z- y2 ]# n# @ content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? / s& _; R, H$ r4 L
                       users.SelectSingleNode("last_name").InnerText : "") + "</td>";   - a8 Y8 \$ T* ^$ _
         + h0 J) b0 W% I
content += "<td>" + ((users.SelectSingleNode("email") != null) ? ' y. e1 [. C# D# U
                       users.SelectSingleNode("email").InnerText : "") + "</td></tr>";   
/ f- ?+ |0 c* _/ U6 V   % e; A* [$ Y$ P; Z, ]
} 5 R4 ~8 o" g& `' W
; N3 n3 A( }+ T0 |( R1 h5 V- p
content += "" +
  G3 R& J- E# F( c" p    "</tbody>" +
' N; W8 k, y* g0 _4 H9 y  "</table>";
' T1 n% v6 s* u; S3 B. B* s' F4 T 0 g5 I4 ]" E' p8 j  F/ `
return myInnovator.newResult(content); 2 P3 Z, ?6 X) L% a

- B3 \7 J- L- M0 c, t: g
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了