/// <summary>
        /// Deletes sources from Indicator_Classification table  and associated records from IC_IUS table
        /// </summary>
        /// <param name="nids">Comma separated nids which may be blank</param>
        public void DeleteSources(string nids)
        {
            DITables TableNames;
            IndicatorClassificationBuilder ICBuilder;
            MetaDataBuilder MetadataBuilderObject;
            if (!string.IsNullOrEmpty(nids))
            {
                try
                {
                    // Step1: Delete records from IndicatorClassification table
                    foreach (DataRow Row in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                    {
                        TableNames = new DITables(this.DBQueries.DataPrefix, Row[Language.LanguageCode].ToString());
                        this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.IndicatorClassification.Delete.DeleteSources(TableNames.IndicatorClassifications, nids));

                    }

                    if (!string.IsNullOrEmpty(nids))
                    {
                        // Step2: Delete records from IC_IUS table
                        ICBuilder = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries);
                        ICBuilder.DeleteClassificationIUSRelation(nids, string.Empty);

                        // delete records data table
                        //this.DBConnection.ExecuteNonQuery(this.DBQueries.Delete.Data.DeleteRecordsBySourceNIds(nids));
                        new DIDatabase(this.DBConnection, this.DBQueries).DeleteDataValue(string.Empty, string.Empty, string.Empty, nids);

                        // delete metadata
                        MetadataBuilderObject = new MetaDataBuilder(this.DBConnection, this.DBQueries);
                        MetadataBuilderObject.DeleteMetadata(nids, MetadataElementType.Source);
                    }
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(ex.ToString());
                }
            }
        }
        /// <summary>
        /// Deletes indicators and associated records from IUS and IC_IUS table
        /// </summary>
        /// <param name="indicatorNids"></param>
        public void DeleteIndicator(string indicatorNids)
        {
            DITables TableNames;
            IUSBuilder IUSBuilder;
            MetaDataBuilder MetadataBuilderObject;
            string AssocicatedIUSNIds = string.Empty;
            try
            {

                IUSBuilder = new IUSBuilder(this.DBConnection, this.DBQueries);

                // Step 1: Delete records from Indicator table
                foreach (DataRow Row in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                {
                    TableNames = new DITables(this.DBQueries.DataPrefix, "_" + Row[Language.LanguageCode].ToString());

                    this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Indicator.Delete.DeleteIndicator(TableNames.Indicator, indicatorNids));
                }

                // Step 2: Delete records from IUS table

                // Step2(a): Get all associated IUSNIds
                AssocicatedIUSNIds = IUSBuilder.GetAllAssociatedIUSNids(indicatorNids, string.Empty, string.Empty);

                // Step2(b): Delete all associated IUSNIds
                IUSBuilder.DeleteIUS(AssocicatedIUSNIds);

                // delete metadata
                MetadataBuilderObject = new MetaDataBuilder(this.DBConnection, this.DBQueries);
                MetadataBuilderObject.DeleteMetadata(indicatorNids, MetadataElementType.Indicator);
            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.ToString());
            }
        }
        /// <summary>
        /// Deletes areas from area and other associtated tables
        /// </summary>
        /// <param name="areaNIds"></param>
        public void DeleteAreas(string areaNIds)
        {
            DataTable TempDT = null;
            DataTable AreaTable = null;
            string LayerNids = string.Empty;
            string TableName = string.Empty;
            MetaDataBuilder MetadataBuilderObject;
            MapBuilder MapBuilderObj = new MapBuilder(this.DBConnection, this.DBQueries);

            try
            {

                LayerNids = DIConnection.GetDelimitedValuesFromDataTable(this.DBConnection.ExecuteDataTable(this.DBQueries.Area.GetAreaMapByAreaNIds(areaNIds, true)), Area_Map.LayerNId);

                // Step 1: Delete records from area table
                foreach (DataRow Row in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                {
                    TableName = this.DBQueries.DataPrefix + AreaTableName + "_" + Row[Language.LanguageCode].ToString();

                    this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Area.Delete.DeleteArea(TableName, areaNIds));
                }

                // Step2: delete metadata
                MetadataBuilderObject = new MetaDataBuilder(this.DBConnection, this.DBQueries);
                MetadataBuilderObject.DeleteMetadata(areaNIds, MetadataElementType.Area);

                if (!string.IsNullOrEmpty(LayerNids))
                {
                    //-- Remove Associated Table Records
                    MapBuilderObj.DeleteMap(LayerNids);
                }

                // -- STEP 3: Delete All First Level Child of this Area
                TempDT = this.DBConnection.ExecuteDataTable(this.DBQueries.Area.GetArea(FilterFieldType.ParentNId, areaNIds));
                foreach (DataRow row in TempDT.Rows)
                {
                    this.DeleteAreas(row[Area.AreaNId].ToString());
                }

                // --  step 4 delete from data table
                new DIDatabase(this.DBConnection, this.DBQueries).DeleteByAreaNIds(areaNIds);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }