Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am facing sometimes the problems that my ideas do not get to work.

I have an application with several reports.
In a Webpage I use a GridView to show the report data triggered by a Button.
Since all reports have infact the same functionality: a generic class should be usable.
WebPage
- GridView
- Button
- Some selection item used as parameters for DB
Report
- DataTable with Records for GridView
- parameterArray
Data Access Layer
- Generic Report class -> internal. I have a public sealed that should be called by the business logic

C#
internal class SimpleReport
{
   internal string StoredProcedure {get; set;}
}

internal class OtherReport
{
   internal string StoredProcedure {get; set;}
}

internal class Report<T> where T : class
    {
        public event Action<DataTable> GeneratedReport;

        /// <summary>
        /// Generates the specified t.
        /// </summary>
        /// <param name="t">The t.</param>
        internal void Generate()
        {
            DataTable aTable = new DataTable();
            /// How to use property StoredProcedure from SimpleReport/OtherReport here?
            /// The class SimpleReport/OtherReport is in the 'T'
            if (GeneratedReport != null)
                GeneratedReport(aTable);

        }
    }

In the Generic class the T could be SimpleReport. In SimpleReport I have a DataTable property. T could also be WeeklySalesreport and has the same DataTable property (by name -> public DataTable Values;
How can I use the property Values in the Generic class based on the given event Action<datatable> GeneratedReport?

Furthermore each report class could have different set of parameters (they all have reportperiodID -int- common) How could I map them via the Generic class?

Or is my idea totally wrong?
Posted
Updated 15-Oct-14 1:09am
v5
Comments
Sergey Alexandrovich Kryukov 14-Oct-14 12:37pm    
What does it mean "to load a class"? "A generic class load a class"?
—SA
Herman<T>.Instance 15-Oct-14 4:37am    
I can understand you can't understand my idea. It is hard to explain for me.
In fact I have a class for reports with properties. And when using the generic class (that is used for a class for a report) these properties should be used.
Sergey Alexandrovich Kryukov 15-Oct-14 11:39am    
Even now, I have no idea. It needs detail.
—SA
Maciej Los 14-Oct-14 16:20pm    
We don't get your idea... ;(
Herman<T>.Instance 15-Oct-14 4:37am    
I can understand you can't understand my idea. It is hard to explain for me.
In fact I have a class for reports with properties. And when using the generic class (that is used for a class for a report) these properties should be used.

C#
public class Cell
{
    private int cell_id;
    private string cell_name;
    private string cell_supervisor;
    private double cell_target;
    private double cell_routing_target, cell_attended_target, cell_lost_time_target, cell_unaccounted_time_target, cell_absence_target;
    private List<string> cell_machinists;
    private List<double> cell_routing_actual, cell_attended_actual, cell_lost_time_actual, cell_unaccounted_time_actual, cell_absence_actual;
    private List<int> cell_ncr_qty;
    private List<double> cell_ncr_cost;
    private List<int> cell_timelost;

    public Cell(int id, string name, double target)
    {
        cell_id = id;
        cell_name = name;
        cell_target = target;
    }
    public void setSupervisor(string name){
        cell_supervisor = name;
    }

    public void setTargets(double routings, double attended, double losttime, double unacccounted, double abscence)
    {
        cell_routing_target = routings;
        cell_attended_target = attended;
        cell_lost_time_target = losttime;
        cell_unaccounted_time_target = unacccounted;
        cell_absence_target = abscence;
    }
    public void setMachinist(string name, double routings, double attended, double lost_time, double unaccounted_time, int ncr_qty, double ncr_cost, int time_lost, double absence)
    {
        cell_machinists.Add(name);
        cell_routing_actual.Add(routings);
        cell_attended_actual.Add(attended);
        cell_lost_time_actual.Add(lost_time);
        cell_unaccounted_time_actual.Add(unaccounted_time);
        cell_ncr_qty.Add(ncr_qty);
        cell_ncr_cost.Add(ncr_cost);
        cell_timelost.Add(time_lost);
        cell_absence_actual.Add(absence);
    }


    public string CellName
    {
        get {
            return cell_name;
        }
    }

    public string Supervisor
    {
        get
        {
            return cell_supervisor;
        }
    }
    public List<string> Machinists
    {
        get
        {
            return cell_machinists;
        }
    }

}


Use nested lists and sub reports is the short answer!
 
Share this answer
 
v2
i fixed it by using a constructor in the generic class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900