Casting a page as Previous Page

G

g3000

I have a problem with a Visual Studio 2005 web project.

I have two pages. SelectProject.aspx and ShowProject.aspx

The first page ( SelectProject.aspx) 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.aspx 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(object 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\cgregory\My Documents\Visual
Studio 2005\WebSites\WebSite4\ShowChart.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.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using dotnetCHARTING;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
Axis yaxis;
SeriesCollection getRandomData()
{
SeriesCollection SC = new SeriesCollection();
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.Percent = true;

// Set the maximum value
this.yaxis.Maximum = 100;

// Set what side of the chart area it will appear
this.yaxis.Orientation = dotnetCHARTING.Orientation.Right;
}

SeriesCollection GetChartData(String p_proj, String p_labor)
{
SeriesCollection sc = new SeriesCollection();
SqlConnection NorfolkConn = new SqlConnection("Data
Source=<snip>\\GSERVER2K3;Integrated Security=SSPI;Initial
Catalog=Norfolk");
DataEngine de = new DataEngine(NorfolkConn);
//DataEngine de1 = new DataEngine(NorfolkConn);
DateTime dt = DateTime.Today;
//Build my query statement
StringBuilder qry = new StringBuilder("Select * from
dbo.getChartData(",80);
qry.Append("'"+ p_proj +"'");
qry.Append(",");
qry.Append("'" + p_labor +"'");
qry.Append(")");
StringBuilder qry1 = new StringBuilder("Select * from
dbo.CalculatePlan2(", 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.Open();

//Create command object and give it the command and connection
SqlCommand selectCMD = new SqlCommand(qry.ToString(),NorfolkConn);
// Create my data adapter
SqlDataAdapter ChartDataAdapter = new
SqlDataAdapter(qry.ToString(), NorfolkConn);

// Populate the data set
DataSet dataSet = new DataSet();
ChartDataAdapter.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_lbrexp,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=Plannedhrs");
tokenStr.Append(",YValue=LaborExp");
tokenStr.Append(",YValue=JTD");
tokenStr.Append(",YValue=ActComp");

//Set the max Y Value for the primary Y axis
Chart1.YAxis.Maximum = 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.Maximum = l_maxSecondaryY + 10;
//Add the token string to the data engine
de.DataFields = tokenStr.ToString();
//Format the XAxis
de.FormatString = "d";
//Get the series collection from the data engine
sc.Add(de.GetSeries());
ChartDataAdapter.SelectCommand = new SqlCommand(qry1.ToString(),
NorfolkConn);
dataSet.Clear();
ChartDataAdapter.Fill(dataSet);
//de1.DataFields = "YValue=PlannedComplete,XValue=lperiod";
//de1.Data = dataSet.Tables[0];
//de1.FormatString = "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.AddElements(plannedElement);
}
//sc.Add(de1.GetSeries());
sc.Add(plannedSeries);
// Close the connection
NorfolkConn.Close();
bool hasData = false;
// Found out if any series in the collection has no data
if (sc.Count > 0)
{
sc[0].LegendEntry.Name = "Planned Hours";
sc[0].LegendEntry.Value = l_plannedhrs.ToString();
//Set Labor Expended to secondary Y axis
sc[1].YAxis = this.yaxis;
sc[1].LegendEntry.Name = "Labor Expended";
sc[1].LegendEntry.Value = l_maxLbrExp.ToString();
sc[2].LegendEntry.Name = "JTD Hours";
sc[2].LegendEntry.Value = l_maxJTD.ToString();

sc[3].LegendEntry.Name = "Actual Complete";
sc[3].LegendEntry.Value = l_actcomp.ToString();
//Set Actual Complete to secondary Y axis
sc[3].YAxis = this.yaxis;
sc[4].LegendEntry.Name = "Planned Complete";
//sc[4].YAxis = this.yaxis;
foreach (Series s in sc)
if (s.Elements.Count != 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.NoDataLabel.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(object 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.SeriesCollection.Add(GetChartData(prevPage.ProjectCode,
prevPage.LaborCode));
}
}
else
{
Chart1.SeriesCollection.Add(GetChartData("0504800", "02"));
}
// Set the title.
Chart1.Title="Project "+prevPage.ProjectCode+" Labor Code
"+prevPage.LaborCode;
Chart1.Debug = true;
// Set the Depth
Chart1.Depth = 15;

// Set 3D
Chart1.Use3D = false;

// set the x axis clustering
Chart1.ChartArea.XAxis.ClusterColumns = false;
//Chart1.DefaultElement.Marker.Visible = false;
// Set a default transparency
Chart1.DefaultSeries.DefaultElement.Transparency = 20;

// Set line new properties
Chart1.DefaultSeries.Line.Width = 5;
Chart1.DefaultSeries.Line.DashStyle = DashStyle.Dash;

// Set the Default Series Type
Chart1.DefaultSeries.Type = SeriesType.Spline;

// Set the y Axis Scale
Chart1.ChartArea.YAxis.Scale = Scale.Time;

// Set the x axis label
Chart1.ChartArea.XAxis.Label.Text = "Period";

//Set the angle of the labels
Chart1.ChartArea.XAxis.TickLabelMode = TickLabelMode.Angled;
// Set the scale of the X Axis to dynamic labeling
//Chart1.XAxis.FormatString = "d";
//Chart1.XAxis.TimeScaleLabels.DayTick.Label.Text =
"m/dd/yyyy";

// Set the y axis label
Chart1.ChartArea.YAxis.Label.Text = "Hours";

// Set the directory where the images will be stored.
Chart1.TempDirectory = "temp";


// Set the chart size.
Chart1.Width = 800;
Chart1.Height = 550;

}

}
Here is SelectProject.aspx:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SelectProject : System.Web.UI.Page
{
protected void Page_Load(object 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.SelectedValue; }
}
}
 
J

jd

Wild guess, but perhaps it can't compile SelectProject.aspx or
SelectProject.apsx.cs. Double check these files (the deployed ones,
in the directory referenced in the error message). BTW, I assume
the second file in your message was SelectProject.aspx.cs (not
SelectProject.aspx).

-- jeff
 
G

g3000

No it cannot compile ShowChart.aspx.cs. But it has been compiling for
the past four months. Why all of a sudden it errors?
I was right clicking on SelectProject.aspx and selecting 'View in
Browser' and testing it out.

All of a sudden it started throwing the error. If the page is there why
would it tell me that?
 
G

g3000

I should say that it is NOT compiling because of the error I posted
previously. There are no other errors in that file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top