/// <summary> /// Vehicle By Type /// </summary> public void VehicleByType() { // --- xml Graph--- StringBuilder xmlDataVehPopType = new StringBuilder(); xmlDataVehPopType.Append("<chart caption='Year By VehicleType Report' subCaption='Vehicle Registration' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>"); // ---------------- objVehiclePopulationPredict.strElementType = ddlVehType.SelectedItem.ToString(); ArrayList DisVehPopulationType = objVehiclePopulationPredict.VehicleByType(objVehiclePopulationPredict); // Loop only By Vehicle Population Type int Get = DisVehPopulationType.Count; for (int i = 0; i < Get; i++) { // --- DisVehPopulation Data To xml --- BL.ArrayVehiclePopulation objVehiclePop = (BL.ArrayVehiclePopulation)(DisVehPopulationType[i]); int yrPopTyp = objVehiclePop.intYear; double vehPopValTyp = objVehiclePop.doubleNoOfVeh; xmlDataVehPopType.AppendFormat("<set label='{0}' value='{1}' />", yrPopTyp.ToString(), vehPopValTyp.ToString()); } /// Create The Vehicle Population Chart - Column3D Chart With Data From xmlDataVehPop xmlDataVehPopType.Append("</chart>"); LiteralVehiclePopulationType.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlDataVehPopType.ToString(), "Column3DVehiclePopulationType", "400", "350", false, true); }
/// <summary> /// Non Prediction To vehicle types /// </summary> public ArrayList VehicleByType(VehiclePopulationPredict myVehType) { SqlConnection sqlConn = new SqlConnection(DL.SQL.conn); sqlConn.Open(); SqlCommand sqlcom = new System.Data.SqlClient.SqlCommand("Select Year,sum(NoOfVeh) AS TotalVeh From tblVehiclePopulation Where [ElementType]='" + myVehType.strElementType + "' Group By Year ", sqlConn); SqlDataReader sqlred = sqlcom.ExecuteReader(); while (sqlred.Read()) { ArrayVehiclePopulation objVehPopulation = new ArrayVehiclePopulation(); objVehPopulation.intYear = Convert.ToInt32(sqlred["Year"]); objVehPopulation.doubleNoOfVeh = Convert.ToDouble(sqlred["TotalVeh"]); myArrayVehPop.Insert(indexVehPop, objVehPopulation); indexVehPop = indexVehPop + 1; } return(myArrayVehPop); }
/// <summary> /// Vehicle Population /// </summary> public void VehiclePopulation() { objVehiclePopulationPredict.intYear = Convert.ToInt16(txt1.Text); ArrayList FindVehPop = objVehiclePopulationPredict.FindVehPopulation(objVehiclePopulationPredict); // --- xml Graph--- StringBuilder xmlDataVehPop = new StringBuilder(); xmlDataVehPop.Append("<chart caption='Year-Vehicle Population Report' subCaption='' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>"); int Get = FindVehPop.Count; for (int i = 0; i < Get; i++) { BL.ArrayVehiclePopulation obj = (BL.ArrayVehiclePopulation)(FindVehPop[i]); int yr = obj.intYear; double val = obj.doubleNoOfVeh; xmlDataVehPop.AppendFormat("<set label='{0}' value='{1}' />", yr.ToString(), val.ToString()); } xmlDataVehPop.Append("</chart>"); VehPopulationGraph.Text = FusionCharts.RenderChart("FusionCharts/Line.swf", "", xmlDataVehPop.ToString(), "Column3DPopulation", "400", "300", false, true); }
public ArrayList FindVehPopulation(VehiclePopulationPredict myVehiclePopulationPredict) { // --- DB Connection --- SqlConnection sqlConn = new SqlConnection(DL.SQL.conn); SqlDataReader sqlRdr = null; VehiclePopulationPredict objVehiclePopulationPredict = new VehiclePopulationPredict(); try { sqlConn.Open(); // ----------------- SqlCommand sqlCom = new SqlCommand("VehiclePopulationPredictor", sqlConn); sqlCom.CommandType = CommandType.StoredProcedure; sqlRdr = sqlCom.ExecuteReader(); // ----------------- while (sqlRdr.Read()) { ArrayVehiclePopulation objArrayVehiclePopulation = new ArrayVehiclePopulation(); objArrayVehiclePopulation.intYear = Convert.ToInt16(sqlRdr["Year"]); objArrayVehiclePopulation.doubleNoOfVeh = Convert.ToDouble(sqlRdr["TotalVehicle"]); LoopForYr = Convert.ToInt16(sqlRdr["Year"]); myArrayVehPop.Insert(indexVehPop, objArrayVehiclePopulation); indexVehPop = indexVehPop + 1; } // --- Insert Year --- int FutureYr = myVehiclePopulationPredict.intYear; // --- Find The Loop Count --- int loopCount = FutureYr - LoopForYr; for (int j = 0; j < loopCount; j++) { // --- Get the Oldest Value From the ArrayList --- ArrayVehiclePopulation objOldestVal = (ArrayVehiclePopulation)(myArrayVehPop[0]); double OldestVal = objOldestVal.doubleNoOfVeh; // ----------------------------------------------- // --- Get the Newest Value From the ArrayList --- int NearestYrVal = myArrayVehPop.Count; NearestYrVal--; ArrayVehiclePopulation objNewVal = (ArrayVehiclePopulation)(myArrayVehPop[NearestYrVal]); double NewVal = objNewVal.doubleNoOfVeh; DbYear = objNewVal.intYear; // ----------------------------------------------- // --- Insert The Calc Value To Array --- DbYear++; // --- Algo --- double Predicton = NewVal * Math.Exp((Math.Log((NewVal / OldestVal), Math.Exp(1)) / 4) * 1); PredictPop = Predicton; // --- Algo --- ArrayVehiclePopulation objArrVehPopInsert = new ArrayVehiclePopulation(); objArrVehPopInsert.intYear = DbYear; objArrVehPopInsert.doubleNoOfVeh = Convert.ToDouble(PredictPop); myArrayVehPop.Insert((myArrayVehPop.Count), objArrVehPopInsert); // --- Insert The Calc Value To Array --- } } catch (Exception ex) { } return(myArrayVehPop); }