/// <summary> /// Add a new Document to the database /// </summary> /// <param name="document">The document to add</param> /// <returns></returns> public int DocumentAdd(Document aDocument) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } int lItemID = 0; if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "INSERT INTO DOCUMENTS " + "(_SCOPE ,_NAME ,_PATH ,_PARENTID) " + "VALUES " + "(@nScope, @cName, @cPath, @nParentID)"; SqlCeParameter[] spParams = new SqlCeParameter[4]; spParams[0] = new SqlCeParameter("@nScope", (int)aDocument.Scope); spParams[1] = new SqlCeParameter("@nParentID", aDocument.ParentID); spParams[2] = new SqlCeParameter("@cName", aDocument.Name); spParams[3] = new SqlCeParameter("@cPath", aDocument.Path); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); command.ExecuteNonQuery(); } using (SqlCeCommand command = new SqlCeCommand("SELECT @@IDENTITY", conn)) { lItemID = Convert.ToInt32(command.ExecuteScalar()); } } } 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(); lItemID = lAuditWizardDataAccess.DocumentAdd(aDocument); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out with id : " + lItemID); } return(lItemID); }