Showing posts with label Departments. Show all posts
Showing posts with label Departments. Show all posts

Thursday, 18 September 2008

Reading and Updating Departments in Sage

In Sage, products are often assigned to Departments, for example, a food wholesaler might have a department for frozen foods, and one for fresh foods.

Reading and updating departments in Sage via Sage Data Objects is easy, and here's how.

Reading departments:

Dim IDepartment As SageDataObject50.Department

Dim strDescription As String

IDepartment = DirectCast(ws50.CreateObject("DepartmentData"), SageDataObject50.Department)

Dim i As Int16

For i = 0 To 100

IDepartment.Read(i)

strDescription = IDepartment.Fields.Item("NAME").Value.ToString()

Me.lvDepartments.Items.Add(strDescription)

Next


To update them, you just use the write(int) method.


Dim IDepartment As SageDataObject50.Department

Dim strDescription As String

IDepartment = DirectCast(ws50.CreateObject("DepartmentData"), SageDataObject50.Department)

Dim i As Int16

For i = 0 To 100

IDepartment.Fields.Item("NAME").Value = "RESET"

IDepartment.Write(i)

Next