admin 发表于 2018-8-1 13:37:47

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





Technique
There is no difference in setting up a query for a single Item or for many.Only the
criteria define the set size returned.In this recipe you create an Item and populate
the query criteria, apply it, and iterating over the Items returned producing a HTML
<TABLE>fragment.


JavaScript
var qryItem = this.newItem("Part","get");
qryItem.setAttribute("select","item_number,description,cost");
qryItem.setProperty("cost", "100", "gt");
var results = qryItem.apply();
var count = results.getItemCount();
var content = "<table>";
for (var i=0; i<count; ++i)
{
var item = results.getItemByIndex(i);
content += "" +
    "<tr>" +
      "<td>" + item.getProperty("item_number") + "</td>" +
      "<td>" + item.getProperty("description") + "</td>" +
      "<td>" + item.getProperty("cost") + "</td>" +
    "</tr>";
}
content += "</table>";
return content;

C#
Item qryItem = this.newItem("Part","get");
qryItem.setAttribute("select","item_number,description,cost");
qryItem.setProperty("cost", "100", "gt");
Item results = qryItem.apply();
int count = results.getItemCount();
int i;
string content = "<table>";
for (i=0; i<count; ++i)
{
Item item = results.getItemByIndex(i);
content += "" +
    "<tr>" +
      "<td>" + item.getProperty("item_number") + "</td>" +
      "<td>" + item.getProperty("description") + "</td>" +
      "<td>" + item.getProperty("cost") + "</td>" +
    "</tr>";
}
content += "</table>";
Innovator innovator = this.newInnovator();
return innovator.newResult(content);

VB.Net
Dim qryItem As Item = Me.NewItem("Part","get")
qryItem.SetAttribute("select","item_number,description,cost")
qryItem.SetProperty("cost", "100", "gt")
Dim results As Item = qryItem.Apply()
Dim count As Integer = results.GetItemCount()
Dim i As Integer
Dim content As String = "<table>"
For i=0 to count - 1
Dim item As Item = results.GetItemByIndex(i)
content += "" + _
    "<tr>" + _
      "<td>" + item.GetProperty("item_number") + "</td>" + _
      "<td>" + item.GetProperty("description") + "</td>" + _
      "<td>" + item.GetProperty("cost") + "</td>" + _
    "</tr>"
Next
content += "</table>"

Dim innovator As Innovator = Me.NewInnovator()
return innovator.NewResult(content)


页: [1]
查看完整版本: 【Aras二次开发】查询和迭代查找item集