Esempio n. 1
0
 public static void Delete(int organisation_id)
 {
     try
     {
         Organisation o = OrganisationDB.GetByID(organisation_id);
         if (o != null)
         {
             DBBase.ExecuteNonResult("DELETE FROM Organisation WHERE organisation_id = " + organisation_id.ToString());
             if (EntityDB.NumForeignKeyDependencies(o.EntityID) == 0)
             {
                 EntityDB.Delete(o.EntityID, false);
             }
         }
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         if (sqlEx.Errors.Count > 0 && sqlEx.Errors[0].Number == 547) // Assume the interesting stuff is in the first error
         {
             throw new ForeignKeyConstraintException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, sqlEx);
         }
         else
         {
             throw;
         }
     }
 }
Esempio n. 2
0
 public static void Delete(int person_id)
 {
     try
     {
         Person p = PersonDB.GetByID(person_id);
         if (p != null)
         {
             DBBase.ExecuteNonResult("DELETE FROM Person WHERE person_id = " + person_id.ToString() + "; DBCC CHECKIDENT(Person,RESEED,1); DBCC CHECKIDENT(Person);");
             if (EntityDB.NumForeignKeyDependencies(p.EntityID) == 0)
             {
                 EntityDB.Delete(p.EntityID, false);
             }
         }
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         if (sqlEx.Errors.Count > 0 && sqlEx.Errors[0].Number == 547) // Assume the interesting stuff is in the first error
         {
             throw new ForeignKeyConstraintException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, sqlEx);
         }
         else
         {
             throw;
         }
     }
 }