查看: 1767|回复: 0

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

[复制链接]

4

主题

4

回帖

52

积分

管理员

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

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

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

×
7 X$ x% I( L4 x: c* x  M! w
" C/ ^( [2 D3 k) ?! z6 x
& X6 Z1 E  n9 }$ W- t

! J5 z" |0 b; [- R5 k/ |7 v  ^Technique  % I; k/ [6 H  @! _  B2 E4 m8 ?
There is no difference in setting up a query for a single Item or for many.  Only the
' G- \3 {0 @# S) f% G+ Q9 Lcriteria define the set size returned.  In this recipe you create an Item and populate / R+ S7 n$ z# w  k+ l$ w' U. V
the query criteria, apply it, and iterating over the Items returned producing a HTML ; c( |- ^' w- U
<TABLE>  fragment. - r9 D! K7 Y. H

2 ]1 g3 f# j+ M8 E# l" f5 n: `

) {: |% u. q% G2 TJavaScript  $ K# r* L; ~) d3 A2 a
var qryItem = this.newItem("Part","get");
( {- f3 ?8 P5 R' uqryItem.setAttribute("select","item_number,description,cost"); ) x5 O) P! M  l) s
qryItem.setProperty("cost", "100", "gt");
5 C8 F1 y4 x9 \" l) Y) Cvar results = qryItem.apply();
4 M/ M" B1 p/ Q+ e3 S# D6 |var count = results.getItemCount(); / w$ u8 e# ^, y$ @! D
var content = "<table>"; ' _& t2 p& T: X2 {
for (var i=0; i<count; ++i)
) g" p3 L: W4 o6 w% c, `5 n{ * W3 i' O8 E! E  R+ |* k1 j. j
  var item = results.getItemByIndex(i);
6 b- C$ ~1 P5 d* g  content += "" +
, J+ i# L1 |1 z" l" q. F$ K    "<tr>" + : i6 ?3 {; h; Q" e" N0 p
      "<td>" + item.getProperty("item_number") + "</td>" +
. [0 B0 D1 e- e      "<td>" + item.getProperty("description") + "</td>" +
3 n8 G3 ^: P; G7 G$ d. v      "<td>" + item.getProperty("cost") + "</td>" +
( s4 h+ E+ U7 x' b; G& x& W6 g    "</tr>"; ' t7 P8 K  w0 n. D( e; \
}   R7 k$ w! P4 w4 P4 k" r3 g
content += "</table>"; , J9 y0 T- j0 L' u* U7 y
return content; 0 Q2 {5 O/ |7 y( J& e3 S
0 i* b6 p7 i1 Y
C#  
0 N+ j# I0 l4 a  i* {8 X1 P) {Item qryItem = this.newItem("Part","get");
" G, P+ L  ^' d" z- PqryItem.setAttribute("select","item_number,description,cost"); ( ^# h$ O; h, C+ o& e( H
qryItem.setProperty("cost", "100", "gt"); 0 y5 m4 n) h' V" r& B$ S3 R
Item results = qryItem.apply();
& @5 r0 X- s# D( F: dint count = results.getItemCount();
1 [: \  i8 h# s: j) Qint i;
- m6 {8 z# h$ H  }% O# kstring content = "<table>"; 2 J; \# A" H: D8 I; s7 U6 a* a
for (i=0; i<count; ++i)
2 m' J4 _& k9 F1 ]7 `  U" U' A{ 4 f8 m: q) _! J
  Item item = results.getItemByIndex(i); , Y3 X; R2 x6 Z+ a9 q
  content += "" +
! Z# |3 Q. s, {2 @& x, L    "<tr>" + : s# z6 Z  J* t4 ]9 }
      "<td>" + item.getProperty("item_number") + "</td>" +
! P2 G8 Z1 G+ A) _4 a) E      "<td>" + item.getProperty("description") + "</td>" +
# m8 }7 w2 |( ~      "<td>" + item.getProperty("cost") + "</td>" +
% y0 g0 Y/ b7 l& S! s, \    "</tr>"; / S3 t- N& I+ e9 o8 |& l! ?
} : b+ G9 @6 U8 ~7 y) `- \, D# I1 E
content += "</table>"; 3 N( J# E* g( Q. \. Z( Q
Innovator innovator = this.newInnovator(); ; H- ~. A8 p# Z# y# _, y
return innovator.newResult(content);
% w/ K3 e0 b: H! G# L- O+ u( C
1 U. R3 j% ]; _0 JVB.Net  
( N& m4 E% k0 X5 W8 V$ A" {Dim qryItem As Item = Me.NewItem("Part","get") 1 ^4 Q. q( p+ @' J- G- n) `' R
qryItem.SetAttribute("select","item_number,description,cost")
: |7 y) f% q1 ?) v( t" vqryItem.SetProperty("cost", "100", "gt") & n# P1 i; L6 p! z; i# d
Dim results As Item = qryItem.Apply() + ]# g7 _& s% @
Dim count As Integer = results.GetItemCount() : ^' Q7 q) q; r0 o; X; v- n
Dim i As Integer 7 {; u* k, y0 g6 V
Dim content As String = "<table>" + P( F/ z+ O7 N& [+ M" g( U
For i=0 to count - 1 8 s2 O. D$ l$ o" J2 X
  Dim item As Item = results.GetItemByIndex(i) " {  A  U  }0 I& M2 E5 R
  content += "" + _ 4 Z- l! y; y7 |, y1 l
    "<tr>" + _
+ ?3 u+ ^( I$ P9 ]3 `: H6 [2 m      "<td>" + item.GetProperty("item_number") + "</td>" + _ 8 x& e: P, H" F7 l, o' X$ D
      "<td>" + item.GetProperty("description") + "</td>" + _
: e6 b% f7 X6 K      "<td>" + item.GetProperty("cost") + "</td>" + _ 7 P! P& T, {! q" J' O
    "</tr>"
1 H  w! D( f: r: l6 mNext . Q# k) O# x2 w- l3 |1 M
content += "</table>" ! _- z- F# ^" c9 y1 ~

) V1 L8 E* B, b+ L) SDim innovator As Innovator = Me.NewInnovator()   x  i3 E1 P8 v- o( E; u7 G
return innovator.NewResult(content)
- A3 p) N; L  j
0 c( @4 c5 x- }  o: ^* y' y7 U6 M6 r* }+ b" T2 l, m! n$ m
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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