来自类的ReportViewer中的嵌套矩阵

时间:2012-01-17 15:31:01

标签: c# object report reportviewer

我希望有人可以帮助我,我创建了一个自定义对象类,它包含几个数据和几个列表。我通过使用多个SQL查询和一些C#计算来填充对象。

在对象中,我有以下内容,

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;

我的想法是设置一个cell_name,supervisor等,然后针对那个单元格设置人们的实际分数。

我这样称呼对象:

results = new Cell(1, "Cell name 1", 80.00);
            results.setSupervisor("John Doe");
            results.setTargets(90, 90, 7, 3, 6.5);
            results.setMachinist("Bob Oblong", 76, 98, 0, 1, 2, 0, 0, 1);
            results.setMachinist("Mary Mask", 72, 91, 0, 1, 2, 0, 0, 1);
this.CellBindingSource.DataSource = results;

            this.reportViewer1.RefreshReport();

问题是如何设置报告以列出我想要的格式的所有单元格,并在这些单元格中列出机械师????

示例报告输出:  Report Output Example

以下完整课程代码:

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;
        }
    }

}

1 个答案:

答案 0 :(得分:1)

使用嵌套列表和子报告是简短的答案!