Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2007

Tip: Looking for answers? Try searching our database.

SMART CLIENT save architecture

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pieter - 15 Mar 2007 14:49 GMT
We have a smart  client but we have some difficulties with saving our
business objects. We would like to have one save method on the client side.
But our problem is that we can't find a good method to find out wathever we
should do an insert or an update on our server side.
What possibilities do you suggest to do this ...
thx in advance!!
VJ - 15 Mar 2007 15:01 GMT
To have a single save you can have a abstract class (object) that runs a
save, and then derive all other business objects from this abstract class.
So you put your save code here.. If the save is going to have different
implementation for each object, but same method signature, then define
interface and make all your business objects implement interface.. Whatever
fits you best, make a call.

For the server side.. DataAdapaters are the best way to interact with a DB
to insert and retrieve data

HTH
VJ

> We have a smart  client but we have some difficulties with saving our
> business objects. We would like to have one save method on the client
[quoted text clipped - 4 lines]
> What possibilities do you suggest to do this ...
> thx in advance!!
RobinS - 15 Mar 2007 20:14 GMT
I am doing what you're talking about. Check out "Doing Objects in VB2005"
by Deborah Kurata. It just came out. It illustrates how to split your app
into layers, and then do updates on the business layer. Even if you are a
C# developer, this book can be really helpful to you. It's very pragmatic
and if you do the follow-along work, you end up building an entire
application.

I have a base class that all of my business objects inherit. It has a
property called EntityState that keeps track of the state of my object,
which matches the RowState of a DataSet.

Public Enum EntityStateEnum
   Unchanged
   Added
   Deleted
   Modified
End Enum

Private _EntityState As EntityStateEnum
Protected Property EntityState() As EntityStateEnum
   Get
       Return _EntityState
   End Get
   Private Set(ByVal value As EntityStateEnum)
       _EntityState = value
   End Set
End Property

'You can use this to check and see if anything has changed.
Protected ReadOnly Property IsDirty() As Boolean
   Get
       Return Me.EntityState <> EntityStateEnum.Unchanged
   End Get
End Property

Protected Sub DataStateChanged(ByVal dataState As EntityStateEnum)
   'if the state is deleted, mark it as deleted
   'if they are adding a new one, mark it as an add so
   '  the stored procedure knows to insert it
   If dataState = EntityStateEnum.Deleted _
     Or dataState = EntityStateEnum.Added Then
       Me.EntityState = dataState
   End If
   If Me.EntityState = EntityStateEnum.Unchanged _
     OrElse dataState = EntityStateEnum.Unchanged Then
       'they are changing it from add or change or delete back to
unchanged
       'or from unchanged to something else
       Me.EntityState = dataState
   End If
End Sub

In my business object's class, I set dataSetChanged:
 -- in the Create method, if adding, set it to Added
 -- in the Create method, if it already exists, set it to Unchanged
 -- in the Delete method, set it to Delete
 -- in every property, if they change a value, set it to Modified.

When I call my Save routine, it calls my SP and passes in this EntityState
as a parameter; it is used in the SP to decide whether to Insert, Update,
or Delete the record. My SP contains all three queries.

Hope this helps.
Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
-------------------------------------------------------------
> We have a smart  client but we have some difficulties with saving our
> business objects. We would like to have one save method on the client
[quoted text clipped - 4 lines]
> What possibilities do you suggest to do this ...
> thx in advance!!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.