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 / February 2006

Tip: Looking for answers? Try searching our database.

Data Storage Suggestions??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian P. Hammer - 19 Feb 2006 19:37 GMT
I load a bunch of data from a dataset (about 10 rows with 125 columns) and
with the dataset rows, I perform a bunch (about 75) of calculations. The
results of all this are loaded into a third party (C1 FlexGrid) grid. I am
trying to figure out the best way to store all this data so that it is
easier to work with and perform calculations as users edit the grid.
Currently, I have to do lookups back to the datasets and reference each
row/column of the grid.  I guess I am looking for some sort of collection
class but the .Net help hasn't provided any real clues as to the direction
to go.  A thought was to have some sort of dataset hold all the combined
data and calculations. Before I head off in any direction, I thought I'd get
suggestions.  Any you have would be great.

Thanks,
Brian
SP - 19 Feb 2006 22:38 GMT
>I load a bunch of data from a dataset (about 10 rows with 125 columns) and
>with the dataset rows, I perform a bunch (about 75) of calculations. The
[quoted text clipped - 7 lines]
>data and calculations. Before I head off in any direction, I thought I'd
>get suggestions.  Any you have would be great.

Without a complete understanding of your situation here are a few thoughts.
I am relating this to similar situations I come across. I think of it as the
business object / display mismatch problem.

As I see it you start with data from a few datasets and then calculate and
create another dataset from this information and then display this dataset
in a grid. After a change is made in the grid you then have to translate
this back to the appropriate dataset / datarow / datacolumn and update and
recalculate and then display the updated data in the grid. This can be very
tedious (and datasets don't help!!).

The additional layer of getting the data into a displayable format is
necessary because the grid is forcing you into a row / column paradigm that
is mismatched with your more hierarchical object based data. In these
situations I avoid a databound grid and use an unbound grid. For example I
might have a collection that contains 10 objects but when displayed it will
be only 4 rows. That is because for display purposes I want to place the
information from 2 or more objects on the same row because the information
is from the same date. So objects containing date and value like 1/1/05 -
22, 1/1/05 - 34, 1/2/05 - 44, 1/2/05 - 23 may need to be displayed like
1/1/05 - 22 - 34 - 56, 1/2/05 - 44 - 23 - 67 (a total also needs to be
displayed in this example). You lay out the data as you iterate your
collections placing the values where you want. Unbound grids offer the
advantage of tagging each cell with the object that is displayed in that
cell so you can get back to the original object easily.

If you need or want to stay with a data bound grid then go with collection
classes and design your objects so that you can get back to the calculation
objects easily from the displayed row object. In the example above
MyCalculationClass has a Date and an Amount property. From these objects we
create a collection of Display objects. MyDisplayClass has Date, Amount1,
Amount2, Amount3 and Total properties but more importantly also has
references to the "originating" MyCalculationClasses so that when Amount1 is
edited I can delegate this edit directly to the correct MyCalculation class.

HTH

SP
Brian P. Hammer - 20 Feb 2006 02:24 GMT
SP - Thanks for the feedback.  You are on-track with my issue except the
fact that my grid is unbound.  Here's what I basically do.  Load a dataset,
add this info to a temp dataset, load info from another dataset and then
merge the data into one dataset.  I then loop through the rows and and
manually populate my grid, adding in grid rows where needed for the
calculations.  Here is kind of the way that I load everything up...

For Each item As String In My.Forms.AircraftSelector.names
   Me.TblAircraftSpecificTableAdapter.FillByAircraftModel(Me.LEADDataSet.tblAircraftSpecific,
item.ToString)
   ds.Merge(LEADDataSet)
Next item
LEADDataSet.Merge(ds)

For r = 0 To Me.LEADDataSet.tblAircraftSpecific.Rows.Count - 1
   intAircraftID =
CInt(Me.LEADDataSet.tblAircraftSpecific.Rows(r)("IDAircraftSpecific").ToString)
   Me.TblModificationTableAdapter.FillBy(Me.LEADDataSet.tblModification,
intAircraftID)
   Me.TblAircraftInspectionTableAdapter.FillBy(Me.LEADDataSet.tblAircraftInspection,
intAircraftID)
   intRunMods = Me.LEADDataSet.tblModification.Rows.Count
   If intRunMods > intKeepMods Then intKeepMods = intRunMods
   intRunInsp = Me.LEADDataSet.tblAircraftInspection.Rows.Count
   If intRunInsp > intKeepInsp Then intKeepInsp = intRunInsp
Next

'Then I begin to load the grid...

For i = 0 To intRows
   Me.TblAPUTableAdapter.FillBy(Me.LEADDataSet.tblAPU, CInt(GetAircraft(i,
"APUID", True)))
   Me.TblEngineModelTableAdapter.FillBy(Me.LEADDataSet.tblEngineModel,
CInt(GetAircraft(i, "EngineID", True)))
   Me.TblAircraftCategoryTableAdapter.FillBy(Me.LEADDataSet.tblAircraftCategory,
CInt(GetAircraft(i, "CategoryID", True)))
   Me.TblGlobalVariablesTableAdapter.Fill(Me.GlobalVariablesDataSet.tblGlobalVariables)
   blnHasAPU = HasAPU() 'Check for an AircraftSpecific APU
   blnHasEngine = HasEngine() 'Check for an AircraftSpecific Engine

flxRow = 1
strManMod = GetAircraft(i, "AircraftManufacturer") & " " & GetAircraft(i,
"AircraftModel")
Me.txtStatus.Text = "Loading " & strManMod
Me.flxAllData.SetData(flxRow, j, strManMod)

Me.flxAllData.SetData(flxRow, 0, "Liability Insurance")
'Me.flxAllData.Rows(k).Style = styCurrency
Me.flxAllData.Rows(flxRow).AllowEditing = True
Me.flxAllData.SetData(flxRow, flxClmn,
CDec(GetAircraftCategory("LiabilityInsurance", True)))
rLiabilityInsurance = flxRow
flxRow += 1

Me.flxAllData.SetData(flxRow, 0, "Number of Pilots")
'Me.flxAllData.Rows(k).Style = styNumber
Me.flxAllData.Rows(flxRow).AllowEditing = True
Me.flxAllData.SetData(flxRow, flxClmn,
CInt(GetAircraftCategory("CrewNumber", True)))
rCrewNumber = flxRow
flxRow += 1

'END OF Sample

flxAllData is the Grid and GetAircraftCategory is simply a function to
return the value from the dataset specific row.

Now, when it comes to calculations, I have to reference the row and column
to get each values I want to use in my calculation.

Another thing I want to do is to set up the loading of all the data and
calculations over to another thread and then display the data to the grid.
I will look more at the collection class but thought I had eliminated it for
one reason or another.

Regards,
Brian

>>I load a bunch of data from a dataset (about 10 rows with 125 columns) and
>>with the dataset rows, I perform a bunch (about 75) of calculations. The
[quoted text clipped - 47 lines]
>
> SP
SP - 20 Feb 2006 04:39 GMT
> SP - Thanks for the feedback.  You are on-track with my issue except the
> fact that my grid is unbound.  Here's what I basically do.  Load a
[quoted text clipped - 77 lines]
> Regards,
> Brian

When I look at the code example I see a need to separate out your business
objects, the database interaction, and the presentation. I have never been a
fan of datasets and perhaps moving away from them will then allow you to
build an object model that represents the relationships between the various
business objects.  Then the lookup / functions that you are calling as you
load the grid can be encapsulated within your business objects. Then your
loading of the grid could be more like (my VB is a little rusty!!)

For Each Aircraft aircraft In Aircrafts
  Me.flxAllData.SetData(flxRow, 0, aircraft.Manufacturer)
   Me.flxAllData.SetData(flxRow, 1, aircraft.Model")
End For

Having a business object model allows you to get to the information you need
by navigating from object to object like aircraft.Manufacturer.Models.Count.
So given an aircraft you can easily get to the number of different aircraft
manufacturered by the maker of that aircraft.

HTH

SP
Brian P. Hammer - 20 Feb 2006 05:12 GMT
Thanks for the feedback.  I'll do some reading into business objects. What
you say makes sense.

>> SP - Thanks for the feedback.  You are on-track with my issue except the
>> fact that my grid is unbound.  Here's what I basically do.  Load a
[quoted text clipped - 101 lines]
>
> SP

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.