Here is what i have for my code:
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;
using CrazyEddie; //my own namespace for vehicles
public partial class Listing : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
long totalwhole = 0;
long totalretail = 0;
ArrayList selection = new ArrayList();
selection=(ArrayList)Session["Vehicles"];
TableRow TOProw = new TableRow();
TableCell VINcell = new TableCell();
VINcell.Text = "VIN";
TOProw.Cells.Add(VINcell);
TableCell MANUFACTURERcell = new TableCell();
MANUFACTURERcell.Text = "MANUFACTURER";
TOProw.Cells.Add(MANUFACTURERcell);
TableCell MAKEcell = new TableCell();
MAKEcell.Text = "MAKE";
TOProw.Cells.Add(MAKEcell);
TableCell MODELcell = new TableCell();
MODELcell.Text = "MODEL";
TOProw.Cells.Add(MODELcell);
TableCell YEARcell = new TableCell();
YEARcell.Text = "YEAR";
TOProw.Cells.Add(YEARcell);
TableCell MANUDATEcell = new TableCell();
MANUDATEcell.Text = "MANUDATE";
TOProw.Cells.Add(MANUDATEcell);
TableCell SHOWDATEcell = new TableCell();
SHOWDATEcell.Text = "SHOWDATE";
TOProw.Cells.Add(SHOWDATEcell);
TableCell VCOLORcell = new TableCell();
VCOLORcell.Text = "VCOLOR";
TOProw.Cells.Add(VCOLORcell);
TableCell GVWcell = new TableCell();
GVWcell.Text = "GVW";
TOProw.Cells.Add(GVWcell);
TableCell ESIZEcell = new TableCell();
ESIZEcell.Text = "ESIZE";
TOProw.Cells.Add(ESIZEcell);
TableCell MSRPcell = new TableCell();
MSRPcell.Text = "MSRP";
TOProw.Cells.Add(MSRPcell);
TableCell WHOLEcell = new TableCell();
WHOLEcell.Text = "WHOLESALE";
TOProw.Cells.Add(WHOLEcell);
TableCell SALEcell = new TableCell();
SALEcell.Text = "SALES DATE";
TOProw.Cells.Add(SALEcell);
TableCell OTHERcell = new TableCell();
OTHERcell.Controls.Add(new LiteralControl("OTHER"));
TOProw.Cells.Add(OTHERcell);
CarTable.Rows.Add(TOProw);
if (selection != null)
{
foreach (Vehicle v in selection)
//foreach (Vehicle v in selection)
{
string s = null;
TableRow TBLrow = new TableRow();
TableCell inVINcell = new TableCell();
VINcell.Text = v.getVIN();
TBLrow.Cells.Add(inVINcell);
TableCell inMANUFACTURERcell = new TableCell();
MANUFACTURERcell.Text = v.getManufacturer();
TBLrow.Cells.Add(inMANUFACTURERcell);
TableCell inMAKEcell = new TableCell();
MAKEcell.Text = v.getMake();
TBLrow.Cells.Add(inMAKEcell);
TableCell inMODELcell = new TableCell();
MODELcell.Text = v.getModel();
TBLrow.Cells.Add(inMODELcell);
TableCell inYEARcell = new TableCell();
YEARcell.Text = v.getYear();
TBLrow.Cells.Add(inYEARcell);
TableCell inMANUDATEcell = new TableCell();
MANUDATEcell.Text = v.getManuDate().ToString();
TBLrow.Cells.Add(inMANUDATEcell);
TableCell inSHOWDATEcell = new TableCell();
SHOWDATEcell.Text = v.getShowDate().ToString();
TBLrow.Cells.Add(inSHOWDATEcell);
TableCell inVCOLORcell = new TableCell();
VCOLORcell.Text = v.getVColor();
TBLrow.Cells.Add(inVCOLORcell);
TableCell inGVWcell = new TableCell();
GVWcell.Text = v.getGVW() + "LB.";
TBLrow.Cells.Add(inGVWcell);
TableCell inESIZEcell = new TableCell();
ESIZEcell.Text = v.getEngineSize().ToString() + "L.";
TBLrow.Cells.Add(inESIZEcell);
TableCell inMSRPcell = new TableCell();
MSRPcell.Text = v.getMSRP().ToString();
TBLrow.Cells.Add(inMSRPcell);
TableCell inWHOLEcell = new TableCell();
WHOLEcell.Text = v.getWholesalePrice().ToString();
TBLrow.Cells.Add(inWHOLEcell);
TableCell inSALEcell = new TableCell();
SALEcell.Text = v.getSDate().ToString();
TBLrow.Cells.Add(inSALEcell);
TableCell inOTHERcell = new TableCell();
if (v.getisAir())
{
Aircraft w = (Aircraft)v;
s = "Aircraft" + '\n' +
"Number of passengers: " + w.getPassNum().ToString() + '\n' +
"Wingspan: "+ w.getWingspan().ToString() + "ft.";
}
else if (v.getisAuto())
{
Automobile a = (Automobile)v;
s = "Automobile" + '\n' +
"Number of pasengers: " + a.getPassNum();
}
else if (v.getisMCycle())
{
Motorcycle b = (Motorcycle)v;
s = "Motorcycle";
}
else if (v.getisTruck())
{
Truck c = (Truck)v;
s = "Truck" + '\n' +
"Number of passengers: " + c.getPassNum().ToString() + '\n' +
"Number of axles: " + c.getAxleNum().ToString() + '\n' +
"Gross Vehicle Weight Rating: " + c.getGVWR();
}
else if (v.getisWatercraft())
{
Watercraft d = (Watercraft)v;
s = "Watercraft" + '\n' +
"Number of passengers: " + d.getPassNum().ToString() + '\n' +
"Length: " + d.getLength().ToString() + "ft.";
}
else
{
s = "I dunno\n";
}
OTHERcell.Text = s;
TBLrow.Cells.Add(inOTHERcell);
CarTable.Rows.Add(TBLrow);
totalwhole += v.getWholesalePrice();
totalretail += v.getMSRP();
}
TableRow TOTWHOLErow = new TableRow();
TableCell TWLcell = new TableCell();
TWLcell.Text = "TOTAL WHOLESALE VALUE: $";
TableCell TWcell = new TableCell();
TWcell.Text = totalwhole.ToString();
TOTWHOLErow.Cells.Add(TWLcell);
TOTWHOLErow.Cells.Add(TWcell);
TableRow TOTRETAILrow = new TableRow();
TableCell TRLcell = new TableCell();
TRLcell.Text = "TOTAL RETAIL VALUE: $";
TableCell TRcell = new TableCell();
TRcell.Text = totalretail.ToString();
TOTRETAILrow.Cells.Add(TRLcell);
TOTRETAILrow.Cells.Add(TRcell);
CarTable.Rows.Add(TOTWHOLErow);
CarTable.Rows.Add(TOTRETAILrow);
}
else
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tc.Text = "No vehicles!";
tr.Cells.Add(tc);
CarTable.Rows.Add(tr);
}
}
}
|