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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82172
QQ
发表于 2018-8-1 13:37:47 | 显示全部楼层 |阅读模式

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

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

x
4 Y( S3 I4 G3 C; [) u' A4 K

6 s5 t* I+ w. D4 r0 s, v
6 D9 S7 s* H4 f2 [& e
& O) G0 _; I6 `* G5 l( _
Technique  
/ E3 |, Y$ f: z" RThere is no difference in setting up a query for a single Item or for many.  Only the
& G4 q+ M+ e; N9 l  \criteria define the set size returned.  In this recipe you create an Item and populate - J  O+ K6 B. n+ i' g7 d$ R# j9 \) }
the query criteria, apply it, and iterating over the Items returned producing a HTML 4 F; J( ]8 c. [0 m& |
<TABLE>  fragment. - T# A. O: ~* R0 F; I: D
+ E% |" V4 x7 @4 }2 U

9 Q) I. l: q9 RJavaScript  
. q; {3 w6 x: z2 l( T( p9 l6 n: lvar qryItem = this.newItem("Part","get"); % X6 g  ]/ k# C8 _( J. _' `4 M
qryItem.setAttribute("select","item_number,description,cost");
3 ~9 O- d+ R: L+ T6 TqryItem.setProperty("cost", "100", "gt");
7 R. N9 ]' V1 D: s8 f7 h$ W0 f9 q+ O5 Hvar results = qryItem.apply();
1 i2 f! \: `  Z# u3 T( Y' ivar count = results.getItemCount();
: f' A. A7 }+ C7 ivar content = "<table>";
0 M# V' B6 a$ f, W4 z' Qfor (var i=0; i<count; ++i) 3 G  e; H6 V: {8 P: X
{   e5 N; q6 J  l
  var item = results.getItemByIndex(i); ; G4 @# V) P9 @! ~+ v8 ]& A$ M
  content += "" + , I( @5 P- A7 y* m
    "<tr>" + : m4 c. B4 K2 @6 ~7 ]. j* Y
      "<td>" + item.getProperty("item_number") + "</td>" +
7 o) g5 i, K; ?! ?9 ]/ S! A: @1 b      "<td>" + item.getProperty("description") + "</td>" + & Q: t# ]7 P3 Z7 u# z# [+ ^1 \
      "<td>" + item.getProperty("cost") + "</td>" +
6 l1 Q+ Y$ _* d% b# U    "</tr>"; " v% j2 y6 `" n
}
5 g& _: d2 O( Jcontent += "</table>"; " |" p: H% q+ X5 l/ y. J5 ?& W
return content; 2 k: c4 j* V+ z: w3 C) u2 u. P

+ j) y. W+ {5 `3 Z/ C* rC#  ; J: d. @7 r8 Y  D7 w4 s
Item qryItem = this.newItem("Part","get");
7 W1 v" ?4 F1 Q( c3 p4 d7 v$ a5 P4 |qryItem.setAttribute("select","item_number,description,cost");
2 v. W6 x) E# T7 fqryItem.setProperty("cost", "100", "gt"); - B0 _5 \, j: x; ]% m
Item results = qryItem.apply();
9 V( j, S8 P9 Bint count = results.getItemCount();
! K7 n+ Q/ R/ \- r/ fint i; ! j* A2 x' o. a( E2 r+ F, @
string content = "<table>";
2 M8 ]+ F0 j3 y  B. M+ `for (i=0; i<count; ++i)
& W9 r' P/ K) y% q; U4 A{ * q/ R0 ^! C7 ?3 Z
  Item item = results.getItemByIndex(i);   }- l  t* K! o3 h( @8 v
  content += "" + ( G# l# S0 J3 x3 k+ R6 H7 V
    "<tr>" +
: u+ B3 M/ Y3 \/ |      "<td>" + item.getProperty("item_number") + "</td>" + , B9 P4 u& f, A
      "<td>" + item.getProperty("description") + "</td>" +
7 O8 q7 t6 o: d8 {1 b- T+ U: Q      "<td>" + item.getProperty("cost") + "</td>" + 7 U& A, R; p, I7 f
    "</tr>"; ' L* [; `% c9 q7 A+ i
} 4 b4 q) V; O6 R
content += "</table>";
( A5 d$ d% o" lInnovator innovator = this.newInnovator();
' w: S% M. C; i- B9 ]( qreturn innovator.newResult(content);
, L/ Z  q! u4 T7 K! z
6 a: [, o; j% O4 _( BVB.Net  1 C; W: `& e- T6 i. t0 p, h
Dim qryItem As Item = Me.NewItem("Part","get")
/ b5 q. t1 i& F) [7 u7 M9 z4 |& aqryItem.SetAttribute("select","item_number,description,cost") ! m/ Q& n3 A- ]
qryItem.SetProperty("cost", "100", "gt")
! J6 j& L: n- @, l4 i: QDim results As Item = qryItem.Apply() . p5 Z* x- u+ E$ Q
Dim count As Integer = results.GetItemCount() ) w3 w' ?  N% X; {9 D! M
Dim i As Integer * ?" p) r( V0 W8 M" [3 q9 ?
Dim content As String = "<table>" 9 Z" _/ _4 X9 e
For i=0 to count - 1 % v5 c6 D, y: E
  Dim item As Item = results.GetItemByIndex(i) & b+ [: S! y& W. t: q; f+ G
  content += "" + _
- t& H! f( D  ]' o; \: ?    "<tr>" + _ ( \! f1 R2 H) ~/ @% b
      "<td>" + item.GetProperty("item_number") + "</td>" + _ 4 G* ~- ^7 A, t7 e% c" v
      "<td>" + item.GetProperty("description") + "</td>" + _ 1 x; K6 [* n3 b/ l. E
      "<td>" + item.GetProperty("cost") + "</td>" + _
5 R1 c/ q4 H$ S; \2 a    "</tr>"
+ W1 _  ?+ I( HNext 3 k2 a% D$ ^0 Q( ^% p3 V4 s
content += "</table>"
1 K6 y5 U! F5 b6 y " O+ a" v7 e: q" S; P- R, x4 J" D
Dim innovator As Innovator = Me.NewInnovator() - l5 H* C# @8 x& m; u9 ?4 S3 |
return innovator.NewResult(content) ( K0 n, |0 u5 ?6 \8 @8 B  F

2 l6 J- I, N# J* a/ ^8 A6 p7 D& o$ f3 q, d
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了