/// <summary> /// This function is the base function for returning notes for a specific item or the specified scope /// and database ID. It is called from the public specific functions /// </summary> /// <param name="aScope"></param> /// <param name="aParentID"></param> /// <returns></returns> public DataTable EnumerateNotes(SCOPE aScope, int aParentID) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } DataTable table = new DataTable(TableNames.NOTES); if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT NOTES.* " + "FROM NOTES " + "WHERE _SCOPE = @nScope AND _PARENTID = @nParentID " + "ORDER BY _DATE DESC"; SqlCeParameter[] spParams = new SqlCeParameter[2]; spParams[0] = new SqlCeParameter("@nScope", (int)aScope); spParams[1] = new SqlCeParameter("@nParentID", aParentID); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); new SqlCeDataAdapter(command).Fill(table); } } } 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(); table = lAuditWizardDataAccess.EnumerateNotes(aScope, aParentID); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(table); }
public int Populate(SCOPE scope, int parentID) { // Ensure that the list is empty initially this.Clear(); AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); DataTable table = lwDataAccess.EnumerateNotes(scope, parentID); // Iterate through the returned rows in the table and create AssetType objects for each foreach (DataRow row in table.Rows) { AddNote(row); } return(this.Count); }