Passing datasources between forms and saving

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Magnus Bergh

    #1

    Passing datasources between forms and saving

    I am developing an application for pocketpc and this involvs a but of
    juggling with different forms.

    I have an "order entry" type of application. On the main form I have a
    grid which displays Order headers. Let call this form "OrderList"

    From this view I edit/enter new orders by opening a new form for
    entering data. This is done using (more or less) the designer generated
    forms, so I have a "Order edit view dialog. I pass the binding source to
    the child form (in constructor). When returning to main form
    "OrderList" I update the database (from the orderlist view checking if
    dialoresult is ok or cancel). Works fine.

    When entering order details I have a form which works much like the
    orderList form (let call this OrderDetailList ). I have a grid with order
    details row. I open the order detail form from "OrderList" passing the
    Orderheader binding source to the Order detail form. I enter/edit order
    detail rows the same way I do with the order header, ie opening a child
    form passing the order detail bindingsource to the edit dialog form.

    Note: the Designer has added dataset object (and tableadapters) to the
    order detail list.

    Now this works fine except for when I try to update the database. I
    first had something like this in the OrderDetail form:

    OrderDetailTabl eAdaper.Update( me.OrderDataSet )

    which didn't work. I come to the conclusion that it doesn't work because
    the DataSet objetc I have in the OrderDetailList is never filled with
    data since I have passed the bindingsource from the OrderList form.

    Am I correct about this?

    Anyway, my next try was to simply using the dataset of the OrderList
    from in the update:

    OrderDetailTabl eAdaper.Update( OrderList.Order DataSet)

    Which I don't like because it breaks the encapsulation of the form by
    referencing another form.

    I then got the idea to "why not pass the datasource of the
    bindingsource" like this:

    OrderDetailTabl eAdaper.Update( OrderHdrBinding Source.datasour ce)

    but that doesn't work, get some error message about latebound overload
    resolution not supported.

    How can I do this ?

    My own solution which is actually better than saving in the orderlist
    view is to do the update when I return to OrderList form. Then I have
    all the database updates in one location. But I still want to know how I
    could do this in the order detail list without having to reference the
    calling form.

    I guess one method is maybe to get the the modified rows and pass that
    to the update method. But still interestign to knwo if I can reference
    the datasource objetc id directly in some way.
Working...