//------------------------------------------
        #endregion

        #region --------------GetObject--------------
        public static SystemCountriesEntity GetObject(int id)
        {
            SystemCountriesEntity systemCountriesObject = SystemCountriesSqlDataPrvider.Instance.GetObject(id);

            //return the object
            return(systemCountriesObject);
        }
        //------------------------------------------
        #endregion

        #region --------------PopulateSystemCountriesEntityFromIDataReader--------------
        private SystemCountriesEntity PopulateSystemCountriesEntityFromIDataReader(IDataReader reader)
        {
            //Create a new SystemCountries object
            SystemCountriesEntity systemCountriesObject = new SystemCountriesEntity();

            //Fill the object with data

            //id
            if (reader["id"] != DBNull.Value)
            {
                systemCountriesObject.id = (int)reader["id"];
            }
            //country_code
            if (reader["country_code"] != DBNull.Value)
            {
                systemCountriesObject.country_code = (string)reader["country_code"];
            }
            //country
            if (reader["country"] != DBNull.Value)
            {
                systemCountriesObject.country = (string)reader["country"];
            }
            //country_ar
            if (reader["country_ar"] != DBNull.Value)
            {
                systemCountriesObject.country_ar = (string)reader["country_ar"];
            }
            //TIMEZONE_H
            if (reader["TIMEZONE_H"] != DBNull.Value)
            {
                systemCountriesObject.TIMEZONE_H = (int)reader["TIMEZONE_H"];
            }
            //TIMEZONE_M
            if (reader["TIMEZONE_M"] != DBNull.Value)
            {
                systemCountriesObject.TIMEZONE_M = (int)reader["TIMEZONE_M"];
            }
            //reg_id
            if (reader["reg_id"] != DBNull.Value)
            {
                systemCountriesObject.reg_id = (int)reader["reg_id"];
            }
            //SimpleEnName
            if (reader["SimpleEnName"] != DBNull.Value)
            {
                systemCountriesObject.SimpleEnName = (string)reader["SimpleEnName"];
            }
            //SimpleArName
            if (reader["SimpleArName"] != DBNull.Value)
            {
                systemCountriesObject.SimpleArName = (string)reader["SimpleArName"];
            }
            //Return the populated object
            return(systemCountriesObject);
        }
        //------------------------------------------
        #endregion

        public static string GetCountryFlag(object countryID)
        {
            string directoryPath        = "/Content/images/flags/";
            SystemCountriesEntity cntry = GetObject((int)countryID);

            if (cntry != null)
            {
                return(directoryPath + cntry.country_code + ".png");
            }
            else
            {
                return("/Content/images/flags/spacer.gif");
            }
        }
        //------------------------------------------
        #endregion

        #region --------------Update--------------
        /// <summary>
        /// Converts the SystemCountries object properties to SQL paramters and executes the update SystemCountries procedure.
        /// <example>[Example]bool  status=SystemCountriesSqlDataPrvider.Instance.Update(systemCountriesObject);.</example>
        /// </summary>
        /// <param name="systemCountriesObject">The SystemCountries object.</param>
        /// <returns>The status of update query.</returns>
        public bool Update(SystemCountriesEntity systemCountriesObject)
        {
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("SystemCountries_Update", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@id", SqlDbType.Int, 4).Value             = systemCountriesObject.id;
                myCommand.Parameters.Add("@country", SqlDbType.NVarChar, 255).Value = systemCountriesObject.country;
                // Execute the command
                bool status = false;
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    status = true;
                }
                myConnection.Close();
                return(status);
            }
        }
        //------------------------------------------
        #endregion

        #region --------------Create--------------
        /// <summary>
        /// Converts the SystemCountries object properties to SQL paramters and executes the create SystemCountries procedure
        /// and updates the SystemCountries object with the SQL data by reference.
        /// <example>[Example]bool status=SystemCountriesSqlDataPrvider.Instance.Create(systemCountriesObject);.</example>
        /// </summary>
        /// <param name="systemCountriesObject">The SystemCountries object.</param>
        /// <returns>The status of create query.</returns>
        public bool Create(SystemCountriesEntity systemCountriesObject)
        {
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("SystemCountries_Create", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@id", SqlDbType.Int, 4).Direction         = ParameterDirection.Output;
                myCommand.Parameters.Add("@country", SqlDbType.NVarChar, 255).Value = systemCountriesObject.country;
                // Execute the command
                bool status = false;
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    status = true;
                    //Get ID value from database and set it in object
                    systemCountriesObject.id = (int)myCommand.Parameters["@id"].Value;
                }
                myConnection.Close();
                return(status);
            }
        }
        public SystemCountriesEntity GetObject(int id)
        {
            SystemCountriesEntity systemCountriesObject = null;

            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("SystemCountries_GetOneByID", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@id", SqlDbType.Int, 4).Value = id;
                // Execute the command
                myConnection.Open();
                using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (dr.Read())
                    {
                        systemCountriesObject = PopulateSystemCountriesEntityFromIDataReader(dr);
                    }
                    dr.Close();
                }
                myConnection.Close();
                return(systemCountriesObject);
            }
        }
        //------------------------------------------
        #endregion

        #region --------------Update--------------
        /// <summary>
        /// Updates SystemCountries object by calling SystemCountries data provider update method.
        /// <example>[Example]bool status=SystemCountriesFactory.Update(systemCountriesObject);.</example>
        /// </summary>
        /// <param name="systemCountriesObject">The SystemCountries object.</param>
        /// <returns>Status of update operation.</returns>
        public static bool Update(SystemCountriesEntity systemCountriesObject)
        {
            bool status = SystemCountriesSqlDataPrvider.Instance.Update(systemCountriesObject);

            return(status);
        }
 /// <summary>
 /// Creates SystemCountries object by calling SystemCountries data provider create method.
 /// <example>[Example]bool status=SystemCountriesFactory.Create(systemCountriesObject);.</example>
 /// </summary>
 /// <param name="systemCountriesObject">The SystemCountries object.</param>
 /// <returns>Status of create operation.</returns>
 public static bool Create(SystemCountriesEntity systemCountriesObject)
 {
     return(SystemCountriesSqlDataPrvider.Instance.Create(systemCountriesObject));
 }