Results 1 to 3 of 3

Thread: Data Object and Business object

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    65

    Data Object and Business object

    Hi,

    I saw in the book. it said that usually we make a data object for each table in the database. But I do not know how to join these object. Such as, I have a data object for Order Table, one for OrderDetail table, one for Product table and an other one for Customer Table. But I do not know how use these together to create a order form. Because in this context these objects are related each other. In this case I do not know should I biuld one Data object Order that include all of them (OrderID, Customer, Orderdetail, products...) or just build seperate data objects as above and use a Business object to link them together?but how to? Are there anybody know about this? Could you please show me in this case?

    Thanks in advance,

    Trung Luu

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You could have an Order class with a method like GetOrderDetails that returns a collection of OrderDetail classes for that given Order.

  3. #3
    New Member
    Join Date
    May 2002
    Location
    UK
    Posts
    14
    Hi,
    right ok..

    what i would do is create:

    clsOrders
    clsOrder
    clsOrderDetails
    clsOrderDetail

    clsOrders:
    private collection for clsOrder objects
    methods: Add, Delete
    Add simply takes an clsOrder object and adds it to the collection using the orders unique key.
    Delete takes the unqiue key for the clsOrder object you want to delete and removes it out of the collection..
    LoadData method takes in a search string of some sort and creates new clsOrder objects calling its load data method with the order number.. and then calls its own add function passing in the new clsOrder

    clsOrder:
    public Order fields. e.g. OrderNumber, CustomerName..etc
    private object clsOrderDetails
    LoadData method takes order number and loads clsOrder object with data from database..
    LoadData also calls the clsOrderDetails.LoadDetails method with the order number.

    clsOrderDetails:
    private collection for clsOrderDetail objects
    methods: Add, Delete
    Add simply takes an clsOrderDetail object and adds it to the collection using the order details unique key.
    Delete takes the unqiue key for the clsOrderDetail object you want to delete and removes it out of the collection..
    LoadDetails takes the order number and gets all the order details for that order. It then creates clsOrderDetail objects and calls its loaddata method with the order detail's unique reference. It then calls its own add method passing it the new clsOrderDetail object which is then added to the collection.

    and finaly
    clsOrderDetail:
    public OrderDetail fields. e.g. OrderNumber, item on order, quantity...etc
    loaddata method that takes in a unique reference for an order detail line and loads all the properties of that line into the object.

    You will probably want to write an item method for clsOrders and clsOrderDetails with takes an index and returns an object reference..
    you will also want to write a newenum function so you can do things like
    for each lobj in lobjOrderDetails
    next

    this is just your business objects.. you will need to write your data objects to return a recordset or something for each load data routine.... for example.. your loaddata rountine in your clsOrders object simply needs the orders order numbers. The loaddata method in the clsOrder simple needs a specific orders properties.. The loaddata method in the clsOrderDetails object simply needs the order details unqiue references.. and finaly the clsOrderDetail object needs the order details properties..

    hope that helps..

    rgds
    chris

    --edit--

    and you can apply the same ideas for product table and customers table... with orders and invoices and stuff like that you tend to copy the data from the customer table onto the order so that you have an actual record of where the items were sent rather than what the current address is for that person. So your customer/product objects probably wont be linked to your order and order detail objects..
    Last edited by lon; Aug 8th, 2002 at 03:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width