PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

2018-8-1 13:37:47 1569 0

admin 发表于 2018-8-1 13:37:47 |阅读模式

admin 楼主

2018-8-1 13:37:47

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

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

x
  U. ?# w; r, q% J' u3 `( t

  f, d2 V2 I, l8 j! [9 C. S" F* L- l. ~  p) t, L2 w4 X4 p6 T5 S

. N, i' L3 i5 eTechnique  . z: D0 J1 K! o  K3 y
There is no difference in setting up a query for a single Item or for many.  Only the
# X7 R) l" w0 R/ |criteria define the set size returned.  In this recipe you create an Item and populate   D$ W9 ?4 N2 F$ ^
the query criteria, apply it, and iterating over the Items returned producing a HTML * R. ^- f3 r  k5 H  H
<TABLE>  fragment.
" P# H* `. U+ {+ K
3 `- ~) B+ s4 [0 P( l

- s- `, w* J# J7 gJavaScript  
! ?) q- A/ s9 h/ zvar qryItem = this.newItem("Part","get"); % x  B& ]6 {& D; v- B& b  x
qryItem.setAttribute("select","item_number,description,cost"); 6 y; t) P& g( g% |: o
qryItem.setProperty("cost", "100", "gt"); 5 ]+ Z- k1 g+ N9 l- C
var results = qryItem.apply(); 7 {: |: A# i. e6 P4 G2 A- z7 Z
var count = results.getItemCount(); 2 }$ u, [! I0 _. u8 v
var content = "<table>"; ( l7 s( f) J7 ]" n! @; I! `/ p
for (var i=0; i<count; ++i)
  ~) v$ s: u7 e. Y& N! Y! l7 M{ 3 v6 B. F' A9 a
  var item = results.getItemByIndex(i); : G4 F9 r5 Y# H) u+ T: S, |& W
  content += "" +
) j5 P$ u% v9 X6 [    "<tr>" + 4 v* a2 M" E. i: `7 f) e. L4 ]
      "<td>" + item.getProperty("item_number") + "</td>" +
: t8 c: w! t2 F( g2 j/ l5 V      "<td>" + item.getProperty("description") + "</td>" +
4 G' G# o3 G: N" Q      "<td>" + item.getProperty("cost") + "</td>" + 0 c/ a8 Z! T& ]; u$ i8 e
    "</tr>";
+ U; K1 P( r, N7 L0 r} " T. z$ q8 K6 a8 v) }( K$ H" B2 l) ?
content += "</table>"; / J( [& e. ]0 ?6 x" i  `' N
return content;
8 Y# v% I5 W) b# e! j2 Q
! y8 Y5 ]8 F1 Z* W" `C#  ; \; F1 J& Q% e
Item qryItem = this.newItem("Part","get"); ) L) m, o. m3 O. J
qryItem.setAttribute("select","item_number,description,cost");
% w/ a% z, t! L8 z" u/ dqryItem.setProperty("cost", "100", "gt");
+ M7 N2 K# {" j, |% ]' IItem results = qryItem.apply(); % M" S+ _* A8 J9 L% @
int count = results.getItemCount();
1 g  n. |; k4 U% [0 L. a- jint i;
; S& r& i. b& \1 _* l8 L2 b; Qstring content = "<table>"; 2 g. u! _: f4 A! {4 ^( \" t' ?
for (i=0; i<count; ++i) 9 C9 d& W1 V4 P" ^% R7 q
{
* Y" w8 X8 u6 S  Item item = results.getItemByIndex(i);
# h+ ]+ Q; m6 k$ R# V5 ]  content += "" +
2 `8 W5 K2 ~2 ?- u    "<tr>" + " K" y* j1 i( Q/ Y
      "<td>" + item.getProperty("item_number") + "</td>" + # U4 m6 G  G7 y( d+ }
      "<td>" + item.getProperty("description") + "</td>" +
8 }8 R/ ~( U) f4 b      "<td>" + item.getProperty("cost") + "</td>" + ! S/ M$ ^# X  Y9 E* |6 j8 e
    "</tr>";
" t8 a2 y! f/ G# k9 q) L} 9 O. [$ e: {, B5 |& h4 Z! H
content += "</table>"; ; }4 w$ Y% C4 Q  x( `+ Z# I
Innovator innovator = this.newInnovator(); 1 i2 N4 z" K8 B% j8 Q5 J  |
return innovator.newResult(content); + s1 L+ C8 x2 U, K  o
7 x6 }) N. _) i6 p* k4 c: b
VB.Net  9 i4 J9 _7 B: e7 h
Dim qryItem As Item = Me.NewItem("Part","get")
( `- ~& D$ p" @qryItem.SetAttribute("select","item_number,description,cost") ; c$ H& [. a8 m8 p' S' C$ G( e$ E: {
qryItem.SetProperty("cost", "100", "gt") : y3 S& X) n# N# a1 q! j
Dim results As Item = qryItem.Apply()
  n  X7 M; ?4 k3 s( A2 v1 JDim count As Integer = results.GetItemCount() 3 D) |1 s' J' }* Y& t0 B. H9 Q
Dim i As Integer + I! ?- @7 Q( K; t
Dim content As String = "<table>"
8 o$ D, D3 p- D7 F" WFor i=0 to count - 1 6 y% a3 @$ m" k9 n. k6 R: a9 R$ ]
  Dim item As Item = results.GetItemByIndex(i) % R8 f4 C+ W; ?1 Q
  content += "" + _
& k# y; K2 E' @" q' A    "<tr>" + _ : @. Q, _$ q3 `7 f  O
      "<td>" + item.GetProperty("item_number") + "</td>" + _   T0 x0 V4 O- Q
      "<td>" + item.GetProperty("description") + "</td>" + _ * A+ T8 W" x8 t8 s4 X8 Z3 S" }
      "<td>" + item.GetProperty("cost") + "</td>" + _
, Y! e& ^- t% x7 [6 |    "</tr>"
! h  x2 W% w3 L( l1 y! {Next
9 @$ \5 e0 F3 l3 d" a8 m7 C% _content += "</table>"
0 j9 u9 f- w3 v& @6 D. J
% ?8 U) u1 V% GDim innovator As Innovator = Me.NewInnovator()
- ^) o7 k: k! R. e% K, X& h4 Nreturn innovator.NewResult(content)
0 m: w. _- T+ R( h9 y$ m1 l" U& k+ \8 Y3 O  d

- C. @4 l, e+ Q6 C0 e
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了