PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2018-8-1 13:37:47

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

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

x

0 r! H" c0 D* v. W% f/ i, _: R- m! f- ^/ ]  }" A
% A- ~# O8 f1 {9 W3 X

: G( W. S/ K% X/ e% H3 J" Q$ w- O3 kTechnique  $ l% e! p, |* O$ X; y) F
There is no difference in setting up a query for a single Item or for many.  Only the
! c& @2 ~( c* N, P2 R6 xcriteria define the set size returned.  In this recipe you create an Item and populate
3 u4 T0 z; B' Qthe query criteria, apply it, and iterating over the Items returned producing a HTML ; A% |+ U+ U" D6 |/ x3 y( c
<TABLE>  fragment.
  Y" A9 R  w- h" V7 z5 W# T3 I9 Z, i' l$ Q
' L1 E% u/ p; J7 _
JavaScript  
' B" r; |7 ~9 ], ^2 v9 gvar qryItem = this.newItem("Part","get");
6 E* P. |9 ]! l2 L/ C$ XqryItem.setAttribute("select","item_number,description,cost"); - J. R  |0 H- B! {% B
qryItem.setProperty("cost", "100", "gt");
4 N. w1 f; C# t2 t' Ovar results = qryItem.apply();
" o  R# L1 o- a5 z$ yvar count = results.getItemCount();
' s7 R  T& p& E$ f$ Svar content = "<table>";
# E! [/ w6 o& N- L/ ifor (var i=0; i<count; ++i) . f: J/ P1 R: p
{ 9 x/ \/ |' d! T# K) v
  var item = results.getItemByIndex(i); 9 [- k: @" o" G! f
  content += "" + 4 r+ f0 q5 D+ R& u' \
    "<tr>" +
9 A" J4 |. l/ l      "<td>" + item.getProperty("item_number") + "</td>" +
2 a2 b$ K4 j* ?) a      "<td>" + item.getProperty("description") + "</td>" + / Z0 \" m8 e6 y' v
      "<td>" + item.getProperty("cost") + "</td>" + . ~. n- L5 u: X8 a2 ?( i5 S
    "</tr>";
  t4 A9 \  d$ [2 E" @! v} , @: X2 w0 w) b& W' P( I1 s
content += "</table>"; 0 `/ Z1 f0 w& G! {1 D. A
return content;
" ^! ~0 j2 g3 \- p7 s : H  n* G* y7 L
C#  $ N: t* J9 |9 n! q
Item qryItem = this.newItem("Part","get"); * O1 [/ u- r1 d9 N( ~2 n
qryItem.setAttribute("select","item_number,description,cost");
# z# J- T1 u  yqryItem.setProperty("cost", "100", "gt");
. f" ^* h, P8 C- t- n& YItem results = qryItem.apply();
# c, J$ c$ l6 I% ?6 A+ X4 _int count = results.getItemCount(); ; t1 L2 O/ K% T5 C! M" w
int i;
9 ^7 Z; T7 U+ _2 h0 E( Q' Cstring content = "<table>"; 8 @, u% d( u  x; Y; ^: W8 l3 O+ r
for (i=0; i<count; ++i)
+ ~& F0 N! e5 v; Z& W% F8 e, y; i: S{
7 v: ?1 u/ M+ W  Item item = results.getItemByIndex(i);
2 V% W) }3 c' z1 p6 r# k0 C& T( H  content += "" + ' }/ s! |5 _' h, P3 g; Q
    "<tr>" +
2 ~' Q( ^& n" \7 A3 U0 j      "<td>" + item.getProperty("item_number") + "</td>" +
+ I7 r- Y7 z4 ]1 V8 d1 z      "<td>" + item.getProperty("description") + "</td>" + : U( X" P, n: b- m, B
      "<td>" + item.getProperty("cost") + "</td>" +
( `# d6 L" Z  q0 C. _1 ^    "</tr>";
, V( Z' w# u3 t" O6 l  U  p, P} 0 l7 o1 |/ n! r" w) O
content += "</table>"; # P$ _0 \4 U- h: M* y5 n! m6 p
Innovator innovator = this.newInnovator(); 1 W" f( u( r* G4 S* r6 r
return innovator.newResult(content);
8 P4 m& T* h' c: A # P' w; V) M' t! g$ e1 r
VB.Net  
1 N8 W4 Y+ }  HDim qryItem As Item = Me.NewItem("Part","get") $ {% {5 X5 W: [0 `5 ~. `
qryItem.SetAttribute("select","item_number,description,cost") , r2 l& E# H! T: ~3 s2 d1 H) G
qryItem.SetProperty("cost", "100", "gt")
- o/ V; _; B$ }+ \# r2 _$ J" ADim results As Item = qryItem.Apply() & W& `/ o2 ?2 `# c8 S, O# k
Dim count As Integer = results.GetItemCount()
7 o$ M. h* ^/ o' V* A: f; dDim i As Integer + E/ B7 h2 w1 a, }6 j
Dim content As String = "<table>"
8 S! A$ Z, |$ WFor i=0 to count - 1
7 p$ @: U! c0 f& o  }: {  Dim item As Item = results.GetItemByIndex(i)
! {: w( a9 r, y8 B% v  y$ K7 ?7 K6 b  content += "" + _
" D- `- A7 e1 {3 i& e" p    "<tr>" + _ 5 g& t, t' [8 a0 L! k& S
      "<td>" + item.GetProperty("item_number") + "</td>" + _
( I, e3 l: g2 m* P      "<td>" + item.GetProperty("description") + "</td>" + _ # d/ p4 O' W& `! t8 {+ }1 X
      "<td>" + item.GetProperty("cost") + "</td>" + _ 0 P" c+ U# ~% s- C% ?& N" ~
    "</tr>"
0 S8 f" a; G1 D/ h7 g$ J/ s6 oNext " _% R: K9 n4 Q: O, V6 z
content += "</table>" # `, F0 @0 x  \# E

  d0 E/ I) M3 zDim innovator As Innovator = Me.NewInnovator() 9 @8 q  D( Y! Y2 O4 I
return innovator.NewResult(content) % w2 g4 V& {7 l) C/ q% [, C, e

, ~  G" H4 S' a. J. L' \. a, L" \# i
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了