Esempio n. 1
0
        /// --- Death ---
        public ArrayList noPredictDeath(PopulationPredict myNoPredictDeath)
        {
            SqlConnection sqlConn = new SqlConnection(DL.SQL.conn);
            SqlDataReader sqlRdr  = null;

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

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

                while (sqlRdr.Read())
                {
                    ArrayDeath objDeath = new ArrayDeath();

                    objDeath.intDeathYear     = Convert.ToInt32(sqlRdr["tempYear"]);
                    objDeath.doubleDeathCount = Convert.ToInt32(sqlRdr["tempCount"]);

                    myDeathArray.Insert(d, objDeath);
                    d = d + 1;
                }
            }
            catch (Exception ex)
            {
            }
            return(myDeathArray);
        }
Esempio n. 2
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);
        }
    }
    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
                lblDeath.Visible = true;
                LstDeath.Visible = true;

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

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

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

                int Get = CalcDeathArray.Count;
                for (int i = 0; i < Get; i++)
                {
                    // --- Display Birth ---
                    BL.ArrayDeath objDeath = (BL.ArrayDeath)(CalcDeathArray[i]);
                    int           DeathYr  = objDeath.intDeathYear;
                    double        DeathVal = objDeath.doubleDeathCount;

                    LstDeath.Items.Add("Year : " + DeathYr + "  -->> " + DeathVal);

                    xmlData.AppendFormat("<set label='{0}' value='{1}' />", DeathYr.ToString(), DeathVal.ToString());
                    // ---------------------
                }

                /// Close chart Element------
                ///
                xmlData.Append("</chart>");
                /// Create The Chart - Column3D Chart With Data From xmlData
                //DeathGraph.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "", xmlData.ToString(), "Column3DDeath", "900", "400", false, true);
                ///
                //DeathPieGraph.Text = FusionCharts.RenderChart("FusionCharts/Pie3D.swf", "", xmlData.ToString(), "Pie3DDeath", "622", "200", false, true);
                ///
                /// -------------------------
            }
            //else
            //lblMsg.Text = "Error Inserted Value... :-(";
        }
        //else
        //lblMsg.Text = "Please Enter Value... :-(";
    }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// --- Death ---
        /// <summary>
        /// ------------
        /// </summary>
        public ArrayList FindDeath(PopulationPredict myFindDeath)
        {
            SqlConnection sqlConn = new SqlConnection(DL.SQL.conn);
            SqlDataReader sqlRdr  = null;

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

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

                while (sqlRdr.Read())
                {
                    ArrayDeath objArrDeath = new ArrayDeath();

                    objArrDeath.intDeathYear     = Convert.ToInt32(sqlRdr["tempYear"]);
                    objArrDeath.doubleDeathCount = Convert.ToInt32(sqlRdr["tempCount"]);

                    myDeathArray.Insert(d, objArrDeath);
                    d = d + 1;
                }
                /// Close The Connections
                sqlRdr.Close();
                sqlConn.Close();

                /// --- Find Oldest Year & Value ---
                ArrayDeath objOldDeathFind   = (ArrayDeath)(myDeathArray[0]);
                int        DB_Old_DeathYear  = objOldDeathFind.intDeathYear;
                double     DB_Old_DeathCount = objOldDeathFind.doubleDeathCount;

                /// --- Find Newest year & Value ---
                int NoOf_tblDeath_DB_Row = myDeathArray.Count;
                int NoOf_Rows            = NoOf_tblDeath_DB_Row - 1;

                ArrayDeath objNewDeathFind   = (ArrayDeath)(myDeathArray[NoOf_Rows]);
                int        DB_New_DeathYear  = objNewDeathFind.intDeathYear;
                double     DB_New_DeathCount = objNewDeathFind.doubleDeathCount;

                /// --- Predict Future ---
                int FindYear = myFindDeath.intPredictYear;
                int t        = FindYear - DB_New_DeathYear;

                int CalcYear = CurrentYear;

                for (int i = 0; i < t; i++)
                {
                    if (CalcYear <= 2028)
                    {
                        /// Algo For Death
                        double NFuture = DB_New_DeathCount * Math.Exp((Math.Log((DB_New_DeathCount / DB_Old_DeathCount), Math.Exp(1)) / 4) * 1);
                        /// Algo For Death

                        ArrayDeath objPredictArrDeath = new ArrayDeath();
                        objPredictArrDeath.intDeathYear     = CalcYear;
                        objPredictArrDeath.doubleDeathCount = Math.Ceiling(NFuture);

                        myDeathArray.Insert(d, objPredictArrDeath);
                        d = d + 1;

                        // Copy Predicted value to calc next year value
                        DB_New_DeathCount = NFuture;
                        // Increment The Year
                        CalcYear++;
                    }
                    else
                    {
                        ArrayDeath objPredictArrDeath = new ArrayDeath();
                        objPredictArrDeath.intDeathYear     = CalcYear;
                        objPredictArrDeath.doubleDeathCount = Math.Ceiling(DB_New_DeathCount);

                        myDeathArray.Insert(d, objPredictArrDeath);
                        d = d + 1;

                        CalcYear++;
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(myDeathArray);
        }