查看: 1715|回复: 0

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

[复制链接]

4

主题

3

回帖

44

积分

管理员

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

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

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

×
. w8 Q8 f' D9 R2 S  Z9 W! G
& E6 g. J5 c- w; p! ~  z

* a) H# F' T! l, r0 F

2 [4 {5 b( C2 |Technique  0 c1 c& q* c  g  f+ K6 U
There is no difference in setting up a query for a single Item or for many.  Only the & v" x2 r; O, B, F! T) k1 C
criteria define the set size returned.  In this recipe you create an Item and populate
" d; g  {: G* a$ F6 Tthe query criteria, apply it, and iterating over the Items returned producing a HTML 2 t" s, w$ n2 p# c8 I
<TABLE>  fragment. / J7 m( C$ P* f" J: S9 ~
& }: f+ v$ H  j3 P) i

2 f  s) ]; g/ WJavaScript  
( e; R1 Y. ^8 F# R$ a; u% ?5 O) Dvar qryItem = this.newItem("Part","get");
! d9 ?- l, R# s9 ]! @8 bqryItem.setAttribute("select","item_number,description,cost");
- q# f% u& G% E/ P  B9 _7 RqryItem.setProperty("cost", "100", "gt"); & u% G! k8 B" O6 }+ v
var results = qryItem.apply();
' n2 E+ z  j  ^( {, Vvar count = results.getItemCount(); * o! q4 g, a- ]1 ]* Q; s
var content = "<table>";
% e+ l; N$ j4 m* _* Lfor (var i=0; i<count; ++i) . v7 S, O- K" {& }$ ?
{
9 f2 ^- P9 E$ l& X  var item = results.getItemByIndex(i);
1 o! `1 \2 |) B2 g# T$ ^8 \  content += "" + ( R7 `( `/ ~* U8 J: ~" j
    "<tr>" +
( v+ Z0 m9 B0 K; o  P( k# p# U      "<td>" + item.getProperty("item_number") + "</td>" +
: M/ B$ q$ t% `5 }) r8 @      "<td>" + item.getProperty("description") + "</td>" + . w. w( x" ]* ^2 Y: c$ F! Q4 ~
      "<td>" + item.getProperty("cost") + "</td>" +
# R5 s+ w7 T. E; {    "</tr>";
( q! K; M1 p1 m" [, ?" Q9 A} 1 X5 `* G! S8 C
content += "</table>";
! L5 a) v0 q# W( Zreturn content; 7 Z9 Z0 q" t/ }$ s

, n% P9 B" D# MC#  " F8 X( a# v% E; F& `
Item qryItem = this.newItem("Part","get");
! u! [- o* }6 c3 V  c, RqryItem.setAttribute("select","item_number,description,cost");
/ O$ N3 o( m1 Q( k: @qryItem.setProperty("cost", "100", "gt"); 6 g% @) V5 ?6 x) d" f# }6 M
Item results = qryItem.apply();
/ |% p" G4 c9 R9 Vint count = results.getItemCount();
/ y/ b: J( g; ?5 J5 tint i;
' P" t7 U& i; [$ V$ [* ostring content = "<table>";
6 z1 ]( a$ t- H  E) Lfor (i=0; i<count; ++i)
! C. Y* Y0 w/ d6 w4 }{ , l3 G5 H2 o, j8 ?4 Z6 M
  Item item = results.getItemByIndex(i); 0 C6 \: k4 q$ U4 ]5 X6 M/ f/ J- V3 E
  content += "" +
  i" T6 i) W+ P  Z# j: |9 L    "<tr>" + 9 m  c- x* G( O  ^! C" Z8 t) K6 \
      "<td>" + item.getProperty("item_number") + "</td>" +
& f: D3 a' K! }& [# p/ M      "<td>" + item.getProperty("description") + "</td>" +
- F2 M1 b  o3 ]9 N8 Y/ ?) f      "<td>" + item.getProperty("cost") + "</td>" +
; w3 d2 {. S6 r    "</tr>"; , J8 f: O5 @( {( c6 M
}
# _$ [5 v6 C: E. Kcontent += "</table>"; 4 E8 |$ k8 O7 W# \2 ?& Q
Innovator innovator = this.newInnovator();
. n8 D+ w1 y2 d% W8 i* ureturn innovator.newResult(content);
- g$ G5 U' d# l$ [4 e( G  V2 f ! R  N  J" Q5 p0 G; E6 |8 J
VB.Net  
8 s9 E% V) B% t2 D# u+ uDim qryItem As Item = Me.NewItem("Part","get") 6 Q( o  _% N& Q# l& @
qryItem.SetAttribute("select","item_number,description,cost")
8 i, ?  A( D! q; {1 u* qqryItem.SetProperty("cost", "100", "gt")
* {  n. P5 I/ X' qDim results As Item = qryItem.Apply() ( v3 i% ^1 x9 K( k6 F
Dim count As Integer = results.GetItemCount() 5 L$ }, C' T+ }: y3 a0 ?, r/ K" N8 n6 f
Dim i As Integer / z6 C$ G) Z0 c2 L* S# u
Dim content As String = "<table>" , N: r" C: a/ B
For i=0 to count - 1 ' n! P9 o' y" f8 y9 `
  Dim item As Item = results.GetItemByIndex(i) , X# j7 b; g0 H  E. P
  content += "" + _
( G/ U! Q/ C0 {( i  p3 e    "<tr>" + _
8 N4 k1 E* a) u* K      "<td>" + item.GetProperty("item_number") + "</td>" + _ + j& i  j; B9 S
      "<td>" + item.GetProperty("description") + "</td>" + _ 5 w4 r5 m. r5 Q- ^! D
      "<td>" + item.GetProperty("cost") + "</td>" + _
  \& t7 o0 w; H! J0 ]7 q    "</tr>"
6 s9 G0 \, c: D/ BNext
$ B, k  x* _8 h: v4 I7 Ycontent += "</table>"
6 Z. @5 Q# P6 L6 e* H4 V8 _ # i1 X; j, R+ S6 K! P5 ]5 W% ]
Dim innovator As Innovator = Me.NewInnovator() . V2 P, j6 S2 S$ x( D$ J
return innovator.NewResult(content)
+ `7 a7 p& u, n
2 i! z4 S9 e1 l
& K% F) _) y$ Q0 f) R$ ?' L# W6 _7 X
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部