mskvarenina
February 27th, 2000, 09:33 AM
I am writing an app that will load a matrix of accounts and document types from a detail file which may contain many accounts and many documents of the same type for each account. Basically all this will be loaded into a treeview with each account showing up only once as a parent, then each document type (only once) under that, and finally every document record read, stored uder the correct account and document type. So for example, I may have some raw data that may come in like this:
Account#, DocType, Date created
55555555, 2, 2/2/00
22222222, 1, 1/31/99
33333333, 1, 1/25/00
55555555, 2, 12/31/99
55555555, 2, 2/1/00
55555555, 1, 11/30/98
The ultimate goal would be to have the tree something like this:
22222222
---1
------1/31/99
33333333
---1
------1/25/00
55555555
---1
------11/30/98
---2
------12/31/99
------2/1/00
------2/2/00
So I am looking for the proper way to store this stuff so A)I can properly load the treeview without adding duplicates and B)so I can access the data at the document level (I simplifed this example, for the purposes of asking for help).
At first I thought I could use a multidimensional array. I would have a single dimension array with just accounts in it and search that array first to see what index a particular account is in. I would use the 2nd dimension to hold the document type. Problem is I don't know ahead of time if I will have 1 or 100 document types for a particular account and I don't want to make a big fixed size array and waste alot of memory.
What I really have here or would like I suppose is an array inside an array. In this approach I would have the account array holding the document type array (which could be a different size for each account).
So my actual question here is how would you implement this situation? I suppose the easiest would be to declare a large multi-dim array, but I wonder if I could use a collection or several collections, or even better, an object. I don't know much about objects yet but maybe there is some way to create one object for each account. I could still have my account array to determine if I 'have' that account already and if not create a new object with it's own array. Even with this approach however, how would I get down to that level, the array within the particular object when desired?
Thanks for taking the time to read all this and I hope you can help me find a solution!
Account#, DocType, Date created
55555555, 2, 2/2/00
22222222, 1, 1/31/99
33333333, 1, 1/25/00
55555555, 2, 12/31/99
55555555, 2, 2/1/00
55555555, 1, 11/30/98
The ultimate goal would be to have the tree something like this:
22222222
---1
------1/31/99
33333333
---1
------1/25/00
55555555
---1
------11/30/98
---2
------12/31/99
------2/1/00
------2/2/00
So I am looking for the proper way to store this stuff so A)I can properly load the treeview without adding duplicates and B)so I can access the data at the document level (I simplifed this example, for the purposes of asking for help).
At first I thought I could use a multidimensional array. I would have a single dimension array with just accounts in it and search that array first to see what index a particular account is in. I would use the 2nd dimension to hold the document type. Problem is I don't know ahead of time if I will have 1 or 100 document types for a particular account and I don't want to make a big fixed size array and waste alot of memory.
What I really have here or would like I suppose is an array inside an array. In this approach I would have the account array holding the document type array (which could be a different size for each account).
So my actual question here is how would you implement this situation? I suppose the easiest would be to declare a large multi-dim array, but I wonder if I could use a collection or several collections, or even better, an object. I don't know much about objects yet but maybe there is some way to create one object for each account. I could still have my account array to determine if I 'have' that account already and if not create a new object with it's own array. Even with this approach however, how would I get down to that level, the array within the particular object when desired?
Thanks for taking the time to read all this and I hope you can help me find a solution!