Hi all!
I have a Master report containing a sub report. In the sub report i'm trying to use a userdefined function called returnThis(). Below are the two versions of the function.
public static double returnThis()
{
return 22.6;
}
//public static double returnThis(double avgMark)
//{
// //SqlConnection conn = null;
// //conn = new SqlConnection("Data Source=AGAHIMBARE-PC;Initial Catalog=VTLARIMS;Integrated Security=True");
// //conn.Open();
// //string strSQLCommand = "SELECT Top(1) GradePoint FROM GradeMarks WHERE avgMark BETWEEN LowerPercentage AND UpperPercentage";
// //SqlCommand command = new SqlCommand(strSQLCommand, conn);
// //string xx = command.ExecuteScalar().ToString();
// // double returnvalue = System.Convert.ToDouble(xx);
// //conn.Close();
// // return returnvalue;
// return avgMark;
//}
when i use the one without any argument, it works fine ie. returns 22.6
However when i use the one which is passed a parameter (the disabled one) i get "An error occured while trying to process text box. The expression contains undefined function call returnThis()"
I call the function using =returnThis(52.1) as the value for a textbox on the subreport.
Can anyone help me here plz. Thnx so much.
//Pie chart Item Data Binding
private void pieChart_ItemDataBinding_1(object sender, EventArgs e)
{
Telerik.Reporting.Processing.Chart chart = sender as Telerik.Reporting.Processing.Chart;
Telerik.Reporting.Processing.DetailSection section = (Telerik.Reporting.Processing.DetailSection)chart.Parent;
Telerik.Reporting.Processing.IDataObject dataObject = (Telerik.Reporting.Processing.IDataObject)section.DataObject;
object rowdata = (object)section.DataObject.RawData;
Telerik.Reporting.Processing.TextBox procTextbox = (Telerik.Reporting.Processing.TextBox)section.ChildElements.Find("taskIDTextBox", true)[0];
Telerik.Reporting.Chart chartDef = (Telerik.Reporting.Chart)chart.ItemDefinition;
Telerik.Reporting.Charting.ChartSeries series = new Telerik.Reporting.Charting.ChartSeries();
series.Type = ChartSeriesType.Pie;
Telerik.Reporting.Charting.ChartLegend legend = new Telerik.Reporting.Charting.ChartLegend();
string CoverDescription;
int itemValue;
string commandText = string.Empty;
SqlConnection connection = new SqlConnection(global::QTaskReporting.Properties.Settings.Default.QTDbConnString);
commandText = "SELECT COUNT(*) AS ItemCount, SDesc, SColor FROM vwSubTasksAndStatuses where TaskID = " + procTextbox.Value + " GROUP BY SDesc,SColor";
SqlCommand cmd = new SqlCommand(commandText, connection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow rowView in ds.Tables[0].Rows)
{
Telerik.Reporting.Charting.ChartSeriesItem seriesItem = new Telerik.Reporting.Charting.ChartSeriesItem();
//The chart Y value will be based on the Value amount
seriesItem.YValue = Convert.ToInt32(rowView["ItemCount"]);
seriesItem.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
//The chart item label should be set to the Value amount
itemValue = Convert.ToInt32(rowView["ItemCount"]);
seriesItem.Label.TextBlock.Text = rowView["SColor"].ToString().Trim() + " - " + rowView["SDesc"].ToString();
seriesItem.Label.Appearance.LabelLocation = Telerik.Reporting.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;
seriesItem.Label.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(58)))), ((int)(((byte)(112)))));
seriesItem.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
seriesItem.Appearance.FillStyle.MainColor = ColorTranslator.FromHtml("#" + rowView["SColor"].ToString().Trim());
//Assign the chart item description
CoverDescription = rowView["SDesc"].ToString();
seriesItem.Name = CoverDescription.Trim();
//Give the "New" chart item an exploded appearance
if (seriesItem.Name == "New")
{
seriesItem.Appearance.Exploded = true;
}
series.AddItem(seriesItem);
}
//Display the legend
series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
series.Appearance.Border.Color = System.Drawing.Color.White;
series.Appearance.Border.Visible = false;
series.Appearance.DiameterScale = .90;
series.Appearance.ExplodePercent = 10;
chartDef.Series.Clear();
chartDef.Series.Add(series);
chartDef.Legend.Appearance.Position.AlignedPosition = Telerik.Reporting.Charting.Styles.AlignedPositions.TopRight;
}
Dim
oTabla
As
New
DataTable
oTabla.Columns.Add(
"F1"
)
oTabla.Columns.Add(
"F2"
)
oTabla.Columns.Add(
"F3"
)
oTabla.Columns.Add(
"F4"
)
Dim
objectDataSource3
As
New
Telerik.Reporting.ObjectDataSource()
Dim
oReport3
As
New
ReportNew1
oReport3.DataSource = oTabla
Dim
oFrm
As
New
FrmReportViewer
oFrm.ReportViewer1.Report = oReport3
oFrm.ReportViewer1.RefreshReport()
oFrm.ShowDialog()