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

【Aras二次开发】查询和迭代查找item集

[复制链接]

2018-8-1 13:37:47 1574 0

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

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

x
2 ~8 C+ V( g7 H6 R8 d$ N0 C% s
5 R5 `( r) T% R7 v( L2 v$ h
8 a( t& d" V+ E& k, x" @
6 f, P1 K# k: m( H  X
Technique  , A) k( P# C- O- p) ^
There is no difference in setting up a query for a single Item or for many.  Only the * R! M/ c% g! ]
criteria define the set size returned.  In this recipe you create an Item and populate - j% L3 k. z6 B4 e6 w5 {5 b0 o, Z
the query criteria, apply it, and iterating over the Items returned producing a HTML
( d6 ^4 T' v! Z$ W0 M4 ^0 V<TABLE>  fragment. ! p% o0 [6 }! \
! U) ?; K$ h5 y' ~

& i9 M3 N; g  V9 @5 O0 A" k5 s4 }+ EJavaScript  
% L5 M- }' _/ j- |* D" j2 wvar qryItem = this.newItem("Part","get"); - [& y2 Q. n; p, T( N
qryItem.setAttribute("select","item_number,description,cost");
4 _9 f# v8 U( z! N6 j+ k2 w3 NqryItem.setProperty("cost", "100", "gt");
3 w; [) p& D& Svar results = qryItem.apply();
4 N1 G! y' r1 k, F! U1 E( R$ Gvar count = results.getItemCount();
2 M* W7 N. l" R  P. R( yvar content = "<table>"; 6 b( H2 e& K4 k! \9 J
for (var i=0; i<count; ++i) 2 X" l( [7 }: K4 R( l( i: d
{ : a1 S, Y7 d+ S8 `- w$ }
  var item = results.getItemByIndex(i);
8 k- Y  _) [! K  content += "" +
2 z- b* k- n+ K$ }# t    "<tr>" +
. q9 \1 }6 `& H( Z9 K      "<td>" + item.getProperty("item_number") + "</td>" +
/ o" f5 A, g+ s+ p2 N6 ^      "<td>" + item.getProperty("description") + "</td>" + * I( n6 l$ |/ M
      "<td>" + item.getProperty("cost") + "</td>" + 0 J) C' Y+ D+ l6 {) {/ Y6 H& N
    "</tr>";
/ L- ~& e( q1 i) b% A# U' ]0 P& g}
& X; \* [; h5 Y6 r/ K$ E  ?- J* Zcontent += "</table>"; % d5 ~1 h! Z2 C2 g8 e8 H7 w
return content; : \. C( w+ a5 B  O% p
8 l3 P; l9 Q+ [2 }& e4 i) r9 d
C#  6 z& Z  v; R0 t; z' ^  w
Item qryItem = this.newItem("Part","get");
2 Y5 L  z+ \4 P: ]" ^qryItem.setAttribute("select","item_number,description,cost"); 6 v) l7 c  j6 \
qryItem.setProperty("cost", "100", "gt");
, d5 N1 ]# K! \2 e; K# IItem results = qryItem.apply();
+ h' c  Q7 }3 k- f% F3 `* fint count = results.getItemCount();
0 F: }0 m0 k$ U6 @! B: Aint i;
* J0 K3 A* M) i& nstring content = "<table>"; 4 W/ M* C: T% m/ D+ S8 A
for (i=0; i<count; ++i)   F% E% I7 O, y/ }5 a2 I$ C
{
9 q6 N5 c( K( l4 m4 T  Item item = results.getItemByIndex(i);
3 H7 c2 ?- Q; e! K. B  {2 Q0 ^  content += "" +
3 A' I! r" ]) g% ?. Z% H    "<tr>" +
4 i, o! d+ ~# @# f      "<td>" + item.getProperty("item_number") + "</td>" +
: @8 k' o$ S+ V. l" w  h      "<td>" + item.getProperty("description") + "</td>" +
2 V) Y2 ]* Q& B2 H! B# G+ W) B7 T      "<td>" + item.getProperty("cost") + "</td>" +
3 u& S: f8 b1 Y+ _: U& Z- X  b    "</tr>";
1 o2 A( z7 c# h( ?% z; N} 9 B: h$ M  F/ w0 Q* J% s2 I
content += "</table>";
9 |5 o4 P) d- B1 a6 qInnovator innovator = this.newInnovator(); ; N. x; j! ^7 b3 W  L, @( _
return innovator.newResult(content);
$ x  S' Z0 h8 y( K6 J$ c
# h+ Z  r2 f# o  G$ jVB.Net  
9 A5 [/ Z5 E# f$ lDim qryItem As Item = Me.NewItem("Part","get") 4 h  s; Z* W4 _3 J
qryItem.SetAttribute("select","item_number,description,cost")
6 F0 _( Y5 E2 P7 v1 I+ T* iqryItem.SetProperty("cost", "100", "gt")
7 t9 W" p3 k& K# s6 m2 V- v. GDim results As Item = qryItem.Apply() ( x+ s1 k0 M' H6 c5 s
Dim count As Integer = results.GetItemCount() 4 Q. q) x( l/ j( ]1 |3 K
Dim i As Integer
* D6 F& a, W( |Dim content As String = "<table>"
7 z- W4 ^" Z8 j" j2 e, pFor i=0 to count - 1 5 B5 |6 d' z: G& L. R7 ^- Z
  Dim item As Item = results.GetItemByIndex(i) ' M- m- D. R) ?3 U" l$ W: |4 L
  content += "" + _
! t( G* S! t# f/ a2 S. y6 i    "<tr>" + _
5 e( |  Q. p* l6 ]      "<td>" + item.GetProperty("item_number") + "</td>" + _ + N' m2 t  E+ k3 [  a5 n; l* Z' P$ F
      "<td>" + item.GetProperty("description") + "</td>" + _
2 B: s% j7 D4 z! ~      "<td>" + item.GetProperty("cost") + "</td>" + _
3 H7 z% O/ s8 Q7 }9 z5 K* ~: G9 W    "</tr>" ) k& z2 _; v4 D6 |& g3 B2 j& M
Next
- T1 d$ M% @8 x" ncontent += "</table>" . R6 @/ o$ d. t7 V! Q

: w( y, k4 r& a: T* dDim innovator As Innovator = Me.NewInnovator()
% p6 U9 K% |' t1 \* z) h* Jreturn innovator.NewResult(content)
( X; ?& M- S4 L3 p4 v! }- v) R
/ s' j. T+ R0 |  Q. b5 K) {6 Z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了