查看: 1704|回复: 0

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

[复制链接]

4

主题

3

回帖

44

积分

管理员

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

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

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

×
+ T, n) J& a/ y- s

8 g* ]9 C7 }3 |" B1 D
0 d% r+ S, R4 T0 ]1 ^
# |# p/ z- m& U$ U. G: ^
Technique  
0 X7 j. B) N6 O5 @There is no difference in setting up a query for a single Item or for many.  Only the
+ B2 T/ c& o1 h' g% |/ bcriteria define the set size returned.  In this recipe you create an Item and populate ( T9 _) K' y! b* g( |9 P( F
the query criteria, apply it, and iterating over the Items returned producing a HTML
4 h0 a  k+ b% Q1 I<TABLE>  fragment. 6 L& X, R2 C. x  a

  T) ]4 |+ p0 D. P- S

$ r5 [/ Y6 |& ]- f; ~% }: XJavaScript  6 M8 Y: {/ b3 z1 c/ W4 O
var qryItem = this.newItem("Part","get");
  M2 X' x1 Y( U$ r! ^) ^qryItem.setAttribute("select","item_number,description,cost");
, V$ e. N2 U, VqryItem.setProperty("cost", "100", "gt");
" H# [' d/ F0 [. {/ u4 Pvar results = qryItem.apply();
" G; r1 b5 C9 B. S! @) ?var count = results.getItemCount(); : S8 {1 q8 |% A( X
var content = "<table>"; 2 N3 d! ^5 E4 l8 X1 v% q
for (var i=0; i<count; ++i)
8 I" o* F; A, E- v4 r# W1 u{ , e+ e' I# ^- M4 N! h, V8 f
  var item = results.getItemByIndex(i); ) ]0 Q4 v1 e+ b
  content += "" +   A# J& o6 D# V; ^% k1 m% w
    "<tr>" + 4 a  w* T+ \; L
      "<td>" + item.getProperty("item_number") + "</td>" +
) D+ {; @1 Q9 C" Q; E      "<td>" + item.getProperty("description") + "</td>" + ; T3 }) l: r" ^/ u
      "<td>" + item.getProperty("cost") + "</td>" + 2 @6 T3 F; a. O2 `- t. `' F6 {
    "</tr>"; 6 L/ \% A; ?$ ]) l8 [" F+ a
}
  l* ^& y' Z: e. V, E; E: pcontent += "</table>";
! C8 q) c, ^3 l" U' Preturn content;
( P: p2 U2 q' c, ]* e
1 F, ^" z. w! W$ }: SC#  + z( h6 D0 ~- [7 j1 n8 u) Q2 ~; Y
Item qryItem = this.newItem("Part","get");
  O6 S. v& ~+ Q5 fqryItem.setAttribute("select","item_number,description,cost");
, E3 i  M, u9 mqryItem.setProperty("cost", "100", "gt"); 5 M/ i( j7 a. |6 q: w
Item results = qryItem.apply();
. c! x# x/ p1 Mint count = results.getItemCount();
$ ~# k: A6 M: @1 t# M+ a. yint i;
! \6 u# _5 q8 K# k: Mstring content = "<table>";
) \: ~0 ?) B7 q- f9 O1 I" T. E6 Gfor (i=0; i<count; ++i)
2 `9 Z: U! k& @$ q4 p1 _$ o{
" G) ~* x4 F: j  Item item = results.getItemByIndex(i); # o4 n$ f' N5 K( u
  content += "" + + W$ z/ {% x: S6 T5 i
    "<tr>" +
, `( d' g, k8 k0 f      "<td>" + item.getProperty("item_number") + "</td>" +
2 h8 v: q' ~) ?: s9 a; R      "<td>" + item.getProperty("description") + "</td>" +
% z2 {+ T1 i* Q      "<td>" + item.getProperty("cost") + "</td>" + ) v+ F+ b! y( q( g0 U2 m: A
    "</tr>";
  b8 v) P3 |( {. L3 d- F} : U  u+ H  C7 V6 r' s
content += "</table>";
: x1 y! y. i3 h' v/ rInnovator innovator = this.newInnovator();
5 l+ r* |7 }1 w2 k, u! m% K. E  Dreturn innovator.newResult(content); ; L( S" i7 ^/ W! ?5 C- c
" S# }7 i8 b7 r6 g
VB.Net  1 ^) a  ~5 R' _4 @4 s
Dim qryItem As Item = Me.NewItem("Part","get") 7 {& f; w8 Q' y: @
qryItem.SetAttribute("select","item_number,description,cost")
' m9 D7 N  N. H  }6 R/ i8 T& O: g% PqryItem.SetProperty("cost", "100", "gt")
( ?' s8 p' _5 i' R( S- }2 EDim results As Item = qryItem.Apply()
! q$ l3 w' I& m' E7 EDim count As Integer = results.GetItemCount() ( {. I1 q' {" |% E! d$ r" k6 b6 y
Dim i As Integer : f: y$ O8 t6 h! K
Dim content As String = "<table>"
, H9 G0 g, j" g0 O+ C( g$ o! rFor i=0 to count - 1 0 R/ G* Q3 F1 }2 C. K
  Dim item As Item = results.GetItemByIndex(i)
( x  B; K# l; }  content += "" + _
- Q+ |! V7 s- M( k0 w3 v3 A5 A2 V% h    "<tr>" + _
* b4 W# d( `( G* Y% h      "<td>" + item.GetProperty("item_number") + "</td>" + _ 0 v/ G: v6 I; ]9 J" Q: h
      "<td>" + item.GetProperty("description") + "</td>" + _ 4 o4 P$ B8 I8 `6 m, C8 s
      "<td>" + item.GetProperty("cost") + "</td>" + _ 5 L) W$ M9 H: T. v
    "</tr>"
) S: a4 i5 X  h  I( LNext
1 w) s  ]% c8 E  [' t$ h+ fcontent += "</table>" , `: R- Q3 n0 n" M0 y

" L) y9 C; F4 X  T! yDim innovator As Innovator = Me.NewInnovator()
  K7 v. q. \# I6 l$ o0 Kreturn innovator.NewResult(content)   }, n/ g9 U- u; a  l  U0 [

/ |. B( ~' d8 V$ J6 X$ E) j% B5 a) k0 }2 t: \
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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