예제 #1
0
        /// <summary>
        /// Delete the specified Audit TRail Entry from the database
        /// </summary>
        /// <param name="ate">The audit trail entry to remove</param>
        /// <returns></returns>
        public int AuditTrailDelete(AuditTrailEntry ate)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            if (compactDatabaseType)
            {
                if (ate.AuditTrailID != 0)
                {
                    try
                    {
                        using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                        {
                            string commandText = "DELETE FROM AUDITTRAIL WHERE _AUDITTRAILID = @nAuditTrailID";

                            using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                            {
                                command.Parameters.AddWithValue("@nAuditTrailID", ate.AuditTrailID);
                                command.ExecuteNonQuery();
                            }
                        }
                    }
                    catch (SqlCeException ex)
                    {
                        Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                    "Please see the log file for further details.");
                        logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                    }
                    catch (Exception ex)
                    {
                        Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                    "Please see the log file for further details.");

                        logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                    }
                }
            }
            else
            {
                AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess();
                lAuditWizardDataAccess.AuditTrailDelete(ate);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(0);
        }