查看: 1805|回复: 0

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

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

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

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

×

" O/ J0 s" w- j& e- g: t+ @+ Y# e) p% M8 k; q2 z) T
. _% E0 D) ?  X
( P! ?$ G6 u+ Z# C
Technique  ! h; A, R6 r) s% p7 x
There is no difference in setting up a query for a single Item or for many.  Only the : O, I: l6 G* G; g2 B9 q6 d) X
criteria define the set size returned.  In this recipe you create an Item and populate
8 }) _9 L+ d& H8 E% x( x* |+ h1 Kthe query criteria, apply it, and iterating over the Items returned producing a HTML ' O/ s' M9 F9 w  ]+ E$ x
<TABLE>  fragment.
1 F( B( S3 |- o7 @$ o# o) R% ]# @9 l5 ~9 ~
5 F! E# F2 Q5 E! n2 x! j) E( }% m
JavaScript  
. x/ q5 E/ J  Y, Dvar qryItem = this.newItem("Part","get");
& b2 c! v+ s) `- wqryItem.setAttribute("select","item_number,description,cost");
9 G, }5 L5 m1 t2 g7 Q, A0 l! n" ZqryItem.setProperty("cost", "100", "gt"); & G; [3 j! `2 ?  h1 [1 A3 |' p
var results = qryItem.apply();
# B7 d/ L' O7 Q5 X0 K' _' pvar count = results.getItemCount();
) T; r, n5 ?* z' H3 l& w7 n. l! gvar content = "<table>";
# O  v7 ?0 P2 p2 q3 m$ f( Q' rfor (var i=0; i<count; ++i)
# H& ?/ z$ O1 e( W* N5 B& I. K{
7 P9 g* L" O# F6 h( Y% a& w  var item = results.getItemByIndex(i);
. G2 A& u* T9 K  content += "" +
; o! n5 l  Q( R0 B# i    "<tr>" + $ Q1 [) t: t' H4 a. {
      "<td>" + item.getProperty("item_number") + "</td>" +
. e# j# t  s( b( R      "<td>" + item.getProperty("description") + "</td>" +
6 o% f0 c9 a) Y6 u1 D0 H      "<td>" + item.getProperty("cost") + "</td>" +
* H$ d8 a! q( E* X; \! ]1 O    "</tr>"; " y! n" s. t' [$ l
} + g' c: X5 \* ?2 H2 W* }7 }
content += "</table>"; ' J0 b4 ~4 v5 |- i, S: m$ K2 y
return content;
1 p" O; y+ ]/ t3 }% K9 Y& | , c1 W+ _8 @3 z/ T7 }
C#  
  g8 E- k; r( I4 ]Item qryItem = this.newItem("Part","get"); $ |$ Y; u# y- t* `% E
qryItem.setAttribute("select","item_number,description,cost");
4 L" i9 l% {+ C: f0 x# vqryItem.setProperty("cost", "100", "gt");
$ V2 m$ \8 t5 \& Q! xItem results = qryItem.apply();
% e/ H& ^) T" B0 ]+ E8 Q$ Mint count = results.getItemCount();
+ ]- x% V6 F) m) M5 b- @4 Mint i;
) h5 i5 l) N" Hstring content = "<table>"; " V3 J4 @; Z  B9 k
for (i=0; i<count; ++i)
2 @: K) o, {# D' _6 e2 v0 }{
' r" g* F3 r% d3 }  Item item = results.getItemByIndex(i);
4 Y3 Q9 X, }; o' k  content += "" + 0 ]- _8 l9 A% \2 l) ?
    "<tr>" +   h8 P5 F$ ]! g0 F4 h' p# i
      "<td>" + item.getProperty("item_number") + "</td>" + ; u- c/ E8 w( H0 j. A3 x! B
      "<td>" + item.getProperty("description") + "</td>" +
9 P; T- F1 t3 g3 U5 W, i" B      "<td>" + item.getProperty("cost") + "</td>" +
1 |2 _% f' m( e( @0 G    "</tr>";
, z0 X5 }9 i% ^/ f- v} ) ^9 g* J: u' x& B
content += "</table>";
& x' j; n# @; Y" l5 c- R; eInnovator innovator = this.newInnovator(); , ?! i& K) g  N$ \" e! s# y. z
return innovator.newResult(content);
( J( Q0 z& b9 }7 \8 t# t  P- U ( A) g- g4 u+ G8 w1 t
VB.Net  * X& }; `$ y- B( J% c9 o" t
Dim qryItem As Item = Me.NewItem("Part","get") - P7 z0 g/ ?; @& F3 _
qryItem.SetAttribute("select","item_number,description,cost")
# A! D3 S: ?8 n  N% o8 f# VqryItem.SetProperty("cost", "100", "gt") $ K" f2 p- t7 n) h
Dim results As Item = qryItem.Apply()
! K. Y* y2 [/ N; n" ~0 ODim count As Integer = results.GetItemCount() / d/ L5 n+ t5 O8 h' a! I4 P/ Y- f
Dim i As Integer ( B. {0 w) F5 ]( q( J
Dim content As String = "<table>"
7 h5 G: [0 m/ K/ Q& W  f4 dFor i=0 to count - 1 , k. M/ D; R- n/ K: s* S
  Dim item As Item = results.GetItemByIndex(i)
" G3 c1 R2 p4 P2 R* G$ `) o  content += "" + _ # n! _8 W2 t$ R6 i$ j
    "<tr>" + _
1 m3 A) E0 H" @' {6 ~      "<td>" + item.GetProperty("item_number") + "</td>" + _
* I$ O( Z: K3 D- F      "<td>" + item.GetProperty("description") + "</td>" + _ 5 S" z  p6 m0 s9 S0 E' U& U1 D
      "<td>" + item.GetProperty("cost") + "</td>" + _ 4 @3 x0 b% V$ [1 S: n4 _1 r
    "</tr>"
9 u' z1 `0 L6 C5 l( BNext 7 }4 P1 U5 R, y7 ]" E+ j5 r
content += "</table>" " B( U/ f$ O! t) l8 Y. K* t
6 m4 n6 i3 U1 b8 W6 E. C
Dim innovator As Innovator = Me.NewInnovator()
9 q/ ^8 S. L4 e" _  w8 A- [# ureturn innovator.NewResult(content) 9 P( z# t' I9 B6 N; v5 W. W
9 ]3 D# Z4 P, _4 d/ E" C
; m- Z6 |6 _# G/ F) p, z. X
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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