Пример #1
0
        /// <summary>
        /// Deletes subgroup type and associated Subgroup, SubgroupVal, SubgroupValSubgroup,  Indicator_Uni_Subgroup and IC_IUS
        /// </summary>
        /// <param name="NIDs">Comma separated NIDs</param>
        public void DeleteSubgroupType(string NIDs)
        {
            string             SqlQuery = string.Empty;
            string             AssociatedSubgroupNIds = string.Empty;
            DITables           TablesName;
            DI6SubgroupBuilder SGBuilder;

            try
            {
                // Step 1:Delete subgroup type
                foreach (DataRow Row in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                {
                    TablesName = new DITables(this.DBQueries.DataPrefix, "_" + Row[Language.LanguageCode].ToString());

                    SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.SubgroupTypes.Delete.DeleteSubgroupType(TablesName.SubgroupType, NIDs);

                    this.DBConnection.ExecuteNonQuery(SqlQuery);
                }

                // Step 2: Delete associated records from Subgroup and Subgroup Builder will automatically  delete records from Subgroup, SubgroupValSubgroup, Indicator_Unit_Subgroup and IC_IUS.
                SGBuilder = new DI6SubgroupBuilder(this.DBConnection, this.DBQueries);

                // Get all associated SubgroupNIds
                AssociatedSubgroupNIds = SGBuilder.GetAllAssociatedSubgroupNIds(NIDs);
                if (!string.IsNullOrEmpty(AssociatedSubgroupNIds))
                {
                    SGBuilder.DeleteSubgroup(AssociatedSubgroupNIds);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
        /// <summary>
        /// Deletes subgroup type and associated Subgroup, SubgroupVal, SubgroupValSubgroup,  Indicator_Uni_Subgroup and IC_IUS
        /// </summary>
        /// <param name="NIDs">Comma separated NIDs</param>
        public void DeleteSubgroupType(string NIDs)
        {
            string SqlQuery = string.Empty;
            string AssociatedSubgroupNIds = string.Empty;
            DITables TablesName;
            DI6SubgroupBuilder SGBuilder;

            try
            {

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

                        SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.SubgroupTypes.Delete.DeleteSubgroupType(TablesName.SubgroupType, NIDs);

                        this.DBConnection.ExecuteNonQuery(SqlQuery);
                    }

                // Step 2: Delete associated records from Subgroup and Subgroup Builder will automatically  delete records from Subgroup, SubgroupValSubgroup, Indicator_Unit_Subgroup and IC_IUS.
                SGBuilder=new DI6SubgroupBuilder(this.DBConnection,this.DBQueries);

                // Get all associated SubgroupNIds
                AssociatedSubgroupNIds =SGBuilder.GetAllAssociatedSubgroupNIds(NIDs);
                if(!string.IsNullOrEmpty(AssociatedSubgroupNIds))
                {
                SGBuilder.DeleteSubgroup(AssociatedSubgroupNIds);
                }

            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.ToString());
            }
        }