Example #1
0
    /// <summary>
    /// Population
    /// </summary>
    public void Population()
    {
        objPopulation.strPredictDistrict = "Colombo";
        objPopulation.intPredictYear     = EntrYr;

        objPopulation.FindBirth(objPopulation);
        objPopulation.FindDeath(objPopulation);
        ArrayList CalcPop = objPopulation.FindPopulation(objPopulation);

        // ---Graph---
        /// --- Population ---
        StringBuilder xmlDataPopu = new StringBuilder();

        xmlDataPopu.Append("<chart caption='Year- Human Population Report' subCaption='' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>");
        // ----------

        /// --- Population ---
        int j          = CalcPop.Count - 1;
        int GetPopLoop = CalcPop.Count;

        for (int i = 0; i < GetPopLoop; i++)
        {
            BL.ArrayPopulation arrPop = (BL.ArrayPopulation)(CalcPop[j]);
            int    PopYr = arrPop.intPopulationYear;
            double Popu  = arrPop.doublePopulationCount;
            j--;

            xmlDataPopu.AppendFormat("<set label='{0}' value='{1}' />", PopYr.ToString(), Popu.ToString());
        }

        xmlDataPopu.Append("</chart>");
        PopulationGraph.Text = FusionCharts.RenderChart("FusionCharts/Bar2D.swf", "", xmlDataPopu.ToString(), "Bar2DPopulation", "400", "300", false, true);
    }
Example #2
0
        /// --- Population ---
        public ArrayList noPredictPopulation(PopulationPredict myNoPredictPopulation)
        {
            SqlConnection sqlConn = new SqlConnection(DL.SQL.conn);
            SqlDataReader sqlRdr  = null;

            try
            {
                sqlConn.Open();
                //-------------------
                SqlCommand sqlCom = new SqlCommand("PopulationPredictor", sqlConn);
                sqlCom.CommandType = CommandType.StoredProcedure;
                sqlCom.Parameters.Add("@SelectedRegion", myNoPredictPopulation.strPredictDistrict);

                sqlRdr = sqlCom.ExecuteReader();
                //-------------------

                while (sqlRdr.Read())
                {
                    ArrayPopulation objPopulation = new ArrayPopulation();

                    objPopulation.intPopulationYear     = Convert.ToInt32(sqlRdr["tempYear"]);
                    objPopulation.doublePopulationCount = Convert.ToInt32(sqlRdr["tempCount"]);

                    myPopulationArray.Insert(p, objPopulation);
                    p = p + 1;
                }
            }
            catch (Exception ex)
            {
            }
            return(myPopulationArray);
        }
Example #3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (txt1.Text != "")
        {
            int CurrentYr = DateTime.Now.Year;
            int EntrYr    = Convert.ToInt16(txt1.Text);
            int t         = EntrYr - CurrentYr;

            // ---Graph---
            /// --- Population ---
            StringBuilder xmlDataPopu = new StringBuilder();
            xmlDataPopu.Append("<chart caption='Year-Population Report' subCaption='By Value' Column3DSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' '>");
            // ----------


            if (0 <= t && t < 5)
            {
                objPopulation.strPredictDistrict = "Colombo";
                objPopulation.intPredictYear     = EntrYr;

                objPopulation.FindBirth(objPopulation);
                objPopulation.FindDeath(objPopulation);
                ArrayList CalcPop = objPopulation.FindPopulation(objPopulation);

                /// --- Population ---
                int GetPopLoop = CalcPop.Count;
                for (int i = 0; i < GetPopLoop; i++)
                {
                    BL.ArrayPopulation arrPop = (BL.ArrayPopulation)(CalcPop[i]);
                    int    PopYr = arrPop.intPopulationYear;
                    double Popu  = arrPop.doublePopulationCount;

                    xmlDataPopu.AppendFormat("<set label='{0}' value='{1}' />", PopYr.ToString(), Popu.ToString());
                }

                xmlDataPopu.Append("</chart>");
                Literal1.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlDataPopu.ToString(), "Column3DRegVehRte", "750", "400", false, true);
            }
        }
        else
        {
            //lblMsg.Text = "Error in inserted Year";
        }
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // --- xml Graph---
        StringBuilder xmlDataBirth = new StringBuilder();

        xmlDataBirth.Append("<chart caption='Year-Birth Report' subCaption='For Colombo' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>");

        StringBuilder xmlDataDeath = new StringBuilder();

        xmlDataDeath.Append("<chart caption='Year-Death Report' subCaption='For Colombo' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>");

        StringBuilder xmlDataPopulation = new StringBuilder();

        xmlDataPopulation.Append("<chart caption='Year-Population Report' subCaption='For Colombo' Column3DSliceDepth='10' showBorder='1' formatNumberScale='0' numberSuffix=' '>");
        // ----------

        if (!IsPostBack)
        {
            objPopulation.strPredictDistrict = "Colombo";
            ArrayList DisBirth      = objPopulation.noPredictBirth(objPopulation);
            ArrayList DisDeath      = objPopulation.noPredictDeath(objPopulation);
            ArrayList DisPopulation = objPopulation.noPredictPopulation(objPopulation);

            // Loop only By Birth
            int Get = DisBirth.Count;

            for (int i = 0; i < Get; i++)
            {
                // --- Birth Data To xml ---
                BL.ArrayBirth objBirth = (BL.ArrayBirth)(DisBirth[i]);
                int           yrBirth  = objBirth.intBirthYear;
                double        valBirth = objBirth.doubleBirthCount;

                xmlDataBirth.AppendFormat("<set label='{0}' value='{1}' />", yrBirth.ToString(), valBirth.ToString());

                // --- Death Data To xml ---
                BL.ArrayDeath objDeath = (BL.ArrayDeath)(DisDeath[i]);
                int           yrDeath  = objDeath.intDeathYear;
                double        valDeath = objDeath.doubleDeathCount;

                xmlDataDeath.AppendFormat("<set label='{0}' value='{1}' />", yrDeath.ToString(), valDeath.ToString());

                // --- Population Data To xml ---
                BL.ArrayPopulation objPop = (BL.ArrayPopulation)(DisPopulation[i]);
                int    yrPopulation       = objPop.intPopulationYear;
                double valPopulation      = objPop.doublePopulationCount;

                xmlDataPopulation.AppendFormat("<set label='{0}' value='{1}' />", yrPopulation.ToString(), valPopulation.ToString());
            }


            /// Create The Birth Chart - Column3D Chart With Data From xmlDataBirth
            xmlDataBirth.Append("</chart>");
            LiteralBirth.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlDataBirth.ToString(), "Column3DBirth", "430", "200", false, true);

            /// Create The Death Chart - Column3D Chart With Data From xmlDataDeath
            xmlDataDeath.Append("</chart>");
            LiteralDeath.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlDataDeath.ToString(), "Column3DDeath", "430", "200", false, true);

            /// Create The Population Chart - Column3D Chart With Data From xmlDataPopulation
            xmlDataPopulation.Append("</chart>");
            LiteralPop.Text = FusionCharts.RenderChart("FusionCharts/Line.swf", "", xmlDataPopulation.ToString(), "Column3DPopulation", "430", "200", false, true);
        }
    }
Example #5
0
    protected void btnEnter_Click(object sender, EventArgs e)
    {
        ClearListBx();
        if (txtYear.Text != "")
        {
            DateTime dt          = DateTime.Now;
            int      CurrentYear = dt.Year;

            string Reg = ddlRegion.SelectedValue.ToString();
            int    t   = int.Parse(txtYear.Text) - CurrentYear;

            //if (Reg != "--Select--" && 0 <= t && t < 5)
            {
                /// Clear The Error Message.
                lblMsg.Text = "";

                /// Make Visible the Content Items
                lblBirth.Visible        = true;
                lblDeath.Visible        = true;
                lblPopulation.Visible   = true;
                LstBxBirth.Visible      = true;
                LstBxDeath.Visible      = true;
                LstBxPopulation.Visible = true;
                btnBirth.Visible        = true;
                btnDeath.Visible        = true;

                /// <summary>
                /// Pass The Value From "PopulationPredict.cs"
                /// </summary>
                objPopulationPredict.strPredictDistrict = Reg;
                objPopulationPredict.intPredictYear     = int.Parse(txtYear.Text);

                ArrayList CalcBirthArray = objPopulationPredict.FindBirth(objPopulationPredict);
                ArrayList CalcDeathArray = objPopulationPredict.FindDeath(objPopulationPredict);
                ArrayList CalcPopArray   = objPopulationPredict.FindPopulation(objPopulationPredict);

                /// <summary>
                /// Inialize The Graph Elements.
                /// And Get The Value From "PopulationPredict.cs"
                /// </summary>

                // ---Graph---
                StringBuilder xmlData = new StringBuilder();
                xmlData.Append("<chart caption='Year-Population Output Report' subCaption='By Value' Column3DSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' '>");
                // ----------

                // --- Copy BL.PopulationPredict -->> Population,Birth & Death Values to a new ArrayList ---
                //ArrayList CalcPopArray = objPopulationPredict.FindPopulation(objPopulationPredict);
                //ArrayList CalcBirthArray = objPopulationPredict.FindBirth(objPopulationPredict);
                //ArrayList CalcDeathArray = objPopulationPredict.FindDeath(objPopulationPredict);
                // -----------------------------------------------------------------------------------------

                int Get = CalcPopArray.Count;
                for (int i = 0; i < Get; i++)
                {
                    // --- Display Population ---
                    BL.ArrayPopulation objPopulation = (BL.ArrayPopulation)(CalcPopArray[i]);
                    int    Yr  = objPopulation.intPopulationYear;
                    double Val = objPopulation.doublePopulationCount;

                    LstBxPopulation.Items.Add("Year : " + Yr + "  -->>" + Val);
                    xmlData.AppendFormat("<set label='{0}' value='{1}' />", Yr.ToString(), Val.ToString());
                    // --------------------------

                    // --- Display Birth ---
                    BL.ArrayBirth objBirth = (BL.ArrayBirth)(CalcBirthArray[i]);
                    int           BirthYr  = objBirth.intBirthYear;
                    double        BirthVal = objBirth.doubleBirthCount;
                    LstBxBirth.Items.Add("Year : " + BirthYr + "  -->>" + BirthVal);
                    // ---------------------

                    // --- Display Death ---
                    BL.ArrayDeath objDeath = (BL.ArrayDeath)(CalcDeathArray[i]);
                    int           DeathYr  = objDeath.intDeathYear;
                    double        DeathVal = objDeath.doubleDeathCount;
                    LstBxDeath.Items.Add("Year : " + DeathYr + "  -->>" + DeathVal);
                    // ---------------------
                }

                /// Close chart Element------
                ///
                xmlData.Append("</chart>");
                /// Create The Chart - Column3D Chart With Data From xmlData
                PopulationGraph.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlData.ToString(), "Column3DRegVehRte", "900", "400", false, true);
                ///
                /// -------------------------
            }
            //else
            //lblMsg.Text = "Error Inserted Value... :-(";
        }
        //else
        //lblMsg.Text = "Please Enter Value... :-(";
    }
Example #6
0
        /// --- Population ---
        /// <summary>
        /// ------------
        /// </summary>
        public ArrayList FindPopulation(PopulationPredict myFindPopulation)
        {
            /// --- Get the Newest Value from DB -->> tblPopulation
            SqlConnection sqlConn = new SqlConnection(DL.SQL.conn);
            SqlDataReader sqlRdr  = null;

            try
            {
                sqlConn.Open();
                //-------------
                SqlCommand sqlCom = new SqlCommand("PopulationPredictor", sqlConn);
                sqlCom.CommandType = CommandType.StoredProcedure;
                sqlCom.Parameters.Add("@SelectedRegion", myFindPopulation.strPredictDistrict);

                sqlRdr = sqlCom.ExecuteReader();
                //------------

                while (sqlRdr.Read())
                {
                    ArrayPopulation objArrPopulation = new ArrayPopulation();

                    objArrPopulation.intPopulationYear     = Convert.ToInt32(sqlRdr["tempYear"]);
                    objArrPopulation.doublePopulationCount = Convert.ToInt32(sqlRdr["tempCount"]);

                    myPopulationArray.Insert(p, objArrPopulation);
                    p = p + 1;
                }
                /// Close The Connections
                sqlRdr.Close();
                sqlConn.Close();

                /// --- Find Newest year & Value ---
                int NoOf_tblPopulation_DB_Row = myPopulationArray.Count;
                int NoOf_Rows = NoOf_tblPopulation_DB_Row - 1;

                ArrayPopulation objNewPopulationFind   = (ArrayPopulation)(myPopulationArray[NoOf_Rows]);
                int             DB_New_PopulationYear  = objNewPopulationFind.intPopulationYear;
                double          DB_New_PopulationCount = objNewPopulationFind.doublePopulationCount;

                /// --- Predict Future ---
                int FindYear = myFindPopulation.intPredictYear;
                int t        = FindYear - DB_New_PopulationYear;

                int CalcYear = CurrentYear;

                for (int i = 0; i < t; i++)
                {
                    /// --- Birth Of The Year ---
                    ArrayBirth objGetBirth = (ArrayBirth)(myBirthArray[NoOf_Rows]);
                    double     GetBirth    = objGetBirth.doubleBirthCount;
                    /// --- Death Of The Year ---
                    ArrayDeath objGetdeath = (ArrayDeath)(myDeathArray[NoOf_Rows]);
                    double     GetDeath    = objGetdeath.doubleDeathCount;

                    /// Population Predict Algo
                    double FuturePopulation = DB_New_PopulationCount + GetBirth - GetDeath;
                    /// Population Predict Algo

                    ArrayPopulation objPredictArrPopulation = new ArrayPopulation();
                    objPredictArrPopulation.intPopulationYear     = CalcYear;
                    objPredictArrPopulation.doublePopulationCount = Math.Ceiling(FuturePopulation);

                    myPopulationArray.Insert(p, objPredictArrPopulation);
                    p = p + 1;

                    // Copy Predicted value to calc next year value
                    DB_New_PopulationCount = FuturePopulation;
                    // Increment The Year
                    CalcYear++;

                    // Increment The Birth & Death Year Value
                    NoOf_Rows++;
                }
            }
            catch (Exception ex)
            {
            }

            return(myPopulationArray);
        }