I have a problem with a Visual Studio 2005 web project.
I have two pages. SelectProject.a spx and ShowProject.asp x
The first page ( SelectProject.a spx) has two drop down lists.
After the user selects the value in the first drop list the second
filters. That works fine.
But when I click the run report button to pass the data to the
ShowProject.asp x page I get and error like this:
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name
'SelectProject' could not be found (are you missing a using directive
or an assembly reference?)
Source Error:
Line 227: protected void Page_Load(objec t sender, EventArgs e)
Line 228: {
Line 229: SelectProject prevPage = PreviousPage as
SelectProject;
Line 230: //if previouspage exist then check for parameter
values
Line 231: if (PreviousPage != null)
Source File: c:\Documents and Settings\cgrego ry\My Documents\Visua l
Studio 2005\WebSites\W ebSite4\ShowCha rt.aspx.cs Line: 229
Funny thing is, I NEVER CHANGED THAT LINE IN literally months!!! It
just stops working.
Here is the code:
using System;
using System.Data;
using System.Drawing;
using System.Drawing. Drawing2D;
using System.Collecti ons;
using System.Collecti ons.Specialized ;
using System.Configur ation;
using System.Text;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
using dotnetCHARTING;
using System.Data.Sql Client;
public partial class _Default : System.Web.UI.P age
{
Axis yaxis;
SeriesCollectio n getRandomData()
{
SeriesCollectio n SC = new SeriesCollectio n();
Random myR = new Random();
for (int a = 0; a < 4; a++)
{
Series s = new Series();
s.Name = "Series " + a;
for (int b = 0; b < 5; b++)
{
Element e = new Element();
e.Name = "E " + b;
e.YValue = myR.Next(50);
s.Elements.Add( e);
}
SC.Add(s);
}
// Set Different Colors for our Series
SC[0].DefaultElement .Color = Color.FromArgb( 49, 255, 49);
SC[1].DefaultElement .Color = Color.FromArgb( 255, 255, 0);
SC[2].DefaultElement .Color = Color.FromArgb( 255, 99, 49);
SC[3].DefaultElement .Color = Color.FromArgb( 0, 156, 255);
return SC;
}
void GetAxis()
{
// Create a second Y axis
this.yaxis = new Axis("Percent") ;
// Set the values to percernt
this.yaxis.Perc ent = true;
// Set the maximum value
this.yaxis.Maxi mum = 100;
// Set what side of the chart area it will appear
this.yaxis.Orie ntation = dotnetCHARTING. Orientation.Rig ht;
}
SeriesCollectio n GetChartData(St ring p_proj, String p_labor)
{
SeriesCollectio n sc = new SeriesCollectio n();
SqlConnection NorfolkConn = new SqlConnection(" Data
Source=<snip>\\ GSERVER2K3;Inte grated Security=SSPI;I nitial
Catalog=Norfolk ");
DataEngine de = new DataEngine(Norf olkConn);
//DataEngine de1 = new DataEngine(Norf olkConn);
DateTime dt = DateTime.Today;
//Build my query statement
StringBuilder qry = new StringBuilder(" Select * from
dbo.getChartDat a(",80);
qry.Append("'"+ p_proj +"'");
qry.Append(",") ;
qry.Append("'" + p_labor +"'");
qry.Append(")") ;
StringBuilder qry1 = new StringBuilder(" Select * from
dbo.CalculatePl an2(", 80);
qry1.Append("'" + p_proj + "'");
qry1.Append("," );
qry1.Append("'" + p_labor + "'");
qry1.Append(",' "+ dt +"')");
// Open Connection - dont open connections sooner then you have to
and close them as soon as possible
NorfolkConn.Ope n();
//Create command object and give it the command and connection
SqlCommand selectCMD = new SqlCommand(qry. ToString(),Norf olkConn);
// Create my data adapter
SqlDataAdapter ChartDataAdapte r = new
SqlDataAdapter( qry.ToString(), NorfolkConn);
// Populate the data set
DataSet dataSet = new DataSet();
ChartDataAdapte r.Fill(dataSet) ;
//Get all my max data values for use in the Legend and Axis
Double l_maxPrimaryY = 0.0;
Double l_maxSecondaryY = 0.0;
Double l_maxJTD = 0.0;
Double l_maxLbrExp = 0.0;
Double l_actcomp = 0.0;
double l_plannedhrs = 0.0;
foreach (DataRow dr in dataSet.Tables[0].Rows)
{
Double l_hrsbud = (Double)dr["HrsBud"];
Double l_lbrexp = (Double)dr["LaborExp"];
Double c_jtd = (Double)dr["JTD"];
l_actcomp = (Double)dr["ActComp"];
//String value if a null is returned from SQL Server
string l_dbnull = "";
if ( l_dbnull.Equals (dr["PlannedHrs "].ToString()) )
{
l_plannedhrs = 0.0;
}
else
{
l_plannedhrs = (Double)dr["PlannedHrs "];
}
//Find the max for the primary Y axis
if (l_hrsbud < c_jtd)
{
l_maxPrimaryY = c_jtd;
}
else
{
l_maxPrimaryY = l_hrsbud;
}
// Find the Max JTD value to display in the Legend Box
if (c_jtd > l_maxJTD)
{
l_maxJTD = c_jtd;
}
if (l_lbrexp > l_maxLbrExp)
{
l_maxLbrExp = Math.Round(l_lb rexp,1);
}
//Find the maximumn value for the secondary Y axis
if (l_lbrexp > 100.0)
{
l_maxSecondaryY = l_lbrexp;
}
else
{
l_maxSecondaryY = 100;
}
}
// Assign the sqlDataReader to the chart data engine
de.Data = dataSet.Tables[0];
// Loop throw the rows and mapp the columns to chart data elements
StringBuilder tokenStr = new StringBuilder() ;
tokenStr.Append ("XValue=lddate ,YValue=Planned hrs");
tokenStr.Append (",YValue=Labor Exp");
tokenStr.Append (",YValue=JTD") ;
tokenStr.Append (",YValue=ActCo mp");
//Set the max Y Value for the primary Y axis
Chart1.YAxis.Ma ximum = l_maxPrimaryY + 100;
//Set the max Y Value for the secondary Y Axis
GetAxis();
//Added 10 to the max percentage to extend the chart and
//prevent the Actual Complete series from begin cut off
this.yaxis.Maxi mum = l_maxSecondaryY + 10;
//Add the token string to the data engine
de.DataFields = tokenStr.ToStri ng();
//Format the XAxis
de.FormatString = "d";
//Get the series collection from the data engine
sc.Add(de.GetSe ries());
ChartDataAdapte r.SelectCommand = new SqlCommand(qry1 .ToString(),
NorfolkConn);
dataSet.Clear() ;
ChartDataAdapte r.Fill(dataSet) ;
//de1.DataFields = "YValue=Planned Complete,XValue =lperiod";
//de1.Data = dataSet.Tables[0];
//de1.FormatStrin g = "d";
//Create a series for the planned metrics
Series plannedSeries = new Series();
foreach (DataRow dr in dataSet.Tables[0].Rows)
{
//Create a new element for the series
Element plannedElement = new Element();
//Setting this property changes the axis type to category
plannedElement. Name = dr["lperiod"].ToString();
//plannedElement. XDateTime = (DateTime) dr["lperiod"];
//Add each column value to the appropriate axis
plannedElement. YValue = (Double)dr["planned"];
//Set the tooltip to be the value
plannedElement. ToolTip = dr["planned"].ToString();
//Add the element to the series
plannedSeries.A ddElements(plan nedElement);
}
//sc.Add(de1.GetS eries());
sc.Add(plannedS eries);
// Close the connection
NorfolkConn.Clo se();
bool hasData = false;
// Found out if any series in the collection has no data
if (sc.Count > 0)
{
sc[0].LegendEntry.Na me = "Planned Hours";
sc[0].LegendEntry.Va lue = l_plannedhrs.To String();
//Set Labor Expended to secondary Y axis
sc[1].YAxis = this.yaxis;
sc[1].LegendEntry.Na me = "Labor Expended";
sc[1].LegendEntry.Va lue = l_maxLbrExp.ToS tring();
sc[2].LegendEntry.Na me = "JTD Hours";
sc[2].LegendEntry.Va lue = l_maxJTD.ToStri ng();
sc[3].LegendEntry.Na me = "Actual Complete";
sc[3].LegendEntry.Va lue = l_actcomp.ToStr ing();
//Set Actual Complete to secondary Y axis
sc[3].YAxis = this.yaxis;
sc[4].LegendEntry.Na me = "Planned Complete";
//sc[4].YAxis = this.yaxis;
foreach (Series s in sc)
if (s.Elements.Cou nt != 0)
hasData = true;
}
// If no data was returned from the query display a message
// from the data engine as to what the error message is
if (!hasData)
{
Chart1.NoDataLa bel.Text = de.ErrorMessage ;
}
return sc;
}
//private double round(double l_lbrexp)
//{
//throw new Exception("The method or operation is not
implemented.");
//}
protected void Page_Load(objec t sender, EventArgs e)
{
SelectProject prevPage = PreviousPage as SelectProject;
//if previouspage exist then check for parameter values
if (PreviousPage != null)
{
// Add the chart data from the database based on select
param
if (prevPage != null)
{
Chart1.SeriesCo llection.Add(Ge tChartData(prev Page.ProjectCod e,
prevPage.LaborC ode));
}
}
else
{
Chart1.SeriesCo llection.Add(Ge tChartData("050 4800", "02"));
}
// Set the title.
Chart1.Title="P roject "+prevPage.Proj ectCode+" Labor Code
"+prevPage.Labo rCode;
Chart1.Debug = true;
// Set the Depth
Chart1.Depth = 15;
// Set 3D
Chart1.Use3D = false;
// set the x axis clustering
Chart1.ChartAre a.XAxis.Cluster Columns = false;
//Chart1.DefaultE lement.Marker.V isible = false;
// Set a default transparency
Chart1.DefaultS eries.DefaultEl ement.Transpare ncy = 20;
// Set line new properties
Chart1.DefaultS eries.Line.Widt h = 5;
Chart1.DefaultS eries.Line.Dash Style = DashStyle.Dash;
// Set the Default Series Type
Chart1.DefaultS eries.Type = SeriesType.Spli ne;
// Set the y Axis Scale
Chart1.ChartAre a.YAxis.Scale = Scale.Time;
// Set the x axis label
Chart1.ChartAre a.XAxis.Label.T ext = "Period";
//Set the angle of the labels
Chart1.ChartAre a.XAxis.TickLab elMode = TickLabelMode.A ngled;
// Set the scale of the X Axis to dynamic labeling
//Chart1.XAxis.Fo rmatString = "d";
//Chart1.XAxis.Ti meScaleLabels.D ayTick.Label.Te xt =
"m/dd/yyyy";
// Set the y axis label
Chart1.ChartAre a.YAxis.Label.T ext = "Hours";
// Set the directory where the images will be stored.
Chart1.TempDire ctory = "temp";
// Set the chart size.
Chart1.Width = 800;
Chart1.Height = 550;
}
}
Here is SelectProject.a spx:
using System;
using System.Data;
using System.Configur ation;
using System.Collecti ons;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
public partial class SelectProject : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
public void ddlProjectCode_ Changed(Object sender, EventArgs e)
{
//Do nothing once form is posted back from this event
//the labor code list will refresh automatically
}
public String ProjectCode
{
get { return DDL_ProjectCode .SelectedValue; }
}
public String LaborCode
{
get { return DDL_LaborCode.S electedValue; }
}
}