查看: 1792|回复: 0

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

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

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

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

×

) Y0 f. I: g) k8 p5 z
0 t: \* [: R/ m  X
9 [- q9 c* b1 v. P: i8 f

6 @5 h1 p0 P8 w! OTechnique  ' @" r+ h8 H- ?; s% t
There is no difference in setting up a query for a single Item or for many.  Only the 6 t7 Z3 |7 _3 M
criteria define the set size returned.  In this recipe you create an Item and populate
! S1 r1 o+ \3 K, H  Z3 ithe query criteria, apply it, and iterating over the Items returned producing a HTML
" {! v* ?' G% c* \) G4 q<TABLE>  fragment.
7 F7 i0 p; }4 A! j% a' `& v  s
# _8 z+ U/ i& a/ k

+ K; B# p2 K0 q0 w0 eJavaScript  & S* ]5 q# R0 F, r
var qryItem = this.newItem("Part","get");
( {( e5 G# O1 pqryItem.setAttribute("select","item_number,description,cost");
* B  k$ t0 K, H! hqryItem.setProperty("cost", "100", "gt");
7 B% f6 J# _% a  l' a0 K* t; `var results = qryItem.apply();
! ]5 b2 z* U1 d2 \6 L3 U* @7 Ovar count = results.getItemCount();
* ]+ N- i, s+ z  m& }$ jvar content = "<table>"; ' W  J) T( A, x* {# l0 j+ z0 s" b
for (var i=0; i<count; ++i)
7 r4 P: |, g7 w+ r( L{
% S, s; }6 w- Z  var item = results.getItemByIndex(i);
, S; R5 Z& }+ N& ]% [7 U0 A7 Y: P  content += "" + 6 O  z# B# x0 H6 r4 N
    "<tr>" +
. q5 G$ J) E2 |3 j1 N      "<td>" + item.getProperty("item_number") + "</td>" + 0 R0 ^7 M; V5 G2 m8 m4 I
      "<td>" + item.getProperty("description") + "</td>" + $ X' w: R$ [% A$ G* L- P
      "<td>" + item.getProperty("cost") + "</td>" + + S. j) R' c, g1 o+ p( b& `
    "</tr>";
* a0 \2 G: V! W* E" G( y! ?}   L; H( G5 O1 M: z" m+ K  p( Q
content += "</table>";
6 `  m! L" |" ^( P! {+ |2 ?* Xreturn content;
2 d' p$ ?6 {  I9 W9 D  d8 r # c5 \0 l! e- m+ ?3 {3 c) S$ G7 G
C#  9 o. b$ T7 T9 v. X; @4 z
Item qryItem = this.newItem("Part","get"); # ~# B7 U+ y3 D; v4 u: p
qryItem.setAttribute("select","item_number,description,cost"); 4 H* L8 a  T9 v% G( {$ Q
qryItem.setProperty("cost", "100", "gt"); % Q  \' q8 h# ~  c# O4 n3 i7 H0 U- }
Item results = qryItem.apply();
6 V! P  H% b; L* p( o! x  Z# tint count = results.getItemCount();
; r3 N% ^. s' @" Hint i;
+ Z2 |, W8 J% E2 Q" _0 c0 f' l0 Wstring content = "<table>"; 5 x7 d& u" p( J+ P( U
for (i=0; i<count; ++i) 2 Z9 y) }" X' m; _
{
1 Q' ]9 A' b; Y8 M4 w% r. L5 j  Item item = results.getItemByIndex(i);
& P& D0 [" Z* j" W  content += "" +
, j# X- ^0 e4 n/ {1 W    "<tr>" + ! `) t4 s) P! i1 d1 d  o& g' q
      "<td>" + item.getProperty("item_number") + "</td>" + , q  m# t% d: i3 c# |
      "<td>" + item.getProperty("description") + "</td>" + 4 \5 r% D! `) y& N/ l
      "<td>" + item.getProperty("cost") + "</td>" + ! H! I! g) {5 P, |4 |& \9 s
    "</tr>";
1 c. s- U' S+ t* D2 X* V5 t: T} . }, k: u' K8 ?8 K; G# `# ?/ M8 m" ]
content += "</table>";
; O* ?" N/ g, K: d( y5 LInnovator innovator = this.newInnovator();
8 V2 h: |" B% y9 G8 B$ greturn innovator.newResult(content); % I: n  g6 Q3 V/ ]/ Y

! \$ h$ o+ @- R6 J% H5 ~* S5 E+ wVB.Net  
9 Y# j. B4 Q  f& @3 n( QDim qryItem As Item = Me.NewItem("Part","get")   Q6 {5 s0 |# i: E- T2 F3 K5 M8 }
qryItem.SetAttribute("select","item_number,description,cost")
$ f; l  m# l9 w% uqryItem.SetProperty("cost", "100", "gt") ! Y( \9 f& u: ?9 {; {8 ^
Dim results As Item = qryItem.Apply() ; ^+ X1 D7 r- p+ Y- [  P3 e7 M" T, L
Dim count As Integer = results.GetItemCount()
3 v3 o7 \+ [* L( d# xDim i As Integer
; i* f* s6 F8 r+ n; e: v0 e. NDim content As String = "<table>"
7 ~3 o' R( {! s  V3 IFor i=0 to count - 1 * F% c0 y( z9 Q5 x& v
  Dim item As Item = results.GetItemByIndex(i) 2 T  x/ {0 c7 s( x% Q& {& i
  content += "" + _
9 H1 a. U3 ?2 q; u" R    "<tr>" + _
" @6 w2 k4 R- b8 f) i, `. f      "<td>" + item.GetProperty("item_number") + "</td>" + _ 8 h* ^; ^" d8 t7 [
      "<td>" + item.GetProperty("description") + "</td>" + _ 4 |4 h, O0 c8 u* `& f# a
      "<td>" + item.GetProperty("cost") + "</td>" + _ ) _% J5 X) [2 d) n1 N! Z1 a
    "</tr>" , N, j( f$ B/ l9 p0 X2 n" u
Next
" K4 C/ B( D( H" {8 ]9 acontent += "</table>"
! U% M$ \2 a3 N0 D & a0 c: P/ T% A$ A6 v$ C% w8 u3 k5 }0 Q8 |
Dim innovator As Innovator = Me.NewInnovator()
! q6 ]1 B; f. I/ o5 l1 R  G% ireturn innovator.NewResult(content)
: \  x) L# P0 I+ s# D! v" V8 h5 o
* h6 u6 U( y5 d( X, d5 R
" F, r+ F. \4 Z4 @5 ^
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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