查看: 1688|回复: 0

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

[复制链接]

4

主题

3

回帖

40

积分

管理员

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

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

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

×

( z) ~- y1 a. [  ?8 y4 d6 s3 h$ J/ t- C
) _9 C4 _) `2 C1 ], h0 }% p. D5 Q8 O% E/ O& m, P$ S
% e! X% T( H) P& Z; S/ u+ s/ ^
Technique  
) A6 X( h0 e( W7 Z* y# hThere is no difference in setting up a query for a single Item or for many.  Only the
) K5 D% s6 E1 P1 T$ x. c6 ?criteria define the set size returned.  In this recipe you create an Item and populate , J; g; x8 c0 G9 r6 c
the query criteria, apply it, and iterating over the Items returned producing a HTML - {2 {4 m& h) F1 ], z, b7 O
<TABLE>  fragment.
3 o' @2 G! b; P
& A( {' l2 K! l0 A

! a. J6 c) i- `' T- [JavaScript  & v) s9 _" [; V# A( H; I
var qryItem = this.newItem("Part","get"); ! ?1 p' N' e. U) j: ]
qryItem.setAttribute("select","item_number,description,cost"); # \5 y2 G* `4 }! Q0 @; G# a* x$ m
qryItem.setProperty("cost", "100", "gt"); 1 u9 Z7 i/ X: Q# |2 h$ L5 n
var results = qryItem.apply(); $ B1 \5 m, y6 t
var count = results.getItemCount();
" |5 Y( L  a' {) O% svar content = "<table>"; . a/ `( y) K/ f
for (var i=0; i<count; ++i) - Y) {+ i/ O0 ^
{ 6 {. `8 E  u. I: e
  var item = results.getItemByIndex(i);   i) Y! y: T4 y& f
  content += "" +
+ d& Z. Z+ Z, U0 r- F/ F- L3 a6 ]    "<tr>" + $ o/ z( w& |: z7 _/ b8 t
      "<td>" + item.getProperty("item_number") + "</td>" + + n; K# M0 Z; L  |0 N6 }; N
      "<td>" + item.getProperty("description") + "</td>" + 7 `( ~2 |7 d* Z0 P9 C5 l5 b1 X
      "<td>" + item.getProperty("cost") + "</td>" + 3 f0 t: c) o, D6 K; k" h( Z1 w- X
    "</tr>";
8 H$ j2 W- Y: m}
- Z# Y( U! o2 U  p, ~7 Kcontent += "</table>";
$ T% b% I# P( J" kreturn content;
) c" |( \2 `) R ; t4 Y; l8 ^" F& H' r7 G
C#  9 Q+ e' f; C, {
Item qryItem = this.newItem("Part","get");   P& T4 ?: a0 S$ ~
qryItem.setAttribute("select","item_number,description,cost");
6 S$ `! [3 G: P  bqryItem.setProperty("cost", "100", "gt"); " A% V1 g0 W' g7 p) o3 x
Item results = qryItem.apply();
: u' d+ m) t, s% M2 z- d' u1 \1 P/ O" gint count = results.getItemCount(); ' G( W, l! R8 R) [
int i; " P, u! `$ Q( V
string content = "<table>"; ' \" Q. N' _) Y/ d" s
for (i=0; i<count; ++i)   B2 B2 G- }3 P9 n7 p% [
{ + O4 M, F2 e) K! C# i2 Z  u* ]
  Item item = results.getItemByIndex(i);
, `, v# Q  [! m! x% R  content += "" + : ^+ J9 y, o3 q; Q
    "<tr>" +
) {7 u, c- N# P      "<td>" + item.getProperty("item_number") + "</td>" + 7 ~/ E% ~9 w3 e9 l
      "<td>" + item.getProperty("description") + "</td>" +
0 X1 T0 H: ?* l# B& a4 O      "<td>" + item.getProperty("cost") + "</td>" +
: h3 m+ X9 s* X. n    "</tr>";
- z" @' Z3 {% Y  s" o}
3 i$ Q' G% S1 s# j# t$ @content += "</table>";
; z- D( P4 W$ M" r9 i) ^7 t  a7 qInnovator innovator = this.newInnovator();
! z( i& m4 L/ B1 \7 Y2 sreturn innovator.newResult(content); " F8 S$ x6 Y, g# l) P2 f  N; T' [

6 Q, }) t9 G" H( l3 u  E5 ~! kVB.Net  : @/ q1 H3 z- Q3 A( L% J
Dim qryItem As Item = Me.NewItem("Part","get") 3 @1 I, d' d  f) Z2 U6 |2 m
qryItem.SetAttribute("select","item_number,description,cost") - T4 R) ?' w$ a( T  ~" x7 i
qryItem.SetProperty("cost", "100", "gt") 3 k# ?3 x( O" v1 {4 O" L/ e
Dim results As Item = qryItem.Apply()
8 ^% ?2 l- o. GDim count As Integer = results.GetItemCount() 3 _$ Q* D; u' r  g& J
Dim i As Integer
8 t$ K) R+ p! u- |% ADim content As String = "<table>" ! z# F5 G3 |0 @% R
For i=0 to count - 1
. j3 T, ~# F% m, m$ c) ?2 V( M  Dim item As Item = results.GetItemByIndex(i)
7 `5 ^0 o, J, J9 _; k0 T  content += "" + _
. p1 \5 q: Y0 J9 ]3 r. _    "<tr>" + _
- F+ i5 v, P! u& T% s      "<td>" + item.GetProperty("item_number") + "</td>" + _
3 w% A# n2 g  T      "<td>" + item.GetProperty("description") + "</td>" + _ " ]8 l2 O: x5 m% V' c3 I4 f( ^4 |
      "<td>" + item.GetProperty("cost") + "</td>" + _
# \) j5 N' }1 U    "</tr>"
% J( t: P0 F  t; GNext . I; ]2 y' h' L
content += "</table>" & N1 T5 p- }) h. S7 e' ?
, k, B* \1 |+ i  x0 c7 f
Dim innovator As Innovator = Me.NewInnovator()
. V5 x# b5 r1 ~return innovator.NewResult(content)
7 j1 e* F9 R. p- k4 q
; x  I$ Q& v4 c
* w- e9 p7 U7 Q& {7 Q/ f
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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