I have a report that has some chart and tables inside.
Chart is working properly. For Table i have created nested classes and i have assigned a those classes to related table.
Description:
I have MainTable which shows the list of CareAreas.
Inside Main Table i have another table called Detaildetable1 which shows the list of Questions.and Inside the DetailTable1
There is one more table DetailTable2, which shows the Resident's Information.
I have created 3 classes.
public class CareAreaDetail
{
private String _care;
private QCIDetail[] _qci;
public String CareAreaQCITag
{
get
{
return _care;
}
set
{
_care = value;
}
}
public QCIDetail[] qci
{
get
{
return _qci;
}
set
{
_qci = value;
}
}
}
public class QCIDetail
{
private String _qcisn;
private ResidentDetail[] _resindet;
public String QuestionShortName
{
get { return _qcisn; }
set { _qcisn = value; }
}
public ResidentDetail[] resDetail
{
get
{
return _resindet;
}
set
{
_resindet = value;
}
}
}
public class ResidentDetail
{
private String _resident, _room;
private DateTime _adate;
//public String QuestionShortName { get;set;}
public String ResidentName
{
get
{
return _resident;
}
set
{
_resident = value;
}
}
public String Room
{
get
{
return _room;
}
set
{
_room = value;
}
}
public DateTime AssessmentDate
{
get
{
return _adate;
}
set
{
_adate = value;
}
}
}
Now on Main Table's NeedDataSource event i have assigned the Array Object of CareAreaDetail Class.
For DetailedTable1's needdatasource property i have assigned QCIDetailed Class object and for DetailTable2, ResidentDetail class object.
Now where report is generated it shows proper Data in MainTable. bt in DetailTable1 and DetailTable2 it shows the same data for all the rows. i.e. for DetailTable1 it shows the data at index 0 in the QCITable class array in all rows and
for DetailTable2 it shows the data at index 0 in the ResidentDetail class array.
Here is the code.
private void DetailTable2_NeedDataSource_1(object sender, EventArgs e)
{
Processing.Table table = (Processing.Table)sender;
DetailTable2.DataSource = table.DataObject["resDetail"];
}
private void DetailTable1_NeedDataSource_1(object sender, EventArgs e)
{
Processing.Table table = (Processing.Table)sender;
DetailTable1.DataSource = table.DataObject["qci"];
}
private void MainTable_NeedDataSource_1(object sender, EventArgs e)
{
DataTable dt = GetAllResponses();
DataTable DistinctCareAreaTable = SelectDistinct(dt, "CareArea");
CareAreaDetail[] cad = new CareAreaDetail[DistinctCareAreaTable.Rows.Count];
int i = 0;
foreach (DataRow row in DistinctCareAreaTable.Rows)
{
cad[i] = new CareAreaDetail();
cad[i].CareAreaQCITag = "Care Area: " + row[0].ToString().Trim() + " (" + dt.Select("CareArea='" + row[0].ToString().Trim() + "'")[0]["QuestionTag"].ToString() + ")";
DataTable dtTemp = dt.Copy();
dtTemp.Clear();
DataRow[] TempDataRow = dt.Select("CareArea='" + row[0].ToString() + "'");
foreach (DataRow dr in TempDataRow)
dtTemp.LoadDataRow(dr.ItemArray, false);
DataTable DistinctQCITable = SelectDistinct(dtTemp, "QuestionShortName");
QCIDetail[] qd = new QCIDetail[DistinctQCITable.Rows.Count];
int j = 0;
foreach (DataRow drQCI in DistinctQCITable.Rows)
{
qd[j] = new QCIDetail();
qd[j].QuestionShortName = drQCI[0].ToString();
DataRow[] ResidentDataRow = dt.Select("QuestionShortName='" + drQCI[0].ToString() + "'");
ResidentDetail[] resDetail = new ResidentDetail[ResidentDataRow.Length];
int k = 0;
foreach (DataRow drRes in ResidentDataRow)
{
resDetail[k] = new ResidentDetail();
resDetail[k].ResidentName = drRes["Resident"].ToString();
resDetail[k].Room = drRes["Room"].ToString();
resDetail[k].AssessmentDate = (DateTime)drRes["AssessmentDate"];
k++;
}
qd[j].resDetail = resDetail;
j++;
}
cad[i].qci = qd;
i++;
}
Processing.Table table = (Processing.Table)sender;
table.DataSource = cad; // DATA assigned in the datasource is accurate and in proper format.
}
I have attached Image of that report.
Chart is working properly. For Table i have created nested classes and i have assigned a those classes to related table.
Description:
I have MainTable which shows the list of CareAreas.
Inside Main Table i have another table called Detaildetable1 which shows the list of Questions.and Inside the DetailTable1
There is one more table DetailTable2, which shows the Resident's Information.
I have created 3 classes.
public class CareAreaDetail
{
private String _care;
private QCIDetail[] _qci;
public String CareAreaQCITag
{
get
{
return _care;
}
set
{
_care = value;
}
}
public QCIDetail[] qci
{
get
{
return _qci;
}
set
{
_qci = value;
}
}
}
public class QCIDetail
{
private String _qcisn;
private ResidentDetail[] _resindet;
public String QuestionShortName
{
get { return _qcisn; }
set { _qcisn = value; }
}
public ResidentDetail[] resDetail
{
get
{
return _resindet;
}
set
{
_resindet = value;
}
}
}
public class ResidentDetail
{
private String _resident, _room;
private DateTime _adate;
//public String QuestionShortName { get;set;}
public String ResidentName
{
get
{
return _resident;
}
set
{
_resident = value;
}
}
public String Room
{
get
{
return _room;
}
set
{
_room = value;
}
}
public DateTime AssessmentDate
{
get
{
return _adate;
}
set
{
_adate = value;
}
}
}
Now on Main Table's NeedDataSource event i have assigned the Array Object of CareAreaDetail Class.
For DetailedTable1's needdatasource property i have assigned QCIDetailed Class object and for DetailTable2, ResidentDetail class object.
Now where report is generated it shows proper Data in MainTable. bt in DetailTable1 and DetailTable2 it shows the same data for all the rows. i.e. for DetailTable1 it shows the data at index 0 in the QCITable class array in all rows and
for DetailTable2 it shows the data at index 0 in the ResidentDetail class array.
Here is the code.
private void DetailTable2_NeedDataSource_1(object sender, EventArgs e)
{
Processing.Table table = (Processing.Table)sender;
DetailTable2.DataSource = table.DataObject["resDetail"];
}
private void DetailTable1_NeedDataSource_1(object sender, EventArgs e)
{
Processing.Table table = (Processing.Table)sender;
DetailTable1.DataSource = table.DataObject["qci"];
}
private void MainTable_NeedDataSource_1(object sender, EventArgs e)
{
DataTable dt = GetAllResponses();
DataTable DistinctCareAreaTable = SelectDistinct(dt, "CareArea");
CareAreaDetail[] cad = new CareAreaDetail[DistinctCareAreaTable.Rows.Count];
int i = 0;
foreach (DataRow row in DistinctCareAreaTable.Rows)
{
cad[i] = new CareAreaDetail();
cad[i].CareAreaQCITag = "Care Area: " + row[0].ToString().Trim() + " (" + dt.Select("CareArea='" + row[0].ToString().Trim() + "'")[0]["QuestionTag"].ToString() + ")";
DataTable dtTemp = dt.Copy();
dtTemp.Clear();
DataRow[] TempDataRow = dt.Select("CareArea='" + row[0].ToString() + "'");
foreach (DataRow dr in TempDataRow)
dtTemp.LoadDataRow(dr.ItemArray, false);
DataTable DistinctQCITable = SelectDistinct(dtTemp, "QuestionShortName");
QCIDetail[] qd = new QCIDetail[DistinctQCITable.Rows.Count];
int j = 0;
foreach (DataRow drQCI in DistinctQCITable.Rows)
{
qd[j] = new QCIDetail();
qd[j].QuestionShortName = drQCI[0].ToString();
DataRow[] ResidentDataRow = dt.Select("QuestionShortName='" + drQCI[0].ToString() + "'");
ResidentDetail[] resDetail = new ResidentDetail[ResidentDataRow.Length];
int k = 0;
foreach (DataRow drRes in ResidentDataRow)
{
resDetail[k] = new ResidentDetail();
resDetail[k].ResidentName = drRes["Resident"].ToString();
resDetail[k].Room = drRes["Room"].ToString();
resDetail[k].AssessmentDate = (DateTime)drRes["AssessmentDate"];
k++;
}
qd[j].resDetail = resDetail;
j++;
}
cad[i].qci = qd;
i++;
}
Processing.Table table = (Processing.Table)sender;
table.DataSource = cad; // DATA assigned in the datasource is accurate and in proper format.
}
I have attached Image of that report.