Link to home
Start Free TrialLog in
Avatar of babybird
babybird

asked on

winforms treeview and gathering related data through datasets

I have the following tables:
Report - contains reports to list in treeview
        Report_cd     Parent_cd     Report_name    report_obj
              2                1             'my report 1'       c:\reports\myreport1.rpt
              3                1             'my report 2'       c:\reports\myreport2.rpt
              4                1             'my report 3'       c:\reports\myreport3.rpt

Report_dm - this gives more info on the report for generation
        Report_cd         report_type   report_node
              2                  pdf                 MYRPT1  
              3                  xls                 MYRPT2          
              4                  pdf                 MYRPT3        

Report_Parameters - this contains the parameters required to call the report. My intention is to dynamically build screens based on this info...that's my intention anyway....I haven't completely figured this out yet.
       Report_cd         parameter_nmbr parameter_name        parameter_control
              2                         1                 Group Number            ddlst_group_nmbr
              2                         2                 Statement Date          ddlst_statement_dt

Ignore report parameters for now....I've gotten the treeview populated my report list.  I'm now on to the double click event to generate the report.  Firstly, however I need the information from the report_dm to construct a file name and I would need the parameters so I can prompt for the information.  This process could be called for one group or loop through and do all groups.  I'm trying to identify the 'right' way to store and access the information so when processing all groups, I'm not hitting the database to get the same info over and over for the different groups.  My inital thought is to go get all this info and store in a collection...not sure how the parameters would work in this case... maybe multiple collections. I don't know..I'm very new at this.  Anyway, I've now double clicked on my tree node.... now I need this information so I can generate the report.  In my dataset to build the tree, I've only pulled back the report_cd, parent_cd and report name...just what is needed to build the tree. How should I gather the remaining info so I can call the report generating class?

thanks so much!
Avatar of topdog770
topdog770
Flag of United States of America image

What do you see as being the next simplest step?  In other words, what is the one thing you are trying to accomplish ( next, first, etc )
So now you have your treeview bind to Report  right?.
Ok let say that you assign report_cd to Tag property of TreeNode. You can gather the remaining info of report from dataset.

- First, you need to retrieve all report data from database and put into a dataset (Report to a DataTable, Report_dm to a DataTable and Report_Parameters to another DataTable then put to DataSet dstData).
- When you double click on a node, retrieve report_cd from selected node and (named strReportCD):
// select all report dm from dataset which belong to selected report cd
DataRow[] drowsReportDM = dstData.Tables["Report_dm"].Select("report_cd = '" + strReportCD + "'";
// select all report parameters from dataset which belong to selected report cd
DataRow[] drowsReportParam = dstData.Tables["Report_Parameters"].Select("report_cd = '" + strReportCD + "'";
// now you can interact with two DataRowCollection.
Avatar of babybird
babybird

ASKER

Would it be best to get the data for the given report cd on the double click - as needed - or in advance and selecting from the dataset tables?

I guess I really have three situations....
1) they select a report from the tree and it immediately pulls up the parameter screen and generates that specific report
    a) in this case, it seems like it would be best to get the info when they double click
2) they select 'monthly invoice' from the tree and this goes into a process that via the database, identifies all the reports assigned to each group and then loops through and generates these reports for each group
   b) in this case, it seems like I should get all the info for all the reports at once so I don't keep hitting the database for the loop, pulling the same info over and over for the same reports, different groups.  This is where I was thinking maybe a collection (and believe me, I know VERY little of what I'm talking about), maybe get accessors.... maybe an array... just something so that I don't have to keep hitting the database over and over to get report data.  What would be 'good' coding?
3) they select 'reprint' which is much like 2 only it is for one group.  It would get all reports assigned to one group and then generate each report for that group.  Not a loop.
   c) in this case, it would seem like it would be better to hit the database for each report, since I will only have a given report generated once. then I wouldn't be dealing with more data than necessary.

However, the number of report rows we would be dealing with is less than 300.  

is there any option that would be better?
ASKER CERTIFIED SOLUTION
Avatar of dungla
dungla
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial