winforms treeview and gathering related data through datasets

Posted on 2006-04-26
Last Modified: 2010-04-16
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!
Question by:babybird
    LVL 12

    Expert Comment

    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 )
    LVL 13

    Expert Comment

    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.

    Author Comment

    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?
    LVL 13

    Accepted Solution

    I think the first option is better. User wish to view individual report not wish to view "all" report in a group.
    LVL 12

    Assisted Solution

    We've taken the approach populating the control/view with the smallest amount of data needed.

    In the case of the TREECONTROL, as example, I only populate the node level(s) needed to show the user all expanded data.. as they expand further down.. I populate the more specific, detailed ( and larger ) amounts of data.

    It's increased the responsiveness of the program ( and reports ) by quite a bit.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now